项目:q-mail
文件:MessageListWidgetProvider.java
private void updateAppWidget(Context context,AppWidgetManager appWidgetManager,int appWidgetId) {
RemoteViews views = new RemoteViews(context.getPackageName(),R.layout.message_list_widget_layout);
views.setTextViewText(R.id.folder,context.getString(R.string.integrated_inBox_title));
Intent intent = new Intent(context,MessageListWidgetService.class);
intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID,appWidgetId);
intent.setData(Uri.parse(intent.toUri(Intent.URI_INTENT_SCHEME)));
views.setRemoteAdapter(R.id.listView,intent);
PendingIntent viewAction = viewActionTemplatePendingIntent(context);
views.setPendingIntentTemplate(R.id.listView,viewAction);
PendingIntent composeAction = composeActionPendingIntent(context);
views.setonClickPendingIntent(R.id.new_message,composeAction);
appWidgetManager.updateAppWidget(appWidgetId,views);
}
项目:buildAPKsSamples
文件:StackWidgetProvider.java
@Override
public void onUpdate(Context context,int[] appWidgetIds) {
// update each of the widgets with the remote adapter
for (int i = 0; i < appWidgetIds.length; ++i) {
// Here we setup the intent which points to the StackViewService which will
// provide the views for this collection.
Intent intent = new Intent(context,StackWidgetService.class);
intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID,appWidgetIds[i]);
// When intents are compared,the extras are ignored,so we need to embed the extras
// into the data so that the extras will not be ignored.
intent.setData(Uri.parse(intent.toUri(Intent.URI_INTENT_SCHEME)));
RemoteViews rv = new RemoteViews(context.getPackageName(),R.layout.widget_layout);
rv.setRemoteAdapter(appWidgetIds[i],R.id.stack_view,intent);
// The empty view is displayed when the collection has no items. It should be a sibling
// of the collection view.
rv.setEmptyView(R.id.stack_view,R.id.empty_view);
// Here we setup the a pending intent template. Individuals items of a collection
// cannot setup their own pending intents,instead,the collection as a whole can
// setup a pending intent template,and the individual items can set a fillInIntent
// to create unique before on an item to item basis.
Intent toastIntent = new Intent(context,StackWidgetProvider.class);
toastIntent.setAction(StackWidgetProvider.TOAST_ACTION);
toastIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID,appWidgetIds[i]);
intent.setData(Uri.parse(intent.toUri(Intent.URI_INTENT_SCHEME)));
PendingIntent toastPendingIntent = PendingIntent.getbroadcast(context,toastIntent,PendingIntent.FLAG_UPDATE_CURRENT);
rv.setPendingIntentTemplate(R.id.stack_view,toastPendingIntent);
appWidgetManager.updateAppWidget(appWidgetIds[i],rv);
}
super.onUpdate(context,appWidgetManager,appWidgetIds);
}
项目:Clases-2017c1
文件:HiAppWidget.java
static void updateAppWidget(Context context,int appWidgetId) {
CharSequence widgetText = HiAppWidgetConfigureActivity.loadTitlePref(context,appWidgetId);
int pos = HiAppWidgetConfigureActivity.loadPosPref(context,appWidgetId) % texts.length;
// Construct the RemoteViews object
int layoutId = pos == 3 ? R.layout.hi_app_widget_other : R.layout.hi_app_widget;
RemoteViews views = new RemoteViews(context.getPackageName(),layoutId);
views.setTextViewText(R.id.title,widgetText);
views.setTextViewText(R.id.appwidget_text,context.getString(texts[pos]));
views.setonClickPendingIntent(R.id.back,getPendingIntent(context,appWidgetId,-1));
views.setonClickPendingIntent(R.id.next,+1));
// Instruct the widget manager to update the widget
appWidgetManager.updateAppWidget(appWidgetId,views);
}
private static <T extends Action> RemoteViews generateBigContentView(Context context,CharSequence contentTitle,CharSequence contentText,CharSequence contentInfo,int number,Bitmap largeIcon,CharSequence subText,boolean useChronometer,long when,List<T> actions,boolean showCancelButton,PendingIntent cancelButtonIntent) {
int actionCount = Math.min(actions.size(),5);
RemoteViews big = applyStandardTemplate(context,contentTitle,contentText,contentInfo,number,largeIcon,subText,useChronometer,when,getBigLayoutResource(actionCount),false);
big.removeAllViews(R.id.media_actions);
if (actionCount > 0) {
for (int i = 0; i < actionCount; i++) {
big.addView(R.id.media_actions,generateMediaActionButton(context,(Action) actions.get(i)));
}
}
if (showCancelButton) {
big.setViewVisibility(R.id.cancel_action,0);
big.setInt(R.id.cancel_action,"setAlpha",context.getResources().getInteger(R.integer.cancel_button_image_alpha));
big.setonClickPendingIntent(R.id.cancel_action,cancelButtonIntent);
} else {
big.setViewVisibility(R.id.cancel_action,8);
}
return big;
}
项目:financisto1-holo
文件:AccountWidget.java
private static void updateWidgets(Context context,AppWidgetManager manager,int[] appWidgetIds,boolean nextAccount) {
Log.d("FinancistoWidget","updateWidgets " + Arrays.toString(appWidgetIds) + " -> " + nextAccount);
for (int id : appWidgetIds) {
appwidgetproviderInfo appWidgetInfo = manager.getAppWidgetInfo(id);
if (appWidgetInfo != null) {
int layoutId = appWidgetInfo.initialLayout;
if (MyPreferences.isWidgetEnabled(context)) {
long accountId = loadAccountForWidget(context,id);
Class providerClass = getProviderClass(appWidgetInfo);
Log.d("FinancistoWidget","using provider " + providerClass);
RemoteViews remoteViews = nextAccount || accountId == -1
? buildUpdateForNextAccount(context,id,layoutId,providerClass,accountId)
: buildUpdateForCurrentAccount(context,accountId);
manager.updateAppWidget(id,remoteViews);
} else {
manager.updateAppWidget(id,noDataUpdate(context,layoutId));
}
}
}
}
项目:ThunderMusic
文件:Mediaappwidgetprovider4x2_Light.java
/**
* Initialize given widgets to default state,where we launch Music on
* default click and hide actions if service not running.
*/
private void defaultAppWidget(Context context,int[] appWidgetIds) {
final Resources res = context.getResources();
final RemoteViews views = new RemoteViews(context.getPackageName(),R.layout.album_appwidget4x2_light);
views.setViewVisibility(R.id.albumname,View.GONE);
views.setViewVisibility(R.id.trackname,View.GONE);
views.setTextViewText(R.id.artistname,res.getText(R.string.widget_initial_text));
views.setimageViewResource(R.id.albumart,R.drawable.albumart_mp_unkNown);
linkButtons(context,views);
pushUpdate(context,appWidgetIds,views);
}
@Override
// 返回item对应的子View
public RemoteViews getViewAt(int position) {
Logger.INSTANCE.i(" --> getViewAt");
if (mNotes.get(position) == null) {
return null;
}
RemoteViews rv = new RemoteViews(context.getPackageName(),R.layout.app_widget_notes_item);
Note note = mNotes.get(position);
rv.setTextViewText(R.id.ic_notes_item_title_tv,note.getLabel());
rv.setTextViewText(R.id.ic_notes_item_content_tv,note.getContent());
rv.setTextViewText(R.id.ic_notes_item_data_tv,context.getString(R.string.note_log_text,context.getString(R.string.create),TimeUtils.getTime(note.getCreateTime())));
// if (StringUtils.isEmpty(note.getimagePath()) || "[]".equals(note.getimagePath())) {
// rv.setViewVisibility(R.id.ic_small_pic,Visibility);
// } else {
// rv.
// holder.setVisible(R.id.small_pic,true);
// ImageUtils.INSTANCE.showThumbnail(mContext,note.getimagePath(),(ImageView) holder.getView(R.id.small_pic));
// }
loadItemOnClickExtras(rv,position);
return rv;
}
项目:Canvas-Vision
文件:StackWidgetProvider.java
@Override
public void onUpdate(Context context,int[] appWidgetIds) {
for (int i = 0; i < appWidgetIds.length; ++i) {
Intent intent = new Intent(context,appWidgetIds[i]);
intent.setData(Uri.parse(intent.toUri(Intent.URI_INTENT_SCHEME)));
RemoteViews rv = new RemoteViews(context.getPackageName(),intent);
rv.setEmptyView(R.id.stack_view,R.id.empty_view);
Intent widgetIntent = new Intent(context,StackWidgetProvider.class);
widgetIntent.setAction(StackWidgetProvider.WIDGET_ACTION);
widgetIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID,appWidgetIds[i]);
intent.setData(Uri.parse(intent.toUri(Intent.URI_INTENT_SCHEME)));
PendingIntent widgetPendingIntent = PendingIntent.getbroadcast(context,widgetIntent,widgetPendingIntent);
appWidgetManager.updateAppWidget(appWidgetIds[i],appWidgetIds);
}
项目:aosp_nav_bar_ex
文件:MainActivity.java
private void addView()
{
NavBarEntry entry = navBarEntryFromView();
if (entry == null) return;
RemoteViews remoteViews = createRemoteViewsId(entry);
if (remoteViews == null) return;
NavBarExServiceMgr navBarExServiceMgr = (NavBarExServiceMgr) getSystemService(Context.NAVBAREX_SERVICE);
String id = navBarExServiceMgr.addView(entry.priority,remoteViews);
if (TextUtils.isEmpty(id))
{
Toast.makeText(this,"Failed to add remote views. Returned null.",Toast.LENGTH_SHORT).show();
return;
}
settings.getIdsMap().put(id,entry);
settings.saveDeferred();
fillListView();
fillViews();
}
项目:buildAPKsApps
文件:AppWidget.java
private RemoteViews buildUpdate(Context context) {
RemoteViews updateViews = new RemoteViews(context.getPackageName(),R.layout.widget);
AudioManager audioManager = (AudioManager) context.getSystemService(Activity.AUdio_SERVICE);
if (audioManager.getRingerMode() == AudioManager.RINGER_MODE_SILENT) {
updateViews.setimageViewResource(R.id.phonestate,R.drawable.phone_state_normal);
audioManager.setRingerMode(AudioManager.RINGER_MODE_norMAL);
} else {
updateViews.setimageViewResource(R.id.phonestate,R.drawable.phone_state_silent);
audioManager.setRingerMode(AudioManager.RINGER_MODE_SILENT);
}
Intent i = new Intent(this,AppWidget.class);
PendingIntent pi = PendingIntent.getbroadcast(context,i,0);
updateViews.setonClickPendingIntent(R.id.phonestate,pi);
return updateViews;
}
@Override
public RemoteViews notificationChange(Notification notification,int notificationId,RemoteViews remoteViews) {
if (mImageNotification != null) {
remoteViews.setViewVisibility(R.id.notification_icon,View.VISIBLE);
Picasso.with(this).load(mImageNotification)
.into(remoteViews,R.id.notification_icon,notificationId,notification);
}
remoteViews.setViewVisibility(R.id.notification_title,View.VISIBLE);
remoteViews.setTextViewText(R.id.notification_title,mTitle.getText().toString());
remoteViews.setViewVisibility(R.id.notification_subtitle,View.VISIBLE);
remoteViews.setTextViewText(R.id.notification_subtitle,mSubtitle.getText().toString());
if (!mStop.isChecked()) {
remoteViews.setViewVisibility(R.id.stop_icon,View.GONE);
}
if (!mPlayPause.isChecked()) {
remoteViews.setViewVisibility(R.id.play_icon,View.GONE);
remoteViews.setViewVisibility(R.id.pause_icon,View.GONE);
}
return remoteViews;
}
项目:android_packages_apps_ClockWidget
文件:ClockWidget.java
private static void setClockAmPm(Context context,RemoteViews widget) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR2) {
if (DateFormat.is24HourFormat(context)) {
widget.setViewVisibility(R.id.ampm_text,View.GONE);
} else {
widget.setViewVisibility(R.id.ampm_text,View.VISIBLE);
Calendar currentCalendar = Calendar.getInstance();
int hour = currentCalendar.get(Calendar.HOUR_OF_DAY);
if (hour < 12) {
widget.setTextViewText(R.id.ampm_text,context.getResources().getString(R.string.time_am_default));
} else {
widget.setTextViewText(R.id.ampm_text,context.getResources().getString(R.string.time_pm_default));
}
}
}
else{
widget.setViewVisibility(R.id.ampm_text,View.GONE);
}
}
@Override
public void onUpdate(Context context,int[] appWidgetIds) {
// Perform this loop procedure for each App Widget that belongs to this provider
for (int i = 0; i < appWidgetIds.length; i++) {
int appWidgetId = appWidgetIds[i];
// Get the layout for the App Widget and attach an on-click listener
// to the button
RemoteViews views = new RemoteViews(context.getPackageName(),R.layout.garage_door_widget);
Intent intent = new Intent(context,GarageDoorIntentService.class);
PendingIntent pendingIntent = PendingIntent.getService(
context,intent,PendingIntent.FLAG_UPDATE_CURRENT);
views.setonClickPendingIntent(R.id.widget_layout,pendingIntent);
// Tell the AppWidgetManager to perform an update on the current app widget
appWidgetManager.updateAppWidget(appWidgetId,views);
}
}
项目:android-widget
文件:KaemWidget.java
static void updateAppWidget(Context context,int appWidgetId) {
setCountersDK(context);
setCountersIO(context);
setCountersFromPreferences(context);
// Construct the RemoteViews object
RemoteViews views = new RemoteViews(context.getPackageName(),R.layout.kaem_widget);
views.setTextViewText(R.id.dk_kaem_users,dkUsersCount);
views.setTextViewText(R.id.dk_kaem_projects,dkProjectsCount);
views.setTextViewText(R.id.dk_kaem_teams,dkTeamsCount);
views.setTextViewText(R.id.dk_kaem_lookups,dkLookupsCount);
views.setTextViewText(R.id.io_kaem_users,IoUsersCount);
views.setTextViewText(R.id.io_kaem_projects,ioProjectsCount);
views.setTextViewText(R.id.io_kaem_teams,ioTeamsCount);
views.setTextViewText(R.id.io_kaem_lookups,ioLookupsCount);
// Pending intent for refresh button
Intent intent = new Intent(REFRESH_BUTTON);
PendingIntent pendingIntent = PendingIntent.getbroadcast(context,PendingIntent.FLAG_UPDATE_CURRENT);
views.setonClickPendingIntent(R.id.REFRESH_BUTTON,pendingIntent);
// Instruct the widget manager to update the widget
appWidgetManager.updateAppWidget(appWidgetId,views);
}
项目:markor
文件:FilesWidgetFactory.java
@Override
public RemoteViews getViewAt(int position) {
RemoteViews rowView = new RemoteViews(_context.getPackageName(),R.layout.widget_file_item);
rowView.setTextViewText(R.id.widget_note_title,"???");
if (position < _widgetFilesList.length) {
File file = _widgetFilesList[position];
Intent fillInIntent = new Intent().putExtra(DocumentIO.EXTRA_PATH,file);
rowView.setTextViewText(R.id.widget_note_title,MarkdownTextConverter.MD_EXTENSION_PATTERN.matcher(file.getName()).replaceAll(""));
rowView.setonClickFillInIntent(R.id.widget_note_title,fillInIntent);
}
return rowView;
}
项目:notification-adapter
文件:NotificationAdapterTest.java
@Test
public void testNotificationAdapter() {
final String NOTIFICATION_TEXT = "adapter-text";
final String NOTIFICATION_TITLE = "adapter-title";
final long TIMEOUT = 5000;
Context appContext = InstrumentationRegistry.getTargetContext();
RemoteViews contentView = new RemoteViews("cn.dreamtobe.toolset.test",R.layout.custom_layout);
contentView.setTextViewText(R.id.title,NOTIFICATION_TITLE);
contentView.setTextViewText(R.id.text,NOTIFICATION_TEXT);
// Fix the Notification-Style problem ---------------
// Set the default title style color to title view.
contentView.setTextColor(R.id.title,NotificationAdapter.getTitleColor(appContext));
// Set the default title style size to title view
contentView.setTextViewTextSize(R.id.title,COMPLEX_UNIT_PX,NotificationAdapter.getTitleSize(appContext));
// Set the default text style color to text view
contentView.setTextColor(R.id.text,NotificationAdapter.getTextColor(appContext));
// Set the default text style size to text view
contentView.setTextViewTextSize(R.id.text,NotificationAdapter.getTextSize(appContext));
// End fix the Notification-Style problem ---------------
Notification notification = new Notification();
notification.icon = R.drawable.ic_launcher;
notification.contentView = contentView;
notification.flags |= Notification.FLAG_AUTO_CANCEL;
notification.defaults |= Notification.DEFAULT_SOUND;
notification.defaults |= Notification.DEFAULT_VIBRATE;
notificationmanager notifyMgr =
(notificationmanager) appContext.getSystemService(NOTIFICATION_SERVICE);
notifyMgr.notify(1,notification);
UiDevice device = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation());
device.openNotification();
device.wait(Until.hasObject(By.text(NOTIFICATION_TITLE)),TIMEOUT);
}
项目:orgzly-android
文件:ListWidgetViewsFactory.java
private void setContent(RemoteViews row,Note note) {
/* see also HeadsListViewAdapter.bindView */
OrgHead head = note.getHead();
row.setTextViewText(R.id.item_list_widget_title,titleGenerator.generateTitle(note,head));
/* Closed time. */
if (head.hasClosed() && AppPreferences.displayPlanning(mContext)) {
row.setTextViewText(R.id.item_list_widget_closed_text,userTimeFormatter.formatAll(head.getClosed()));
row.setViewVisibility(R.id.item_list_widget_closed,View.VISIBLE);
} else {
row.setViewVisibility(R.id.item_list_widget_closed,View.GONE);
}
/* Deadline time. */
if (head.hasDeadline() && AppPreferences.displayPlanning(mContext)) {
row.setTextViewText(R.id.item_list_widget_deadline_text,userTimeFormatter.formatAll(head.getDeadline()));
row.setViewVisibility(R.id.item_list_widget_deadline,View.VISIBLE);
} else {
row.setViewVisibility(R.id.item_list_widget_deadline,View.GONE);
}
/* Scheduled time. */
if (head.hasScheduled() && AppPreferences.displayPlanning(mContext)) {
row.setTextViewText(R.id.item_list_widget_scheduled_text,userTimeFormatter.formatAll(head.getScheduled()));
row.setViewVisibility(R.id.item_list_widget_scheduled,View.VISIBLE);
} else {
row.setViewVisibility(R.id.item_list_widget_scheduled,View.GONE);
}
if (AppPreferences.todoKeywordsSet(mContext).contains(head.getState())) {
row.setViewVisibility(R.id.item_list_widget_done,View.VISIBLE);
} else {
row.setViewVisibility(R.id.item_list_widget_done,View.GONE);
}
}
@Override
protected void onHandleWork(@NonNull Intent intent) {
AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(this);
int[] ids = appWidgetManager.getAppWidgetIds(new ComponentName(this,AppWidget.class));
RemoteViews views = new RemoteViews(getPackageName(),R.layout.app_widget);
try (Cursor cursor = getContentResolver().query(StatsProvider.CONTENT_URI,null,null)) {
if (cursor == null || cursor.getCount() <= 0) {
return;
}
cursor.movetoPrevIoUs();
while (cursor.movetoNext()) {
switch (getEnum(cursor,Stats.ID,Id.class)) {
case S2X:
setCell(views,R.id.appwidget_value_sw,getFloat(cursor,Stats.D1));
break;
case EC:
setCell(views,R.id.appwidget_value_ec,Stats.D1));
break;
}
}
}
Intent mainIntent = new Intent(this,MainActivity.class);
PendingIntent pendingIntent = PendingIntent.getActivity(this,mainIntent,0);
views.setonClickPendingIntent(R.id.appwidget_root,pendingIntent);
appWidgetManager.updateAppWidget(ids,views);
}
项目:q-mail
文件:MessageListRemoteViewFactory.java
@Override
public RemoteViews getLoadingView() {
RemoteViews loadingView = new RemoteViews(context.getPackageName(),R.layout.message_list_widget_loading);
loadingView.setTextViewText(R.id.loadingText,context.getString(R.string.mail_list_widget_loading));
loadingView.setViewVisibility(R.id.loadingText,View.VISIBLE);
return loadingView;
}
protected void updateAppWidget(Context context,R.layout.up_down_widget);
views.setonClickPendingIntent(R.id.up_btn,PendingIntent.getbroadcast(context,new Intent(ArcadeCommon.ACTION_UP),0));
views.setonClickPendingIntent(R.id.down_btn,new Intent(ArcadeCommon.ACTION_DOWN),0));
appWidgetManager.updateAppWidget(appWidgetId,views);
}
项目:GitHub
文件:AppWidgetTargetTest.java
@Before
public void setUp() {
shadowManager = (UpdateShadowAppWidgetManager) Shadow
.extract(AppWidgetManager.getInstance(RuntimeEnvironment.application));
viewId = 1234;
views = mock(RemoteViews.class);
}
项目:lighthouse
文件:Medianotificationmanager.java
private void setRecordState(RemoteViews remoteViews,podcast podcast,Record record) {
remoteViews.setTextViewText(android.R.id.title,podcast.getName());
remoteViews.setTextViewText(android.R.id.text1,record.getName());
BitmapInfo bitmapInfo = podcastImageCache.getInstance().getIcon(podcast.getId());
if (bitmapInfo != null) {
remoteViews.setimageViewBitmap(android.R.id.icon,bitmapInfo.getBitmap());
}
}
private void showRemoteViews(RemoteViews remoteViews) {
View inflatedView = remoteViews.apply(mActivity,getBottomBarView());
if (mClickableIDs != null && mClickPendingIntent != null) {
for (int id: mClickableIDs) {
if (id < 0) return;
View view = inflatedView.findViewById(id);
if (view != null) view.setonClickListener(mBottomBarClickListener);
}
}
getBottomBarView().addView(inflatedView,1);
}
项目:GitHub
文件:RouteService.java
private void initNotification() {
int icon = R.mipmap.bike_icon2;
contentView = new RemoteViews(getPackageName(),R.layout.notification_layout);
notification = new NotificationCompat.Builder(this).setContent(contentView).setSmallIcon(icon).build();
Intent notificationIntent = new Intent(this,MainActivity.class);
notificationIntent.putExtra("flag","notification");
notification.contentIntent = PendingIntent.getActivity(this,notificationIntent,0);
}
项目:chromium-for-android-56-debug-video
文件:Customtabactivity.java
/**
* Checks whether the active {@link CustomTabContentHandler} belongs to the given session,and
* if true,updates {@link RemoteViews} on the secondary toolbar.
* @return Whether the update is successful.
*/
static boolean updateRemoteViews(
CustomTabsSessionToken session,RemoteViews remoteViews,int[] clickableIDs,PendingIntent pendingIntent) {
ThreadUtils.assertOnUiThread();
// Do nothing if there is no activity or the activity does not belong to this session.
if (sActiveContentHandler == null || !sActiveContentHandler.getSession().equals(session)) {
return false;
}
return sActiveContentHandler.updateRemoteViews(remoteViews,clickableIDs,pendingIntent);
}
项目:Mobike
文件:RouteService.java
private void initNotification() {
int icon = R.drawable.mobike_logo;
contentView = new RemoteViews(getPackageName(),0);
}
项目:MusicX-music-player
文件:MusicXwidget4x4.java
private void pushUpdate(Context context,RemoteViews views) {
// Update specific list of appWidgetIds if given,otherwise default to all
final AppWidgetManager gm = AppWidgetManager.getInstance(context);
if (appWidgetIds != null) {
gm.updateAppWidget(appWidgetIds,views);
} else {
gm.updateAppWidget(new ComponentName(context,this.getClass()),views);
}
}
项目:letv
文件:DownloadNotification.java
private void initNotification() {
if (this.mNotification == null || this.nm == null) {
this.mNotification = new Notification(R.drawable.notification_icon,this.mContext.getString(R.string.notification_download_ing),System.currentTimeMillis());
this.mNotification.contentView = new RemoteViews(this.mContext.getPackageName(),R.layout.notification_download);
this.mNotification.contentView.setProgressBar(R.id.notify_progressbar,100,false);
this.mNotification.flags = 32;
this.nm = (notificationmanager) this.mContext.getSystemService("notification");
}
}
项目:javaide
文件:WidgetHelper.java
private static void updateWidget(Context context,int appWidgetId,boolean serviceRunning) {
RemoteViews updateViews = new RemoteViews(context.getPackageName(),R.layout.widget_recording);
// change the subtext depending on whether the service is running or not
CharSequence subtext = context.getText(
serviceRunning ? R.string.widget_recording_in_progress : R.string.widget_start_recording);
updateViews.setTextViewText(R.id.widget_subtext,subtext);
// if service not running,don't show the "recording" icon
updateViews.setViewVisibility(R.id.record_badge_image_view,serviceRunning ? View.VISIBLE : View.INVISIBLE);
PendingIntent pendingIntent = getPendingIntent(context,appWidgetId);
updateViews.setonClickPendingIntent(R.id.clickable_linear_layout,pendingIntent);
manager.updateAppWidget(appWidgetId,updateViews);
}
项目:MuslimMateAndroid
文件:CalenderWidget.java
/**
* Function fire on system update widget
*
* @param context Context of application
* @param appWidgetManager App widget manger
* @param appWidgetIds Widget system ids
*/
@Override
public void onUpdate(Context context,final AppWidgetManager appWidgetManager,int[] appWidgetIds) {
final int count = appWidgetIds.length;
//set widget language with the system language
Locale locale = new Locale(Resources.getSystem().getConfiguration().locale.getLanguage());
Locale.setDefault(locale);
Configuration config = new Configuration();
config.locale = locale;
context.getResources().updateConfiguration(config,context.getResources().getdisplayMetrics());
this.context = context;
//loop in all widgets
for (int i = 0; i < count; i++) {
svcIntent = new Intent(context,CalenderRemoteViewsService.class);
final int widgetId = appWidgetIds[i];
remoteViews = new RemoteViews(context.getPackageName(),R.layout.widget_calender);
remoteViews.setRemoteAdapter(R.id.calendar_pager,svcIntent);
appWidgetManager.notifyAppWidgetViewDataChanged(appWidgetIds[i],R.id.calendar_pager);
HGDate hgDate = new HGDate();
hgDate.toHigri();
remoteViews.setTextViewText(R.id.textView8,Dates.getCurrentWeekDay());
remoteViews.setTextViewText(R.id.textView7,NumbersLocal.convertToNumberTypeSystem(context,hgDate.getDay() + ""));
remoteViews.setTextViewText(R.id.textView24,hgDate.getYear() + ""));
remoteViews.setTextViewText(R.id.curr_month_txt,Dates.islamicMonthName(context,hgDate.getMonth() - 1));
remoteViews.setTextViewText(R.id.curr_month_txt_other,showOtherMonth(hgDate));
PendingIntent configPendingIntent = PendingIntent.getActivity(context,new Intent(context,MainActivity.class),0);
remoteViews.setonClickPendingIntent(R.id.relativeLayout,configPendingIntent);
appWidgetManager.updateAppWidget(widgetId,remoteViews);
}
}
项目:buildAPKsSamples
文件:WeatherWidgetService.java
public RemoteViews getViewAt(int position) {
// Get the data for this position from the content provider
String day = "UnkNown Day";
int temp = 0;
if (mCursor.movetoPosition(position)) {
final int dayColIndex = mCursor.getColumnIndex(WeatherDataProvider.Columns.DAY);
final int tempColIndex = mCursor.getColumnIndex(
WeatherDataProvider.Columns.TEMPERATURE);
day = mCursor.getString(dayColIndex);
temp = mCursor.getInt(tempColIndex);
}
// Return a proper item with the proper day and temperature
final String formatStr = mContext.getResources().getString(R.string.item_format_string);
final int itemId = R.layout.widget_item;
RemoteViews rv = new RemoteViews(mContext.getPackageName(),itemId);
rv.setTextViewText(R.id.widget_item,String.format(formatStr,temp,day));
// Set the click intent so that we can handle it and show a toast message
final Intent fillInIntent = new Intent();
final Bundle extras = new Bundle();
extras.putString(WeatherWidgetProvider.EXTRA_DAY_ID,day);
fillInIntent.putExtras(extras);
rv.setonClickFillInIntent(R.id.widget_item,fillInIntent);
return rv;
}
项目:QuranAndroid
文件:QuranPageReadActivity.java
public void cancelNotification() {
remoteViews = new RemoteViews(this.getPackageName(),R.layout.notification_download_progress);
builder = new NotificationCompat.Builder(this)
.setSmallIcon(aboveLollipopFlag ? R.drawable.ic_quran_trans : R.drawable.logo)
.setColor(Color.parseColor("#3E686A"));
builder.setAutoCancel(true);
}
项目:PlusGram
文件:MusicPlayerService.java
public void setListeners(RemoteViews view) {
PendingIntent pendingIntent = PendingIntent.getbroadcast(getApplicationContext(),new Intent(NOTIFY_PREVIoUS),PendingIntent.FLAG_UPDATE_CURRENT);
view.setonClickPendingIntent(R.id.player_prevIoUs,pendingIntent);
pendingIntent = PendingIntent.getbroadcast(getApplicationContext(),new Intent(NOTIFY_CLOSE),PendingIntent.FLAG_UPDATE_CURRENT);
view.setonClickPendingIntent(R.id.player_close,new Intent(NOTIFY_PAUSE),PendingIntent.FLAG_UPDATE_CURRENT);
view.setonClickPendingIntent(R.id.player_pause,new Intent(NOTIFY_NEXT),PendingIntent.FLAG_UPDATE_CURRENT);
view.setonClickPendingIntent(R.id.player_next,new Intent(NOTIFY_PLAY),PendingIntent.FLAG_UPDATE_CURRENT);
view.setonClickPendingIntent(R.id.player_play,pendingIntent);
}
项目:airgram
文件:MusicPlayerService.java
public void setListeners(RemoteViews view) {
PendingIntent pendingIntent = PendingIntent.getbroadcast(getApplicationContext(),pendingIntent);
}
项目:IdealMedia
文件:NotificationUtils.java
public static RemoteViews getNotificationViews(final Track track,final Context context,boolean isPlaying) {
final RemoteViews views = new RemoteViews(context.getPackageName(),R.layout.notification);
views.setTextViewText(R.id.notifTitle,track.getTitle());
views.setTextViewText(R.id.notifArtist,track.getArtist());
Bitmap cover = MediaUtils.getArtworkQuick(context,track,180,180);
if (cover != null)
views.setimageViewBitmap(R.id.notifAlbum,cover);
else
views.setimageViewResource(R.id.notifAlbum,R.drawable.ic_launcher);
if (Build.VERSION.SDK_INT < 11) {
views.setViewVisibility(R.id.action_prev,View.GONE);
views.setViewVisibility(R.id.action_play,View.GONE);
views.setViewVisibility(R.id.action_next,View.GONE);
}
views.setimageViewResource(R.id.action_play,isPlaying ? R.drawable.selector_pause_button : R.drawable.selector_play_button);
ComponentName componentName = new ComponentName(context,PlayerService.class);
Intent intentPlay = new Intent(PlayerService.PLAY);
intentPlay.setComponent(componentName);
views.setonClickPendingIntent(R.id.action_play,PendingIntent.getService(context,intentPlay,0));
Intent intentNext = new Intent(PlayerService.NEXT);
intentNext.setComponent(componentName);
views.setonClickPendingIntent(R.id.action_next,intentNext,0));
Intent intentPrevIoUs = new Intent(PlayerService.PREV);
intentPrevIoUs.setComponent(componentName);
views.setonClickPendingIntent(R.id.action_prev,intentPrevIoUs,0));
return views;
}
项目:ArtOfAndroid
文件:Myappwidgetprovider.java
/**
* 更新桌面小部件
*/
private void onWidgetUpdate(Context context,int appWidgetId) {
Log.d(TAG,"appWidgetId = " + appWidgetId);
RemoteViews remoteViews = new RemoteViews(context.getPackageName(),R.layout.layout_widget);
//设置点击事件
Intent clickIntent = new Intent(ACTION_CLICK);
PendingIntent pendingIntent = PendingIntent.getbroadcast(context,clickIntent,0);
remoteViews.setonClickPendingIntent(R.id.iv_widget,pendingIntent);
appWidgetManager.updateAppWidget(appWidgetId,remoteViews);
}
项目:CSipSimple
文件:AccountWidgetProvider.java
@Override
public void onUpdate(Context context,int[] appWidgetIds) {
// Update each requested appWidgetId
for (int widgetId : appWidgetIds) {
RemoteViews view = buildUpdate(context,widgetId);
appWidgetManager.updateAppWidget(widgetId,view);
}
}
项目:PingWidget
文件:Util.java
public static void registerWidgetStartPauSEOnClickListener(Context context,int widgetId,RemoteViews views) {
//Register an Intent so that onClicks on the widget are received by PingWidgetProvider.onReceive()
//Create an Intent,set PING_WIDGET_TOGGLE action to it,put EXTRA_APPWIDGET_ID as extra
Intent clickIntent = new Intent(context,PingWidgetProvider.class);
clickIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID,widgetId);
clickIntent.setAction(Constants.PING_WIDGET_TOGGLE);
//Construct a PendingIntent using the Intent above
PendingIntent pendingIntent = PendingIntent.getbroadcast(context,widgetId,0);
//Register pendingIntent in RemoteViews onClick
views.setonClickPendingIntent(R.id.widget_start_pause,pendingIntent);
}
项目:letv
文件:LetvPushService.java
private RemoteViews createBigRemoteViews(Bitmap bitmapBig,String title,String subtitle) {
if (bitmapBig == null) {
return null;
}
RemoteViews bigView = new RemoteViews(getPackageName(),R.layout.push_layout_3);
bigView.setimageViewBitmap(R.id.push_big_img,bitmapBig);
bigView.setTextViewText(R.id.push_big_img_title,title);
bigView.setTextViewText(R.id.push_big_img_title_subtitle,subtitle);
return bigView;
}
private boolean shouldBlockByRemoteViews(RemoteViews remoteViews) {
if (remoteViews == null) {
return false;
} else if (remoteViews != null && sSystemLayoutResIds.containsKey(remoteViews.getLayoutId())) {
return false;
} else {
return true;
}
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。