Merge pull request #98 from kirmanak/fix-crash-on-url-fragment
Fix crash on URL input fragment
This commit is contained in:
@@ -17,8 +17,8 @@ plugins {
|
|||||||
android {
|
android {
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId = "gq.kirmanak.mealient"
|
applicationId = "gq.kirmanak.mealient"
|
||||||
versionCode = 19
|
versionCode = 20
|
||||||
versionName = "0.3.4"
|
versionName = "0.3.5"
|
||||||
}
|
}
|
||||||
|
|
||||||
signingConfigs {
|
signingConfigs {
|
||||||
|
|||||||
@@ -53,8 +53,8 @@ class MainActivity : AppCompatActivity(R.layout.main_activity) {
|
|||||||
logger.d { "configureNavGraph: received destination" }
|
logger.d { "configureNavGraph: received destination" }
|
||||||
val controller = navController
|
val controller = navController
|
||||||
val graph = controller.navInflater.inflate(R.navigation.nav_graph)
|
val graph = controller.navInflater.inflate(R.navigation.nav_graph)
|
||||||
graph.setStartDestination(it)
|
graph.setStartDestination(it.startDestinationId)
|
||||||
controller.setGraph(graph, intent.extras)
|
controller.setGraph(graph, it.startDestinationArgs)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import gq.kirmanak.mealient.data.baseurl.ServerInfoRepo
|
|||||||
import gq.kirmanak.mealient.data.disclaimer.DisclaimerStorage
|
import gq.kirmanak.mealient.data.disclaimer.DisclaimerStorage
|
||||||
import gq.kirmanak.mealient.data.recipes.RecipeRepo
|
import gq.kirmanak.mealient.data.recipes.RecipeRepo
|
||||||
import gq.kirmanak.mealient.logging.Logger
|
import gq.kirmanak.mealient.logging.Logger
|
||||||
|
import gq.kirmanak.mealient.ui.baseurl.BaseURLFragmentArgs
|
||||||
import kotlinx.coroutines.channels.Channel
|
import kotlinx.coroutines.channels.Channel
|
||||||
import kotlinx.coroutines.flow.Flow
|
import kotlinx.coroutines.flow.Flow
|
||||||
import kotlinx.coroutines.flow.launchIn
|
import kotlinx.coroutines.flow.launchIn
|
||||||
@@ -32,8 +33,8 @@ class MainActivityViewModel @Inject constructor(
|
|||||||
get() = checkNotNull(_uiState.value) { "UiState must not be null" }
|
get() = checkNotNull(_uiState.value) { "UiState must not be null" }
|
||||||
private set(value) = _uiState.postValue(value)
|
private set(value) = _uiState.postValue(value)
|
||||||
|
|
||||||
private val _startDestination = MutableLiveData<Int>()
|
private val _startDestination = MutableLiveData<StartDestinationInfo>()
|
||||||
val startDestination: LiveData<Int> = _startDestination
|
val startDestination: LiveData<StartDestinationInfo> = _startDestination
|
||||||
|
|
||||||
private val _clearSearchViewFocusChannel = Channel<Unit>()
|
private val _clearSearchViewFocusChannel = Channel<Unit>()
|
||||||
val clearSearchViewFocus: Flow<Unit> = _clearSearchViewFocusChannel.receiveAsFlow()
|
val clearSearchViewFocus: Flow<Unit> = _clearSearchViewFocusChannel.receiveAsFlow()
|
||||||
@@ -45,9 +46,15 @@ class MainActivityViewModel @Inject constructor(
|
|||||||
|
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
_startDestination.value = when {
|
_startDestination.value = when {
|
||||||
!disclaimerStorage.isDisclaimerAccepted() -> R.id.disclaimerFragment
|
!disclaimerStorage.isDisclaimerAccepted() -> {
|
||||||
serverInfoRepo.getUrl() == null -> R.id.baseURLFragment
|
StartDestinationInfo(R.id.disclaimerFragment)
|
||||||
else -> R.id.recipesListFragment
|
}
|
||||||
|
serverInfoRepo.getUrl() == null -> {
|
||||||
|
StartDestinationInfo(R.id.baseURLFragment, BaseURLFragmentArgs(true).toBundle())
|
||||||
|
}
|
||||||
|
else -> {
|
||||||
|
StartDestinationInfo(R.id.recipesListFragment)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package gq.kirmanak.mealient.ui.activity
|
||||||
|
|
||||||
|
import android.os.Bundle
|
||||||
|
import androidx.annotation.IdRes
|
||||||
|
|
||||||
|
data class StartDestinationInfo(
|
||||||
|
@IdRes val startDestinationId: Int,
|
||||||
|
val startDestinationArgs: Bundle? = null,
|
||||||
|
)
|
||||||
Reference in New Issue
Block a user