List of usage examples for android.appwidget AppWidgetManager notifyAppWidgetViewDataChanged
public void notifyAppWidgetViewDataChanged(int appWidgetId, int viewId)
From source file:com.kubotaku.android.code4kyoto5374.fragments.HomeSelectFragment.java
private void updateAppWidget() { Context context = getContext(); AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context); ComponentName componentName = new ComponentName(context, GarbageCollectDayWidget.class); appWidgetManager.notifyAppWidgetViewDataChanged(appWidgetManager.getAppWidgetIds(componentName), R.id.list_collect_days);//from w ww .ja v a 2s .co m }
From source file:de.hero.vertretungsplan.HtmlWork.java
@SuppressLint("NewApi") private void updateWidget(boolean before) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { RemoteViews widget = new RemoteViews(context.getPackageName(), R.layout.widget); AppWidgetManager appManager = AppWidgetManager.getInstance(context); ComponentName name = new ComponentName(context, WidgetProvider.class); if (before) { widget.setImageViewResource(R.id.aktButton, R.drawable.ic_action_aktualisieren_pressed); } else {/*from w w w. ja v a2s . c o m*/ widget.setImageViewResource(R.id.aktButton, R.drawable.aktualisieren_drawable); if (dataChanged) { appManager.notifyAppWidgetViewDataChanged(appManager.getAppWidgetIds(name), R.id.words); } } appManager.partiallyUpdateAppWidget(appManager.getAppWidgetIds(name), widget); } }
From source file:nl.mpcjanssen.simpletask.TodoApplication.java
public void updateWidgets() { AppWidgetManager mgr = AppWidgetManager.getInstance(getApplicationContext()); for (int appWidgetId : mgr .getAppWidgetIds(new ComponentName(getApplicationContext(), MyAppWidgetProvider.class))) { mgr.notifyAppWidgetViewDataChanged(appWidgetId, R.id.widgetlv); Log.v(TAG, "Updating widget: " + appWidgetId); }// www. jav a 2s . c o m }
From source file:com.grarak.kerneladiutor.fragments.tools.ProfileFragment.java
private void load(List<RecyclerViewItem> items) { mProfiles = new Profiles(getActivity()); List<Profiles.ProfileItem> profileItems = mProfiles.getAllProfiles(); if (mTaskerMode && profileItems.size() == 0) { Snackbar.make(getRootView(), R.string.no_profiles, Snackbar.LENGTH_LONG).show(); return;/*from w ww .j a v a 2 s .c om*/ } for (int i = 0; i < profileItems.size(); i++) { final int position = i; final CardView cardView = new CardView(getActivity()); cardView.setOnMenuListener(new CardView.OnMenuListener() { @Override public void onMenuReady(final CardView cardView, PopupMenu popupMenu) { Menu menu = popupMenu.getMenu(); menu.add(Menu.NONE, 0, Menu.NONE, getString(R.string.append)); menu.add(Menu.NONE, 1, Menu.NONE, getString(R.string.edit)); menu.add(Menu.NONE, 2, Menu.NONE, getString(R.string.details)); final MenuItem onBoot = menu.add(Menu.NONE, 3, Menu.NONE, getString(R.string.on_boot)) .setCheckable(true); onBoot.setChecked(mProfiles.getAllProfiles().get(position).isOnBootEnabled()); menu.add(Menu.NONE, 4, Menu.NONE, getString(R.string.export)); menu.add(Menu.NONE, 5, Menu.NONE, getString(R.string.delete)); popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { List<Profiles.ProfileItem> items = mProfiles.getAllProfiles(); switch (item.getItemId()) { case 0: if (Utils.DONATED) { Intent intent = new Intent(getActivity(), ProfileActivity.class); intent.putExtra(ProfileActivity.POSITION_INTENT, position); startActivityForResult(intent, 2); } else { mDonateDialog = ViewUtils.dialogDonate(getActivity()); mDonateDialog.show(); } break; case 1: if (Utils.DONATED) { Intent intent = new Intent(getActivity(), ProfileEditActivity.class); intent.putExtra(ProfileEditActivity.POSITION_INTENT, position); startActivityForResult(intent, 3); } else { mDonateDialog = ViewUtils.dialogDonate(getActivity()); mDonateDialog.show(); } break; case 2: if (items.get(position).getName() != null) { List<Profiles.ProfileItem.CommandItem> commands = items.get(position) .getCommands(); if (commands.size() > 0) { setForegroundText(items.get(position).getName().toUpperCase()); mDetailsFragment.setText(commands); showForeground(); } else { Utils.toast(R.string.profile_empty, getActivity()); } } break; case 3: onBoot.setChecked(!onBoot.isChecked()); items.get(position).enableOnBoot(onBoot.isChecked()); mProfiles.commit(); break; case 4: mExportProfile = items.get(position); requestPermission(0, Manifest.permission.WRITE_EXTERNAL_STORAGE); break; case 5: mDeleteDialog = ViewUtils.dialogBuilder(getString(R.string.sure_question), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { } }, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { mProfiles.delete(position); mProfiles.commit(); reload(); } }, new DialogInterface.OnDismissListener() { @Override public void onDismiss(DialogInterface dialogInterface) { mDeleteDialog = null; } }, getActivity()); mDeleteDialog.show(); break; } return false; } }); } }); final DescriptionView descriptionView = new DescriptionView(); descriptionView.setSummary(profileItems.get(i).getName()); descriptionView.setOnItemClickListener(new RecyclerViewItem.OnItemClickListener() { @Override public void onClick(RecyclerViewItem item) { if (mTaskerMode) { mSelectDialog = ViewUtils.dialogBuilder( getString(R.string.select_question, descriptionView.getSummary()), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { } }, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { ((ProfileTaskerActivity) getActivity()).finish( descriptionView.getSummary().toString(), mProfiles.getAllProfiles().get(position).getCommands()); } }, new DialogInterface.OnDismissListener() { @Override public void onDismiss(DialogInterface dialogInterface) { mSelectDialog = null; } }, getActivity()); mSelectDialog.show(); } else { mApplyDialog = ViewUtils.dialogBuilder( getString(R.string.apply_question, descriptionView.getSummary()), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { } }, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { for (Profiles.ProfileItem.CommandItem command : mProfiles.getAllProfiles() .get(position).getCommands()) { CPUFreq.ApplyCpu applyCpu; if (command.getCommand().startsWith("#") && ((applyCpu = new CPUFreq.ApplyCpu( command.getCommand().substring(1))) .toString() != null)) { for (String applyCpuCommand : Service.getApplyCpu(applyCpu, RootUtils.getSU())) { Control.runSetting(applyCpuCommand, null, null, null); } } else { Control.runSetting(command.getCommand(), null, null, null); } } } }, new DialogInterface.OnDismissListener() { @Override public void onDismiss(DialogInterface dialogInterface) { mApplyDialog = null; } }, getActivity()); try { mApplyDialog.show(); } catch (NullPointerException ignored) { } } } }); if (mTaskerMode) { items.add(descriptionView); } else { cardView.addItem(descriptionView); items.add(cardView); } } if (!mTaskerMode) { AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(getActivity()); int appWidgetIds[] = appWidgetManager.getAppWidgetIds(new ComponentName(getActivity(), Widget.class)); appWidgetManager.notifyAppWidgetViewDataChanged(appWidgetIds, R.id.profile_list); Tile.publishProfileTile(profileItems, getActivity()); } }
From source file:cn.studyjams.s2.sj0132.bowenyan.mygirlfriend.nononsenseapps.notepad.ui.widget.ListWidgetConfig.java
void setupActionBar() { final WidgetPrefs widgetPrefs = new WidgetPrefs(this, appWidgetId); LayoutInflater inflater = (LayoutInflater) getActionBar().getThemedContext() .getSystemService(LAYOUT_INFLATER_SERVICE); final View customActionBarView = inflater.inflate(R.layout.actionbar_custom_view_done, null); customActionBarView.findViewById(R.id.actionbar_done).setOnClickListener(new View.OnClickListener() { @Override//from www . j a va 2 s .c o m public void onClick(View v) { // "Done" // // Set success widgetPrefs.setPresent(); Intent resultValue = new Intent(); resultValue.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId); setResult(RESULT_OK, resultValue); // Build/Update widget AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(getApplicationContext()); // Log.d(TAG, "finishing WidgetId " + appWidgetId); appWidgetManager.updateAppWidget(appWidgetId, ListWidgetProvider .buildRemoteViews(getApplicationContext(), appWidgetManager, appWidgetId, widgetPrefs)); // Update list items appWidgetManager.notifyAppWidgetViewDataChanged(appWidgetId, R.id.notesList); // Destroy activity finish(); } }); // Show the custom action bar view and hide the normal Home icon and // title. final ActionBar actionBar = getActionBar(); actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM, ActionBar.DISPLAY_SHOW_CUSTOM | ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_SHOW_TITLE); actionBar.setCustomView(customActionBarView); }
From source file:org.kiwix.kiwixmobile.KiwixMobileActivity.java
public static void updateWidgets(Context context) { Intent intent = new Intent(context.getApplicationContext(), KiwixSearchWidget.class); intent.setAction(AppWidgetManager.ACTION_APPWIDGET_UPDATE); // Use an array and EXTRA_APPWIDGET_IDS instead of AppWidgetManager.EXTRA_APPWIDGET_ID, // since it seems the onUpdate() is only fired on that: AppWidgetManager widgetManager = AppWidgetManager.getInstance(context); int[] ids = widgetManager.getAppWidgetIds(new ComponentName(context, KiwixSearchWidget.class)); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { widgetManager.notifyAppWidgetViewDataChanged(ids, android.R.id.list); intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, ids); context.sendBroadcast(intent);//from w w w .j a v a 2s . c om } }
From source file:au.com.wallaceit.reddinator.SubredditSelectActivity.java
private void updateFeedAndFinish() { if (widgetFirstTimeSetup) { finishWidgetSetup();/*from www .j a va 2 s . c om*/ return; } if (mAppWidgetId != 0) { // refresh widget and close activity (NOTE: put in function) AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(SubredditSelectActivity.this); RemoteViews views = new RemoteViews(getPackageName(), R.layout.widget); views.setTextViewText(R.id.subreddittxt, global.getSubredditManager().getCurrentFeedName(mAppWidgetId)); views.setViewVisibility(R.id.srloader, View.VISIBLE); views.setViewVisibility(R.id.erroricon, View.INVISIBLE); // bypass cache if service not loaded global.setBypassCache(true); appWidgetManager.partiallyUpdateAppWidget(mAppWidgetId, views); appWidgetManager.notifyAppWidgetViewDataChanged(mAppWidgetId, R.id.listview); } else { Intent intent = new Intent(); intent.putExtra("themeupdate", needsThemeUpdate); setResult(2, intent); // update feed prefs + reload feed } finish(); }
From source file:au.com.wallaceit.reddinator.SubredditSelectActivity.java
public void onBackPressed() { if (widgetFirstTimeSetup) { finishWidgetSetup();/*from ww w . ja va2 s. c om*/ return; } // check if sort has changed if (needsFeedUpdate || needsFeedViewUpdate || needsThemeUpdate) { if (mAppWidgetId != 0) { AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(SubredditSelectActivity.this); RemoteViews views = new RemoteViews(getPackageName(), R.layout.widget); views.setViewVisibility(R.id.srloader, View.VISIBLE); views.setViewVisibility(R.id.erroricon, View.INVISIBLE); // bypass the cached entrys only if the sorting preference has changed if (needsFeedUpdate) { global.setBypassCache(true); } else { global.setRefreshView(); } if (needsThemeUpdate) { WidgetProvider.updateAppWidgets(SubredditSelectActivity.this, appWidgetManager, new int[] { mAppWidgetId }, false); } else { appWidgetManager.partiallyUpdateAppWidget(mAppWidgetId, views); } appWidgetManager.notifyAppWidgetViewDataChanged(mAppWidgetId, R.id.listview); } else { Intent intent = new Intent(); intent.putExtra("themeupdate", needsThemeUpdate); if (needsFeedUpdate) { setResult(2, intent); // reload feed and prefs } else { setResult(1, intent); // tells main activity to update feed prefs } if (needsThemeUpdate) { global.setRefreshView(); AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(SubredditSelectActivity.this); int[] widgetIds = appWidgetManager .getAppWidgetIds(new ComponentName(SubredditSelectActivity.this, WidgetProvider.class)); WidgetProvider.updateAppWidgets(SubredditSelectActivity.this, appWidgetManager, widgetIds, false); appWidgetManager.notifyAppWidgetViewDataChanged(widgetIds, R.id.listview); } } } else { setResult(0); } finish(); }