mirror of
https://github.com/imcarlost/Friendlists.git
synced 2026-04-10 02:46:54 -04:00
implement navigation
This commit is contained in:
@@ -39,6 +39,8 @@ dependencies {
|
||||
api deps.androidx.lifecycle_ext
|
||||
api deps.androidx.lifecycle_viewmodel
|
||||
api deps.androidx.recycler_view
|
||||
api deps.androidx.navigation_fragment
|
||||
api deps.androidx.navigation_ui
|
||||
api deps.retrofit.runtime
|
||||
api deps.retrofit.gson
|
||||
api deps.retrofit.rx
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.hako.base.extensions
|
||||
|
||||
import androidx.annotation.IdRes
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.navigation.fragment.NavHostFragment
|
||||
|
||||
fun AppCompatActivity.findNavHostFragment(@IdRes id: Int) =
|
||||
supportFragmentManager.findFragmentById(id) as NavHostFragment
|
||||
|
||||
fun Fragment.findNavHostFragment(@IdRes id: Int) =
|
||||
childFragmentManager.findFragmentById(id) as NavHostFragment
|
||||
|
||||
fun Fragment.findNavController(@IdRes id: Int) =
|
||||
androidx.navigation.Navigation.findNavController(view?.findViewById(id) ?: viewNotFound(id, this))
|
||||
|
||||
private fun viewNotFound(@IdRes id: Int, fragment: Fragment): Nothing = throw IllegalStateException(
|
||||
"View ID $id at '${fragment::class.java.simpleName}' not found."
|
||||
)
|
||||
@@ -7,6 +7,7 @@ versions.androidx_core = "1.1.0"
|
||||
versions.androidx_constraint_layout = "1.1.3"
|
||||
versions.androidx_lifecycle = "2.2.0"
|
||||
versions.androidx_recycler_view = "1.1.0"
|
||||
versions.androidx_navigation = "2.2.0"
|
||||
versions.okhttp_logging_interceptor = "4.3.1"
|
||||
versions.retrofit = "2.7.1"
|
||||
versions.timber = "4.7.1"
|
||||
@@ -33,6 +34,8 @@ androidx.constraint_layout = "androidx.constraintlayout:constraintlayout:$versio
|
||||
androidx.lifecycle_ext = "androidx.lifecycle:lifecycle-extensions:$versions.androidx_lifecycle"
|
||||
androidx.lifecycle_viewmodel = "androidx.lifecycle:lifecycle-viewmodel-ktx:$versions.androidx_lifecycle"
|
||||
androidx.recycler_view = "androidx.recyclerview:recyclerview:$versions.androidx_recycler_view"
|
||||
androidx.navigation_fragment = "androidx.navigation:navigation-fragment-ktx:$versions.androidx_navigation"
|
||||
androidx.navigation_ui = "androidx.navigation:navigation-ui-ktx:$versions.androidx_navigation"
|
||||
deps.androidx = androidx
|
||||
|
||||
def retrofit = [:]
|
||||
|
||||
Reference in New Issue
Block a user