Improve Session & BottomSheet

feature/top10
Aurelien Hubert 7 years ago
parent dfa629f013
commit 9c08a3fa90
  1. 5
      app/src/main/AndroidManifest.xml
  2. 8
      app/src/main/java/net/pokeranalytics/android/model/realm/Session.kt
  3. 2
      app/src/main/java/net/pokeranalytics/android/ui/fragment/components/bottomsheet/BottomSheetDoubleEditTextFragment.kt
  4. 2
      app/src/main/java/net/pokeranalytics/android/ui/fragment/components/bottomsheet/BottomSheetFragment.kt
  5. 17
      app/src/main/java/net/pokeranalytics/android/ui/fragment/components/bottomsheet/BottomSheetSumFragment.kt

@ -6,12 +6,12 @@
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<application
android:name=".PokerAnalyticsApplication"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:name=".PokerAnalyticsApplication"
android:theme="@style/PokerAnalyticsTheme">
<activity
@ -26,7 +26,8 @@
<activity android:name=".ui.activity.DataListActivity" />
<activity
android:name=".ui.activity.SessionActivity"
android:launchMode="singleTop"/>
android:launchMode="singleTop"
android:windowSoftInputMode="adjustNothing" />
<activity android:name=".ui.activity.EditableDataActivity" />

@ -382,8 +382,8 @@ open class Session : RealmObject(), SessionInterface, Savable,
data.add(RowRepresentableEditDescriptor(bankroll, data = LiveData.BANKROLL.items(realm)))
}
SessionRow.BLINDS -> {
data.add(RowRepresentableEditDescriptor(cgSmallBlind, R.string.smallblind, InputType.TYPE_CLASS_NUMBER))
data.add(RowRepresentableEditDescriptor(cgBigBlind, R.string.bigblind, InputType.TYPE_CLASS_NUMBER))
data.add(RowRepresentableEditDescriptor(cgSmallBlind?.round(), R.string.smallblind, InputType.TYPE_CLASS_NUMBER))
data.add(RowRepresentableEditDescriptor(cgBigBlind?.round(), R.string.bigblind, InputType.TYPE_CLASS_NUMBER))
}
SessionRow.COMMENT -> {
data.add(RowRepresentableEditDescriptor(comment, R.string.comment, InputType.TYPE_CLASS_TEXT))
@ -430,6 +430,7 @@ open class Session : RealmObject(), SessionInterface, Savable,
SessionRow.LOCATION -> location = value as Location?
SessionRow.COMMENT -> comment = value as String? ?: ""
SessionRow.BLINDS -> if (value is ArrayList<*>) {
cgSmallBlind = try {
(value[0] as String? ?: "0").toDouble()
} catch (e: Exception) {
@ -446,6 +447,9 @@ open class Session : RealmObject(), SessionInterface, Savable,
cgSmallBlind = it / 2.0
}
}
} else if (value == null) {
cgSmallBlind = null
cgBigBlind = null
}
SessionRow.START_DATE -> if (value is Date?) {
if (value == null) {

@ -41,6 +41,8 @@ class BottomSheetDoubleEditTextFragment : BottomSheetFragment() {
*/
private fun initUI() {
setAddButtonVisible(false)
val data = getData()
values.add(0, "")

@ -10,8 +10,8 @@ import com.google.android.material.bottomsheet.BottomSheetDialogFragment
import kotlinx.android.synthetic.main.fragment_bottom_sheet.*
import net.pokeranalytics.android.R
import net.pokeranalytics.android.ui.adapter.RowRepresentableDelegate
import net.pokeranalytics.android.ui.view.RowRepresentableEditDescriptor
import net.pokeranalytics.android.ui.view.RowRepresentable
import net.pokeranalytics.android.ui.view.RowRepresentableEditDescriptor
enum class BottomSheetType {
NONE,

@ -16,6 +16,7 @@ import net.pokeranalytics.android.util.toCurrency
class BottomSheetSumFragment : BottomSheetFragment() {
private var value = 0.0
private var currentDefaultValue = 0.0
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
@ -29,6 +30,10 @@ class BottomSheetSumFragment : BottomSheetFragment() {
}
override fun getValue(): Any? {
val editText2Value = editText2.text ?: ""
if (editText2Value.isEmpty()) {
return currentDefaultValue
}
return value
}
@ -52,7 +57,7 @@ class BottomSheetSumFragment : BottomSheetFragment() {
if (data.size == 5) {
// Default value for the sum
val currentDefaultValue = try {
currentDefaultValue = try {
data[2].defaultValue as Double
} catch (e: Exception) {
0.0
@ -67,7 +72,7 @@ class BottomSheetSumFragment : BottomSheetFragment() {
0.0
}
button1.text = defaultValue1.toCurrency()
button1.text = "+ ${defaultValue1.toCurrency()}"
button1.visibility = if (defaultValue1 > 0) View.VISIBLE else View.GONE
button1.setOnClickListener {
this.delegate.onRowValueChanged(currentDefaultValue + defaultValue1, row)
@ -81,7 +86,7 @@ class BottomSheetSumFragment : BottomSheetFragment() {
0.0
}
button2.text = defaultValue2.toCurrency()
button2.text = "+ ${defaultValue2.toCurrency()}"
button2.visibility = if (defaultValue2 > 0) View.VISIBLE else View.GONE
button2.setOnClickListener {
this.delegate.onRowValueChanged(currentDefaultValue + defaultValue2, row)
@ -105,7 +110,11 @@ class BottomSheetSumFragment : BottomSheetFragment() {
data[4].hint?.let { editText2.hint = getString(it) }
editText2.inputType = data[4].inputType ?: InputType.TYPE_CLASS_TEXT
editText2.addTextChangedListener {
value = it.toString().toDouble()
value = try {
it.toString().toDouble()
} catch (e: Exception) {
0.0
}
}
editText2.setOnEditorActionListener { v, actionId, event ->

Loading…
Cancel
Save