Local broadcast receiver used as observer in loader
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
package com.philliphsu.clock2.util;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.support.v4.content.LocalBroadcastManager;
|
||||
|
||||
/**
|
||||
@@ -14,5 +16,16 @@ public final class LocalBroadcastHelper {
|
||||
LocalBroadcastManager.getInstance(context).sendBroadcast(new Intent(action));
|
||||
}
|
||||
|
||||
/** Registers a BroadcastReceiver that filters intents by the action specified */
|
||||
// TODO: Refactor any local registrations to use this utility method.
|
||||
public static void registerReceiver(Context context, BroadcastReceiver receiver, String action) {
|
||||
LocalBroadcastManager.getInstance(context).registerReceiver(receiver, new IntentFilter(action));
|
||||
}
|
||||
|
||||
// TODO: Refactor any local unregistrations to use this utility method.
|
||||
public static void unregisterReceiver(Context context, BroadcastReceiver receiver) {
|
||||
LocalBroadcastManager.getInstance(context).unregisterReceiver(receiver);
|
||||
}
|
||||
|
||||
private LocalBroadcastHelper() {}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user