package net.pokeranalytics.android.ui.activity.components

import android.content.Context
import android.content.Intent
import androidx.fragment.app.Fragment
import net.pokeranalytics.android.calculus.Report
import net.pokeranalytics.android.calculus.Stat

class ReportParameters(var report: Report, var title: String, var stat: Stat? = null, var showAggregationChoices: Boolean = true)

abstract class ReportActivity : PokerAnalyticsActivity() {

	companion object {

		// Unparcel fails when setting a custom Parcelable object on Entry so we use a static reference to passe objects
		var parameters: ReportParameters? = null

		/**
		 * Default constructor
		 */
		fun newInstance(context: Context, report: Report, reportTitle: String, stat: Stat? = null) {
			val options = report.options
			this.parameters = ReportParameters(report, reportTitle, stat)
			val intent = Intent(context, options.display.activityClass)
			context.startActivity(intent)
		}

		fun newInstanceForResult(fragment: Fragment, report: Report, reportTitle: String, stat: Stat? = null) {
			val options = report.options
			this.parameters = ReportParameters(report, reportTitle, stat)
			val intent = Intent(fragment.requireContext(), options.display.activityClass)
			fragment.startActivityForResult(intent, RequestCode.DEFAULT.value)
		}

	}

}