Skip to content

Commit 29b3529

Browse files
Add sort menu names, and animation for fragment transaction
1 parent 496826d commit 29b3529

21 files changed

+187
-31
lines changed

app/src/main/res/anim/fade_in.xml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
~ Copyright (C) 2018 The Android Open Source Project
4+
~
5+
~ Licensed under the Apache License, Version 2.0 (the "License");
6+
~ you may not use this file except in compliance with the License.
7+
~ You may obtain a copy of the License at
8+
~
9+
~ http://www.apache.org/licenses/LICENSE-2.0
10+
~
11+
~ Unless required by applicable law or agreed to in writing, software
12+
~ distributed under the License is distributed on an "AS IS" BASIS,
13+
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
~ See the License for the specific language governing permissions and
15+
~ limitations under the License.
16+
-->
17+
18+
<set xmlns:android="http://schemas.android.com/apk/res/android">
19+
<alpha
20+
android:duration="@android:integer/config_mediumAnimTime"
21+
android:fromAlpha="0.0"
22+
android:toAlpha="1.0"/>
23+
</set>

app/src/main/res/anim/fade_out.xml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
~ Copyright (C) 2018 The Android Open Source Project
4+
~
5+
~ Licensed under the Apache License, Version 2.0 (the "License");
6+
~ you may not use this file except in compliance with the License.
7+
~ You may obtain a copy of the License at
8+
~
9+
~ http://www.apache.org/licenses/LICENSE-2.0
10+
~
11+
~ Unless required by applicable law or agreed to in writing, software
12+
~ distributed under the License is distributed on an "AS IS" BASIS,
13+
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
~ See the License for the specific language governing permissions and
15+
~ limitations under the License.
16+
-->
17+
18+
<set xmlns:android="http://schemas.android.com/apk/res/android">
19+
<alpha
20+
android:duration="@android:integer/config_mediumAnimTime"
21+
android:fromAlpha="1.0"
22+
android:toAlpha="0.0"/>
23+
</set>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<set xmlns:android="http://schemas.android.com/apk/res/android">
3+
4+
<translate android:fromXDelta="-100%" android:toXDelta="0%"
5+
android:fromYDelta="0%" android:toYDelta="0%"
6+
android:duration="700"/>
7+
</set>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<set xmlns:android="http://schemas.android.com/apk/res/android">
3+
4+
<translate android:fromXDelta="100%" android:toXDelta="0%"
5+
android:fromYDelta="0%" android:toYDelta="0%"
6+
android:duration="700"/>
7+
</set>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<set xmlns:android="http://schemas.android.com/apk/res/android">
3+
4+
<translate android:fromXDelta="0%" android:toXDelta="-100%"
5+
android:fromYDelta="0%" android:toYDelta="0%"
6+
android:duration="700"/>
7+
</set>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<set xmlns:android="http://schemas.android.com/apk/res/android">
3+
4+
<translate android:fromXDelta="0%" android:toXDelta="100%"
5+
android:fromYDelta="0%" android:toYDelta="0%"
6+
android:duration="700"/>
7+
</set>

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,11 @@
1313

1414
<action
1515
android:id="@+id/action_mainFragment_to_propertyDetailFragment"
16-
app:destination="@id/nav_graph_property_detail" />
16+
app:destination="@id/nav_graph_property_detail"
17+
app:enterAnim="@anim/slide_in_right"
18+
app:exitAnim="@anim/slide_out_left"
19+
app:popEnterAnim="@anim/slide_in_left"
20+
app:popExitAnim="@anim/slide_out_right" />
1721

1822
</fragment>
1923

features/home/src/main/java/com/smarttoolfactory/home/HomeFragment.kt

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import androidx.core.os.bundleOf
88
import androidx.fragment.app.DialogFragment
99
import androidx.fragment.app.Fragment
1010
import androidx.fragment.app.activityViewModels
11-
import androidx.lifecycle.Observer
1211
import androidx.lifecycle.ViewModelProvider
1312
import androidx.navigation.NavController
1413
import androidx.navigation.fragment.findNavController
@@ -129,7 +128,7 @@ class HomeFragment : DynamicNavigationFragment<FragmentHomeBinding>() {
129128
private fun subscribeAppbarNavigation() {
130129
navControllerViewModel.currentNavController.observe(
131130
viewLifecycleOwner,
132-
Observer { it ->
131+
{ it ->
133132

134133
it?.let { event: Event<NavController?> ->
135134
event.getContentIfNotHandled()?.let { navController ->
@@ -192,18 +191,18 @@ class SortDialogFragment : DialogFragment() {
192191

193192
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
194193

195-
val displayNames = viewModel.sortPropertyList.toTypedArray()
196194
currentItem = viewModel.sortPropertyList.indexOf(viewModel.currentSortFilter)
197195
checkedItem = currentItem
198196

199-
displayNames[0] = "Featured"
200-
201197
val builder = AlertDialog.Builder(requireActivity())
202198
builder.setTitle("Sorting")
203199
.setNegativeButton("CANCEL") { dialog, which ->
204200
dismiss()
205201
}
206-
.setSingleChoiceItems(displayNames, currentItem) { dialog, which ->
202+
.setSingleChoiceItems(
203+
viewModel.sortFilterNames.toTypedArray(),
204+
currentItem
205+
) { dialog, which ->
207206
checkedItem = which
208207
}.setOnDismissListener {
209208

features/home/src/main/java/com/smarttoolfactory/home/viewmodel/HomeToolbarVM.kt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,13 @@ class HomeToolbarVM @ViewModelInject constructor() : ViewModel() {
2222
ORDER_BY_DES_DESCENDING
2323
)
2424

25+
val sortFilterNames = listOf(
26+
"Featured",
27+
"Price Ascending",
28+
"Price Descending",
29+
"Beds Ascending",
30+
"Beds Descending"
31+
)
32+
2533
val queryBySort = MutableLiveData<Event<String>>()
2634
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
~ Copyright (C) 2018 The Android Open Source Project
4+
~
5+
~ Licensed under the Apache License, Version 2.0 (the "License");
6+
~ you may not use this file except in compliance with the License.
7+
~ You may obtain a copy of the License at
8+
~
9+
~ http://www.apache.org/licenses/LICENSE-2.0
10+
~
11+
~ Unless required by applicable law or agreed to in writing, software
12+
~ distributed under the License is distributed on an "AS IS" BASIS,
13+
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
~ See the License for the specific language governing permissions and
15+
~ limitations under the License.
16+
-->
17+
18+
<set xmlns:android="http://schemas.android.com/apk/res/android">
19+
<alpha
20+
android:duration="@android:integer/config_mediumAnimTime"
21+
android:fromAlpha="0.0"
22+
android:toAlpha="1.0"/>
23+
</set>

0 commit comments

Comments
 (0)