Status Update
Comments
ro...@gmail.com <ro...@gmail.com> #2
This actually has nothing to do with NavHostFragment, but is the behavior of NavController's setGraph().
When you call navController.setGraph(R.navigation.navigation_graph), it stores that ID and will restore that ID automatically.
If you were to instead use:
NavInflater navInflater = new NavInflater(this, navController.getNavigatorProvider());
navController.setGraph(navInflater.inflate(R.navigation.navigation_graph));
Then NavController would not restore the graph itself and the call to restoreState() you point out would only restore the back stack state, etc. but would wait for you to call setGraph again.
You're right that the inconsistency between the two setGraph methods is concerning. We'll take a look.
When you call navController.setGraph(R.navigation.navigation_graph), it stores that ID and will restore that ID automatically.
If you were to instead use:
NavInflater navInflater = new NavInflater(this, navController.getNavigatorProvider());
navController.setGraph(navInflater.inflate(R.navigation.navigation_graph));
Then NavController would not restore the graph itself and the call to restoreState() you point out would only restore the back stack state, etc. but would wait for you to call setGraph again.
You're right that the inconsistency between the two setGraph methods is concerning. We'll take a look.
Description
AI-183.4284.148.34.5159543, JRE 1.8.0_152-release-1248-b01x64 JetBrains s.r.o, OS Windows 10(amd64) v10.0 , screens 1600x900, 1920x1080
Android Gradle Plugin: 3.4.0-alpha07
Gradle: 5.0
NDK: from local.properties: (not specified); latest from SDK: (not found);
LLDB: pinned revision 3.1 not found; latest from SDK: (package not found);
CMake: from local.properties: (not specified); latest from SDK: (not found); from PATH: (not found);
IMPORTANT: Please read
---
android.arch.work:work-runtime:1.0.0-alpha12 breaks, (doWork's) Result is missing success() and failure() with no parameters.
Trying to follow last minute changes to WorkManager implementation, this introduced breaking changes in Result, which doWork use.
Trying to follow the transcript for doWork here:
Like this:
======
package no.rogo.projectfk303.workers
import android.content.Context
import android.os.Bundle
import android.util.Log
import androidx.work.Worker
import androidx.work.WorkerParameters
import no.rogo.projectfk303.repositories.CommonDatabaseRepository
import no.rogo.projectfk303.repositories.StationListRepository
/**
* Created by Roar on 13.11.2018.
* Copyright RoGo Software / Gronmo IT
*/
class ReadDatabaseWorker(context: Context, workerParameters: WorkerParameters): Worker(context, workerParameters)
{
private val TAG by lazy { ReadDatabaseWorker::class.java.simpleName }
override fun doWork(): Result { //<--- Failure: One type argument expected for class Result<out T>
return try {
Log.i(TAG,"doWork () !")
val bundle = Bundle()
bundle.putString("kindID","0")
StationListRepository.readStations(bundle)
CommonDatabaseRepository.readKinds()
return Result.success() // <--- Failure: No value passed for parameter 'value'
}catch (ex: Exception)
{
Log.e(TAG,"Error doWork() !!")
return Result.failure() // <---- Fauilure: No value passed for parameter 'exception'
}
}
}
===
of course I could put in 'ex' in Result.failure and 'null' in Result.success(), but I still don't know what to put behind Result...
Opportunities
1. Change documentation so it follows what we should do.
2. Fix implemention of Result.success() and Result.failure() (with no parameters) as shown in example.
In meantime I fall back to alpha11...
RG