Java 类com.bumptech.glide.request.target.NotificationTarget 实例源码

项目:Android-Tech    文件:MainActivity.java   
private void testNotification() {
    final RemoteViews rv = new RemoteViews(this.getPackageName(), R.layout.remoteview_notification);
    rv.setImageViewResource(R.id.remoteview_notification_icon, R.mipmap.ic_launcher);

    rv.setTextViewText(R.id.remoteview_notification_headline, "Headline");
    rv.setTextViewText(R.id.remoteview_notification_short_message, "Short Message");

    // build notification
    NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this)
            .setSmallIcon(R.mipmap.ic_launcher)
            .setContentTitle("Content Title")
            .setContentText("Content Text")
            .setContent(rv)
            .setPriority(NotificationCompat.PRIORITY_MIN);

    final Notification notification = mBuilder.build();

    // set big content view for newer androids
    if (Build.VERSION.SDK_INT >= 16) {
        notification.bigContentView = rv;
    }
    NotificationManager mNotificationManager = (NotificationManager) this.getSystemService(Context.NOTIFICATION_SERVICE);
    mNotificationManager.notify(NOTIFICATION_ID, notification);

    NotificationTarget notificationTarget = new NotificationTarget(this, rv, R.id.remoteview_notification_icon, notification, NOTIFICATION_ID);

    Glide.with(this.getApplicationContext())// safer!
    .load(eatFoodyImages[3]).asBitmap().into(notificationTarget);
}
项目:aptoide-client-v8    文件:ImageLoader.java   
public NotificationTarget loadImageToNotification(NotificationTarget notificationTarget,
    String url) {
  Context context = weakContext.get();
  if (context != null) {
    return Glide.with(context.getApplicationContext())
        .load(url)
        .asBitmap()
        .into(notificationTarget);
  } else {
    Log.e(TAG, "::loadImageToNotification() Context is null");
  }
  return notificationTarget;
}
项目:aptoide-client-v8    文件:SystemNotificationShower.java   
private void loadImage(Context context, int notificationId, Notification notification, String url,
    RemoteViews expandedView, @IdRes int viewId) {
  NotificationTarget notificationTarget =
      new NotificationTarget(context, expandedView, viewId, notification, notificationId);
  ImageLoader.with(context)
      .loadImageToNotification(notificationTarget, url);
}
项目:PureMusic    文件:PlayService.java   
private void popNotification() {
//        if (musics != null && musics.size() > current) {
//            Music music = musics.get(current);
        if (hadLoadMusics) {
            final Music music = musics.get(current);
            Intent intent = MainActivity.newIntent(PlayService.this);
            PendingIntent pi = PendingIntent.getActivity(PlayService.this, 0, intent, 0);
            RemoteViews rv = new RemoteViews(getPackageName(), R.layout.notification_layout);

            rv.setImageViewResource(R.id.notification_play, mp.isPlaying() ? R.drawable.pause_icon : R.drawable.play_icon);
            rv.setTextViewText(R.id.notification_title, music.getTitle() == null ? music.getName() : music.getTitle());
            rv.setTextViewText(R.id.notification_artist, music.getArtist());

            Intent playIntent = new Intent(getPackageName() + "PLAY");
            PendingIntent playPi = PendingIntent.getBroadcast(PlayService.this, 0, playIntent, 0);
            Intent nextIntent = new Intent(getPackageName() + "NEXT");
            PendingIntent nextPi = PendingIntent.getBroadcast(PlayService.this, 0, nextIntent, 0);
            Intent previousIntent = new Intent(getPackageName() + "PREVIOUS");
            PendingIntent previousPi = PendingIntent.getBroadcast(PlayService.this, 0, previousIntent, 0);

            rv.setOnClickPendingIntent(R.id.notification_play, playPi);
            rv.setOnClickPendingIntent(R.id.notification_next, nextPi);
            rv.setOnClickPendingIntent(R.id.notification_previous, previousPi);


            Notification notification = new NotificationCompat.Builder(PlayService.this)
                    .setContentTitle(music.getTitle() == null ? music.getName() : music.getTitle())
                    .setContentText(music.getArtist())
//                .setLargeIcon((Bitmap) message.obj)
                    .setContentIntent(pi)
                    .setSmallIcon(R.drawable.ic_album)
                    .setCustomBigContentView(rv)
                    .build();

            startForeground(1, notification);

            final NotificationTarget bigTarget = new NotificationTarget(
                    this, rv, R.id.notification_cover, notification, 1
            );

            final Handler handler = new Handler();
            new Thread(new Runnable() {
                @Override
                public void run() {
                    final byte[] model = Music.getAlbumByte(music.getPath());
                    handler.post(new Runnable() {
                        @Override
                        public void run() {
                            Glide.with(PlayService.this)
                                    .load(model)
                                    .asBitmap()
                                    .error(R.drawable.ic_notification)
                                    .into(bigTarget);
                        }
                    });

                }
            }).start();


        }

    }
项目:uPods-android    文件:DefaultNotificationPanel.java   
public DefaultNotificationPanel(Context mContext, MediaItem playableMediaItem) {
    super(mContext, playableMediaItem);
    this.currentState = UniversalPlayer.State.PLAYING;
    this.nBuilder = new NotificationCompat.Builder(mContext);
    this.nBuilder.setContentTitle(playableMediaItem.getName());
    this.nBuilder.setContentInfo(playableMediaItem.getName());
    this.nBuilder.setContentText(playableMediaItem.getName());
    this.nBuilder.setSmallIcon(R.drawable.ic_pause_white);
    this.nBuilder.setAutoCancel(false);
    this.nBuilder.setOngoing(true);

    Intent intentOpen = new Intent(mContext, ActivityPlayer.class);
    PendingIntent piOpen = PendingIntent.getActivity(mContext, 0, intentOpen, 0);

    this.nBuilder.setContentIntent(piOpen);
    this.nBuilder.setOngoing(false);

    this.remoteView = new RemoteViews(mContext.getPackageName(), R.layout.player_notification);
    this.remoteView.setTextViewText(R.id.tvPlayerTitleNtBar, playableMediaItem.getName());
    this.remoteView.setTextViewText(R.id.tvPlayerSubTitleNtBar, playableMediaItem.getSubHeader());
    setListeners();

    this.nBuilder.setContent(remoteView);
    Notification notification = nBuilder.build();
    this.nManager = (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE);
    this.nManager.notify(NOTIFICATION_ID, notification);

    if (playableMediaItem.getCoverImageUrl() != null) {
        Glide.with(mContext)
                .load(playableMediaItem.getCoverImageUrl())
                .asBitmap()
                .into(new NotificationTarget(
                        mContext,
                        remoteView,
                        R.id.imgPlayerNtBar,
                        notification,
                        NOTIFICATION_ID));
    } else {
        final LetterBitmap letterBitmap = new LetterBitmap(mContext);
        Bitmap letterTile = letterBitmap.getLetterTile(playableMediaItem.getName(), playableMediaItem.getName(), COVER_IMAGE_SIZE, COVER_IMAGE_SIZE);
        remoteView.setImageViewBitmap(R.id.imgPlayerNtBar, letterTile);
        this.nManager.notify(NOTIFICATION_ID, notification);
    }
}
项目:android-tutorials-glide    文件:UsageExampleTargetsAndRemoteViews.java   
private void loadImageNotification() {
    // create RemoteViews
    final RemoteViews remoteViews = new RemoteViews(context.getPackageName(), R.layout.remoteview_notification);

    remoteViews.setImageViewResource(R.id.remoteview_notification_icon, R.mipmap.future_studio_launcher);

    remoteViews.setTextViewText(R.id.remoteview_notification_headline, "Headline");
    remoteViews.setTextViewText(R.id.remoteview_notification_short_message, "Short Message");

    remoteViews.setTextColor(R.id.remoteview_notification_headline, context.getResources().getColor( android.R.color.black));
    remoteViews.setTextColor(R.id.remoteview_notification_short_message, context.getResources().getColor(android.R.color.black));

    // build notification
    NotificationCompat.Builder mBuilder =
            new NotificationCompat.Builder(context)
                    .setSmallIcon(R.mipmap.future_studio_launcher)
                    .setContentTitle("Content Title")
                    .setContentText("Content Text")
                    .setContent(remoteViews)
                    .setPriority( NotificationCompat.PRIORITY_MIN);

    final Notification notification = mBuilder.build();

    // set big content view for newer androids
    if (android.os.Build.VERSION.SDK_INT >= 16) {
        notification.bigContentView = remoteViews;
    }

    NotificationManager mNotificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
    mNotificationManager.notify(NOTIFICATION_ID, notification);

    notificationTarget = new NotificationTarget(
            context,
            remoteViews,
            R.id.remoteview_notification_icon,
            notification,
            NOTIFICATION_ID);

    Glide
            .with( context.getApplicationContext() ) // safer!
            .load( eatFoodyImages[3] )
            .asBitmap()
            .into( notificationTarget );
}