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

feature/top10
Laurent 7 years ago
commit b2222dab43
  1. 7
      app/src/main/java/net/pokeranalytics/android/model/realm/Bankroll.kt
  2. 12
      app/src/main/java/net/pokeranalytics/android/model/realm/Location.kt
  3. 14
      app/src/main/java/net/pokeranalytics/android/ui/fragment/EditableDataFragment.kt
  4. 4
      app/src/main/java/net/pokeranalytics/android/ui/fragment/StatsFragment.kt
  5. 8
      app/src/main/java/net/pokeranalytics/android/ui/helpers/PlacePickerManager.kt
  6. 4
      app/src/main/java/net/pokeranalytics/android/ui/view/RowViewType.kt
  7. 2
      app/src/main/java/net/pokeranalytics/android/ui/view/rowrepresentable/BankrollRow.kt
  8. 21
      app/src/main/res/layout/row_button.xml

@ -63,7 +63,7 @@ open class Bankroll(name: String = "") : RealmObject(), Savable,
override fun boolForRow(row: RowRepresentable): Boolean {
when (row) {
BankrollRow.LIVE -> return this.live
BankrollRow.LIVE -> return !this.live
else -> return super.boolForRow(row)
}
}
@ -84,8 +84,9 @@ open class Bankroll(name: String = "") : RealmObject(), Savable,
override fun updateValue(value: Any?, row: RowRepresentable) {
when (row) {
SimpleRow.NAME -> this.name = value as String? ?: ""
BankrollRow.LIVE -> this.live = value as Boolean? ?: false
BankrollRow.LIVE -> {
this.live = if (value is Boolean) !value else false
}
}
}

@ -2,6 +2,7 @@ package net.pokeranalytics.android.model.realm
import com.google.android.libraries.places.api.model.Place
import io.realm.RealmObject
import io.realm.annotations.Ignore
import io.realm.annotations.PrimaryKey
import net.pokeranalytics.android.model.interfaces.Savable
import net.pokeranalytics.android.ui.adapter.StaticRowRepresentableDataSource
@ -30,6 +31,9 @@ open class Location : RealmObject(), Savable, StaticRowRepresentableDataSource,
// the latitude of the location
var latitude: Double? = null
@Ignore
var isLookingForPlaces = false
override fun getDisplayName(): String {
return this.name
}
@ -53,6 +57,13 @@ open class Location : RealmObject(), Savable, StaticRowRepresentableDataSource,
}
}
override fun boolForRow(row: RowRepresentable): Boolean {
return when(row) {
LocationRow.LOCATE_ME -> return isLookingForPlaces
else -> super.boolForRow(row)
}
}
override fun editDescriptors(row: RowRepresentable): ArrayList<RowRepresentableEditDescriptor> {
val data = java.util.ArrayList<RowRepresentableEditDescriptor>()
when (row) {
@ -78,6 +89,7 @@ open class Location : RealmObject(), Savable, StaticRowRepresentableDataSource,
SimpleRow.NAME -> this.name = value as String? ?: ""
LocationRow.ADDRESS -> this.address = value as String? ?: ""
LocationRow.LOCATE_ME -> {
isLookingForPlaces = false
if (value is Place) {
setPlace(value)
}

@ -69,12 +69,12 @@ class EditableDataFragment : PokerAnalyticsFragment(), RowRepresentableDelegate,
override fun onRowSelected(position: Int, row: RowRepresentable, fromAction: Boolean) {
when (row) {
LocationRow.LOCATE_ME -> PlacePickerManager.create(parentActivity, row, this)
else -> {
BottomSheetFragment.create(
fragmentManager, row, this, (this.item as RowRepresentableDataSource).editDescriptors(row)
)
LocationRow.LOCATE_ME -> {
(item as Location).isLookingForPlaces = true
PlacePickerManager.create(parentActivity, row, this)
rowRepresentableAdapter.refreshRow(row)
}
else -> BottomSheetFragment.create(fragmentManager, row, this, (this.item as RowRepresentableDataSource).editDescriptors(row))
}
}
@ -87,7 +87,9 @@ class EditableDataFragment : PokerAnalyticsFragment(), RowRepresentableDelegate,
(this.item as Savable).updateValue(value, row)
}
when (row) {
LocationRow.LOCATE_ME -> rowRepresentableAdapter.notifyDataSetChanged()
LocationRow.LOCATE_ME -> {
rowRepresentableAdapter.notifyDataSetChanged()
}
else -> rowRepresentableAdapter.refreshRow(row)
}

@ -21,7 +21,7 @@ import net.pokeranalytics.android.util.NULL_TEXT
class StatsFragment : SessionObserverFragment(), StaticRowRepresentableDataSource {
private var rowRepresentables: ArrayList<RowRepresentable> = ArrayList<RowRepresentable>()
private var rowRepresentables: ArrayList<RowRepresentable> = ArrayList()
private lateinit var statsAdapter: RowRepresentableAdapter
@ -56,7 +56,7 @@ class StatsFragment : SessionObserverFragment(), StaticRowRepresentableDataSourc
}
override fun contentDescriptorForRow(row: RowRepresentable): DisplayDescriptor? {
var dc = DisplayDescriptor()
val dc = DisplayDescriptor()
dc.textFormat = TextFormat(NULL_TEXT)
if (row is StatRepresentable) {
context?.let { context ->

@ -16,22 +16,26 @@ class PlacePickerManager {
activity: PokerAnalyticsActivity,
row: RowRepresentable,
delegate: RowRepresentableDelegate,
maxResults: Int? = 2
maxResults: Int? = 3
) {
activity.askForPlacesRequest { success, places ->
if (success && places.size > 0) {
val placesArray = ArrayList<CharSequence>()
for ((index, place) in places.withIndex()) {
placesArray.add(place.place.name.toString())
if (index == maxResults) {
if (index == (maxResults ?: 3) - 1) {
break
}
}
val builder = AlertDialog.Builder(activity)
builder.setItems(placesArray.toTypedArray()) { _, which ->
delegate.onRowValueChanged(places[which].place, row)
}.setOnCancelListener {
delegate.onRowValueChanged(null, row)
}
builder.show()
} else {
delegate.onRowValueChanged(null, row)
}
}
}

@ -7,6 +7,8 @@ import androidx.appcompat.widget.AppCompatImageView
import androidx.appcompat.widget.AppCompatTextView
import androidx.appcompat.widget.SwitchCompat
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.core.view.isVisible
import androidx.core.widget.ContentLoadingProgressBar
import androidx.recyclerview.widget.RecyclerView
import kotlinx.android.synthetic.main.row_history_session.view.*
import kotlinx.android.synthetic.main.row_stats_title_value.view.*
@ -205,6 +207,8 @@ enum class RowViewType(private var layoutRes: Int) {
inner class RowButtonViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView), BindableHolder {
override fun bind(position: Int, row: RowRepresentable, adapter: RowRepresentableAdapter) {
itemView.findViewById<AppCompatTextView>(R.id.title).text = row.localizedTitle(itemView.context)
itemView.findViewById<AppCompatTextView>(R.id.title).isVisible = !adapter.dataSource.boolForRow(row)
itemView.findViewById<ContentLoadingProgressBar>(R.id.progressBar).isVisible = adapter.dataSource.boolForRow(row)
val listener = View.OnClickListener {
adapter.delegate?.onRowSelected(position, row)
}

@ -12,7 +12,7 @@ enum class BankrollRow : RowRepresentable {
override val resId: Int?
get() {
return when (this) {
LIVE -> R.string.live
LIVE -> R.string.online
}
}

@ -4,23 +4,36 @@
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_height="56dp"
android:background="?selectableItemBackground">
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/title"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_height="match_parent"
style="@style/PokerAnalyticsTheme.TextView.ButtonRow"
android:gravity="center"
android:paddingTop="16dp"
android:paddingBottom="16dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="@+id/guidelineEnd"
app:layout_constraintStart_toStartOf="@+id/guidelineStart"
app:layout_constraintTop_toTopOf="parent"
tools:text="Data Type Title" />
<androidx.core.widget.ContentLoadingProgressBar
android:id="@+id/progressBar"
style="?android:attr/progressBarStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<androidx.constraintlayout.widget.Guideline
android:id="@+id/guidelineStart"
android:layout_width="wrap_content"

Loading…
Cancel
Save