android / codelab-android-lifecycles Goto Github PK
View Code? Open in Web Editor NEWHome Page: https://codelabs.developers.google.com/codelabs/android-lifecycles/
License: Apache License 2.0
Home Page: https://codelabs.developers.google.com/codelabs/android-lifecycles/
License: Apache License 2.0
I am using kotlin coroutines and lifecycle extensions for it, specifically viewModelScope. I also turned on StrictMode. When I call
viewModelScope.launch {}
in viewModel I have an error
StrictMode ThreadPolicy violation. Caused by: android.os.strictmode.DiskReadViolation
Why viewModelScope uses disk read in initialization and how to init viewModelScope right (without strict mode violations)?
This is not a bug it is more a suggestion and is referred to the usage of the Enum compareTo method (based on constants ordinals). As suggested by Joshua Bloch in Effective Java (Item 31 "Use instance fields instead of ordinals") I'd go for this approach given that it is less fragile and self-explaining.
Keep up the good work.
Paolo
Unable to navigate to other steps after introduction. Even direct link isnt working
Step 2 says open and examine how ChronoActivity2 uses ViewModel. And then it asks to run without giving instructions on what to change and expects a different output.
Is there a Kotlin version of this somewhere?
Lat Long is not showing up..
Tried including three lines as mentioned in codelabs , step 4.
Failed to achieve desired output
Running Solution_step4 is also resulting same textview saying 'Location'
Devices tested on : Samsung SM-G610F 7.0 24 & Redmi Note 5
Let me know what i am doing wrong.
Looks like startDate
field name here is irrelevant. startTime
or mInitialTime
would make sense.
Unable clone, don't have permissions. Downloaded .zip, ChronoActivity2 does not exist as indicated in Step 2.
The codelab at
https://codelabs.developers.google.com/codelabs/android-lifecycles/
uses deprecated classes, It should be mentioned that AppcompatActivity replaces LifecycleActivity.
java.lang.IllegalStateException: Cannot invoke setValue on a background thread
public LiveDataTimerViewModel() {
mInitialTime = SystemClock.elapsedRealtime();
Timer timer = new Timer();
// Update the elapsed time every second.
timer.scheduleAtFixedRate(new TimerTask() {
@Override
public void run() {
final long newValue = (SystemClock.elapsedRealtime() - mInitialTime) / 1000;
// setValue() cannot be called from a background thread so post to main thread.
//TODO post the new value with LiveData.postValue()
mElapsedTime.setValue(newValue);
}
}, ONE_SECOND, ONE_SECOND);
Long newValue = null;
mElapsedTime.setValue(newValue);
}
On Step-4 :
As mentioned above, When the configuration is changed when App is asking for Location Permission, the onRequestPermissionsResult() method will be called again where it will find grantResults as empty array, so the grantResult[0] will result in ArrayOutOfBoundIndex Exception.
Fix:
@OverRide
public void onRequestPermissionsResult(int requestCode, @nonnull String[] permissions,
@nonnull int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
if (requestCode == REQUEST_LOCATION_PERMISSION_CODE && grantResults.length > 0) {
... < all code remaining same >
}
}
The project needs to be "opened" as opposed to "imported". It didn't specify either. Also, after opening, you should instruct the user to do a gradle sync so that the configurations pick up the app and therefor load. So, just some clarity in instruction needed. Thanks!
The EVENT
Enum needs to be refactored to Event
as the Lifecycle
class does not have EVENT
, instead it is Event
as an Enum.
https://codelabs.developers.google.com/codelabs/android-lifecycles/#4
Hi guys,
I can't find an example of how to handle a situation when a callback needs to be dispatched from a global object that lives in Application scope.
Given the potential multiplicity of Lifecycles involved, is this possible at all?
I would like to refactor this code to use Lifecycles:
public class MyActivity extends Activity implements UserStateManagerListener {
private UserStateManager mUserStateManager;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
...
mUserStateManager = ((MyApplication)getApplication()).getUserStateManager();
}
@Override
protected void onStart() {
super.onStart();
mUserStateManager.registerListener(this);
}
@Override
protected void onStop() {
super.onStop();
mUserStateManager.unregisterListener(this);
}
@Override
public boolean onUserStateChanged(UserState userState) {
...
}
}
Can't select run configurations during tutorial. While the repo shows .idea/runConfigurations with 8 configuration files, the master download does not have this folder. ..idea/ does have a runConfigurations.xml that doesn't list the steps.
You wrote:
this
refers to an instance of LifecycleOwner
You can change super class to just an Activity and it will work fine, like this:
ChronoActivity2 extends AppCompatActivity
Documentation for ViewModelProviders.of
says about param activity
an activity, in whose scope ViewModels should be retained
So LifecycleOwner is not needed to get a ViewModel.
Please write easy example, where ViewModel will use custom constructor with ViewDataBinding class. How init/restore its ViewModel?
I see only Class type
ViewModelProviders.of(this).get(CustomResultViewModel.class);
Thanks for help.
Im using Lifecycle and got a lot of crash on Android 5.0.2 devices
crash log
Caused by: java.lang.IllegalArgumentException
at android.arch.lifecycle.LifecycleRegistry.downEvent(SourceFile:233)
at android.arch.lifecycle.LifecycleRegistry.backwardPass(SourceFile:284)
at android.arch.lifecycle.LifecycleRegistry.sync(SourceFile:299)
at android.arch.lifecycle.LifecycleRegistry.handleLifecycleEvent(SourceFile:120)
at android.arch.lifecycle.ReportFragment.dispatch(SourceFile:122)
at android.arch.lifecycle.ReportFragment.onDestroy(SourceFile:107)
at android.app.Fragment.performDestroy(Fragment.java:2266)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1017)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1067)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1049)
at android.app.FragmentManagerImpl.dispatchDestroy(FragmentManager.java:1897)
at android.app.Activity.performDestroy(Activity.java:6111)
at android.app.Instrumentation.callActivityOnDestroy(Instrumentation.java:1140)
at android.taobao.atlas.runtime.InstrumentationHook.callActivityOnDestroy(SourceFile:1069)
at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:3761)
... 12 more
I have no idea why we got this crash , any ideas?
Thanks in advance
Here, there is addObserver()
call, but there is no removeObserver()
call for onDestroy. Is this intentional?
Step 3, in section 'Update ChronoActivity' >step 2
mElapsedTime.postValue(newValue);
PFA code.
Also, I am looking for alternatives to segregate Permission code from every activity. Can you please provide any leads for that?
I have a question concerning the LiveDataTimerViewModel
example. Wouldn't it make sense to call the timer.cancel()
method in the ViewModel's onCleared()
method? I had very similar code as in the example and LeakCanary gave me a leak notfication. Adding the timer.cancel ()
fixed the leak.
Kind regards,
Alain
I was playing around with google maps MapView
which needs a bunch of lifecycle events to be called manually on the view, like onLowMemory() and onSaveInstanceState().
Are there any plans to include such events in the library? Or is there a way to extend the library to suit our needs.
Within the "Update ChronoActivity" section and specifically on step (3.) it is being stated that:
"Notice that the log updates every second unless you navigate to another app. If your device supports multi-window mode, you may like to try using it."
However, the "multi-window" statement is misleading and kind of incorrect. When using "multi-window" and switching between apps while in that mode, the "onPause/onResume" will get triggered and not the "onStop", which in its turn will not cause the LiveData to stop observing (the timer will keep counting). LiveData stops observing for changes after an "onStop".
So, the "onStop" will get triggered (and thus LiveData will stop observing for changes) when you navigate to another app, but not when you use multi-window mode.
Build project fails with below error
Could not find runtime.aar (android.arch.lifecycle:runtime:1.0.3).
Searched in the following locations:
https://jcenter.bintray.com/android/arch/lifecycle/runtime/1.0.3/runtime-1.0.3.aar
Doesn't work. After updates it auto selects a virtual device. The AVD then complains that VTx is disabled in BIOS even though VTd is enabled in BIOS! I was trying to run a Codelab Project. https://codelabs.developers.google.com/codelabs/android-lifecycles/#1 Note: My other projects run fine on a real device.
When following the codelab, and downloading the source, when you run the application you get an activity containing 2 sliders, rather than the ChronoActivity1 activity described.
This is because the AndroidManifest.xml sets the last activity (for step 5) to be default by adding:
<category android:name="android.intent.category.LAUNCHER" />
Presumably this should instead be set on the Step 1 activity?
In LiveDataTimeViewModel.java step 3, the CodeLab at https://codelabs.developers.google.com/codelabs/android-lifecycles/#3 states:
2. Next, set the new elapsed time value in the LiveDataTimerViewModel class. Find the following comment:
//TODO set the new value
Replace the comment with the following statement:
mElapsedTime.setValue(newValue);
Which does result in the error stated in the CodeLab code starting at line 48:
// setValue() cannot be called from a background thread so post to main thread.
// TODO post the new value with LiveData.postValue()
// mElapsedTime.setValue(newValue); // as instructed by webpage results in the error
mElapsedTime.postValue(newValue); // no error but not explicitly stated in the webpage itself.
Seems to not reflect each other unless that is the point.
By the way, these components are much needed I think and I wished I had discovered them sooner :)
Using studio 3.1.2 download from github and it fails to build due to some weird error.
Program type already present: android.arch.lifecycle.LiveData$LifecycleBoundObserver
Message{kind=ERROR, text=Program type already present: android.arch.lifecycle.LiveData$LifecycleBoundObserver, sources=[Unknown source file], tool name=Optional.of(D8)}
On the run section of the build it shows more errors:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:100)
at ........and more
Caused by: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives: C:\amine\AndroidStudioWorkspace\android-lifecycles\app\build\intermediates\transforms\dexBuilder\debug\0.jar, C:\amine\AndroidStudioWorkspace\android-lifecycles\app\build\intermediates\transforms\dexBuilder\debug\1.jar, C:\amine\AndroidStudioWorkspace\android-lifecycles\app\build\intermediates\transforms\dexBuilder\debug\2.jar,
changed the gradle to reflect new studio changes:
Project gradle:
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
mavenCentral()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
ext {
supportLibVersion = "27.1.0"
runnerVersion = "1.0.1"
rulesVersion = "1.0.1"
espressoVersion = "3.0.1"
archLifecycleVersion = "1.0.0"
archRoomVersion = "1.0.0"
}
App gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId 'com.example.android.codelabs.lifecycle'
minSdkVersion 21
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dataBinding {
enabled = true
}
productFlavors {
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:' + rootProject.supportLibVersion
implementation 'com.android.support:cardview-v7:' + rootProject.supportLibVersion
implementation 'com.android.support:recyclerview-v7:' + rootProject.supportLibVersion
implementation 'com.android.support:support-v4:' + rootProject.supportLibVersion
implementation 'android.arch.lifecycle:extensions:' + rootProject.archLifecycleVersion
implementation 'android.arch.persistence.room:runtime:' + rootProject.archRoomVersion
annotationProcessor 'android.arch.lifecycle:compiler:' + rootProject.archLifecycleVersion
annotationProcessor 'android.arch.persistence.room:compiler:' + rootProject.archRoomVersion
androidTestImplementation('com.android.support.test.espresso:espresso-core:' + rootProject.espressoVersion, {
exclude group: 'com.android.support', module: 'support-annotations'
})
testImplementation 'junit:junit:4.12'
}
The location listener callback is a non-static inner class of Activity and therefore registering it in the lifecycle listener can cause memory leak.
It should be replaced with LiveData and ViewModel to show best practices, or needs a warning to specify that this is normally not how it should be done.
android-lifecycles project and the codelab documentation is different.
I can't run any configuration of the project.
First of all configurations show the same error: "Module not specified"
Then the "Error running Step 1: No Android facet found for app" message is shown.
How to solve it?
I try to kill the apps then go back into the apps but the data is not saved .Why?
I tried to make new activity by intent it. I ln new activity I implement the same code as statelifecyle. But why when I backpressed and try to enter back the newactivity the data is not saved ?
I think need to use Room for persisted of the data.
The codelab documentation (not the github code, but the web page instructions) refer to classes deprecated in Jan 2018:
LifecycleActivity
LifecycleFragment
(Offending page: https://codelabs.developers.google.com/codelabs/android-lifecycles/#3)
This was raised previously (#45) but was closed without fixing the problem
Hello,
I was originally just googling for examples of a Timer in a Viewmodel and came across this repo
With regards to the timer used here...
https://github.com/googlecodelabs/android-lifecycles/blob/17c5b6fcec2eb2de3f943557bcca3b209d110671/app/src/main/java/com/example/android/lifecycles/step3_solution/LiveDataTimerViewModel.java#L40
Dont we still need to cancel that in the viewmodel?
Something like....
override fun onCleared() {
super.onCleared()
timer.cancel()
}
Here https://codelabs.developers.google.com/codelabs/android-lifecycles/#1
I entered the team to clone the repository and agreed with the key. Now I have a mistake:
Cloning into 'android-lifecycles'...
[email protected]: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
What kind of garbage and why don't you write clear documentation?
Can Google engineer update the project to use the latest gradle 3.1.0 and AS 3.1?
It will be removed at the end of 2018
Configuration 'androidTestApi' is obsolete and has been replaced with 'androidTestImplementation'.
It will be removed at the end of 2018
Configuration 'testCompile' is obsolete and has been replaced with 'testImplementation'.
It will be removed at the end of 2018
Configuration 'testApi' is obsolete and has been replaced with 'testImplementation'.
It will be removed at the end of 2018
Configuration 'androidTestCompile' is obsolete and has been replaced with 'androidTestImplementation'.
It will be removed at the end of 2018
This example is broken :(
you have to update some gradle settings to get it to work..
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
First of all, I don’t see steps that I can choose when launching an application.
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:compileDebugJavaWithJavac'.
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:95)
at org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.java:91)
at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:57)
at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:119)
at org.gradle.api.internal.tasks.execution.ResolvePreviousStateExecuter.execute(ResolvePreviousStateExecuter.java:43)
at org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:93)
at org.gradle.api.internal.tasks.execution.FinalizePropertiesTaskExecuter.execute(FinalizePropertiesTaskExecuter.java:45)
at org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:94)
at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:56)
at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:55)
at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:36)
at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.executeTask(EventFiringTaskExecuter.java:67)
at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.call(EventFiringTaskExecuter.java:52)
at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.call(EventFiringTaskExecuter.java:49)
at org.gradle.internal.operations.DefaultBuildOperationExecutor$CallableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:315)
at org.gradle.internal.operations.DefaultBuildOperationExecutor$CallableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:305)
at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:175)
at org.gradle.internal.operations.DefaultBuildOperationExecutor.call(DefaultBuildOperationExecutor.java:101)
at org.gradle.internal.operations.DelegatingBuildOperationExecutor.call(DelegatingBuildOperationExecutor.java:36)
at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter.execute(EventFiringTaskExecuter.java:49)
at org.gradle.execution.plan.LocalTaskNodeExecutor.execute(LocalTaskNodeExecutor.java:43)
at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$InvokeNodeExecutorsAction.execute(DefaultTaskExecutionGraph.java:355)
at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$InvokeNodeExecutorsAction.execute(DefaultTaskExecutionGraph.java:343)
at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareExecutionAction.execute(DefaultTaskExecutionGraph.java:336)
at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareExecutionAction.execute(DefaultTaskExecutionGraph.java:322)
at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker$1.execute(DefaultPlanExecutor.java:134)
at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker$1.execute(DefaultPlanExecutor.java:129)
at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.execute(DefaultPlanExecutor.java:202)
at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.executeNextNode(DefaultPlanExecutor.java:193)
at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.run(DefaultPlanExecutor.java:129)
at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.gradle.api.internal.tasks.compile.CompilationFailedException: Compilation failed; see the compiler error output for details.
at org.gradle.api.internal.tasks.compile.JdkJavaCompiler.execute(JdkJavaCompiler.java:52)
at org.gradle.api.internal.tasks.compile.JdkJavaCompiler.execute(JdkJavaCompiler.java:36)
at org.gradle.api.internal.tasks.compile.NormalizingJavaCompiler.delegateAndHandleErrors(NormalizingJavaCompiler.java:100)
at org.gradle.api.internal.tasks.compile.NormalizingJavaCompiler.execute(NormalizingJavaCompiler.java:52)
at org.gradle.api.internal.tasks.compile.NormalizingJavaCompiler.execute(NormalizingJavaCompiler.java:38)
at org.gradle.api.internal.tasks.compile.AnnotationProcessorDiscoveringCompiler.execute(AnnotationProcessorDiscoveringCompiler.java:51)
at org.gradle.api.internal.tasks.compile.AnnotationProcessorDiscoveringCompiler.execute(AnnotationProcessorDiscoveringCompiler.java:37)
at org.gradle.api.internal.tasks.compile.CleaningJavaCompilerSupport.execute(CleaningJavaCompilerSupport.java:39)
at org.gradle.api.internal.tasks.compile.incremental.IncrementalCompilerFactory$2.execute(IncrementalCompilerFactory.java:110)
at org.gradle.api.internal.tasks.compile.incremental.IncrementalCompilerFactory$2.execute(IncrementalCompilerFactory.java:106)
at org.gradle.api.internal.tasks.compile.incremental.IncrementalResultStoringCompiler.execute(IncrementalResultStoringCompiler.java:59)
at org.gradle.api.internal.tasks.compile.incremental.IncrementalResultStoringCompiler.execute(IncrementalResultStoringCompiler.java:43)
at org.gradle.api.internal.tasks.compile.CompileJavaBuildOperationReportingCompiler$2.call(CompileJavaBuildOperationReportingCompiler.java:59)
at org.gradle.api.internal.tasks.compile.CompileJavaBuildOperationReportingCompiler$2.call(CompileJavaBuildOperationReportingCompiler.java:51)
at org.gradle.internal.operations.DefaultBuildOperationExecutor$CallableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:315)
at org.gradle.internal.operations.DefaultBuildOperationExecutor$CallableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:305)
at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:175)
at org.gradle.internal.operations.DefaultBuildOperationExecutor.call(DefaultBuildOperationExecutor.java:101)
at org.gradle.internal.operations.DelegatingBuildOperationExecutor.call(DelegatingBuildOperationExecutor.java:36)
at org.gradle.api.internal.tasks.compile.CompileJavaBuildOperationReportingCompiler.execute(CompileJavaBuildOperationReportingCompiler.java:51)
at org.gradle.api.tasks.compile.JavaCompile.performCompilation(JavaCompile.java:154)
at org.gradle.api.tasks.compile.JavaCompile.compile(JavaCompile.java:122)
at com.android.build.gradle.tasks.AndroidJavaCompile.compile(AndroidJavaCompile.kt:214)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73)
at org.gradle.api.internal.project.taskfactory.IncrementalTaskAction.doExecute(IncrementalTaskAction.java:47)
at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:41)
at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:28)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$2.run(ExecuteActionsTaskExecuter.java:284)
at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:301)
at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:293)
at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:175)
at org.gradle.internal.operations.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:91)
at org.gradle.internal.operations.DelegatingBuildOperationExecutor.run(DelegatingBuildOperationExecutor.java:31)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:273)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:258)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.access$200(ExecuteActionsTaskExecuter.java:67)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$TaskExecution.execute(ExecuteActionsTaskExecuter.java:145)
at org.gradle.internal.execution.impl.steps.ExecuteStep.execute(ExecuteStep.java:49)
at org.gradle.internal.execution.impl.steps.CancelExecutionStep.execute(CancelExecutionStep.java:34)
at org.gradle.internal.execution.impl.steps.TimeoutStep.executeWithoutTimeout(TimeoutStep.java:69)
at org.gradle.internal.execution.impl.steps.TimeoutStep.execute(TimeoutStep.java:49)
at org.gradle.internal.execution.impl.steps.CatchExceptionStep.execute(CatchExceptionStep.java:33)
at org.gradle.internal.execution.impl.steps.CreateOutputsStep.execute(CreateOutputsStep.java:50)
at org.gradle.internal.execution.impl.steps.SnapshotOutputStep.execute(SnapshotOutputStep.java:43)
at org.gradle.internal.execution.impl.steps.SnapshotOutputStep.execute(SnapshotOutputStep.java:29)
at org.gradle.internal.execution.impl.steps.CacheStep.executeWithoutCache(CacheStep.java:134)
at org.gradle.internal.execution.impl.steps.CacheStep.lambda$execute$3(CacheStep.java:83)
at java.util.Optional.orElseGet(Optional.java:267)
at org.gradle.internal.execution.impl.steps.CacheStep.execute(CacheStep.java:82)
at org.gradle.internal.execution.impl.steps.CacheStep.execute(CacheStep.java:36)
at org.gradle.internal.execution.impl.steps.PrepareCachingStep.execute(PrepareCachingStep.java:33)
at org.gradle.internal.execution.impl.steps.StoreSnapshotsStep.execute(StoreSnapshotsStep.java:38)
at org.gradle.internal.execution.impl.steps.StoreSnapshotsStep.execute(StoreSnapshotsStep.java:23)
at org.gradle.internal.execution.impl.steps.SkipUpToDateStep.executeBecause(SkipUpToDateStep.java:96)
at org.gradle.internal.execution.impl.steps.SkipUpToDateStep.lambda$execute$1(SkipUpToDateStep.java:91)
at java.util.Optional.orElseGet(Optional.java:267)
at org.gradle.internal.execution.impl.steps.SkipUpToDateStep.execute(SkipUpToDateStep.java:91)
at org.gradle.internal.execution.impl.steps.SkipUpToDateStep.execute(SkipUpToDateStep.java:36)
at org.gradle.internal.execution.impl.DefaultWorkExecutor.execute(DefaultWorkExecutor.java:34)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:91)
... 35 more
Do you think anyone will want to deal with your code? To hell with your useless project, delete it and do not disgrace
LifecycleRegistryOwner is mentioned in the Step3 description.
But LifecycleRegistryOwner was deprecated in API level 1.1.0.
In introduction part, it warn readers with this:
Caution: The architecture component libraries are in an alpha state of development. The API may change before general availability, and you may encounter stability or performance issues.
which is not valid anymore, since version 1.0 is stable.
https://codelabs.developers.google.com/codelabs/android-lifecycles/#0
Step 2 could be simplify as for proper implementation only ViewModel notion is required without LifecycleActivity.
In the step 3 at LifecycleOwner section. It's stated that
ChronoActivity3
is an instance of LifecycleActivity
, which can provide the state of a lifecycle. This is the class declaration:
public class LifecycleActivity extends FragmentActivity implements LifecycleRegistryOwner {...}
But in the code example, ChronoActivity3
only extends AppCompatActivity and it works fine. Maybe you can add more information about the relationship between AppCompatActivity
with LifecycleActivity
.
Thanks.
In step 5, the observer should be bound to the Fragment's lifecycle, not the Activity's.
This code should be changed to use the Fragment as LifecycleOwner (Fragment needs to extend LifecycleFragment):
mSeekBarViewModel.seekbarValue.observe(
(LifecycleOwner) getActivity(),
new Observer<Integer>() {
@Override
public void onChanged(@Nullable Integer value) {
if (value != null) {
mSeekBar.setProgress(value);
}
}
});
Both ChronoActivities are not resolved in the manifest even though the namespace is right. I don't see the icon to run the individual steps too. Why does the instruction always lack these details? It's fucking annoying.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.