|
|
|
|
@ -7,15 +7,16 @@ import android.view.ViewGroup |
|
|
|
|
import androidx.recyclerview.widget.LinearLayoutManager |
|
|
|
|
import io.realm.Realm |
|
|
|
|
import io.realm.RealmObject |
|
|
|
|
import io.realm.kotlin.createObject |
|
|
|
|
import kotlinx.android.synthetic.main.fragment_new_session.* |
|
|
|
|
import net.pokeranalytics.android.R |
|
|
|
|
import net.pokeranalytics.android.model.realm.* |
|
|
|
|
import net.pokeranalytics.android.ui.adapter.components.* |
|
|
|
|
import net.pokeranalytics.android.util.PokerAnalyticsFragment |
|
|
|
|
|
|
|
|
|
class EditableDataFragment : PokerAnalyticsFragment() { |
|
|
|
|
class EditableDataFragment : PokerAnalyticsFragment(), DynamicRowCallback { |
|
|
|
|
|
|
|
|
|
private var item: RealmObject? = null |
|
|
|
|
private lateinit var item: RealmObject |
|
|
|
|
private var dataType: SettingRow = SettingRow.BANKROLL |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -29,6 +30,10 @@ class EditableDataFragment : PokerAnalyticsFragment() { |
|
|
|
|
initUI() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
override fun onRowSelected(row: DynamicRowInterface) { |
|
|
|
|
TODO("not implemented") //To change body of created functions use File | Settings | File Templates. |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private fun initData() { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -38,12 +43,12 @@ class EditableDataFragment : PokerAnalyticsFragment() { |
|
|
|
|
private fun initUI() { |
|
|
|
|
|
|
|
|
|
val viewManager = LinearLayoutManager(requireContext()) |
|
|
|
|
// val dynamicListAdapter = DynamicListAdapter(this, this) |
|
|
|
|
val dynamicListAdapter = DynamicListAdapter((this.item as DynamicRowDelegate), this) |
|
|
|
|
|
|
|
|
|
recyclerView.apply { |
|
|
|
|
setHasFixedSize(true) |
|
|
|
|
layoutManager = viewManager |
|
|
|
|
// adapter = dynamicListAdapter |
|
|
|
|
adapter = dynamicListAdapter |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -52,15 +57,21 @@ class EditableDataFragment : PokerAnalyticsFragment() { |
|
|
|
|
*/ |
|
|
|
|
fun setData(dataType: Int, primaryKey: String?) { |
|
|
|
|
this.dataType = SettingRow.values()[dataType] |
|
|
|
|
primaryKey?.let { |
|
|
|
|
val realm = Realm.getDefaultInstance() |
|
|
|
|
this.item = realm.copyFromRealm( when (this.dataType) { |
|
|
|
|
primaryKey?.let { |
|
|
|
|
when (this.dataType) { |
|
|
|
|
SettingRow.BANKROLL -> realm.where(Bankroll::class.java).equalTo("id", it).findFirst() |
|
|
|
|
SettingRow.GAME -> realm.where(Game::class.java).equalTo("id", it).findFirst() |
|
|
|
|
SettingRow.LOCATION -> realm.where(Location::class.java).equalTo("id", it).findFirst() |
|
|
|
|
SettingRow.TOURNAMENT_TYPE -> realm.where(TournamentFeature::class.java).equalTo("id", it).findFirst() |
|
|
|
|
SettingRow.TRANSACTION_TYPE-> realm.where(TransactionType::class.java).equalTo("id", it).findFirst() |
|
|
|
|
}) |
|
|
|
|
}?.let { |
|
|
|
|
this.item = realm.copyFromRealm(it) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (this.item == null) { |
|
|
|
|
this.item = realm.createObject(Bankroll) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |