package net.pokeranalytics.android.ui.activity

import android.content.Intent
import android.os.Bundle
import androidx.fragment.app.Fragment
import net.pokeranalytics.android.R
import net.pokeranalytics.android.calculus.bankroll.BankrollReport
import net.pokeranalytics.android.ui.activity.components.PokerAnalyticsActivity
import net.pokeranalytics.android.ui.fragment.BankrollDetailsFragment

class BankrollDetailsActivity : PokerAnalyticsActivity() {

	companion object {

		private var bankrollReport: BankrollReport? = null

		/**
		 * Default constructor
		 */
		fun newInstanceForResult(fragment: Fragment, bankrollReport: BankrollReport, requestCode: Int) {
			this.bankrollReport = bankrollReport
			val intent = Intent(fragment.requireContext(), BankrollDetailsActivity::class.java)
			fragment.startActivityForResult(intent, requestCode)
		}
	}

	override fun onCreate(savedInstanceState: Bundle?) {
		super.onCreate(savedInstanceState)
		setContentView(R.layout.activity_bankroll_details)
		initUI()
	}

	/**
	 * Init UI
	 */
	private fun initUI() {

		bankrollReport?.let {
			val fragmentTransaction = supportFragmentManager.beginTransaction()
			val reportDetailsFragment = BankrollDetailsFragment.newInstance(it)
			fragmentTransaction.add(R.id.container, reportDetailsFragment)
			fragmentTransaction.commit()

			bankrollReport = null
		}
	}

}