Trigger with event

This commit is contained in:
topjohnwu 2016-12-25 15:29:24 +08:00
parent 2fa5e4679f
commit a5a2df4956
2 changed files with 9 additions and 6 deletions

View File

@ -68,7 +68,7 @@ public class Async {
@Override
protected void onPostExecute(Void v) {
CallbackHandler.triggerCallback(StatusFragment.updateCheckDone);
StatusFragment.updateCheckDone.trigger();
}
}
@ -77,7 +77,7 @@ public class Async {
@Override
public void handleResults(int i) {
StatusFragment.SNCheckResult = i;
CallbackHandler.triggerCallback(StatusFragment.safetyNetDone);
StatusFragment.safetyNetDone.trigger();
}
}.requestTest();
}
@ -92,7 +92,7 @@ public class Async {
@Override
protected void onPostExecute(Void v) {
CallbackHandler.triggerCallback(ModulesFragment.moduleLoadDone);
ModulesFragment.moduleLoadDone.trigger();
}
}
@ -112,7 +112,7 @@ public class Async {
@Override
protected void onPostExecute(Void v) {
CallbackHandler.triggerCallback(ReposFragment.repoLoadDone);
ReposFragment.repoLoadDone.trigger();
}
}

View File

@ -23,8 +23,7 @@ public class CallbackHandler {
}
}
public static void triggerCallback(Event event) {
event.isTriggered = true;
private static void triggerCallback(Event event) {
HashSet<EventListener> list = listeners.get(event);
if (list != null) {
for (EventListener listener : list) {
@ -35,6 +34,10 @@ public class CallbackHandler {
public static class Event {
public boolean isTriggered = false;
public void trigger() {
isTriggered = true;
triggerCallback(this);
}
}
public interface EventListener {