|
|
|
|
@ -1,14 +1,15 @@ |
|
|
|
|
package net.pokeranalytics.android.ui.modules.handhistory |
|
|
|
|
|
|
|
|
|
import android.content.DialogInterface |
|
|
|
|
import android.content.Intent |
|
|
|
|
import android.os.Bundle |
|
|
|
|
import androidx.appcompat.app.AlertDialog |
|
|
|
|
import androidx.fragment.app.Fragment |
|
|
|
|
import net.pokeranalytics.android.R |
|
|
|
|
import net.pokeranalytics.android.model.realm.Session |
|
|
|
|
import net.pokeranalytics.android.ui.activity.components.BaseActivity |
|
|
|
|
import net.pokeranalytics.android.ui.activity.components.RequestCode |
|
|
|
|
import net.pokeranalytics.android.ui.modules.handhistory.evaluator.Hand |
|
|
|
|
import timber.log.Timber |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class HandHistoryActivity : BaseActivity() { |
|
|
|
|
|
|
|
|
|
@ -18,6 +19,8 @@ class HandHistoryActivity : BaseActivity() { |
|
|
|
|
ATTACHED("attached") |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private var fragment: HandHistoryFragment? = null |
|
|
|
|
|
|
|
|
|
companion object { |
|
|
|
|
|
|
|
|
|
fun newInstance(fragment: Fragment, session: Session, attached: Boolean) { |
|
|
|
|
@ -57,18 +60,31 @@ class HandHistoryActivity : BaseActivity() { |
|
|
|
|
fragmentTransaction.add(R.id.container, fragment) |
|
|
|
|
fragmentTransaction.commit() |
|
|
|
|
|
|
|
|
|
// test() |
|
|
|
|
this.fragment = fragment |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
override fun onBackPressed() { |
|
|
|
|
|
|
|
|
|
var shouldShowDataLossWarning = false |
|
|
|
|
this.fragment?.let { hhFragment -> |
|
|
|
|
if (hhFragment.isEditing) { |
|
|
|
|
shouldShowDataLossWarning = true |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (shouldShowDataLossWarning) { |
|
|
|
|
|
|
|
|
|
fun test() { |
|
|
|
|
AlertDialog.Builder(this) |
|
|
|
|
.setIcon(android.R.drawable.ic_dialog_alert) |
|
|
|
|
.setTitle(R.string.your_attention) |
|
|
|
|
.setMessage(R.string.data_loss_warning) |
|
|
|
|
.setPositiveButton(R.string.yes) { _, _ -> finish() } |
|
|
|
|
.setNegativeButton(R.string.no, null) |
|
|
|
|
.show() |
|
|
|
|
|
|
|
|
|
val h1 = Hand.fromString("Kd Ts Jc Ah Qc") |
|
|
|
|
val h2 = Hand.fromString("Kd 5d Jd Ad Qd") |
|
|
|
|
val r1 = Hand.evaluate(h1) |
|
|
|
|
val r2 = Hand.evaluate(h2) |
|
|
|
|
Timber.d(">>> Hand evaluation = $r1") |
|
|
|
|
Timber.d(">>> Hand evaluation = $r2") |
|
|
|
|
} else { |
|
|
|
|
super.onBackPressed() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|