2017-02-07 02:01:32 +08:00
|
|
|
package com.topjohnwu.magisk.components;
|
|
|
|
|
2017-11-17 01:39:34 +08:00
|
|
|
import android.content.Intent;
|
|
|
|
|
2017-02-07 02:01:32 +08:00
|
|
|
import com.topjohnwu.magisk.MagiskManager;
|
2017-08-04 00:12:11 +08:00
|
|
|
import com.topjohnwu.magisk.utils.Topic;
|
2017-02-12 05:02:18 +08:00
|
|
|
import com.topjohnwu.magisk.utils.Utils;
|
2017-02-07 02:01:32 +08:00
|
|
|
|
2018-08-01 00:47:31 +08:00
|
|
|
public class Fragment extends android.support.v4.app.Fragment implements Topic.AutoSubscriber {
|
2017-02-07 02:01:32 +08:00
|
|
|
|
|
|
|
public MagiskManager getApplication() {
|
2017-02-12 05:02:18 +08:00
|
|
|
return Utils.getMagiskManager(getActivity());
|
2017-02-07 02:01:32 +08:00
|
|
|
}
|
|
|
|
|
2017-07-23 00:12:15 +08:00
|
|
|
@Override
|
|
|
|
public void onResume() {
|
|
|
|
super.onResume();
|
2018-08-01 00:47:31 +08:00
|
|
|
Topic.subscribe(this);
|
2017-07-23 00:12:15 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onPause() {
|
2018-08-01 00:47:31 +08:00
|
|
|
Topic.unsubscribe(this);
|
2017-07-23 00:12:15 +08:00
|
|
|
super.onPause();
|
|
|
|
}
|
2017-11-17 01:39:34 +08:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void startActivityForResult(Intent intent, int requestCode) {
|
|
|
|
startActivityForResult(intent, requestCode, this::onActivityResult);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void startActivityForResult(Intent intent, int requestCode, Activity.ActivityResultListener listener) {
|
2018-07-30 20:37:00 +08:00
|
|
|
((Activity) requireActivity()).startActivityForResult(intent, requestCode, listener);
|
2017-11-17 01:39:34 +08:00
|
|
|
}
|
2018-06-09 17:14:24 +08:00
|
|
|
|
|
|
|
public void runWithPermission(String[] permissions, Runnable callback) {
|
2018-07-30 20:37:00 +08:00
|
|
|
((Activity) requireActivity()).runWithPermission(permissions,callback);
|
2018-06-09 17:14:24 +08:00
|
|
|
}
|
2018-08-01 00:47:31 +08:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public int[] getSubscribedTopics() {
|
|
|
|
return FlavorActivity.EMPTY_INT_ARRAY;
|
|
|
|
}
|
2017-02-07 02:01:32 +08:00
|
|
|
}
|