|
|
|
|
@ -1,7 +1,6 @@ |
|
|
|
|
package net.pokeranalytics.android.ui.fragment |
|
|
|
|
|
|
|
|
|
import android.os.Bundle |
|
|
|
|
import android.text.InputType |
|
|
|
|
import android.view.LayoutInflater |
|
|
|
|
import android.view.View |
|
|
|
|
import android.view.ViewGroup |
|
|
|
|
@ -13,19 +12,17 @@ import kotlinx.android.synthetic.main.fragment_editable_data.* |
|
|
|
|
import kotlinx.android.synthetic.main.fragment_editable_data.view.* |
|
|
|
|
import net.pokeranalytics.android.R |
|
|
|
|
import net.pokeranalytics.android.model.DataList |
|
|
|
|
import net.pokeranalytics.android.model.realm.Bankroll |
|
|
|
|
import net.pokeranalytics.android.ui.activity.components.PokerAnalyticsActivity |
|
|
|
|
import net.pokeranalytics.android.ui.adapter.components.* |
|
|
|
|
import net.pokeranalytics.android.ui.fragment.components.BottomSheetData |
|
|
|
|
import net.pokeranalytics.android.ui.fragment.components.BottomSheetDelegate |
|
|
|
|
import net.pokeranalytics.android.ui.fragment.components.BottomSheetFragment |
|
|
|
|
import net.pokeranalytics.android.ui.fragment.components.PokerAnalyticsFragment |
|
|
|
|
import java.util.* |
|
|
|
|
|
|
|
|
|
class EditableDataFragment : PokerAnalyticsFragment(), DynamicRowCallback, BottomSheetDelegate { |
|
|
|
|
|
|
|
|
|
private lateinit var item: RealmObject |
|
|
|
|
private lateinit var dataType: DataList |
|
|
|
|
private lateinit var dynamicListAdapter: DynamicListAdapter |
|
|
|
|
|
|
|
|
|
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { |
|
|
|
|
return inflater.inflate(R.layout.fragment_editable_data, container, false) |
|
|
|
|
@ -52,9 +49,9 @@ class EditableDataFragment : PokerAnalyticsFragment(), DynamicRowCallback, Botto |
|
|
|
|
override fun setValue(value: Any, row: DynamicRowInterface) { |
|
|
|
|
(this.item as EditableDataSource).setBottomSheetValue(value, row) |
|
|
|
|
this.getRealm().executeTransaction { |
|
|
|
|
it.copyToRealm(this.item) |
|
|
|
|
it.copyToRealmOrUpdate(this.item) |
|
|
|
|
} |
|
|
|
|
Toast.makeText(requireContext(), "Callback for ${row.localizedTitle(requireContext())} ($value)", Toast.LENGTH_SHORT).show() |
|
|
|
|
dynamicListAdapter.refreshRow(row) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private fun initData() { |
|
|
|
|
@ -92,7 +89,7 @@ class EditableDataFragment : PokerAnalyticsFragment(), DynamicRowCallback, Botto |
|
|
|
|
|
|
|
|
|
this.item = this.dataType.updateOrCreate(realm, primaryKey) |
|
|
|
|
|
|
|
|
|
val dynamicListAdapter = DynamicListAdapter((this.item as DynamicRowDelegate), this) |
|
|
|
|
this.dynamicListAdapter = DynamicListAdapter((this.item as DynamicRowDelegate), this) |
|
|
|
|
this.recyclerView.adapter = dynamicListAdapter |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|