parent
185c459066
commit
e83914815d
@ -0,0 +1,24 @@ |
||||
package net.pokeranalytics.android.ui.activity |
||||
|
||||
import android.content.Context |
||||
import android.content.Intent |
||||
import android.os.Bundle |
||||
import net.pokeranalytics.android.R |
||||
import net.pokeranalytics.android.ui.activity.components.PokerAnalyticsActivity |
||||
|
||||
class ReportCreationActivity : PokerAnalyticsActivity() { |
||||
|
||||
companion object { |
||||
fun newInstance(context: Context) { |
||||
val intent = Intent(context, ReportCreationActivity::class.java) |
||||
context.startActivity(intent) |
||||
} |
||||
|
||||
} |
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) { |
||||
super.onCreate(savedInstanceState) |
||||
setContentView(R.layout.activity_reportcreation) |
||||
} |
||||
|
||||
} |
||||
@ -0,0 +1,102 @@ |
||||
package net.pokeranalytics.android.ui.fragment |
||||
|
||||
import android.os.Bundle |
||||
import android.view.LayoutInflater |
||||
import android.view.View |
||||
import android.view.ViewGroup |
||||
import io.realm.Realm |
||||
import net.pokeranalytics.android.R |
||||
import net.pokeranalytics.android.calculus.Stat |
||||
import net.pokeranalytics.android.model.Criteria |
||||
import net.pokeranalytics.android.model.realm.Filter |
||||
import net.pokeranalytics.android.model.realm.ReportDisplay |
||||
import net.pokeranalytics.android.ui.fragment.components.RealmFragment |
||||
import net.pokeranalytics.android.ui.view.RowRepresentable |
||||
|
||||
class ReportCreationFragment : RealmFragment() { |
||||
|
||||
class Process { |
||||
|
||||
var step: Step = Step.TYPE |
||||
var display: ReportDisplay? = null |
||||
var stats = listOf<Stat>() |
||||
var comparators = listOf<Criteria>() |
||||
var useFilter: Boolean? = null |
||||
var filter: Filter? = null |
||||
|
||||
enum class Step { |
||||
TYPE, |
||||
STAT, |
||||
COMPARATOR, |
||||
FILTER, |
||||
FINALIZE |
||||
} |
||||
|
||||
val nextStep: Step |
||||
get() { |
||||
return when (this.display) { |
||||
null -> Step.TYPE |
||||
else -> { |
||||
if (this.stats.isEmpty()) { |
||||
Step.STAT |
||||
} else if (this.display!! == ReportDisplay.COMPARISON_GRAPH && this.comparators.isEmpty()) { |
||||
Step.COMPARATOR |
||||
} else if (this.useFilter == null) { |
||||
Step.FILTER |
||||
} else { |
||||
Step.FINALIZE |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
fun titleForStep(step: Step) : Int? { |
||||
return when (step) { |
||||
Step.TYPE -> R.string.new_report_step_type |
||||
Step.STAT -> R.string.new_report_step_stat |
||||
Step.COMPARATOR -> R.string.new_report_step_comparator |
||||
Step.FILTER -> R.string.new_report_step_filter |
||||
else -> null |
||||
} |
||||
} |
||||
|
||||
val dataSource: List<RowRepresentable> |
||||
get() { |
||||
return when (this.step) { |
||||
Step.TYPE -> return listOf(ReportDisplay.FIGURES, ReportDisplay.EVO_GRAPH, ReportDisplay.COMPARISON_GRAPH) |
||||
Step.STAT -> return Stat.values().toList() |
||||
Step.COMPARATOR -> Criteria.all |
||||
Step.FILTER -> { |
||||
val realm = Realm.getDefaultInstance() |
||||
val filters = Filter.sortedByUsage(realm) |
||||
realm.close() |
||||
filters |
||||
} |
||||
else -> listOf() |
||||
} |
||||
} |
||||
|
||||
val nextButtonShouldAppear: Boolean |
||||
get() { |
||||
return when (this.step) { |
||||
Step.STAT, Step.COMPARATOR, Step.FILTER -> true |
||||
else -> false |
||||
} |
||||
} |
||||
|
||||
val nextButtonTitle: Int |
||||
get() { |
||||
return when (this.step) { |
||||
Step.FILTER -> R.string.launch_report |
||||
else -> R.string.next |
||||
} |
||||
} |
||||
|
||||
} |
||||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { |
||||
super.onCreateView(inflater, container, savedInstanceState) |
||||
return inflater.inflate(R.layout.fragment_report_creation, container, false) |
||||
} |
||||
|
||||
} |
||||
@ -0,0 +1,15 @@ |
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" |
||||
xmlns:tools="http://schemas.android.com/tools" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="match_parent" |
||||
android:orientation="vertical"> |
||||
|
||||
<fragment |
||||
android:id="@+id/reportCreationFragment" |
||||
android:name="net.pokeranalytics.android.ui.fragment.ReportCreationFragment" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="match_parent" |
||||
tools:layout="@layout/fragment_report_creation" /> |
||||
|
||||
</LinearLayout> |
||||
@ -0,0 +1,20 @@ |
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" |
||||
xmlns:app="http://schemas.android.com/apk/res-auto" |
||||
android:orientation="vertical" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="match_parent"> |
||||
|
||||
<androidx.appcompat.widget.Toolbar |
||||
android:id="@+id/toolbar" |
||||
app:title="@string/new_report" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="?attr/actionBarSize" |
||||
app:layout_constraintEnd_toEndOf="parent" |
||||
app:layout_constraintStart_toStartOf="parent" |
||||
app:layout_constraintTop_toTopOf="parent" /> |
||||
|
||||
|
||||
|
||||
|
||||
</LinearLayout> |
||||
Loading…
Reference in new issue