mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-03 23:04:08 +01:00
add lifecycle lib (events only logged only so far)
This commit is contained in:
parent
6bafbecd75
commit
6177914213
2 changed files with 19 additions and 1 deletions
|
@ -208,6 +208,9 @@ dependencies {
|
|||
implementation "com.android.support:support-v4:$SUPPORT_LIB_VERSION"
|
||||
implementation "com.android.support:support-compat:$SUPPORT_LIB_VERSION"
|
||||
|
||||
implementation "android.arch.lifecycle:extensions:1.1.1"
|
||||
annotationProcessor "android.arch.lifecycle:compiler:1.1.1"
|
||||
|
||||
// 2.6.8 is probably as far forward as I can go without upping my
|
||||
// min-supported SDK version
|
||||
xw4dImplementation('com.crashlytics.sdk.android:crashlytics:2.6.3@aar') {
|
||||
|
|
|
@ -21,6 +21,11 @@
|
|||
package org.eehouse.android.xw4;
|
||||
|
||||
import android.app.Application;
|
||||
import android.arch.lifecycle.Lifecycle;
|
||||
import android.arch.lifecycle.LifecycleObserver;
|
||||
import android.arch.lifecycle.LifecycleOwner;
|
||||
import android.arch.lifecycle.OnLifecycleEvent;
|
||||
import android.arch.lifecycle.ProcessLifecycleOwner;
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.os.Build;
|
||||
|
@ -32,7 +37,9 @@ import java.util.UUID;
|
|||
|
||||
import junit.framework.Assert;
|
||||
|
||||
public class XWApp extends Application {
|
||||
import static android.arch.lifecycle.Lifecycle.Event.ON_ANY;
|
||||
|
||||
public class XWApp extends Application implements LifecycleObserver {
|
||||
private static final String TAG = XWApp.class.getSimpleName();
|
||||
|
||||
public static final boolean BTSUPPORTED = true;
|
||||
|
@ -65,6 +72,8 @@ public class XWApp extends Application {
|
|||
Assert.assertTrue( s_context == s_context.getApplicationContext() );
|
||||
super.onCreate();
|
||||
|
||||
ProcessLifecycleOwner.get().getLifecycle().addObserver(this);
|
||||
|
||||
// This one line should always get logged even if logging is
|
||||
// off -- because logging is on by default until logEnable is
|
||||
// called.
|
||||
|
@ -91,6 +100,12 @@ public class XWApp extends Application {
|
|||
WiDirWrapper.init( this );
|
||||
}
|
||||
|
||||
@OnLifecycleEvent(ON_ANY)
|
||||
public void onAny(LifecycleOwner source, Lifecycle.Event event)
|
||||
{
|
||||
Log.d( TAG, "onAny(%s, %s)", source, event );
|
||||
}
|
||||
|
||||
// This is called on emulator only, but good for ensuring no memory leaks
|
||||
// by forcing JNI cleanup
|
||||
@Override
|
||||
|
|
Loading…
Reference in a new issue