Search in sources :

Example 21 with LocalBroadcastManager

use of android.support.v4.content.LocalBroadcastManager in project quickstart-android by firebase.

the class MainActivity method onStart.

@Override
public void onStart() {
    super.onStart();
    updateUI(mAuth.getCurrentUser());
    // Register receiver for uploads and downloads
    LocalBroadcastManager manager = LocalBroadcastManager.getInstance(this);
    manager.registerReceiver(mBroadcastReceiver, MyDownloadService.getIntentFilter());
    manager.registerReceiver(mBroadcastReceiver, MyUploadService.getIntentFilter());
}
Also used : LocalBroadcastManager(android.support.v4.content.LocalBroadcastManager)

Example 22 with LocalBroadcastManager

use of android.support.v4.content.LocalBroadcastManager in project facebook-android-sdk by facebook.

the class BoltsMeasurementEventListener method open.

private void open() {
    LocalBroadcastManager broadcastManager = LocalBroadcastManager.getInstance(applicationContext);
    broadcastManager.registerReceiver(this, new IntentFilter(MEASUREMENT_EVENT_NOTIFICATION_NAME));
}
Also used : IntentFilter(android.content.IntentFilter) LocalBroadcastManager(android.support.v4.content.LocalBroadcastManager)

Example 23 with LocalBroadcastManager

use of android.support.v4.content.LocalBroadcastManager in project facebook-android-sdk by facebook.

the class LikeView method associateWithLikeActionController.

private void associateWithLikeActionController(LikeActionController likeActionController) {
    this.likeActionController = likeActionController;
    this.broadcastReceiver = new LikeControllerBroadcastReceiver();
    LocalBroadcastManager localBroadcastManager = LocalBroadcastManager.getInstance(getContext());
    // add the broadcast receiver
    IntentFilter filter = new IntentFilter();
    filter.addAction(LikeActionController.ACTION_LIKE_ACTION_CONTROLLER_UPDATED);
    filter.addAction(LikeActionController.ACTION_LIKE_ACTION_CONTROLLER_DID_ERROR);
    filter.addAction(LikeActionController.ACTION_LIKE_ACTION_CONTROLLER_DID_RESET);
    localBroadcastManager.registerReceiver(broadcastReceiver, filter);
}
Also used : IntentFilter(android.content.IntentFilter) LocalBroadcastManager(android.support.v4.content.LocalBroadcastManager)

Example 24 with LocalBroadcastManager

use of android.support.v4.content.LocalBroadcastManager in project facebook-android-sdk by facebook.

the class ProfileManagerTest method testLoadCurrentProfileWithCache.

@Test
public void testLoadCurrentProfileWithCache() {
    ProfileCache profileCache = mock(ProfileCache.class);
    Profile profile = ProfileTest.createDefaultProfile();
    when(profileCache.load()).thenReturn(profile);
    LocalBroadcastManager localBroadcastManager = mock(LocalBroadcastManager.class);
    ProfileManager profileManager = new ProfileManager(localBroadcastManager, profileCache);
    assertTrue(profileManager.loadCurrentProfile());
    verify(profileCache, times(1)).load();
    // Verify that we don't save it back
    verify(profileCache, never()).save(any(Profile.class));
    // Verify that we broadcast
    verify(localBroadcastManager).sendBroadcast(any(Intent.class));
    // Verify that if we set the same (semantically) profile there is no additional broadcast.
    profileManager.setCurrentProfile(ProfileTest.createDefaultProfile());
    verify(localBroadcastManager, times(1)).sendBroadcast(any(Intent.class));
    // Verify that if we unset the profile there is a broadcast
    profileManager.setCurrentProfile(null);
    verify(localBroadcastManager, times(2)).sendBroadcast(any(Intent.class));
}
Also used : Intent(android.content.Intent) LocalBroadcastManager(android.support.v4.content.LocalBroadcastManager) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 25 with LocalBroadcastManager

use of android.support.v4.content.LocalBroadcastManager in project facebook-android-sdk by facebook.

the class AccessTokenManager method getInstance.

static AccessTokenManager getInstance() {
    if (instance == null) {
        synchronized (AccessTokenManager.class) {
            if (instance == null) {
                Context applicationContext = FacebookSdk.getApplicationContext();
                LocalBroadcastManager localBroadcastManager = LocalBroadcastManager.getInstance(applicationContext);
                AccessTokenCache accessTokenCache = new AccessTokenCache();
                instance = new AccessTokenManager(localBroadcastManager, accessTokenCache);
            }
        }
    }
    return instance;
}
Also used : Context(android.content.Context) LocalBroadcastManager(android.support.v4.content.LocalBroadcastManager)

Aggregations

LocalBroadcastManager (android.support.v4.content.LocalBroadcastManager)36 IntentFilter (android.content.IntentFilter)15 Intent (android.content.Intent)11 Test (org.junit.Test)10 Context (android.content.Context)9 BroadcastReceiver (android.content.BroadcastReceiver)7 Bundle (android.os.Bundle)3 AccessToken (com.facebook.AccessToken)2 WaitForBroadcastReceiver (com.facebook.WaitForBroadcastReceiver)2 AppEventsLogger (com.facebook.appevents.AppEventsLogger)2 CountDownLatch (java.util.concurrent.CountDownLatch)2 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)2 Uri (android.net.Uri)1 Parcel (android.os.Parcel)1 Parcelable (android.os.Parcelable)1 Gson (com.google.gson.Gson)1 GsonBuilder (com.google.gson.GsonBuilder)1 RecipeList (com.se491.chef_ly.model.RecipeList)1 IOException (java.io.IOException)1 Type (java.lang.reflect.Type)1