Improve Session & BottomSheet

feature/top10
Aurelien Hubert 7 years ago
parent dfa629f013
commit 9c08a3fa90
  1. 35
      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

@ -1,34 +1,35 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="net.pokeranalytics.android"> package="net.pokeranalytics.android">
<uses-permission android:name="android.permission.INTERNET"/> <uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<application <application
android:allowBackup="true" android:name=".PokerAnalyticsApplication"
android:icon="@mipmap/ic_launcher" android:allowBackup="true"
android:label="@string/app_name" android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher_round" android:label="@string/app_name"
android:supportsRtl="true" android:roundIcon="@mipmap/ic_launcher_round"
android:name=".PokerAnalyticsApplication" android:supportsRtl="true"
android:theme="@style/PokerAnalyticsTheme"> android:theme="@style/PokerAnalyticsTheme">
<activity <activity
android:name=".ui.activity.HomeActivity" android:name=".ui.activity.HomeActivity"
android:label="@string/app_name"> android:label="@string/app_name">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN"/> <action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER"/> <category android:name="android.intent.category.LAUNCHER" />
</intent-filter> </intent-filter>
</activity> </activity>
<activity android:name=".ui.activity.DataListActivity" /> <activity android:name=".ui.activity.DataListActivity" />
<activity <activity
android:name=".ui.activity.SessionActivity" android:name=".ui.activity.SessionActivity"
android:launchMode="singleTop"/> android:launchMode="singleTop"
android:windowSoftInputMode="adjustNothing" />
<activity android:name=".ui.activity.EditableDataActivity"/> <activity android:name=".ui.activity.EditableDataActivity" />
<meta-data <meta-data
android:name="preloaded_fonts" android:name="preloaded_fonts"

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

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

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

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

Loading…
Cancel
Save