Improve UI for session (floating action button)

feature/top10
Aurelien Hubert 7 years ago
parent 957d855018
commit 524e54b541
  1. 32
      app/src/main/java/net/pokeranalytics/android/ui/fragment/SessionFragment.kt
  2. 8
      app/src/main/res/layout/fragment_session.xml

@ -88,7 +88,7 @@ class SessionFragment : PokerAnalyticsFragment(), RowRepresentableDelegate {
val data = currentSession.editDescriptors(row) val data = currentSession.editDescriptors(row)
when (row) { when (row) {
SessionRow.START_DATE -> DateTimePickerManager.create(requireContext(),row,this,currentSession.startDate) SessionRow.START_DATE -> DateTimePickerManager.create(requireContext(), row, this, currentSession.startDate)
SessionRow.END_DATE -> DateTimePickerManager.create( SessionRow.END_DATE -> DateTimePickerManager.create(
requireContext(), requireContext(),
row, row,
@ -135,15 +135,15 @@ class SessionFragment : PokerAnalyticsFragment(), RowRepresentableDelegate {
} }
floatingActionButton.setOnClickListener { floatingActionButton.setOnClickListener {
if (this.currentSession.isValidForSave()) { if (this.currentSession.isValidForSave()) {
sessionHasBeenCustomized = true sessionHasBeenCustomized = true
manageSessionState() manageSessionState()
} else { } else {
val builder = AlertDialog.Builder(requireContext()) val builder = AlertDialog.Builder(requireContext())
.setMessage(this.currentSession.getFailedSaveMessage(SaveValidityStatus.DATA_INVALID)) .setMessage(this.currentSession.getFailedSaveMessage(SaveValidityStatus.DATA_INVALID))
.setNegativeButton(R.string.ok, null) .setNegativeButton(R.string.ok, null)
builder.show() builder.show()
} }
} }
} }
@ -151,12 +151,14 @@ class SessionFragment : PokerAnalyticsFragment(), RowRepresentableDelegate {
* Update the UI with the session data * Update the UI with the session data
* Should be called after the initialization of the session * Should be called after the initialization of the session
*/ */
private fun updateSessionUI() { private fun updateSessionUI(firstDisplay: Boolean = false) {
this.currentSession.updateRowRepresentation() this.currentSession.updateRowRepresentation()
handler.removeCallbacksAndMessages(null) handler.removeCallbacksAndMessages(null)
val animationDuration = if (firstDisplay) 0L else 300L
when (currentSession.getState()) { when (currentSession.getState()) {
SessionState.PENDING, SessionState.PLANNED -> { SessionState.PENDING, SessionState.PLANNED -> {
state.setTextColor(ContextCompat.getColor(requireContext(), R.color.white)) state.setTextColor(ContextCompat.getColor(requireContext(), R.color.white))
@ -164,6 +166,7 @@ class SessionFragment : PokerAnalyticsFragment(), RowRepresentableDelegate {
floatingActionButton.setImageResource(R.drawable.ic_outline_play) floatingActionButton.setImageResource(R.drawable.ic_outline_play)
sessionMenu?.findItem(R.id.stop)?.isVisible = false sessionMenu?.findItem(R.id.stop)?.isVisible = false
floatingActionButton.animate().scaleX(1f).scaleY(1f).alpha(1f) floatingActionButton.animate().scaleX(1f).scaleY(1f).alpha(1f)
.setDuration(animationDuration)
.setInterpolator(OvershootInterpolator()).start() .setInterpolator(OvershootInterpolator()).start()
} }
SessionState.STARTED -> { SessionState.STARTED -> {
@ -172,6 +175,7 @@ class SessionFragment : PokerAnalyticsFragment(), RowRepresentableDelegate {
floatingActionButton.setImageResource(R.drawable.ic_outline_pause) floatingActionButton.setImageResource(R.drawable.ic_outline_pause)
sessionMenu?.findItem(R.id.stop)?.isVisible = true sessionMenu?.findItem(R.id.stop)?.isVisible = true
floatingActionButton.animate().scaleX(1f).scaleY(1f).alpha(1f) floatingActionButton.animate().scaleX(1f).scaleY(1f).alpha(1f)
.setDuration(animationDuration)
.setInterpolator(OvershootInterpolator()).start() .setInterpolator(OvershootInterpolator()).start()
handler.postDelayed(refreshTimer, 30000) handler.postDelayed(refreshTimer, 30000)
} }
@ -181,6 +185,7 @@ class SessionFragment : PokerAnalyticsFragment(), RowRepresentableDelegate {
floatingActionButton.setImageResource(R.drawable.ic_outline_play) floatingActionButton.setImageResource(R.drawable.ic_outline_play)
sessionMenu?.findItem(R.id.stop)?.isVisible = true sessionMenu?.findItem(R.id.stop)?.isVisible = true
floatingActionButton.animate().scaleX(1f).scaleY(1f).alpha(1f) floatingActionButton.animate().scaleX(1f).scaleY(1f).alpha(1f)
.setDuration(animationDuration)
.setInterpolator(OvershootInterpolator()).start() .setInterpolator(OvershootInterpolator()).start()
} }
SessionState.FINISHED -> { SessionState.FINISHED -> {
@ -188,6 +193,7 @@ class SessionFragment : PokerAnalyticsFragment(), RowRepresentableDelegate {
sessionMenu?.findItem(R.id.restart)?.isVisible = true sessionMenu?.findItem(R.id.restart)?.isVisible = true
sessionMenu?.findItem(R.id.stop)?.isVisible = false sessionMenu?.findItem(R.id.stop)?.isVisible = false
floatingActionButton.animate().scaleX(0f).scaleY(0f).alpha(0f) floatingActionButton.animate().scaleX(0f).scaleY(0f).alpha(0f)
.setDuration(animationDuration)
.setInterpolator(FastOutSlowInInterpolator()).start() .setInterpolator(FastOutSlowInInterpolator()).start()
} }
} }
@ -299,7 +305,7 @@ class SessionFragment : PokerAnalyticsFragment(), RowRepresentableDelegate {
currentSession.location = location currentSession.location = location
realm.commitTransaction() realm.commitTransaction()
updateSessionUI() updateSessionUI(true)
} }
} }
sessionHasBeenCustomized = false sessionHasBeenCustomized = false
@ -312,7 +318,7 @@ class SessionFragment : PokerAnalyticsFragment(), RowRepresentableDelegate {
sessionAdapter = RowRepresentableAdapter(currentSession, this) sessionAdapter = RowRepresentableAdapter(currentSession, this)
recyclerView.adapter = sessionAdapter recyclerView.adapter = sessionAdapter
updateSessionUI() updateSessionUI(true)
} }
/** /**

@ -145,8 +145,14 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="bottom|center" android:layout_gravity="bottom|center"
android:layout_marginBottom="28dp" android:layout_marginBottom="28dp"
android:alpha="0"
android:elevation="16dp" android:elevation="16dp"
android:scaleX="0"
android:scaleY="0"
android:src="@drawable/ic_outline_play" android:src="@drawable/ic_outline_play"
android:tint="@color/black" /> android:tint="@color/black"
tools:alpha="1"
tools:scaleX="1"
tools:scaleY="1" />
</androidx.coordinatorlayout.widget.CoordinatorLayout> </androidx.coordinatorlayout.widget.CoordinatorLayout>
Loading…
Cancel
Save