Update CallbackEvents

This commit is contained in:
topjohnwu
2017-07-23 00:12:15 +08:00
parent bd6585765e
commit 36124ddca4
13 changed files with 125 additions and 131 deletions
@@ -1,14 +1,14 @@
package com.topjohnwu.magisk.components;
import android.content.res.Configuration;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.view.WindowManager;
import com.topjohnwu.magisk.MagiskManager;
import com.topjohnwu.magisk.R;
import com.topjohnwu.magisk.utils.Utils;
import java.util.Locale;
import com.topjohnwu.magisk.utils.CallbackEvent;
public class Activity extends AppCompatActivity {
@@ -19,6 +19,22 @@ public class Activity extends AppCompatActivity {
applyOverrideConfiguration(configuration);
}
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (this instanceof CallbackEvent.Listener) {
((CallbackEvent.Listener) this).registerEvents();
}
}
@Override
protected void onDestroy() {
if (this instanceof CallbackEvent.Listener) {
((CallbackEvent.Listener) this).unregisterEvents();
}
super.onDestroy();
}
@Override
public MagiskManager getApplicationContext() {
return (MagiskManager) super.getApplicationContext();
@@ -1,6 +1,7 @@
package com.topjohnwu.magisk.components;
import com.topjohnwu.magisk.MagiskManager;
import com.topjohnwu.magisk.utils.CallbackEvent;
import com.topjohnwu.magisk.utils.Utils;
public class Fragment extends android.support.v4.app.Fragment {
@@ -9,4 +10,19 @@ public class Fragment extends android.support.v4.app.Fragment {
return Utils.getMagiskManager(getActivity());
}
@Override
public void onResume() {
super.onResume();
if (this instanceof CallbackEvent.Listener) {
((CallbackEvent.Listener) this).registerEvents();
}
}
@Override
public void onPause() {
if (this instanceof CallbackEvent.Listener) {
((CallbackEvent.Listener) this).unregisterEvents();
}
super.onPause();
}
}