Java Code Examples for androidx.localbroadcastmanager.content.LocalBroadcastManager#sendBroadcast()

The following examples show how to use androidx.localbroadcastmanager.content.LocalBroadcastManager#sendBroadcast() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AdapterImage.java    From FairEmail with GNU General Public License v3.0 6 votes vote down vote up
@Override
public boolean onLongClick(View v) {
    int pos = getAdapterPosition();
    if (pos == RecyclerView.NO_POSITION)
        return false;

    EntityAttachment attachment = items.get(pos);
    if (!attachment.available)
        return false;

    LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(context);
    lbm.sendBroadcast(
            new Intent(FragmentMessages.ACTION_STORE_ATTACHMENT)
                    .putExtra("id", attachment.id)
                    .putExtra("name", Helper.sanitizeFilename(attachment.name))
                    .putExtra("type", attachment.getMimeType()));
    return true;
}
 
Example 2
Source File: AdapterNavFolder.java    From FairEmail with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onClick(View v) {
    int pos = getAdapterPosition();
    if (pos == RecyclerView.NO_POSITION)
        return;

    TupleFolderNav folder = items.get(pos);
    if (folder == null)
        return;

    LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(context);
    lbm.sendBroadcast(
            new Intent(ActivityView.ACTION_VIEW_MESSAGES)
                    .putExtra("account", folder.account)
                    .putExtra("folder", folder.id)
                    .putExtra("type", folder.type));
}
 
Example 3
Source File: AdapterRule.java    From FairEmail with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onClick(View v) {
    int pos = getAdapterPosition();
    if (pos == RecyclerView.NO_POSITION)
        return;

    TupleRuleEx rule = items.get(pos);

    LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(context);
    lbm.sendBroadcast(
            new Intent(ActivityView.ACTION_EDIT_RULE)
                    .putExtra("id", rule.id)
                    .putExtra("account", rule.account)
                    .putExtra("folder", rule.folder));
}
 
Example 4
Source File: LocalBroadcastHelper.java    From ProjectX with Apache License 2.0 5 votes vote down vote up
/**
 * 发送本地广播
 *
 * @param intent Intent
 */
@SuppressWarnings("WeakerAccess")
public static void sendBroadcast(@NonNull Intent intent) {
    final ProjectXApplication application = ProjectXApplication.getInstance();
    if (application == null)
        return;
    final LocalBroadcastManager manager = application.getLocalBroadcastManager();
    if (manager == null)
        return;
    manager.sendBroadcast(intent);
}
 
Example 5
Source File: DfuActivity.java    From Android-nRF-Toolbox with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private void showUploadCancelDialog() {
	final LocalBroadcastManager manager = LocalBroadcastManager.getInstance(this);
	final Intent pauseAction = new Intent(DfuService.BROADCAST_ACTION);
	pauseAction.putExtra(DfuService.EXTRA_ACTION, DfuService.ACTION_PAUSE);
	manager.sendBroadcast(pauseAction);

	final UploadCancelFragment fragment = UploadCancelFragment.getInstance();
	fragment.show(getSupportFragmentManager(), TAG);
}
 
Example 6
Source File: UploadCancelFragment.java    From Android-nRF-Toolbox with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void onCancel(@NonNull final DialogInterface dialog) {
	final LocalBroadcastManager manager = LocalBroadcastManager.getInstance(requireContext());
	final Intent pauseAction = new Intent(DfuService.BROADCAST_ACTION);
	pauseAction.putExtra(DfuService.EXTRA_ACTION, DfuService.ACTION_RESUME);
	manager.sendBroadcast(pauseAction);
}
 
Example 7
Source File: FBaseMessagingService.java    From tindroid with Apache License 2.0 5 votes vote down vote up
@Override
public void onNewToken(@NonNull final String refreshedToken) {
    super.onNewToken(refreshedToken);
    Log.d(TAG, "Refreshed token: " + refreshedToken);

    // Send token to the server.
    LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(this);
    Intent intent = new Intent("FCM_REFRESH_TOKEN");
    intent.putExtra("token", refreshedToken);
    lbm.sendBroadcast(intent);

    // The token is currently retrieved in co.tinode.tindroid.Cache.
}
 
Example 8
Source File: CropHelper.java    From science-journal with Apache License 2.0 5 votes vote down vote up
private static void sendStatsUpdatedBroadcast(Context context, String sensorId, String trialId) {
  if (context == null) {
    return;
  }
  // Use a LocalBroadcastManager, because we do not need this broadcast outside the app.
  LocalBroadcastManager lbm = getBroadcastManager(context);
  Intent intent = new Intent();
  intent.setAction(ACTION_CROP_STATS_RECALCULATED);
  intent.putExtra(EXTRA_SENSOR_ID, sensorId);
  intent.putExtra(EXTRA_TRIAL_ID, trialId);
  lbm.sendBroadcast(intent);
}
 
Example 9
Source File: AdapterAttachment.java    From FairEmail with GNU General Public License v3.0 5 votes vote down vote up
private void onSave(EntityAttachment attachment) {
    LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(context);
    lbm.sendBroadcast(
            new Intent(FragmentMessages.ACTION_STORE_ATTACHMENT)
                    .putExtra("id", attachment.id)
                    .putExtra("name", Helper.sanitizeFilename(attachment.name))
                    .putExtra("type", attachment.getMimeType()));
}
 
Example 10
Source File: AdapterFolder.java    From FairEmail with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onClick(View view) {
    if (view.getId() == R.id.btnHelp)
        Helper.viewFAQ(context, 22);
    else {
        int pos = getAdapterPosition();
        if (pos == RecyclerView.NO_POSITION)
            return;

        TupleFolderEx folder = items.get(pos);
        if (folder.tbd != null)
            return;

        switch (view.getId()) {
            case R.id.ibExpander:
                onCollapse(folder);
                break;
            case R.id.tvFlagged:
            case R.id.ibFlagged:
                onFlagged(folder);
                break;
            default:
                if (listener == null) {
                    LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(context);
                    lbm.sendBroadcast(
                            new Intent(ActivityView.ACTION_VIEW_MESSAGES)
                                    .putExtra("account", folder.account)
                                    .putExtra("folder", folder.id)
                                    .putExtra("type", folder.type));
                } else {
                    if (folder.read_only)
                        return;
                    if (disabledIds.contains(folder.id))
                        return;
                    listener.onFolderSelected(folder);
                }
        }
    }
}
 
Example 11
Source File: NotificationRecyclerViewAdapter.java    From BaldPhone with Apache License 2.0 5 votes vote down vote up
public void clearAll() {
    LocalBroadcastManager localBroadcastManager = LocalBroadcastManager.getInstance(context);
    for (int i = 0; i < bundles.length; i++) {
        localBroadcastManager.sendBroadcast(
                new Intent(NotificationListenerService.ACTION_CLEAR)
                        .putExtra(NotificationListenerService.KEY_EXTRA_KEY, bundles[i].getString(NotificationListenerService.KEY_EXTRA_KEY))

        );
    }

}
 
Example 12
Source File: AdapterIdentity.java    From FairEmail with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onClick(View view) {
    int pos = getAdapterPosition();
    if (pos == RecyclerView.NO_POSITION)
        return;

    TupleIdentityEx identity = items.get(pos);

    LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(context);
    lbm.sendBroadcast(
            new Intent(ActivitySetup.ACTION_EDIT_IDENTITY)
                    .putExtra("id", identity.id));
}
 
Example 13
Source File: AdapterNavUnified.java    From FairEmail with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onClick(View v) {
    int pos = getAdapterPosition();
    if (pos == RecyclerView.NO_POSITION)
        return;

    TupleFolderUnified folder = items.get(pos);
    if (folder == null || folder.type == null)
        return;

    LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(context);
    lbm.sendBroadcast(
            new Intent(ActivityView.ACTION_VIEW_MESSAGES)
                    .putExtra("type", folder.type));
}
 
Example 14
Source File: SimpleTask.java    From FairEmail with GNU General Public License v3.0 5 votes vote down vote up
private void cleanup(Context context) {
    future = null;
    synchronized (tasks) {
        tasks.remove(this);
        if (count)
            executing--;
    }

    LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(context);
    lbm.sendBroadcast(new Intent(ACTION_TASK_COUNT).putExtra("count", executing));
    Log.i("Remaining tasks=" + tasks.size());
}
 
Example 15
Source File: AdapterAnswer.java    From FairEmail with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onClick(View v) {
    int pos = getAdapterPosition();
    if (pos == RecyclerView.NO_POSITION)
        return;

    EntityAnswer answer = items.get(pos);

    LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(context);
    lbm.sendBroadcast(
            new Intent(ActivityView.ACTION_EDIT_ANSWER)
                    .putExtra("id", answer.id));
}
 
Example 16
Source File: AdapterNavAccount.java    From FairEmail with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onClick(View v) {
    int pos = getAdapterPosition();
    if (pos == RecyclerView.NO_POSITION)
        return;

    TupleAccountEx account = items.get(pos);
    if (account == null)
        return;

    LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(context);
    lbm.sendBroadcast(
            new Intent(ActivityView.ACTION_VIEW_FOLDERS)
                    .putExtra("id", account.id));
}
 
Example 17
Source File: AdapterKeyword.java    From FairEmail with GNU General Public License v3.0 5 votes vote down vote up
private void update(TupleKeyword keyword, Integer color) {
    btnColor.setColor(color);
    keyword.color = color;

    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
    if (color == null)
        prefs.edit().remove("keyword." + keyword.name).apply();
    else
        prefs.edit().putInt("keyword." + keyword.name, keyword.color).apply();

    LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(context);
    lbm.sendBroadcast(new Intent(FragmentMessages.ACTION_KEYWORDS));
}
 
Example 18
Source File: Core.java    From FairEmail with GNU General Public License v3.0 5 votes vote down vote up
private static void reportNewMessage(Context context, EntityAccount account, EntityFolder folder, EntityMessage message) {
    // Prepare scroll to top
    if (!message.ui_seen && !message.ui_hide &&
            message.received > account.created) {
        Intent report = new Intent(ActivityView.ACTION_NEW_MESSAGE);
        report.putExtra("folder", folder.id);
        report.putExtra("unified", folder.unified);
        Log.i("Report new id=" + message.id + " folder=" + folder.name + " unified=" + folder.unified);

        LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(context);
        lbm.sendBroadcast(report);
    }
}
 
Example 19
Source File: StopTimerUtils.java    From abnd-track-pomodoro-timer-app with MIT License 4 votes vote down vote up
/**
 * Update MainActivity Elements through  broadcast
 */
private static void sendBroadcast(Context context) {
    LocalBroadcastManager completedBroadcastManager = LocalBroadcastManager.getInstance(context);
    completedBroadcastManager.sendBroadcast(
            new Intent(COMPLETE_ACTION_BROADCAST));
}
 
Example 20
Source File: StartTimerUtils.java    From abnd-track-pomodoro-timer-app with MIT License 4 votes vote down vote up
/**
 * Update MainActivity Elements through  broadcast
 */
private static void sendBroadcast(Context context) {
    LocalBroadcastManager completedBroadcastManager = LocalBroadcastManager.getInstance(context);
    completedBroadcastManager.sendBroadcast(
            new Intent(START_ACTION_BROADCAST));
}