diff --git a/app/build.gradle b/app/build.gradle index f70ef2d..a8c4727 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -72,6 +72,8 @@ dependencies { implementation "com.squareup.okhttp3:logging-interceptor:$rootProject.okHttpLoggingVersion" implementation "io.reactivex.rxjava2:rxandroid:$rootProject.rxAndroidVersion" implementation("com.squareup.moshi:moshi-kotlin:1.9.2") + implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0' + implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.2.0' // Test dependencies testImplementation "junit:junit:$rootProject.jUnitVersion" diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 0d308aa..ae34831 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -1,7 +1,6 @@ - - + + android:theme="@style/AppTheme"> + - - (R.id.sorting_tab_layout)?.apply { + for (sortBy in HomeViewModel.SortBy.values()) { + addTab(newTab().also { + it.tag = sortBy + it.text = getString(sortBy.text) + }) + } + addOnTabSelectedListener(object : TabLayout.OnTabSelectedListener { + override fun onTabSelected(tab: TabLayout.Tab?) { + val tag = tab?.tag + check(tag is HomeViewModel.SortBy) { "Sorting tab tag is invalid!" } + Log.d(LOG_TAG, "Sorting orders by ${tag.name}") + viewModel.onSortByChanged(tag) + } + + override fun onTabReselected(tab: TabLayout.Tab?) {} + + override fun onTabUnselected(tab: TabLayout.Tab?) {} + }) + } + } + + private fun setupBottomButtons(view: View) { + view.findViewById