|
|
|
@ -43,12 +43,10 @@ class EditableDataFragment : PokerAnalyticsFragment(), DynamicRowCallback { |
|
|
|
private fun initUI() { |
|
|
|
private fun initUI() { |
|
|
|
|
|
|
|
|
|
|
|
val viewManager = LinearLayoutManager(requireContext()) |
|
|
|
val viewManager = LinearLayoutManager(requireContext()) |
|
|
|
val dynamicListAdapter = DynamicListAdapter((this.item as DynamicRowDelegate), this) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
recyclerView.apply { |
|
|
|
recyclerView.apply { |
|
|
|
setHasFixedSize(true) |
|
|
|
setHasFixedSize(true) |
|
|
|
layoutManager = viewManager |
|
|
|
layoutManager = viewManager |
|
|
|
adapter = dynamicListAdapter |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -58,20 +56,21 @@ class EditableDataFragment : PokerAnalyticsFragment(), DynamicRowCallback { |
|
|
|
fun setData(dataType: Int, primaryKey: String?) { |
|
|
|
fun setData(dataType: Int, primaryKey: String?) { |
|
|
|
this.dataType = SettingRow.values()[dataType] |
|
|
|
this.dataType = SettingRow.values()[dataType] |
|
|
|
val realm = Realm.getDefaultInstance() |
|
|
|
val realm = Realm.getDefaultInstance() |
|
|
|
|
|
|
|
var _item : RealmObject? = null |
|
|
|
primaryKey?.let { |
|
|
|
primaryKey?.let { |
|
|
|
when (this.dataType) { |
|
|
|
val t = realm.where(this.dataType.clazz()).equalTo("id", it).findFirst() |
|
|
|
SettingRow.BANKROLL -> realm.where(Bankroll::class.java).equalTo("id", it).findFirst() |
|
|
|
t?.let { |
|
|
|
SettingRow.GAME -> realm.where(Game::class.java).equalTo("id", it).findFirst() |
|
|
|
_item = t |
|
|
|
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) { |
|
|
|
_item?.let { |
|
|
|
this.item = realm.createObject(Bankroll) |
|
|
|
this.item = it |
|
|
|
} |
|
|
|
} ?: run { |
|
|
|
|
|
|
|
this.item = realm.createObject(this.dataType.clazz()) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
val dynamicListAdapter = DynamicListAdapter((this.item as DynamicRowDelegate), this) |
|
|
|
|
|
|
|
this.recyclerView.adapter = dynamicListAdapter |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |