Example usage for android.appwidget AppWidgetManager notifyAppWidgetViewDataChanged

List of usage examples for android.appwidget AppWidgetManager notifyAppWidgetViewDataChanged

Introduction

In this page you can find the example usage for android.appwidget AppWidgetManager notifyAppWidgetViewDataChanged.

Prototype

public void notifyAppWidgetViewDataChanged(int appWidgetId, int viewId) 

Source Link

Document

Notifies the specified collection view in the specified AppWidget instance to invalidate its data.

Usage

From source file:de.domjos.schooltools.helper.Helper.java

public static void receiveBroadCast(Context context, Intent intent, int id) {
    Bundle bundle = intent.getExtras();// w  w w  .  j ava  2  s .c  o m
    if (bundle != null) {
        if (intent.hasExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS)) {
            int[] ids = bundle.getIntArray(AppWidgetManager.EXTRA_APPWIDGET_IDS);
            AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);
            appWidgetManager.notifyAppWidgetViewDataChanged(ids, id);
        }
    }
}

From source file:com.dycody.android.idealnote.BaseActivity.java

/**
 * Notifies App Widgets about data changes so they can update theirselves
 *//*from ww  w .j av  a 2 s. c o m*/
public static void notifyAppWidgets(Context context) {
    // Home widgets
    AppWidgetManager mgr = AppWidgetManager.getInstance(context);
    int[] ids = mgr.getAppWidgetIds(new ComponentName(context, ListWidgetProvider.class));
    Log.d(Constants.TAG, "Notifies AppWidget data changed for widgets " + Arrays.toString(ids));
    mgr.notifyAppWidgetViewDataChanged(ids, R.id.widget_list);

    // Dashclock
    LocalBroadcastManager.getInstance(context).sendBroadcast(new Intent(Constants.INTENT_UPDATE_DASHCLOCK));
}

From source file:com.gelakinetic.inboxwidget.InboxCheckerAppWidgetConfigure.java

/**
 * @param context A context to build the intent with
 * @return An Intent which will call onUpdate for all Inbox Widgets
 *//*from ww w .j av a  2s. c om*/
private static Intent getUpdateWidgetIntent(Context context) {
    /* Get an intent for the InboxCheckerAppWidgetProvider class */
    Intent intent = new Intent(context.getApplicationContext(), InboxCheckerAppWidgetProvider.class);
    /* Tell it to update widgets */
    intent.setAction(AppWidgetManager.ACTION_APPWIDGET_UPDATE);

    /* Get a list of IDs for all the widgets */
    AppWidgetManager widgetManager = AppWidgetManager.getInstance(context);
    int[] ids = widgetManager.getAppWidgetIds(new ComponentName(context, InboxCheckerAppWidgetProvider.class));

    /* Tell the intent which widgets to update */
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        widgetManager.notifyAppWidgetViewDataChanged(ids, android.R.id.list);
    }
    intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, ids);

    /* Return the intent */
    return intent;
}

From source file:com.tlongdev.bktf.util.Utility.java

public static void notifyPricesWidgets(Context context) {
    AppWidgetManager manager = AppWidgetManager.getInstance(context);
    int[] appWidgetIds = manager
            .getAppWidgetIds(new ComponentName(context.getApplicationContext(), FavoritesWidget.class));
    manager.notifyAppWidgetViewDataChanged(appWidgetIds, R.id.list_view);
}

From source file:com.udacity.stockhawk.ui.widget.StockWidget.java

@Override
public void onReceive(Context context, Intent intent) {
    super.onReceive(context, intent);
    if (QuoteSyncJob.ACTION_DATA_UPDATED.equals(intent.getAction())) {
        AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);

        appWidgetManager.notifyAppWidgetViewDataChanged(
                appWidgetManager.getAppWidgetIds(new ComponentName(context, getClass())), R.id.lv_widget_stock);
    }/*from   w w w  .  j av a2s. c  o m*/
}

From source file:com.miz.functions.TheMovieDb.java

private void updateWidgets() {
    AppWidgetManager awm = AppWidgetManager.getInstance(context);
    awm.notifyAppWidgetViewDataChanged(
            awm.getAppWidgetIds(new ComponentName(context, MovieStackWidgetProvider.class)), R.id.stack_view); // Update stack view widget
    awm.notifyAppWidgetViewDataChanged(//from w ww  .  j a  va  2 s  . c o m
            awm.getAppWidgetIds(new ComponentName(context, MovieCoverWidgetProvider.class)), R.id.widget_grid); // Update grid view widget
    awm.notifyAppWidgetViewDataChanged(
            awm.getAppWidgetIds(new ComponentName(context, MovieBackdropWidgetProvider.class)),
            R.id.widget_grid); // Update grid view widget
}

From source file:com.udacity.stockhawk.widget.StockAppWidgetProvider.java

@Override
public void onReceive(Context context, Intent intent) {
    super.onReceive(context, intent);
    if (QuoteSyncJob.ACTION_DATA_UPDATED.equals(intent.getAction())) {

        AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);
        int[] appWidgetIds = appWidgetManager.getAppWidgetIds(new ComponentName(context, getClass()));
        appWidgetManager.notifyAppWidgetViewDataChanged(appWidgetIds, R.id.lv_stock_list);
    }//from  w w w . j  a va 2  s .c  o  m
}

From source file:ru.yandex.subtitles.ui.appwidget.AbstractAppWidget.java

private void notifyAppWidgetsViewDataChanged(final AppWidgetManager appWidgetManager,
        final int[] appWidgetIds) {
    for (final int appWidgetId : appWidgetIds) {
        appWidgetManager.notifyAppWidgetViewDataChanged(appWidgetId, R.id.list);
    }//from  www.  ja va2  s  .co  m
}

From source file:org.flerda.android.honeypad.NoteEditFragment.java

/**
 * Persists the details of the current note. This will either create a new
 * note, or update an existing note./*  w  ww.  j  av  a 2  s . c  om*/
 */
private void saveNote() {
    ContentValues values = new ContentValues(2);
    values.put(NotesProvider.KEY_TITLE, mTitleText.getText().toString());
    values.put(NotesProvider.KEY_BODY, mBodyText.getText().toString());
    final boolean updating = mCurrentNote != null;
    if (updating) {
        getActivity().getContentResolver().update(mCurrentNote, values, null, null);
    } else {
        Uri newNote = getActivity().getContentResolver().insert(NotesProvider.CONTENT_URI, values);

        if (newNote != null) {
            mCurrentNote = newNote;
        }
    }

    // show a toast confirmation
    Toast.makeText(getActivity(), updating ? R.string.note_updated : R.string.note_saved, Toast.LENGTH_SHORT)
            .show();

    if (mIsV11) {
        // update widget
        AppWidgetManager awm = AppWidgetManager.getInstance(getActivity());

        awm.notifyAppWidgetViewDataChanged(
                awm.getAppWidgetIds(new ComponentName(getActivity(), WidgetProvider.class)), R.id.stack_view);
    }
    Toast.makeText(getActivity(), "Note Saved", Toast.LENGTH_SHORT).show();
    Bundle b = getArguments();
    if (null != b && b.containsKey(ARGUMENT_POP_ON_SAVE)) {
        getFragmentManager().popBackStack();
    }
}

From source file:com.example.olivi.maphap.widget.DetailWidgetProvider.java

@Override
public void onReceive(@NonNull Context context, @NonNull Intent intent) {
    super.onReceive(context, intent);
    if (MapHapService.ACTION_DATA_UPDATED.equals(intent.getAction())) {
        AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);
        int[] appWidgetIds = appWidgetManager.getAppWidgetIds(new ComponentName(context, getClass()));
        appWidgetManager.notifyAppWidgetViewDataChanged(appWidgetIds, R.id.widget_list);
    }/*from w  w  w .j a  v a2  s. c  o m*/
}