Example usage for android.support.v4.content LocalBroadcastManager getInstance

List of usage examples for android.support.v4.content LocalBroadcastManager getInstance

Introduction

In this page you can find the example usage for android.support.v4.content LocalBroadcastManager getInstance.

Prototype

public static LocalBroadcastManager getInstance(Context context) 

Source Link

Usage

From source file:com.afwsamples.testdpc.EnableProfileActivity.java

@Override
protected void onResume() {
    super.onResume();
    LocalBroadcastManager.getInstance(this).registerReceiver(mCheckInStateReceiver, sIntentFilter);
    // In case the broadcast is sent before we register the receiver.
    refreshUi();/* w  w  w .  j  a  v  a  2 s. c  o  m*/
}

From source file:com.antew.redditinpictures.library.ui.ImageViewerActivity.java

/**
 * Register BroadcastReceivers with the LocalBroadcastManager
 *//*from  w w w.jav  a 2 s. c o m*/
private void registerLocalBroadcastReceivers() {
    LocalBroadcastManager.getInstance(this).registerReceiver(mToggleFullscreenReceiver,
            new IntentFilter(Constants.Broadcast.BROADCAST_TOGGLE_FULLSCREEN));
}

From source file:cloud.artik.example.simplecontroller.ControlActivity.java

@Override
protected void onPause() {
    super.onPause();
    ArtikCloudSession.getInstance().disconnectFirehoseWS();
    ArtikCloudSession.getInstance().disconnectDeviceChannelWS();
    LocalBroadcastManager.getInstance(this).unregisterReceiver(mWSUpdateReceiver);
}

From source file:com.android.madpausa.cardnotificationviewer.ConcreteNotificationListenerService.java

public void handlePostedNotification(StatusBarNotification sbn) {
    //should be removed if already existing, in order to put it back in top position
    removeInternalNotification(sbn);/*from   w w w  . j a  va2 s  .  co  m*/
    NotificationFilter priorityFilter = ((NotificationFilter) baseNotificationFilter.clone())
            .setMinPriority(Notification.PRIORITY_DEFAULT);
    //if the notification has to be shown, is putted in the primary map
    if (!alwaysArchiveFilter.matchFilter(sbn, notificationGroups, true)
            && priorityFilter.matchFilter(sbn, notificationGroups, true))
        notificationMap.put(NotificationFilter.getNotificationKey(sbn), sbn);
    else {
        //otherwise, it goes directly in the archived ones
        archivedNotificationMap.put(NotificationFilter.getNotificationKey(sbn), sbn);
    }

    //adding it to the group structure
    notificationGroups.addGroupMember(sbn);

    //if the notification are more than the threshold, archive older ones
    if (notificationMap.size() > Integer
            .parseInt(sp.getString(SettingsActivityFragment.NOTIFICATION_THRESHOLD, "-1")))
        archiveNotifications();

    //sending notification to binded clients
    Intent intent = new Intent(ADD_NOTIFICATION_ACTION);
    intent.putExtra(NOTIFICATION_EXTRA, sbn);
    LocalBroadcastManager.getInstance(this).sendBroadcast(intent);

    //sending notification only at the end, always, as it would be canceled, at most
    handleServiceNotification();
}

From source file:app.com.vaipo.ContactsFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.dial_ui, container, false);

    progressGenerator = new ProgressGenerator(this);
    btnContacts = (ActionProcessButton) rootView.findViewById(R.id.dialTo);
    btnContacts.setMode(ActionProcessButton.Mode.ENDLESS);

    contactEditText = (EditText) rootView.findViewById(R.id.contacts_btn);
    isContactNameSelected = false;/*from   ww w .  ja v  a  2 s  . c  o m*/
    btnContacts.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (isState(State.LAUNCH_CONTACTS)) {
                progressGenerator.start(btnContacts);

                mCallback.onContactsBtnClicked();
            } else if (isState(State.DIAL)) {
                String number = sharedPreferences.getString("number", "");
                //mOutGoingNumber = contactEditText.getText().toString();
                setupDialMsg(mOutGoingNumber, number);
                enterState(State.END);
            } else if (isState(State.END)) {
                setupEndMsg();
                enterState(State.LAUNCH_CONTACTS);
            }
        }
    });

    contactEditText.addTextChangedListener(new TextWatcher() {
        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {

        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {

        }

        @Override
        public void afterTextChanged(Editable s) {
            if (s.length() == 0) {
                enterState(State.LAUNCH_CONTACTS);
                mOutGoingNumber = "";
            } else {
                if (Utils.inCall()) {
                    enterState(State.END);
                } else {
                    enterState(State.DIAL);
                }
                if (!isContactNameSelected)
                    mOutGoingNumber = s.toString();
            }
        }
    });

    LocalBroadcastManager.getInstance(getActivity()).registerReceiver(mMessageReceiver,
            new IntentFilter(Utils.END_VAIPO_CALL));
    return rootView;
}

From source file:com.antew.redditinpictures.ui.RedditImageGridFragmentFree.java

/**
 * Unregister our BroadcastReceiver/*from  w ww . j a v  a  2 s  . c  o  m*/
 */
@Override
public void onDestroy() {
    LocalBroadcastManager.getInstance(getActivity()).unregisterReceiver(mHideAds);
    if (mAdView != null) {
        mAdView.destroy();
        mAdView = null;
    }
    super.onDestroy();

}

From source file:ca.farrelltonsolar.classic.HourLogChart.java

private void unRegisterReceiver() {
    if (isReceiverRegistered) {
        try {//w  w w.j a  v a2  s  . c  o  m
            LocalBroadcastManager.getInstance(HourLogChart.this.getActivity())
                    .unregisterReceiver(mReadingsReceiver);
        } catch (IllegalArgumentException e) {
            // Do nothing
        }
        isReceiverRegistered = false;
    }
}

From source file:com.afwsamples.testdpc.EnableProfileActivity.java

@Override
protected void onStop() {
    super.onStop();
    LocalBroadcastManager.getInstance(this).unregisterReceiver(mCheckInStateReceiver);
}

From source file:com.achep.acdisplay.services.activemode.ActiveModeService.java

@Override
public void onCreate() {
    Context context = getContext();
    mListeningAtom = new Atomic(this, TAG);
    mSensors = buildAvailableSensorsList(context);
    mHandlers = new ActiveModeHandler[] { new ScreenHandler(context, this),
            new InactiveTimeHandler(context, this), new WithoutNotifiesHandler(context, this), };

    for (ActiveModeHandler handler : mHandlers) {
        handler.create();/* w w w .  j a va2 s  . c  o m*/
    }

    requestActive();

    IntentFilter filter = new IntentFilter();
    filter.addAction(App.ACTION_INTERNAL_PING_SENSORS);
    LocalBroadcastManager.getInstance(context).registerReceiver(mLocalReceiver, filter);

    NotificationPresenter.getInstance().registerListener(this);
}

From source file:android.content.ScopedContextImpl.java

@Override
public void unregisterReceiver(BroadcastReceiver receiver) {
    LocalBroadcastManager.getInstance(SystemConfig.getApplicationContext()).unregisterReceiver(receiver);
}