Update Topic
This commit is contained in:
parent
454abc388b
commit
da9d00be7d
@ -15,16 +15,15 @@ public class Topic {
|
|||||||
public static final int MODULE_LOAD_DONE = 1;
|
public static final int MODULE_LOAD_DONE = 1;
|
||||||
public static final int REPO_LOAD_DONE = 2;
|
public static final int REPO_LOAD_DONE = 2;
|
||||||
public static final int UPDATE_CHECK_DONE = 3;
|
public static final int UPDATE_CHECK_DONE = 3;
|
||||||
public static final int SNET_CHECK_DONE = 4;
|
public static final int LOCALE_FETCH_DONE = 4;
|
||||||
public static final int LOCALE_FETCH_DONE = 5;
|
|
||||||
|
|
||||||
@IntDef({MAGISK_HIDE_DONE, MODULE_LOAD_DONE, REPO_LOAD_DONE,
|
@IntDef({MAGISK_HIDE_DONE, MODULE_LOAD_DONE, REPO_LOAD_DONE,
|
||||||
UPDATE_CHECK_DONE, SNET_CHECK_DONE, LOCALE_FETCH_DONE})
|
UPDATE_CHECK_DONE, LOCALE_FETCH_DONE})
|
||||||
@Retention(RetentionPolicy.SOURCE)
|
@Retention(RetentionPolicy.SOURCE)
|
||||||
public @interface TopicID {}
|
public @interface TopicID {}
|
||||||
|
|
||||||
// We will not dynamically add topics, so use arrays instead of hash tables
|
// We will not dynamically add topics, so use arrays instead of hash tables
|
||||||
private static Store[] topicList = new Store[6];
|
private static Store[] topicList = new Store[5];
|
||||||
|
|
||||||
public static void subscribe(Subscriber sub, @TopicID int... topics) {
|
public static void subscribe(Subscriber sub, @TopicID int... topics) {
|
||||||
for (int topic : topics) {
|
for (int topic : topics) {
|
||||||
@ -38,8 +37,7 @@ public class Topic {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void subscribe(AutoSubscriber sub) {
|
public static void subscribe(AutoSubscriber sub) {
|
||||||
if (sub instanceof Subscriber)
|
subscribe(sub, sub.getSubscribedTopics());
|
||||||
subscribe((Subscriber) sub, sub.getSubscribedTopics());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void unsubscribe(Subscriber sub, @TopicID int... topics) {
|
public static void unsubscribe(Subscriber sub, @TopicID int... topics) {
|
||||||
@ -51,8 +49,7 @@ public class Topic {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void unsubscribe(AutoSubscriber sub) {
|
public static void unsubscribe(AutoSubscriber sub) {
|
||||||
if (sub instanceof Subscriber)
|
unsubscribe(sub, sub.getSubscribedTopics());
|
||||||
unsubscribe((Subscriber) sub, sub.getSubscribedTopics());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void publish(@TopicID int topic, Object... results) {
|
public static void publish(@TopicID int topic, Object... results) {
|
||||||
@ -100,7 +97,7 @@ public class Topic {
|
|||||||
void onPublish(int topic, Object[] result);
|
void onPublish(int topic, Object[] result);
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface AutoSubscriber {
|
public interface AutoSubscriber extends Subscriber {
|
||||||
@TopicID
|
@TopicID
|
||||||
int[] getSubscribedTopics();
|
int[] getSubscribedTopics();
|
||||||
}
|
}
|
||||||
|
@ -43,6 +43,9 @@ public abstract class BaseActivity extends AppCompatActivity implements Topic.Au
|
|||||||
return EMPTY_INT_ARRAY;
|
return EMPTY_INT_ARRAY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPublish(int topic, Object[] result) {}
|
||||||
|
|
||||||
@StyleRes
|
@StyleRes
|
||||||
public int getDarkTheme() {
|
public int getDarkTheme() {
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -8,7 +8,7 @@ import com.topjohnwu.magisk.utils.Topic;
|
|||||||
import androidx.fragment.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
import butterknife.Unbinder;
|
import butterknife.Unbinder;
|
||||||
|
|
||||||
public class BaseFragment extends Fragment implements Topic.AutoSubscriber {
|
public abstract class BaseFragment extends Fragment implements Topic.AutoSubscriber {
|
||||||
|
|
||||||
public App app = App.self;
|
public App app = App.self;
|
||||||
protected Unbinder unbinder = null;
|
protected Unbinder unbinder = null;
|
||||||
@ -49,4 +49,7 @@ public class BaseFragment extends Fragment implements Topic.AutoSubscriber {
|
|||||||
public int[] getSubscribedTopics() {
|
public int[] getSubscribedTopics() {
|
||||||
return BaseActivity.EMPTY_INT_ARRAY;
|
return BaseActivity.EMPTY_INT_ARRAY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPublish(int topic, Object[] result) {}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user