diff --git a/app/src/main/java/net/pokeranalytics/android/ui/fragment/SessionFragment.kt b/app/src/main/java/net/pokeranalytics/android/ui/fragment/SessionFragment.kt index ddf62652..732e8b10 100644 --- a/app/src/main/java/net/pokeranalytics/android/ui/fragment/SessionFragment.kt +++ b/app/src/main/java/net/pokeranalytics/android/ui/fragment/SessionFragment.kt @@ -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, @@ -135,15 +135,15 @@ class SessionFragment : PokerAnalyticsFragment(), RowRepresentableDelegate { } floatingActionButton.setOnClickListener { - if (this.currentSession.isValidForSave()) { - sessionHasBeenCustomized = true - manageSessionState() - } else { - val builder = AlertDialog.Builder(requireContext()) - .setMessage(this.currentSession.getFailedSaveMessage(SaveValidityStatus.DATA_INVALID)) - .setNegativeButton(R.string.ok, null) - builder.show() - } + if (this.currentSession.isValidForSave()) { + sessionHasBeenCustomized = true + manageSessionState() + } else { + val builder = AlertDialog.Builder(requireContext()) + .setMessage(this.currentSession.getFailedSaveMessage(SaveValidityStatus.DATA_INVALID)) + .setNegativeButton(R.string.ok, null) + builder.show() + } } } @@ -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) } /** diff --git a/app/src/main/res/layout/fragment_session.xml b/app/src/main/res/layout/fragment_session.xml index bbe0d2f0..53457fd3 100644 --- a/app/src/main/res/layout/fragment_session.xml +++ b/app/src/main/res/layout/fragment_session.xml @@ -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" /> \ No newline at end of file