Merge branch 'master' of gitlab.com:stax-river/poker-analytics

feature/top10
Laurent 7 years ago
commit c2bede9988
  1. 4
      app/src/main/java/net/pokeranalytics/android/exceptions/Exceptions.kt
  2. 42
      app/src/main/java/net/pokeranalytics/android/ui/fragment/EditableDataFragment.kt

@ -7,3 +7,7 @@ class ModelException(message: String) : Exception(message) {
class FormattingException(message: String) : Exception(message) {
}
class TypeException(message: String) : Exception(message) {
}

@ -11,6 +11,7 @@ import io.realm.RealmObject
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.exceptions.TypeException
import net.pokeranalytics.android.model.LiveData
import net.pokeranalytics.android.model.interfaces.Identifiable
import net.pokeranalytics.android.model.interfaces.Savable
@ -47,7 +48,6 @@ class EditableDataFragment : PokerAnalyticsFragment(), RowRepresentableDelegate,
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
initData()
initUI()
}
@ -70,9 +70,13 @@ class EditableDataFragment : PokerAnalyticsFragment(), RowRepresentableDelegate,
override fun onRowSelected(position: Int, row: RowRepresentable, fromAction: Boolean) {
when (row) {
LocationRow.LOCATE_ME -> {
(item as Location).isLookingForPlaces = true
PlacePickerManager.create(parentActivity, row, this)
rowRepresentableAdapter.refreshRow(row)
if (item is Location) {
(item as Location).isLookingForPlaces = true
PlacePickerManager.create(parentActivity, row, this)
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))
}
@ -92,10 +96,6 @@ class EditableDataFragment : PokerAnalyticsFragment(), RowRepresentableDelegate,
}
else -> rowRepresentableAdapter.refreshRow(row)
}
}
private fun initData() {
}
/**
@ -144,7 +144,6 @@ class EditableDataFragment : PokerAnalyticsFragment(), RowRepresentableDelegate,
is Location -> R.string.location_empty_field_error
is Game -> R.string.location_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")
}
@ -154,41 +153,24 @@ class EditableDataFragment : PokerAnalyticsFragment(), RowRepresentableDelegate,
builder.show()
}
}
/**
* Delete data
*/
private fun deleteData() {
val builder = AlertDialog.Builder(requireContext())
builder.setTitle(R.string.warning)
.setMessage(R.string.are_you_sure_you_want_to_do_that_)
.setNegativeButton(R.string.no, null)
.setPositiveButton(R.string.yes) { _, _ ->
//TODO: Maybe update this code, does the object need to be managed?
this.getRealm().executeTransaction {
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()
}
builder.show()
}
/**
@ -221,5 +203,13 @@ class EditableDataFragment : PokerAnalyticsFragment(), RowRepresentableDelegate,
this
)
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)
}
}
}
}
Loading…
Cancel
Save