Add the ability to override destroyOnScreenOff functionality if desired
This commit is contained in:
parent
ba2f911909
commit
f5c6dfc942
1 changed files with 9 additions and 9 deletions
|
@ -43,15 +43,9 @@ public abstract class BaseActivity extends ThemedActivity {
|
||||||
@Override
|
@Override
|
||||||
protected void onDestroy() {
|
protected void onDestroy() {
|
||||||
unregisterReceiver(screenOffReceiver);
|
unregisterReceiver(screenOffReceiver);
|
||||||
|
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void destroyIfNotMain() {
|
|
||||||
if (getClass() != MainActivity.class)
|
|
||||||
finish();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setBroadcastCallback(BroadcastReceivedCallback cb) {
|
public void setBroadcastCallback(BroadcastReceivedCallback cb) {
|
||||||
this.broadcastReceivedCallback = cb;
|
this.broadcastReceivedCallback = cb;
|
||||||
}
|
}
|
||||||
|
@ -62,12 +56,18 @@ public abstract class BaseActivity extends ThemedActivity {
|
||||||
@Override
|
@Override
|
||||||
public void onReceive(Context context, Intent intent) {
|
public void onReceive(Context context, Intent intent) {
|
||||||
if (intent.getAction().equals(Intent.ACTION_SCREEN_OFF)) {
|
if (intent.getAction().equals(Intent.ACTION_SCREEN_OFF)) {
|
||||||
if (broadcastReceivedCallback != null)
|
if (broadcastReceivedCallback != null) {
|
||||||
broadcastReceivedCallback.onReceivedScreenOff();
|
broadcastReceivedCallback.onReceivedScreenOff();
|
||||||
|
}
|
||||||
|
if (shouldDestroyOnScreenOff()) {
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
destroyIfNotMain();
|
protected boolean shouldDestroyOnScreenOff() {
|
||||||
}
|
return getClass() != MainActivity.class;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
interface BroadcastReceivedCallback {
|
interface BroadcastReceivedCallback {
|
||||||
|
|
Loading…
Reference in a new issue