use of androidx.localbroadcastmanager.content.LocalBroadcastManager in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class SurveyMixinTest method onPause_removesReceiverIfPreviouslySet.
@Test
public void onPause_removesReceiverIfPreviouslySet() {
// Pretend there is a survey in memory
when(mProvider.getSurveyExpirationDate(any(), any())).thenReturn(-1L);
// Pretend we are an activity that starts and stops
FragmentActivity temp = Robolectric.setupActivity(FragmentActivity.class);
when(mFragment.getActivity()).thenReturn(temp);
when(mProvider.createAndRegisterReceiver(any())).thenReturn(mReceiver);
LocalBroadcastManager manager = LocalBroadcastManager.getInstance(temp);
SurveyMixin mixin = new SurveyMixin(mFragment, FAKE_KEY);
mixin.onResume();
manager.registerReceiver(mReceiver, new IntentFilter());
mixin.onPause();
// Verify we remove the receiver
HashMap<BroadcastReceiver, ArrayList<IntentFilter>> map = ReflectionHelpers.getField(manager, "mReceivers");
assertThat(map.containsKey(mReceiver)).isFalse();
}
use of androidx.localbroadcastmanager.content.LocalBroadcastManager in project sexytopo by richsmith.
the class SystemLogActivity method onPause.
@Override
protected void onPause() {
super.onPause();
LocalBroadcastManager broadcastManager = LocalBroadcastManager.getInstance(this);
broadcastManager.unregisterReceiver(logUpdateReceiver);
}
use of androidx.localbroadcastmanager.content.LocalBroadcastManager in project sexytopo by richsmith.
the class SystemLogActivity method onResume.
@Override
protected void onResume() {
super.onResume();
LocalBroadcastManager broadcastManager = LocalBroadcastManager.getInstance(this);
IntentFilter logFilter = new IntentFilter();
logFilter.addAction(SexyTopo.SYSTEM_LOG_UPDATED_EVENT);
broadcastManager.registerReceiver(logUpdateReceiver, logFilter);
logUpdateReceiver.update();
}
use of androidx.localbroadcastmanager.content.LocalBroadcastManager in project sexytopo by richsmith.
the class TableActivity method onResume.
@Override
protected void onResume() {
super.onResume();
LocalBroadcastManager broadcastManager = LocalBroadcastManager.getInstance(this);
broadcastManager.registerReceiver(receiver, new IntentFilter(SexyTopo.SURVEY_UPDATED_EVENT));
syncTableWithSurvey();
Bundle bundle = getIntent().getExtras();
if (bundle != null && bundle.getString(SexyTopo.JUMP_TO_STATION) != null) {
String requestedStationName = bundle.getString(SexyTopo.JUMP_TO_STATION);
Station requestedStation = getSurvey().getStationByName(requestedStationName);
jumpToStation(requestedStation);
} else {
final ScrollView scrollView = findViewById(R.id.BodyTableScrollView);
scrollView.fullScroll(View.FOCUS_DOWN);
}
}
use of androidx.localbroadcastmanager.content.LocalBroadcastManager in project fdroidclient by f-droid.
the class InstallHistoryService method register.
public static void register(Context context) {
if (broadcastReceiver != null) {
// already registered
return;
}
IntentFilter intentFilter = new IntentFilter();
intentFilter.addDataScheme("http");
intentFilter.addDataScheme("https");
intentFilter.addDataScheme("package");
intentFilter.addAction(Installer.ACTION_INSTALL_STARTED);
intentFilter.addAction(Installer.ACTION_INSTALL_COMPLETE);
intentFilter.addAction(Installer.ACTION_INSTALL_INTERRUPTED);
intentFilter.addAction(Installer.ACTION_INSTALL_USER_INTERACTION);
intentFilter.addAction(Installer.ACTION_UNINSTALL_STARTED);
intentFilter.addAction(Installer.ACTION_UNINSTALL_COMPLETE);
intentFilter.addAction(Installer.ACTION_UNINSTALL_INTERRUPTED);
intentFilter.addAction(Installer.ACTION_UNINSTALL_USER_INTERACTION);
broadcastReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
queue(context, intent);
}
};
LocalBroadcastManager localBroadcastManager = LocalBroadcastManager.getInstance(context);
localBroadcastManager.registerReceiver(broadcastReceiver, intentFilter);
}
Aggregations