Improve UI for session (floating action button)

feature/top10
Aurelien Hubert 7 years ago
parent 957d855018
commit 524e54b541
  1. 14
      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)
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(
requireContext(),
row,
@ -151,12 +151,14 @@ class SessionFragment : PokerAnalyticsFragment(), RowRepresentableDelegate {
* Update the UI with the session data
* Should be called after the initialization of the session
*/
private fun updateSessionUI() {
private fun updateSessionUI(firstDisplay: Boolean = false) {
this.currentSession.updateRowRepresentation()
handler.removeCallbacksAndMessages(null)
val animationDuration = if (firstDisplay) 0L else 300L
when (currentSession.getState()) {
SessionState.PENDING, SessionState.PLANNED -> {
state.setTextColor(ContextCompat.getColor(requireContext(), R.color.white))
@ -164,6 +166,7 @@ class SessionFragment : PokerAnalyticsFragment(), RowRepresentableDelegate {
floatingActionButton.setImageResource(R.drawable.ic_outline_play)
sessionMenu?.findItem(R.id.stop)?.isVisible = false
floatingActionButton.animate().scaleX(1f).scaleY(1f).alpha(1f)
.setDuration(animationDuration)
.setInterpolator(OvershootInterpolator()).start()
}
SessionState.STARTED -> {
@ -172,6 +175,7 @@ class SessionFragment : PokerAnalyticsFragment(), RowRepresentableDelegate {
floatingActionButton.setImageResource(R.drawable.ic_outline_pause)
sessionMenu?.findItem(R.id.stop)?.isVisible = true
floatingActionButton.animate().scaleX(1f).scaleY(1f).alpha(1f)
.setDuration(animationDuration)
.setInterpolator(OvershootInterpolator()).start()
handler.postDelayed(refreshTimer, 30000)
}
@ -181,6 +185,7 @@ class SessionFragment : PokerAnalyticsFragment(), RowRepresentableDelegate {
floatingActionButton.setImageResource(R.drawable.ic_outline_play)
sessionMenu?.findItem(R.id.stop)?.isVisible = true
floatingActionButton.animate().scaleX(1f).scaleY(1f).alpha(1f)
.setDuration(animationDuration)
.setInterpolator(OvershootInterpolator()).start()
}
SessionState.FINISHED -> {
@ -188,6 +193,7 @@ class SessionFragment : PokerAnalyticsFragment(), RowRepresentableDelegate {
sessionMenu?.findItem(R.id.restart)?.isVisible = true
sessionMenu?.findItem(R.id.stop)?.isVisible = false
floatingActionButton.animate().scaleX(0f).scaleY(0f).alpha(0f)
.setDuration(animationDuration)
.setInterpolator(FastOutSlowInInterpolator()).start()
}
}
@ -299,7 +305,7 @@ class SessionFragment : PokerAnalyticsFragment(), RowRepresentableDelegate {
currentSession.location = location
realm.commitTransaction()
updateSessionUI()
updateSessionUI(true)
}
}
sessionHasBeenCustomized = false
@ -312,7 +318,7 @@ class SessionFragment : PokerAnalyticsFragment(), RowRepresentableDelegate {
sessionAdapter = RowRepresentableAdapter(currentSession, this)
recyclerView.adapter = sessionAdapter
updateSessionUI()
updateSessionUI(true)
}
/**

@ -145,8 +145,14 @@
android:layout_height="wrap_content"
android:layout_gravity="bottom|center"
android:layout_marginBottom="28dp"
android:alpha="0"
android:elevation="16dp"
android:scaleX="0"
android:scaleY="0"
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>
Loading…
Cancel
Save