Skip to content

Commit

Permalink
Added a basic default fragment transition animation
Browse files Browse the repository at this point in the history
  • Loading branch information
rt-bishop committed Mar 1, 2022
1 parent 930e05c commit 20306ec
Show file tree
Hide file tree
Showing 8 changed files with 63 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,9 @@ class EntriesFragment : Fragment(R.layout.fragment_entries) {
is DataState.Success -> {
entriesAdapter.submitList(dataState.data)
binding.entriesProgress.visibility = View.INVISIBLE
binding.entriesRecycler.visibility = View.VISIBLE
}
is DataState.Loading -> {
binding.entriesProgress.visibility = View.VISIBLE
binding.entriesRecycler.visibility = View.INVISIBLE
}
else -> {}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import com.rtbishop.look4sat.domain.ISettings
import com.rtbishop.look4sat.domain.model.DataState
import com.rtbishop.look4sat.domain.model.SatItem
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.delay
import java.util.*
import javax.inject.Inject

Expand All @@ -34,7 +35,10 @@ class EntriesViewModel @Inject constructor(

private val transModes = MutableLiveData(settings.loadModesSelection())
private val currentQuery = MutableLiveData(String())
private val itemsFromRepo = liveData { emit(loadEntriesWithSelection()) } as MutableLiveData
private val itemsFromRepo = liveData {
delay(125)
emit(loadEntriesWithSelection())
} as MutableLiveData
private val itemsWithModes = transModes.switchMap { modes ->
itemsFromRepo.map { items -> filterByModes(items, modes) }
}
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/res/layout/fragment_entries.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="match_parent"
android:transitionGroup="true">

<androidx.cardview.widget.CardView
android:id="@+id/entries_toolbar"
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/layout/fragment_map.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:transitionGroup="true"
android:keepScreenOn="true">

<androidx.cardview.widget.CardView
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/res/layout/fragment_passes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="match_parent"
android:transitionGroup="true">

<androidx.cardview.widget.CardView
android:id="@+id/passes_toolbar"
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/layout/fragment_radar.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:transitionGroup="true"
android:keepScreenOn="true">

<androidx.cardview.widget.CardView
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/res/layout/fragment_settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="match_parent"
android:transitionGroup="true">

<androidx.cardview.widget.CardView
android:id="@+id/settings_toolbar"
Expand Down
60 changes: 50 additions & 10 deletions app/src/main/res/navigation/nav_graph.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,23 @@
tools:layout="@layout/fragment_entries">
<action
android:id="@+id/entries_to_modes"
app:destination="@id/nav_modes" />
app:destination="@id/nav_modes"
app:enterAnim="@anim/nav_default_enter_anim"
app:exitAnim="@anim/nav_default_exit_anim"
app:popEnterAnim="@anim/nav_default_pop_enter_anim"
app:popExitAnim="@anim/nav_default_pop_exit_anim" />
</fragment>
<fragment
android:id="@+id/nav_passes"
android:name="com.rtbishop.look4sat.presentation.passesScreen.PassesFragment"
tools:layout="@layout/fragment_passes">
<action
android:id="@+id/passes_to_filter"
app:destination="@id/nav_filter" />
app:destination="@id/nav_filter"
app:enterAnim="@anim/nav_default_enter_anim"
app:exitAnim="@anim/nav_default_exit_anim"
app:popEnterAnim="@anim/nav_default_pop_enter_anim"
app:popExitAnim="@anim/nav_default_pop_exit_anim" />
</fragment>
<fragment
android:id="@+id/nav_radar"
Expand Down Expand Up @@ -48,7 +56,11 @@
tools:layout="@layout/fragment_settings">
<action
android:id="@+id/settings_to_sources"
app:destination="@id/nav_sources" />
app:destination="@id/nav_sources"
app:enterAnim="@anim/nav_default_enter_anim"
app:exitAnim="@anim/nav_default_exit_anim"
app:popEnterAnim="@anim/nav_default_pop_enter_anim"
app:popExitAnim="@anim/nav_default_pop_exit_anim" />
</fragment>
<dialog
android:id="@+id/nav_modes"
Expand All @@ -72,23 +84,51 @@
tools:layout="@layout/dialog_locator" />
<action
android:id="@+id/global_to_entries"
app:destination="@id/nav_entries" />
app:destination="@id/nav_entries"
app:enterAnim="@anim/nav_default_enter_anim"
app:exitAnim="@anim/nav_default_exit_anim"
app:popEnterAnim="@anim/nav_default_pop_enter_anim"
app:popExitAnim="@anim/nav_default_pop_exit_anim" />
<action
android:id="@+id/global_to_passes"
app:destination="@id/nav_passes" />
app:destination="@id/nav_passes"
app:enterAnim="@anim/nav_default_enter_anim"
app:exitAnim="@anim/nav_default_exit_anim"
app:popEnterAnim="@anim/nav_default_pop_enter_anim"
app:popExitAnim="@anim/nav_default_pop_exit_anim" />
<action
android:id="@+id/global_to_radar"
app:destination="@id/nav_radar" />
app:destination="@id/nav_radar"
app:enterAnim="@anim/nav_default_enter_anim"
app:exitAnim="@anim/nav_default_exit_anim"
app:popEnterAnim="@anim/nav_default_pop_enter_anim"
app:popExitAnim="@anim/nav_default_pop_exit_anim" />
<action
android:id="@+id/global_to_map"
app:destination="@id/nav_map" />
app:destination="@id/nav_map"
app:enterAnim="@anim/nav_default_enter_anim"
app:exitAnim="@anim/nav_default_exit_anim"
app:popEnterAnim="@anim/nav_default_pop_enter_anim"
app:popExitAnim="@anim/nav_default_pop_exit_anim" />
<action
android:id="@+id/global_to_settings"
app:destination="@id/nav_settings" />
app:destination="@id/nav_settings"
app:enterAnim="@anim/nav_default_enter_anim"
app:exitAnim="@anim/nav_default_exit_anim"
app:popEnterAnim="@anim/nav_default_pop_enter_anim"
app:popExitAnim="@anim/nav_default_pop_exit_anim" />
<action
android:id="@+id/global_to_position"
app:destination="@id/nav_position" />
app:destination="@id/nav_position"
app:enterAnim="@anim/nav_default_enter_anim"
app:exitAnim="@anim/nav_default_exit_anim"
app:popEnterAnim="@anim/nav_default_pop_enter_anim"
app:popExitAnim="@anim/nav_default_pop_exit_anim" />
<action
android:id="@+id/global_to_locator"
app:destination="@id/nav_locator" />
app:destination="@id/nav_locator"
app:enterAnim="@anim/nav_default_enter_anim"
app:exitAnim="@anim/nav_default_exit_anim"
app:popEnterAnim="@anim/nav_default_pop_enter_anim"
app:popExitAnim="@anim/nav_default_pop_exit_anim" />
</navigation>

0 comments on commit 20306ec

Please sign in to comment.