Java 类android.widget.RemoteViews 实例源码

项目: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, AppWidgetManager appWidgetManager, 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, 0, 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, AppWidgetManager appWidgetManager,
                            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, getPendingIntent(context, appWidgetId, +1));

    // Instruct the widget manager to update the widget
    appWidgetManager.updateAppWidget(appWidgetId, views);
}
项目:boohee_v5.6    文件:NotificationCompatImplBase.java   
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, id, layoutId, providerClass, 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);
}
项目:MinimalismJotter    文件:NotesRemoteViewsFactory.java   
@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, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
    for (int i = 0; i < appWidgetIds.length; ++i) {

        Intent intent = new Intent(context, StackWidgetService.class);
        intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetIds[i]);
        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);

        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, 0, widgetIntent,
                PendingIntent.FLAG_UPDATE_CURRENT);
        rv.setPendingIntentTemplate(R.id.stack_view, widgetPendingIntent);

        appWidgetManager.updateAppWidget(appWidgetIds[i], rv);
    }
    super.onUpdate(context, appWidgetManager, 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, 0, i, 0);
    updateViews.setOnClickPendingIntent(R.id.phoneState, pi);

    return updateViews;

}
项目:AJCPlayer    文件:SecondAudioActivity.java   
@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);
    }

}
项目:GarageDoor    文件:GarageDoorWidgetProvider.java   
@Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager, 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, 0, 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, AppWidgetManager appWidgetManager,
                            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, 0, intent, 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, COMPLEX_UNIT_PX, 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);
    }
}
项目:blockvote    文件:AppWidgetUpdateService.java   
@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, 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, getFloat(cursor, Stats.D1));
                    break;
            }
        }
    }

    Intent        mainIntent    = new Intent(this, MainActivity.class);
    PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, 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;
}
项目:homescreenarcade    文件:UpDownWidget.java   
protected void updateAppWidget(Context context, AppWidgetManager appWidgetManager,
                            int appWidgetId) {
    RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.up_down_widget);
    views.setOnClickPendingIntent(R.id.up_btn,
            PendingIntent.getBroadcast(context, 0, new Intent(ArcadeCommon.ACTION_UP), 0));
    views.setOnClickPendingIntent(R.id.down_btn,
            PendingIntent.getBroadcast(context, 0, 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());
    }
}
项目:chromium-for-android-56-debug-video    文件:CustomTabBottomBarDelegate.java   
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, 0, 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(), 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, 0, notificationIntent, 0);
}
项目:MusicX-music-player    文件:MusicXwidget4x4.java   
private void pushUpdate(Context context, int[] appWidgetIds, 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, 0, false);
        this.mNotification.flags = 32;
        this.nm = (NotificationManager) this.mContext.getSystemService("notification");
    }
}
项目:javaide    文件:WidgetHelper.java   
private static void updateWidget(Context context, AppWidgetManager manager, 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, NumbersLocal.convertToNumberTypeSystem(context, 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, 0, 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(), 0, new Intent(NOTIFY_PREVIOUS), PendingIntent.FLAG_UPDATE_CURRENT);
    view.setOnClickPendingIntent(R.id.player_previous, pendingIntent);
    pendingIntent = PendingIntent.getBroadcast(getApplicationContext(), 0, new Intent(NOTIFY_CLOSE), PendingIntent.FLAG_UPDATE_CURRENT);
    view.setOnClickPendingIntent(R.id.player_close, pendingIntent);
    pendingIntent = PendingIntent.getBroadcast(getApplicationContext(), 0, new Intent(NOTIFY_PAUSE), PendingIntent.FLAG_UPDATE_CURRENT);
    view.setOnClickPendingIntent(R.id.player_pause, pendingIntent);
    pendingIntent = PendingIntent.getBroadcast(getApplicationContext(), 0, new Intent(NOTIFY_NEXT), PendingIntent.FLAG_UPDATE_CURRENT);
    view.setOnClickPendingIntent(R.id.player_next, pendingIntent);
    pendingIntent = PendingIntent.getBroadcast(getApplicationContext(), 0, 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(), 0, new Intent(NOTIFY_PREVIOUS), PendingIntent.FLAG_UPDATE_CURRENT);
    view.setOnClickPendingIntent(R.id.player_previous, pendingIntent);
    pendingIntent = PendingIntent.getBroadcast(getApplicationContext(), 0, new Intent(NOTIFY_CLOSE), PendingIntent.FLAG_UPDATE_CURRENT);
    view.setOnClickPendingIntent(R.id.player_close, pendingIntent);
    pendingIntent = PendingIntent.getBroadcast(getApplicationContext(), 0, new Intent(NOTIFY_PAUSE), PendingIntent.FLAG_UPDATE_CURRENT);
    view.setOnClickPendingIntent(R.id.player_pause, pendingIntent);
    pendingIntent = PendingIntent.getBroadcast(getApplicationContext(), 0, new Intent(NOTIFY_NEXT), PendingIntent.FLAG_UPDATE_CURRENT);
    view.setOnClickPendingIntent(R.id.player_next, pendingIntent);
    pendingIntent = PendingIntent.getBroadcast(getApplicationContext(), 0, new Intent(NOTIFY_PLAY), PendingIntent.FLAG_UPDATE_CURRENT);
    view.setOnClickPendingIntent(R.id.player_play, 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, 0, intentPlay, 0));

    Intent intentNext = new Intent(PlayerService.NEXT);
    intentNext.setComponent(componentName);
    views.setOnClickPendingIntent(R.id.action_next, PendingIntent.getService(context, 0, intentNext, 0));

    Intent intentPrevious = new Intent(PlayerService.PREV);
    intentPrevious.setComponent(componentName);
    views.setOnClickPendingIntent(R.id.action_prev, PendingIntent.getService(context, 0, intentPrevious, 0));

    return views;
}
项目:ArtOfAndroid    文件:MyAppWidgetProvider.java   
/**
 * 更新桌面小部件
 */
private void onWidgetUpdate(Context context, AppWidgetManager appWidgetManager, 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, 0, clickIntent, 0);
    remoteViews.setOnClickPendingIntent(R.id.iv_widget, pendingIntent);

    appWidgetManager.updateAppWidget(appWidgetId, remoteViews);
}
项目:CSipSimple    文件:AccountWidgetProvider.java   
@Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager, 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, clickIntent, 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;
}
项目:DroidPlugin    文件:INotificationManagerHookHandle.java   
private boolean shouldBlockByRemoteViews(RemoteViews remoteViews) {
    if (remoteViews == null) {
        return false;
    } else if (remoteViews != null && sSystemLayoutResIds.containsKey(remoteViews.getLayoutId())) {
        return false;
    } else {
        return true;
    }
}