|
|
|
@ -11,6 +11,7 @@ import io.realm.RealmObject |
|
|
|
import kotlinx.android.synthetic.main.fragment_editable_data.* |
|
|
|
import kotlinx.android.synthetic.main.fragment_editable_data.* |
|
|
|
import kotlinx.android.synthetic.main.fragment_editable_data.view.* |
|
|
|
import kotlinx.android.synthetic.main.fragment_editable_data.view.* |
|
|
|
import net.pokeranalytics.android.R |
|
|
|
import net.pokeranalytics.android.R |
|
|
|
|
|
|
|
import net.pokeranalytics.android.exceptions.TypeException |
|
|
|
import net.pokeranalytics.android.model.LiveData |
|
|
|
import net.pokeranalytics.android.model.LiveData |
|
|
|
import net.pokeranalytics.android.model.interfaces.Identifiable |
|
|
|
import net.pokeranalytics.android.model.interfaces.Identifiable |
|
|
|
import net.pokeranalytics.android.model.interfaces.Savable |
|
|
|
import net.pokeranalytics.android.model.interfaces.Savable |
|
|
|
@ -47,7 +48,6 @@ class EditableDataFragment : PokerAnalyticsFragment(), RowRepresentableDelegate, |
|
|
|
|
|
|
|
|
|
|
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { |
|
|
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { |
|
|
|
super.onViewCreated(view, savedInstanceState) |
|
|
|
super.onViewCreated(view, savedInstanceState) |
|
|
|
initData() |
|
|
|
|
|
|
|
initUI() |
|
|
|
initUI() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -70,9 +70,13 @@ class EditableDataFragment : PokerAnalyticsFragment(), RowRepresentableDelegate, |
|
|
|
override fun onRowSelected(position: Int, row: RowRepresentable, fromAction: Boolean) { |
|
|
|
override fun onRowSelected(position: Int, row: RowRepresentable, fromAction: Boolean) { |
|
|
|
when (row) { |
|
|
|
when (row) { |
|
|
|
LocationRow.LOCATE_ME -> { |
|
|
|
LocationRow.LOCATE_ME -> { |
|
|
|
|
|
|
|
if (item is Location) { |
|
|
|
(item as Location).isLookingForPlaces = true |
|
|
|
(item as Location).isLookingForPlaces = true |
|
|
|
PlacePickerManager.create(parentActivity, row, this) |
|
|
|
PlacePickerManager.create(parentActivity, row, this) |
|
|
|
rowRepresentableAdapter.refreshRow(row) |
|
|
|
rowRepresentableAdapter.refreshRow(row) |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
throw TypeException("Need to manage LocationRow.LOCATE_ME for ${item::class.java}") |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
else -> BottomSheetFragment.create(fragmentManager, row, this, (this.item as RowRepresentableDataSource).editDescriptors(row)) |
|
|
|
else -> BottomSheetFragment.create(fragmentManager, row, this, (this.item as RowRepresentableDataSource).editDescriptors(row)) |
|
|
|
} |
|
|
|
} |
|
|
|
@ -92,10 +96,6 @@ class EditableDataFragment : PokerAnalyticsFragment(), RowRepresentableDelegate, |
|
|
|
} |
|
|
|
} |
|
|
|
else -> rowRepresentableAdapter.refreshRow(row) |
|
|
|
else -> rowRepresentableAdapter.refreshRow(row) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private fun initData() { |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
@ -144,7 +144,6 @@ class EditableDataFragment : PokerAnalyticsFragment(), RowRepresentableDelegate, |
|
|
|
is Location -> R.string.location_empty_field_error |
|
|
|
is Location -> R.string.location_empty_field_error |
|
|
|
is Game -> R.string.location_empty_field_error |
|
|
|
is Game -> R.string.location_empty_field_error |
|
|
|
is TournamentType -> R.string.tt_empty_field_error |
|
|
|
is TournamentType -> R.string.tt_empty_field_error |
|
|
|
//is TransactionType -> R.string.operation_type_empty_field_error |
|
|
|
|
|
|
|
else -> throw IllegalStateException("Need to manage ${item::class.java} error") |
|
|
|
else -> throw IllegalStateException("Need to manage ${item::class.java} error") |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -154,41 +153,24 @@ class EditableDataFragment : PokerAnalyticsFragment(), RowRepresentableDelegate, |
|
|
|
builder.show() |
|
|
|
builder.show() |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Delete data |
|
|
|
* Delete data |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private fun deleteData() { |
|
|
|
private fun deleteData() { |
|
|
|
|
|
|
|
|
|
|
|
val builder = AlertDialog.Builder(requireContext()) |
|
|
|
val builder = AlertDialog.Builder(requireContext()) |
|
|
|
builder.setTitle(R.string.warning) |
|
|
|
builder.setTitle(R.string.warning) |
|
|
|
.setMessage(R.string.are_you_sure_you_want_to_do_that_) |
|
|
|
.setMessage(R.string.are_you_sure_you_want_to_do_that_) |
|
|
|
.setNegativeButton(R.string.no, null) |
|
|
|
.setNegativeButton(R.string.no, null) |
|
|
|
.setPositiveButton(R.string.yes) { _, _ -> |
|
|
|
.setPositiveButton(R.string.yes) { _, _ -> |
|
|
|
|
|
|
|
|
|
|
|
//TODO: Maybe update this code, does the object need to be managed? |
|
|
|
//TODO: Maybe update this code, does the object need to be managed? |
|
|
|
this.getRealm().executeTransaction { |
|
|
|
this.getRealm().executeTransaction { |
|
|
|
this.liveDataType.deleteData(it, (this.item as Savable)) |
|
|
|
this.liveDataType.deleteData(it, (this.item as Savable)) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/* |
|
|
|
|
|
|
|
if (this.item.isManaged) { |
|
|
|
|
|
|
|
Toast.makeText(requireContext(), "isManaged", Toast.LENGTH_SHORT).show() |
|
|
|
|
|
|
|
Timber.d("is managed") |
|
|
|
|
|
|
|
this.getRealm().executeTransaction { |
|
|
|
|
|
|
|
this.liveDataType.deleteData(it, (this.item as Savable)) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
Toast.makeText(requireContext(), "isNotManaged", Toast.LENGTH_SHORT).show() |
|
|
|
|
|
|
|
Timber.d("is not managed") |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
this.activity?.finish() |
|
|
|
this.activity?.finish() |
|
|
|
} |
|
|
|
} |
|
|
|
builder.show() |
|
|
|
builder.show() |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
@ -221,5 +203,13 @@ class EditableDataFragment : PokerAnalyticsFragment(), RowRepresentableDelegate, |
|
|
|
this |
|
|
|
this |
|
|
|
) |
|
|
|
) |
|
|
|
this.recyclerView.adapter = rowRepresentableAdapter |
|
|
|
this.recyclerView.adapter = rowRepresentableAdapter |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// When creating an object, open automatically the keyboard for the first row |
|
|
|
|
|
|
|
if (!isUpdating && this.item is RowRepresentableDataSource) { |
|
|
|
|
|
|
|
val row = (this.item as RowRepresentableDataSource).adapterRows()?.firstOrNull() |
|
|
|
|
|
|
|
row?.let { |
|
|
|
|
|
|
|
onRowSelected(0, it) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |