Skip to content

Commit 9295530

Browse files
Added vertical slide animations while fragments destinations swap
1 parent 2d69582 commit 9295530

File tree

4 files changed

+65
-37
lines changed

4 files changed

+65
-37
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<set xmlns:android="http://schemas.android.com/apk/res/android">
3+
4+
<translate
5+
android:duration="@android:integer/config_shortAnimTime"
6+
android:fromXDelta="0%"
7+
android:fromYDelta="100%"
8+
android:toXDelta="0%"
9+
android:toYDelta="0%" />
10+
</set>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<set xmlns:android="http://schemas.android.com/apk/res/android">
3+
4+
<translate
5+
android:duration="@android:integer/config_shortAnimTime"
6+
android:fromXDelta="0%"
7+
android:fromYDelta="-100%"
8+
android:toXDelta="0%"
9+
android:toYDelta="0%" />
10+
</set>

app/src/main/res/navigation/nav_graph.xml

Lines changed: 45 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -22,47 +22,35 @@
2222
tools:layout="@layout/fragment_home">
2323
<action
2424
android:id="@+id/homeToSearch"
25-
app:destination="@id/searchFragment" />
26-
<action
27-
android:id="@+id/homeToDetail"
28-
app:destination="@id/articleDetailFragment" />
29-
<action
30-
android:id="@+id/homeToOptions"
31-
app:destination="@id/optionsFragment" />
25+
app:destination="@id/searchFragment"
26+
app:enterAnim="@anim/fade_enter_anim"
27+
app:popEnterAnim="@anim/fade_enter_anim"
28+
app:popExitAnim="@anim/slide_out_left" />
3229
<action
3330
android:id="@+id/homeToArticleList"
34-
app:destination="@id/articleListFragment" />
31+
app:destination="@id/articleListFragment"
32+
app:enterAnim="@anim/fade_enter_anim"
33+
app:popEnterAnim="@anim/fade_enter_anim"
34+
app:popExitAnim="@anim/slide_out_left" />
3535
</fragment>
3636

3737
<fragment
3838
android:id="@+id/articleListFragment"
3939
android:name="com.developerbreach.developerbreach.view.list.ArticleListFragment"
4040
android:label="Articles"
41-
tools:layout="@layout/fragment_article_list">
42-
<action
43-
android:id="@+id/articleListToDetail"
44-
app:destination="@id/articleDetailFragment" />
45-
</fragment>
41+
tools:layout="@layout/fragment_article_list" />
4642

4743
<fragment
4844
android:id="@+id/searchFragment"
4945
android:name="com.developerbreach.developerbreach.view.search.SearchFragment"
5046
android:label="Search"
51-
tools:layout="@layout/fragment_search">
52-
<action
53-
android:id="@+id/searchToDetail"
54-
app:destination="@id/articleDetailFragment" />
55-
</fragment>
47+
tools:layout="@layout/fragment_search" />
5648

5749
<fragment
5850
android:id="@+id/favoritesFragment"
5951
android:name="com.developerbreach.developerbreach.view.favorites.FavoritesFragment"
6052
android:label="favorites"
61-
tools:layout="@layout/fragment_favorites">
62-
<action
63-
android:id="@+id/favoritesToDetail"
64-
app:destination="@id/articleDetailFragment" />
65-
</fragment>
53+
tools:layout="@layout/fragment_favorites" />
6654

6755
<fragment
6856
android:id="@+id/articleDetailFragment"
@@ -81,11 +69,7 @@
8169
app:popExitAnim="@android:anim/slide_out_right" />
8270
<action
8371
android:id="@+id/detailToBanner"
84-
app:destination="@id/bannerFragment"
85-
app:enterAnim="@anim/slide_in_right"
86-
app:exitAnim="@anim/slide_out_left"
87-
app:popEnterAnim="@android:anim/slide_in_left"
88-
app:popExitAnim="@android:anim/slide_out_right" />
72+
app:destination="@id/bannerFragment" />
8973
</fragment>
9074

9175
<fragment
@@ -141,25 +125,34 @@
141125
tools:layout="@layout/fragment_options">
142126
<action
143127
android:id="@+id/optionsToAuthors"
144-
app:destination="@id/authorsFragment" />
128+
app:destination="@id/authorsFragment"
129+
app:enterAnim="@anim/slide_in_bottom"
130+
app:popEnterAnim="@anim/fade_enter_anim"
131+
app:popExitAnim="@anim/slide_out_bottom" />
145132
<action
146133
android:id="@+id/optionsToFavorites"
147-
app:destination="@id/favoritesFragment" />
134+
app:destination="@id/favoritesFragment"
135+
app:enterAnim="@anim/slide_in_bottom"
136+
app:popEnterAnim="@anim/fade_enter_anim"
137+
app:popExitAnim="@anim/slide_out_bottom" />
148138
<action
149139
android:id="@+id/optionsToSearch"
150-
app:destination="@id/searchFragment" />
140+
app:destination="@id/searchFragment"
141+
app:enterAnim="@anim/slide_in_bottom"
142+
app:popEnterAnim="@anim/fade_enter_anim"
143+
app:popExitAnim="@anim/slide_out_bottom" />
151144
<action
152145
android:id="@+id/optionsToSettings"
153-
app:destination="@id/settingsFragment" />
154-
<action
155-
android:id="@+id/optionsToIntro"
156-
app:destination="@id/introFragment" />
146+
app:destination="@id/settingsFragment"
147+
app:enterAnim="@anim/slide_in_bottom"
148+
app:popEnterAnim="@anim/fade_enter_anim"
149+
app:popExitAnim="@anim/slide_out_bottom" />
157150
</dialog>
158151

159152
<fragment
160153
android:id="@+id/authorsFragment"
161154
android:name="com.developerbreach.developerbreach.view.authors.AuthorsFragment"
162-
android:label="AuthorsFragment"
155+
android:label="Authors"
163156
tools:layout="@layout/fragment_authors" />
164157

165158
<fragment
@@ -168,4 +161,20 @@
168161
android:label="Network"
169162
tools:layout="@layout/fragment_network" />
170163

164+
<action
165+
android:id="@+id/toDetailFragmentGlobal"
166+
app:destination="@id/articleDetailFragment" />
167+
168+
<action
169+
android:id="@+id/toIntroFragmentGlobal"
170+
app:destination="@id/introFragment" />
171+
172+
<action
173+
android:id="@+id/toOptionsFragmentGlobal"
174+
app:destination="@id/optionsFragment" />
175+
176+
<action
177+
android:id="@+id/toNetworkFragmentGlobal"
178+
app:destination="@id/networkFragment" />
179+
171180
</navigation>

app/src/main/res/values/dimens.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
<!-- item_article, favorite, search -->
88
<dimen name="detail_appbar_layout_height">278dp</dimen>
99

10-
<dimen name="image_size_tools">200dp</dimen>
1110
<dimen name="hor_guideline_width">1dp</dimen>
1211

1312
<!-- Layout Margin, Padding -->

0 commit comments

Comments
 (0)