Example usage for android.widget RemoteViews setTextViewText

List of usage examples for android.widget RemoteViews setTextViewText

Introduction

In this page you can find the example usage for android.widget RemoteViews setTextViewText.

Prototype

public void setTextViewText(int viewId, CharSequence text) 

Source Link

Document

Equivalent to calling TextView#setText(CharSequence)

Usage

From source file:com.example.accessibility.OverlayManager.java

private void triggerNotification() {
    //The idea is that this notification allows you to switch off the service. Now you can only access the application information and stop it there.

    NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
    Notification notification = new Notification.Builder(this).setContentText("Hola hola")
            .setSmallIcon(R.drawable.images).setWhen(System.currentTimeMillis()).build();

    RemoteViews contentView = new RemoteViews(getPackageName(), R.layout.notification_layout);
    contentView.setImageViewResource(R.id.img_notification, R.drawable.images);
    contentView.setTextViewText(R.id.txt_notification, "Switch off TouchAccessibility.");

    notification.contentView = contentView;

    notificationManager.notify(NOTIFICATION_ID, notification);
}

From source file:com.onyx.deskclock.deskclock.data.StopwatchModel.java

/**
 * Updates the notification to reflect the latest state of the stopwatch and recorded laps.
 *//*w ww  .j  a  va 2 s.com*/
void updateNotification() {
    final Stopwatch stopwatch = getStopwatch();

    // Notification should be hidden if the stopwatch has no time or the app is open.
    if (stopwatch.isReset() || mNotificationModel.isApplicationInForeground()) {
        mNotificationManager.cancel(mNotificationModel.getStopwatchNotificationId());
        return;
    }

    @StringRes
    final int eventLabel = R.string.label_notification;

    // Intent to load the app when the notification is tapped.
    final Intent showApp = new Intent(mContext, HandleDeskClockApiCalls.class)
            .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK).setAction(HandleDeskClockApiCalls.ACTION_SHOW_STOPWATCH)
            .putExtra(HandleDeskClockApiCalls.EXTRA_EVENT_LABEL, eventLabel);

    final PendingIntent pendingShowApp = PendingIntent.getActivity(mContext, 0, showApp,
            PendingIntent.FLAG_ONE_SHOT | PendingIntent.FLAG_UPDATE_CURRENT);

    // Compute some values required below.
    final boolean running = stopwatch.isRunning();
    final String pname = mContext.getPackageName();
    final Resources res = mContext.getResources();
    final long base = SystemClock.elapsedRealtime() - stopwatch.getTotalTime();

    final RemoteViews collapsed = new RemoteViews(pname, R.layout.stopwatch_notif_collapsed);
    collapsed.setChronometer(R.id.swn_collapsed_chronometer, base, null, running);
    collapsed.setOnClickPendingIntent(R.id.swn_collapsed_hitspace, pendingShowApp);
    collapsed.setImageViewResource(R.id.notification_icon, R.drawable.stat_notify_stopwatch);

    final RemoteViews expanded = new RemoteViews(pname, R.layout.stopwatch_notif_expanded);
    expanded.setChronometer(R.id.swn_expanded_chronometer, base, null, running);
    expanded.setOnClickPendingIntent(R.id.swn_expanded_hitspace, pendingShowApp);
    expanded.setImageViewResource(R.id.notification_icon, R.drawable.stat_notify_stopwatch);

    @IdRes
    final int leftButtonId = R.id.swn_left_button;
    @IdRes
    final int rightButtonId = R.id.swn_right_button;
    if (running) {
        // Left button: Pause
        expanded.setTextViewText(leftButtonId, res.getText(R.string.sw_pause_button));
        //            setTextViewDrawable(expanded, leftButtonId, R.drawable.ic_pause_24dp);
        final Intent pause = new Intent(mContext, StopwatchService.class)
                .setAction(HandleDeskClockApiCalls.ACTION_PAUSE_STOPWATCH)
                .putExtra(HandleDeskClockApiCalls.EXTRA_EVENT_LABEL, eventLabel);
        expanded.setOnClickPendingIntent(leftButtonId, pendingServiceIntent(pause));

        // Right button: Add Lap
        if (canAddMoreLaps()) {
            expanded.setTextViewText(rightButtonId, res.getText(R.string.sw_lap_button));
            //                setTextViewDrawable(expanded, rightButtonId, R.drawable.ic_sw_lap_24dp);

            final Intent lap = new Intent(mContext, StopwatchService.class)
                    .setAction(HandleDeskClockApiCalls.ACTION_LAP_STOPWATCH)
                    .putExtra(HandleDeskClockApiCalls.EXTRA_EVENT_LABEL, eventLabel);
            expanded.setOnClickPendingIntent(rightButtonId, pendingServiceIntent(lap));
            expanded.setViewVisibility(rightButtonId, VISIBLE);
        } else {
            expanded.setViewVisibility(rightButtonId, INVISIBLE);
        }

        // Show the current lap number if any laps have been recorded.
        final int lapCount = getLaps().size();
        if (lapCount > 0) {
            final int lapNumber = lapCount + 1;
            final String lap = res.getString(R.string.sw_notification_lap_number, lapNumber);
            collapsed.setTextViewText(R.id.swn_collapsed_laps, lap);
            collapsed.setViewVisibility(R.id.swn_collapsed_laps, VISIBLE);
            expanded.setTextViewText(R.id.swn_expanded_laps, lap);
            expanded.setViewVisibility(R.id.swn_expanded_laps, VISIBLE);
        } else {
            collapsed.setViewVisibility(R.id.swn_collapsed_laps, GONE);
            expanded.setViewVisibility(R.id.swn_expanded_laps, GONE);
        }
    } else {
        // Left button: Start
        expanded.setTextViewText(leftButtonId, res.getText(R.string.sw_start_button));
        //            setTextViewDrawable(expanded, leftButtonId, R.drawable.ic_start_24dp);
        final Intent start = new Intent(mContext, StopwatchService.class)
                .setAction(HandleDeskClockApiCalls.ACTION_START_STOPWATCH)
                .putExtra(HandleDeskClockApiCalls.EXTRA_EVENT_LABEL, eventLabel);
        expanded.setOnClickPendingIntent(leftButtonId, pendingServiceIntent(start));

        // Right button: Reset (HandleDeskClockApiCalls will also bring forward the app)
        expanded.setViewVisibility(rightButtonId, VISIBLE);
        expanded.setTextViewText(rightButtonId, res.getText(R.string.sw_reset_button));
        //            setTextViewDrawable(expanded, rightButtonId, R.drawable.ic_reset_24dp);
        final Intent reset = new Intent(mContext, HandleDeskClockApiCalls.class)
                .setAction(HandleDeskClockApiCalls.ACTION_RESET_STOPWATCH)
                .putExtra(HandleDeskClockApiCalls.EXTRA_EVENT_LABEL, eventLabel);
        expanded.setOnClickPendingIntent(rightButtonId, pendingActivityIntent(reset));

        // Indicate the stopwatch is paused.
        collapsed.setTextViewText(R.id.swn_collapsed_laps, res.getString(R.string.swn_paused));
        collapsed.setViewVisibility(R.id.swn_collapsed_laps, VISIBLE);
        expanded.setTextViewText(R.id.swn_expanded_laps, res.getString(R.string.swn_paused));
        expanded.setViewVisibility(R.id.swn_expanded_laps, VISIBLE);
    }

    // Swipe away will reset the stopwatch without bringing forward the app.
    final Intent reset = new Intent(mContext, StopwatchService.class)
            .setAction(HandleDeskClockApiCalls.ACTION_RESET_STOPWATCH)
            .putExtra(HandleDeskClockApiCalls.EXTRA_EVENT_LABEL, eventLabel);

    final Notification notification = new NotificationCompat.Builder(mContext).setLocalOnly(true)
            .setOngoing(running).setContent(collapsed).setAutoCancel(stopwatch.isPaused())
            .setPriority(Notification.PRIORITY_MAX).setDeleteIntent(pendingServiceIntent(reset))
            .setSmallIcon(R.drawable.ic_tab_stopwatch_activated).build();
    if (Build.VERSION.SDK_INT >= 16) {
        notification.bigContentView = expanded;
    }
    mNotificationManager.notify(mNotificationModel.getStopwatchNotificationId(), notification);
}

From source file:org.physical_web.physicalweb.UriBeaconDiscoveryService.java

private void updateSummaryNotificationRemoteViewsSecondBeacon(String url, RemoteViews remoteViews) {
    MetadataResolver.UrlMetadata urlMetadata_secondBeacon = mUrlToUrlMetadata.get(url);
    if (urlMetadata_secondBeacon != null) {
        String title = mUrlToUrlMetadata.get(url).title;
        String description = mUrlToUrlMetadata.get(url).description;
        Bitmap icon = mUrlToUrlMetadata.get(url).icon;
        remoteViews.setImageViewBitmap(R.id.icon_secondBeacon, icon);
        remoteViews.setTextViewText(R.id.title_secondBeacon, title);
        remoteViews.setTextViewText(R.id.url_secondBeacon, url);
        remoteViews.setTextViewText(R.id.description_secondBeacon, description);
        // Recolor notifications to have light text for non-Lollipop devices
        if (!(android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)) {
            remoteViews.setTextColor(R.id.title_secondBeacon, NON_LOLLIPOP_NOTIFICATION_TITLE_COLOR);
            remoteViews.setTextColor(R.id.url_secondBeacon, NON_LOLLIPOP_NOTIFICATION_URL_COLOR);
            remoteViews.setTextColor(R.id.description_secondBeacon, NON_LOLLIPOP_NOTIFICATION_SNIPPET_COLOR);
        }/*from w  w w .  ja  v a 2s. c  om*/

        // Create an intent that will open the browser to the beacon's url
        // if the user taps the notification
        PendingIntent pendingIntent = createNavigateToUrlPendingIntent(url);
        remoteViews.setOnClickPendingIntent(R.id.second_beacon_main_layout, pendingIntent);
        remoteViews.setViewVisibility(R.id.secondBeaconLayout, View.VISIBLE);
    } else {
        remoteViews.setViewVisibility(R.id.secondBeaconLayout, View.GONE);
    }
}

From source file:com.devbrackets.android.playlistcore.helper.NotificationHelper.java

/**
 * Creates the RemoteViews used for the custom (standard) notification
 *
 * @return The resulting RemoteViews//  w  w  w  . j a  v  a2s . c  om
 */
@NonNull
protected RemoteViews getCustomNotification(@NonNull Class<? extends Service> serviceClass) {
    RemoteViews customNotification = new RemoteViews(context.getPackageName(),
            R.layout.playlistcore_notification_content);

    customNotification.setOnClickPendingIntent(R.id.playlistcore_notification_playpause,
            createPendingIntent(RemoteActions.ACTION_PLAY_PAUSE, serviceClass));
    customNotification.setOnClickPendingIntent(R.id.playlistcore_notification_next,
            createPendingIntent(RemoteActions.ACTION_NEXT, serviceClass));
    customNotification.setOnClickPendingIntent(R.id.playlistcore_notification_prev,
            createPendingIntent(RemoteActions.ACTION_PREVIOUS, serviceClass));

    customNotification.setTextViewText(R.id.playlistcore_notification_title, notificationInfo.getTitle());
    customNotification.setTextViewText(R.id.playlistcore_notification_album, notificationInfo.getAlbum());
    customNotification.setTextViewText(R.id.playlistcore_notification_artist, notificationInfo.getArtist());
    if (notificationInfo.getLargeImage() != null) {
        customNotification.setBitmap(R.id.playlistcore_notification_large_image, "setImageBitmap",
                notificationInfo.getLargeImage());
    }

    if (notificationInfo.getMediaState() != null) {
        updateCustomNotificationMediaState(customNotification);
    }

    return customNotification;
}

From source file:com.syncedsynapse.kore2.service.NotificationService.java

@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
private void buildNotification(PlayerType.GetActivePlayersReturnType getActivePlayerResult,
        PlayerType.PropertyValue getPropertiesResult, ListType.ItemsAll getItemResult) {
    final String title, underTitle, poster;
    int smallIcon, playPauseIcon, rewindIcon, ffIcon;

    boolean isVideo = ((getItemResult.type.equals(ListType.ItemsAll.TYPE_MOVIE))
            || (getItemResult.type.equals(ListType.ItemsAll.TYPE_EPISODE)));

    switch (getItemResult.type) {
    case ListType.ItemsAll.TYPE_MOVIE:
        title = getItemResult.title;//ww  w  .java2  s.  com
        underTitle = getItemResult.tagline;
        poster = getItemResult.thumbnail;
        smallIcon = R.drawable.ic_movie_white_24dp;
        break;
    case ListType.ItemsAll.TYPE_EPISODE:
        title = getItemResult.title;
        String seasonEpisode = String.format(getString(R.string.season_episode_abbrev), getItemResult.season,
                getItemResult.episode);
        underTitle = String.format("%s | %s", getItemResult.showtitle, seasonEpisode);
        poster = getItemResult.art.poster;
        smallIcon = R.drawable.ic_tv_white_24dp;
        break;
    case ListType.ItemsAll.TYPE_SONG:
        title = getItemResult.title;
        underTitle = getItemResult.displayartist + " | " + getItemResult.album;
        poster = getItemResult.thumbnail;
        smallIcon = R.drawable.ic_headset_white_24dp;
        break;
    case ListType.ItemsAll.TYPE_MUSIC_VIDEO:
        title = getItemResult.title;
        underTitle = Utils.listStringConcat(getItemResult.artist, ", ") + " | " + getItemResult.album;
        poster = getItemResult.thumbnail;
        smallIcon = R.drawable.ic_headset_white_24dp;
        break;
    default:
        // We don't know what this is, forget it
        return;
    }

    switch (getPropertiesResult.speed) {
    case 1:
        playPauseIcon = R.drawable.ic_pause_white_24dp;
        break;
    default:
        playPauseIcon = R.drawable.ic_play_arrow_white_24dp;
        break;
    }

    // Create the actions, depending on the type of media
    PendingIntent rewindPendingItent, ffPendingItent, playPausePendingIntent;
    playPausePendingIntent = buildActionPendingIntent(getActivePlayerResult.playerid,
            IntentActionsService.ACTION_PLAY_PAUSE);
    if (getItemResult.type.equals(ListType.ItemsAll.TYPE_SONG)) {
        rewindPendingItent = buildActionPendingIntent(getActivePlayerResult.playerid,
                IntentActionsService.ACTION_PREVIOUS);
        rewindIcon = R.drawable.ic_skip_previous_white_24dp;
        ffPendingItent = buildActionPendingIntent(getActivePlayerResult.playerid,
                IntentActionsService.ACTION_NEXT);
        ffIcon = R.drawable.ic_skip_next_white_24dp;
    } else {
        rewindPendingItent = buildActionPendingIntent(getActivePlayerResult.playerid,
                IntentActionsService.ACTION_REWIND);
        rewindIcon = R.drawable.ic_fast_rewind_white_24dp;
        ffPendingItent = buildActionPendingIntent(getActivePlayerResult.playerid,
                IntentActionsService.ACTION_FAST_FORWARD);
        ffIcon = R.drawable.ic_fast_forward_white_24dp;
    }

    // Setup the collpased and expanded notifications
    final RemoteViews collapsedRV = new RemoteViews(this.getPackageName(), R.layout.notification_colapsed);
    collapsedRV.setImageViewResource(R.id.rewind, rewindIcon);
    collapsedRV.setOnClickPendingIntent(R.id.rewind, rewindPendingItent);
    collapsedRV.setImageViewResource(R.id.play, playPauseIcon);
    collapsedRV.setOnClickPendingIntent(R.id.play, playPausePendingIntent);
    collapsedRV.setImageViewResource(R.id.fast_forward, ffIcon);
    collapsedRV.setOnClickPendingIntent(R.id.fast_forward, ffPendingItent);
    collapsedRV.setTextViewText(R.id.title, title);
    collapsedRV.setTextViewText(R.id.text2, underTitle);

    final RemoteViews expandedRV = new RemoteViews(this.getPackageName(), R.layout.notification_expanded);
    expandedRV.setImageViewResource(R.id.rewind, rewindIcon);
    expandedRV.setOnClickPendingIntent(R.id.rewind, rewindPendingItent);
    expandedRV.setImageViewResource(R.id.play, playPauseIcon);
    expandedRV.setOnClickPendingIntent(R.id.play, playPausePendingIntent);
    expandedRV.setImageViewResource(R.id.fast_forward, ffIcon);
    expandedRV.setOnClickPendingIntent(R.id.fast_forward, ffPendingItent);
    expandedRV.setTextViewText(R.id.title, title);
    expandedRV.setTextViewText(R.id.text2, underTitle);
    final int expandedIconResId;
    if (isVideo) {
        expandedIconResId = R.id.icon_slim;
        expandedRV.setViewVisibility(R.id.icon_slim, View.VISIBLE);
        expandedRV.setViewVisibility(R.id.icon_square, View.GONE);
    } else {
        expandedIconResId = R.id.icon_square;
        expandedRV.setViewVisibility(R.id.icon_slim, View.GONE);
        expandedRV.setViewVisibility(R.id.icon_square, View.VISIBLE);
    }

    // Build the notification
    NotificationCompat.Builder builder = new NotificationCompat.Builder(this);
    final Notification notification = builder.setSmallIcon(smallIcon).setShowWhen(false).setOngoing(true)
            .setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
            .setCategory(NotificationCompat.CATEGORY_TRANSPORT).setContentIntent(mRemoteStartPendingIntent)
            .setContent(collapsedRV).build();

    // This is a convoluted way of loading the image and showing the
    // notification, but it's what works with Picasso and is efficient.
    // Here's what's going on:
    //
    // 1. The image is loaded asynchronously into a Target, and only after
    // it is loaded is the notification shown. Using targets is a lot more
    // efficient than letting Picasso load it directly into the
    // notification imageview, which causes a lot of flickering
    //
    // 2. The target needs to be static, because Picasso only keeps a weak
    // reference to it, so we need to keed a strong reference and reset it
    // to null when we're done. We also need to check if it is not null in
    // case a previous request hasn't finished yet.
    //
    // 3. We can only show the notification after the bitmap is loaded into
    // the target, so it is done in the callback
    //
    // 4. We specifically resize the image to the same dimensions used in
    // the remote, so that Picasso reuses it in the remote and here from the cache
    Resources resources = this.getResources();
    final int posterWidth = resources.getDimensionPixelOffset(R.dimen.now_playing_poster_width);
    final int posterHeight = isVideo ? resources.getDimensionPixelOffset(R.dimen.now_playing_poster_height)
            : posterWidth;
    if (picassoTarget == null) {
        picassoTarget = new Target() {
            @Override
            public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {
                showNotification(bitmap);
            }

            @Override
            public void onBitmapFailed(Drawable errorDrawable) {
                CharacterDrawable avatarDrawable = UIUtils.getCharacterAvatar(NotificationService.this, title);
                showNotification(Utils.drawableToBitmap(avatarDrawable, posterWidth, posterHeight));
            }

            @Override
            public void onPrepareLoad(Drawable placeHolderDrawable) {
            }

            private void showNotification(Bitmap bitmap) {
                collapsedRV.setImageViewBitmap(R.id.icon, bitmap);
                if (Utils.isJellybeanOrLater()) {
                    notification.bigContentView = expandedRV;
                    expandedRV.setImageViewBitmap(expandedIconResId, bitmap);
                }

                NotificationManager notificationManager = (NotificationManager) getSystemService(
                        Context.NOTIFICATION_SERVICE);
                notificationManager.notify(NOTIFICATION_ID, notification);
                picassoTarget = null;
            }
        };

        // Load the image
        HostManager hostManager = HostManager.getInstance(this);
        hostManager.getPicasso().load(hostManager.getHostInfo().getImageUrl(poster))
                .resize(posterWidth, posterHeight).into(picassoTarget);
    }
}

From source file:net.sourceforge.servestream.service.AppWidgetOneProvider.java

/**
 * Update all active widget instances by pushing changes 
 *//*from w ww.  j av a2  s . c o  m*/
public void performUpdate(MediaPlaybackService service, int[] appWidgetIds, String what) {
    final Resources res = service.getResources();
    final RemoteViews views = new RemoteViews(service.getPackageName(), R.layout.appwidget_one);

    if (what.equals(MediaPlaybackService.PLAYER_CLOSED)) {
        defaultAppWidget(service, appWidgetIds);
    } else {
        CharSequence trackName = service.getTrackName();
        CharSequence artistName = service.getArtistName();
        //CharSequence errorState = null;

        if (trackName == null || trackName.equals(Media.UNKNOWN_STRING)) {
            trackName = res.getText(R.string.widget_one_track_info_unavailable);
        }

        if (artistName == null || artistName.equals(Media.UNKNOWN_STRING)) {
            artistName = service.getMediaUri();
        }

        // Show media info
        views.setViewVisibility(R.id.title, View.VISIBLE);
        views.setTextViewText(R.id.title, trackName);
        views.setViewVisibility(R.id.artist, View.VISIBLE);
        views.setTextViewText(R.id.artist, artistName);

        // Set correct drawable for pause state
        final boolean playing = service.isPlaying();
        if (playing) {
            views.setImageViewResource(R.id.control_play, android.R.drawable.ic_media_pause);
        } else {
            views.setImageViewResource(R.id.control_play, android.R.drawable.ic_media_play);
        }

        BitmapFactory.Options opts = new BitmapFactory.Options();
        opts.inPreferredConfig = Bitmap.Config.ARGB_8888;
        Bitmap b = BitmapFactory.decodeStream(
                service.getResources().openRawResource(R.drawable.albumart_mp_unknown_widget), null, opts);

        views.setImageViewBitmap(R.id.coverart, b);

        if (service.getAudioId() >= 0) {
            views.setImageViewBitmap(R.id.coverart, service.getAlbumArt(true));
        }

        // Link actions buttons to intents
        linkButtons(service, views, true);
        pushUpdate(service, appWidgetIds, views);
    }
}

From source file:com.teclib.service.BootService.java

public void CustomNotification(int status) {
    if (status == 1) {
        //enrolement ok
    } else {/*from w ww .  j a  va 2s . c  o m*/
        RemoteViews remoteViews = new RemoteViews(getPackageName(), R.layout.notification_enrolment);

        String strTitle = getString(R.string.app_name);
        String strText = getString(R.string.enrolement_string);

        Intent intent = new Intent(this, MainActivity.class);
        intent.putExtra("title", strTitle);
        intent.putExtra("text", strText);

        PendingIntent pIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);

        NotificationCompat.Builder builder = new NotificationCompat.Builder(this)
                .setSmallIcon(R.mipmap.ic_white_stork).setTicker(getString(R.string.enrolement_string))
                .setOngoing(true).setContentIntent(pIntent).setContent(remoteViews);

        remoteViews.setImageViewResource(R.id.imagenotileft, R.mipmap.ic_notification_enrolment);
        remoteViews.setTextViewText(R.id.title, getString(R.string.app_name));
        remoteViews.setTextViewText(R.id.text, getString(R.string.enrolement_string));

        NotificationManager notificationmanager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
        notificationmanager.notify(1, builder.build());
    }

}

From source file:leoisasmendi.android.com.suricatepodcast.services.MediaPlayerService.java

private void updateWidgets(PlaybackStatus playbackStatus) {

    final RemoteViews view = new RemoteViews(getPackageName(), R.layout.podcast_widget_player);

    if (playbackStatus == PlaybackStatus.PLAYING) {
        view.setImageViewResource(R.id.widget_play, R.drawable.media_player_pause_24x24);
    } else if (playbackStatus == PlaybackStatus.PAUSED) {
        view.setImageViewResource(R.id.widget_play, R.drawable.media_player_play_24x24);
    }/*from  www.  j av a2 s  . c  om*/

    view.setTextViewText(R.id.widget_title, activeAudio.getTitle());
    view.setTextViewText(R.id.widget_length, activeAudio.getDuration());

    Picasso.with(getBaseContext()).setLoggingEnabled(true);

    Target target = new Target() {
        @Override
        public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {
            view.setImageViewBitmap(R.id.widget_thumbail, bitmap);
        }

        @Override
        public void onBitmapFailed(Drawable errorDrawable) {
            view.setImageViewResource(R.id.widget_thumbail, R.drawable.picture);
        }

        @Override
        public void onPrepareLoad(Drawable placeHolderDrawable) {
            view.setImageViewResource(R.id.widget_thumbail, R.drawable.picture);
        }
    };

    Picasso.with(getBaseContext()).load(activeAudio.getPoster()).into(target);

    // Push update for this widget to the home screen
    ComponentName thisWidget = new ComponentName(this, PodcastWidgetProvider.class);
    AppWidgetManager manager = AppWidgetManager.getInstance(this);
    manager.updateAppWidget(thisWidget, view);
}

From source file:com.devbrackets.android.playlistcore.helper.NotificationHelper.java

/**
 * Creates the RemoteViews used for the expanded (big) notification
 *
 * @return The resulting RemoteViews//w ww  .ja  v  a 2  s  . c  o  m
 */
@NonNull
protected RemoteViews getBigNotification(Class<? extends Service> serviceClass) {
    RemoteViews bigContent = new RemoteViews(context.getPackageName(),
            R.layout.playlistcore_big_notification_content);

    bigContent.setOnClickPendingIntent(R.id.playlistcore_big_notification_close,
            createPendingIntent(RemoteActions.ACTION_STOP, serviceClass));
    bigContent.setOnClickPendingIntent(R.id.playlistcore_big_notification_playpause,
            createPendingIntent(RemoteActions.ACTION_PLAY_PAUSE, serviceClass));
    bigContent.setOnClickPendingIntent(R.id.playlistcore_big_notification_next,
            createPendingIntent(RemoteActions.ACTION_NEXT, serviceClass));
    bigContent.setOnClickPendingIntent(R.id.playlistcore_big_notification_prev,
            createPendingIntent(RemoteActions.ACTION_PREVIOUS, serviceClass));

    bigContent.setTextViewText(R.id.playlistcore_big_notification_title, notificationInfo.getTitle());
    bigContent.setTextViewText(R.id.playlistcore_big_notification_album, notificationInfo.getAlbum());
    bigContent.setTextViewText(R.id.playlistcore_big_notification_artist, notificationInfo.getArtist());
    bigContent.setBitmap(R.id.playlistcore_big_notification_large_image, "setImageBitmap",
            notificationInfo.getLargeImage());
    bigContent.setBitmap(R.id.playlistcore_big_notification_secondary_image, "setImageBitmap",
            notificationInfo.getSecondaryImage());

    //Makes sure the play/pause, next, and previous are displayed correctly
    if (notificationInfo.getMediaState() != null) {
        updateBigNotificationMediaState(bigContent);
    }

    return bigContent;
}

From source file:com.ratusapparatus.tapsaff.TapsAff.java

protected void onPostExecute(String feed) {
    ComponentName thisWidget = new ComponentName(context, TapsAff.class);
    RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.widget_layout);

    Log.i("tapsaffonPostExecuteFeed", feed);
    JSONObject jsonObj;//from  w w  w . ja v a  2s. c  om
    try {
        jsonObj = new JSONObject(feed);
        /*for (int i = 0; i < jsonArray.length(); i++)
        {
        JSONObject jsonObject = jsonArray.getJSONObject(i);
        Log.i(TapsAff.class.getName(), jsonObject.getString("text"));
        }*/
        String oanAff = jsonObj.get("taps").toString();
        Integer itsClose = (Integer) jsonObj.get("temp_f");
        if (itsClose >= TapsAff.tapsTemp - 5 && itsClose <= TapsAff.tapsTemp)
            views.setViewVisibility(R.id.bottom, View.VISIBLE);
        else
            views.setViewVisibility(R.id.bottom, View.GONE);
        String colour = "blue";
        if (oanAff == "Aff")
            colour = "red";
        String text = "taps" + " " + "<font color='" + colour + "'>" + oanAff + "</font>";
        //textView.setText(, TextView.BufferType.SPANNABLE);
        views.setTextViewText(R.id.main, Html.fromHtml(text));
    } catch (Exception e) {
        Log.i("tapsaffonPostExecuteException", e.getLocalizedMessage());
    }
    appWidgetManager.updateAppWidget(thisWidget, views);
}