当前位置: 首页>>代码示例>>Java>>正文


Java RemoteViews.setImageViewBitmap方法代码示例

本文整理汇总了Java中android.widget.RemoteViews.setImageViewBitmap方法的典型用法代码示例。如果您正苦于以下问题:Java RemoteViews.setImageViewBitmap方法的具体用法?Java RemoteViews.setImageViewBitmap怎么用?Java RemoteViews.setImageViewBitmap使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.widget.RemoteViews的用法示例。


在下文中一共展示了RemoteViews.setImageViewBitmap方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: updateWidget

import android.widget.RemoteViews; //导入方法依赖的package包/类
private void updateWidget() {
        //获取WidgetManager对象
        AppWidgetManager awm = AppWidgetManager.getInstance(this);
        //使用RemoteViews远程更新控件
        RemoteViews remoteViews = new RemoteViews(getPackageName(), R.layout.process_widget);
        if (mBitmap_icon != null) {
            remoteViews.setImageViewBitmap(R.id.iv_icon, mBitmap_icon);
        }
        remoteViews.setTextViewText(R.id.tv_publis_time, mPublishTime);
        remoteViews.setTextViewText(R.id.tv_temp, mCurrentTemp);
        remoteViews.setTextViewText(R.id.tv_city, mCurrentCity);


        //点击小部件的进程总数和剩余控件总数的textview处,跳转到应用的主界面处
        Intent i = new Intent("android.intent.action.HOME");
        i.addCategory("android.intent.category.DEFAULT");
        PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, i, PendingIntent.FLAG_CANCEL_CURRENT);
        remoteViews.setOnClickPendingIntent(R.id.fl_icon, pendingIntent);

//        让AppWidgetManager更新小部件的内容
        ComponentName componentName = new ComponentName(this, MyAppWidgetProvider.class);
        awm.updateAppWidget(componentName, remoteViews);
    }
 
开发者ID:BlueLeer,项目名称:XiaoTianQi,代码行数:24,代码来源:AppWidgetService.java

示例2: updateRemoteViews

import android.widget.RemoteViews; //导入方法依赖的package包/类
private void updateRemoteViews(RemoteViews remoteView) {
    Song currentSong = mPlayer.getPlayingSong();
    if (currentSong != null) {
        remoteView.setTextViewText(R.id.text_view_name, currentSong.getDisplayName());
        remoteView.setTextViewText(R.id.text_view_artist, currentSong.getArtist());
    }
    remoteView.setImageViewResource(R.id.image_view_play_toggle, isPlaying()
            ? R.drawable.ic_remote_view_pause : R.drawable.ic_remote_view_play);
    Bitmap album = AlbumUtils.parseAlbum(getPlayingSong());
    if (album == null) {
        remoteView.setImageViewResource(R.id.image_view_album, R.mipmap.ic_launcher);
    } else {
        remoteView.setImageViewBitmap(R.id.image_view_album, album);

    }
}
 
开发者ID:xxczaki,项目名称:music-player,代码行数:17,代码来源:PlaybackService.java

示例3: addWorkProfileBadge

import android.widget.RemoteViews; //导入方法依赖的package包/类
/**
 * Shows the work profile badge if it is needed.
 */
private void addWorkProfileBadge(RemoteViews view) {
    Resources resources = mContext.getResources();
    DisplayMetrics metrics = resources.getDisplayMetrics();
    int size = dpToPx(WORK_PROFILE_BADGE_SIZE_DP, metrics);
    int[] colors = new int[size * size];

    // Create an immutable bitmap, so that it can not be reused for painting a badge into it.
    Bitmap bitmap = Bitmap.createBitmap(colors, size, size, Bitmap.Config.ARGB_8888);

    Drawable inputDrawable = new BitmapDrawable(resources, bitmap);
    Drawable outputDrawable = ApiCompatibilityUtils.getUserBadgedDrawableForDensity(
            mContext, inputDrawable, null /* badgeLocation */, metrics.densityDpi);

    // The input bitmap is immutable, so the output drawable will be a different instance from
    // the input drawable if the work profile badge was applied.
    if (inputDrawable != outputDrawable && outputDrawable instanceof BitmapDrawable) {
        view.setImageViewBitmap(
                R.id.work_profile_badge, ((BitmapDrawable) outputDrawable).getBitmap());
        view.setViewVisibility(R.id.work_profile_badge, View.VISIBLE);
    }
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:25,代码来源:CustomNotificationBuilder.java

示例4: fixIconImage

import android.widget.RemoteViews; //导入方法依赖的package包/类
void fixIconImage(Resources resources, RemoteViews remoteViews, boolean hasIconBitmap, Notification notification) {
    if (remoteViews == null || notification.icon == 0) return;
    if (!mNotificationCompat.isSystemLayout(remoteViews)) {
        return;
    }
    try {
        //noinspection deprecation
        int id = R_Hide.id.icon.get();
        //only fake small icon
        if (!hasIconBitmap && notification.largeIcon == null) {
            Drawable drawable = resources.getDrawable(notification.icon);
            drawable.setLevel(notification.iconLevel);
            Bitmap bitmap = drawableToBitMap(drawable);
            remoteViews.setImageViewBitmap(id, bitmap);
            //emui
            if(OSUtils.getInstance().isEmui()) {
                if (notification.largeIcon == null) {
                    notification.largeIcon = bitmap;
                }
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
开发者ID:coding-dream,项目名称:TPlayer,代码行数:26,代码来源:NotificationFixer.java

示例5: fixIconImage

import android.widget.RemoteViews; //导入方法依赖的package包/类
void fixIconImage(Resources resources, RemoteViews remoteViews, boolean hasIconBitmap, Notification notification) {
    if (remoteViews == null) return;
    if (!mNotificationCompat.isSystemLayout(remoteViews)) {
        return;
    }
    try {
        //noinspection deprecation
        int id = R_Hide.id.icon.get();
        //only fake small icon
        if (!hasIconBitmap && notification.largeIcon == null) {
            Drawable drawable = resources.getDrawable(notification.icon);
            drawable.setLevel(notification.iconLevel);
            Bitmap bitmap = drawableToBitMap(drawable);
            remoteViews.setImageViewBitmap(id, bitmap);
        }
        if (Build.VERSION.SDK_INT >= 21) {
            remoteViews.setInt(id, "setBackgroundColor", Color.TRANSPARENT);
        }
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
            remoteViews.setViewPadding(id, 0, 0, 0, 0);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
开发者ID:7763sea,项目名称:VirtualHook,代码行数:26,代码来源:NotificationFixer.java

示例6: getViewAt

import android.widget.RemoteViews; //导入方法依赖的package包/类
public RemoteViews getViewAt(int position) {

        File file = new File(Environment.getExternalStoragePublicDirectory("/"+mContext.getResources().getString(R.string.app_name)), mWidgetItems.get(position).getId() +mContext.getResources().getString(R.string.jpg) );

        BitmapFactory.Options options = new BitmapFactory.Options();
        options.inPreferredConfig = Bitmap.Config.ARGB_8888;
        Bitmap bitmap = BitmapFactory.decodeFile(file.getPath(), options);
        RemoteViews rv = new RemoteViews(mContext.getPackageName(), R.layout.widget_item);
        rv.setImageViewBitmap(R.id.widget_item,Bitmap.createScaledBitmap(bitmap, 450,300, false));
        Bundle extras = new Bundle();
        extras.putInt(StackWidgetProvider.EXTRA_ITEM, position);
        Intent fillInIntent = new Intent();
        fillInIntent.putExtras(extras);
        rv.setOnClickFillInIntent(R.id.widget_item, fillInIntent);


        try {
            System.out.println(mContext.getResources().getString(R.string.Loading_view) + position);
            Thread.sleep(500);
        } catch (InterruptedException e) {
            MyApplication.getInstance().trackException(e);

            e.printStackTrace();
        }


        return rv;
    }
 
开发者ID:MuditSrivastava,项目名称:Canvas-Vision,代码行数:29,代码来源:StackWidgetService.java

示例7: defaultAppWidget

import android.widget.RemoteViews; //导入方法依赖的package包/类
/**
 * Initialize given widgets to default state, where we launch Music on
 * default click and hide actions if service not running.
 */
private void defaultAppWidget(final Context context, final int[] appWidgetIds) {
    final RemoteViews appWidgetView = new RemoteViews(context.getPackageName(), R.layout.app_widget_big);

    appWidgetView.setViewVisibility(R.id.media_titles, View.INVISIBLE);
    appWidgetView.setViewVisibility(R.id.image, View.INVISIBLE);
    appWidgetView.setImageViewBitmap(R.id.button_next, createBitmap(Util.getTintedVectorDrawable(context, R.drawable.ic_skip_next_white_24dp, MaterialValueHelper.getPrimaryTextColor(context, false)), 1f));
    appWidgetView.setImageViewBitmap(R.id.button_prev, createBitmap(Util.getTintedVectorDrawable(context, R.drawable.ic_skip_previous_white_24dp, MaterialValueHelper.getPrimaryTextColor(context, false)), 1f));
    appWidgetView.setImageViewBitmap(R.id.button_toggle_play_pause, createBitmap(Util.getTintedVectorDrawable(context, R.drawable.ic_play_arrow_white_24dp, MaterialValueHelper.getPrimaryTextColor(context, false)), 1f));

    linkButtons(context, appWidgetView);
    pushUpdate(context, appWidgetIds, appWidgetView);
}
 
开发者ID:aliumujib,项目名称:Orin,代码行数:17,代码来源:AppWidgetBig.java

示例8: defaultAppWidget

import android.widget.RemoteViews; //导入方法依赖的package包/类
/**
 * Initialize given widgets to default state, where we launch Music on
 * default click and hide actions if service not running.
 */
private void defaultAppWidget(final Context context, final int[] appWidgetIds) {
    final RemoteViews appWidgetView = new RemoteViews(context.getPackageName(), R.layout.app_widget_classic);

    appWidgetView.setViewVisibility(R.id.media_titles, View.INVISIBLE);
    appWidgetView.setViewVisibility(R.id.image, View.INVISIBLE);
    appWidgetView.setImageViewBitmap(R.id.button_next, createBitmap(Util.getTintedVectorDrawable(context, R.drawable.ic_skip_next_white_24dp, MaterialValueHelper.getSecondaryTextColor(context, false)), 1f));
    appWidgetView.setImageViewBitmap(R.id.button_prev, createBitmap(Util.getTintedVectorDrawable(context, R.drawable.ic_skip_previous_white_24dp, MaterialValueHelper.getSecondaryTextColor(context, false)), 1f));
    appWidgetView.setImageViewBitmap(R.id.button_toggle_play_pause, createBitmap(Util.getTintedVectorDrawable(context, R.drawable.ic_play_arrow_white_24dp, MaterialValueHelper.getSecondaryTextColor(context, false)), 1f));

    linkButtons(context, appWidgetView);
    pushUpdate(context, appWidgetIds, appWidgetView);
}
 
开发者ID:aliumujib,项目名称:Orin,代码行数:17,代码来源:AppWidgetClassic.java

示例9: createViews

import android.widget.RemoteViews; //导入方法依赖的package包/类
public RemoteViews createViews(Context context, Context pluginContext, RemoteViews contentView, boolean isBig) {
	if (contentView == null) {
		return null;
	}
	final boolean systemId = !NotificationUtils.isSystemLayout(contentView);
	final PendIntentCompat pendIntentCompat = new PendIntentCompat(contentView);
	// 根据点击时间选择布局(优化)
	final int layoutId;
	if (pendIntentCompat.findPendIntents() <= 0) {
		// 如果就一个点击事件,没必要用复杂view
		layoutId = R.layout.custom_notification_lite;
	} else {
		layoutId = R.layout.custom_notification;
	}
	// 代理view创建
	RemoteViews remoteViews = new RemoteViews(context.getPackageName(), layoutId);
	// 目标显示的内容绘制成bitmap
	final Bitmap bmp = RemoteViewsUtils.getInstance().createBitmap(pluginContext, contentView, isBig, systemId);
	if (bmp == null) {
		VLog.e(TAG, "bmp is null,contentView=" + contentView);
		// 出错也显示空白的,要不改为系统布局?
		// return null;
	}
	remoteViews.setImageViewBitmap(R.id.im_main, bmp);
	// 点击事件
	if (layoutId == R.layout.custom_notification) {
		// 根据旧view的点击事件,设置区域点击事件
		pendIntentCompat.setPendIntent(remoteViews,
				RemoteViewsUtils.getInstance().createView(context, remoteViews, isBig, systemId),
				RemoteViewsUtils.getInstance().createView(pluginContext, contentView, isBig, systemId));
	}
	return remoteViews;
}
 
开发者ID:codehz,项目名称:container,代码行数:34,代码来源:RemoteViewsUtils.java

示例10: defaultAppWidget

import android.widget.RemoteViews; //导入方法依赖的package包/类
/**
 * Initialize given widgets to default state, where we launch Music on
 * default click and hide actions if service not running.
 */
protected void defaultAppWidget(final Context context, final int[] appWidgetIds) {
    final RemoteViews appWidgetView = new RemoteViews(context.getPackageName(), R.layout.app_widget_card);

    appWidgetView.setViewVisibility(R.id.media_titles, View.INVISIBLE);
    appWidgetView.setViewVisibility(R.id.image, View.INVISIBLE);
    appWidgetView.setImageViewBitmap(R.id.button_next, createBitmap(Util.getTintedVectorDrawable(context, R.drawable.ic_skip_next_white_24dp, MaterialValueHelper.getSecondaryTextColor(context, true)), 1f));
    appWidgetView.setImageViewBitmap(R.id.button_prev, createBitmap(Util.getTintedVectorDrawable(context, R.drawable.ic_skip_previous_white_24dp, MaterialValueHelper.getSecondaryTextColor(context, true)), 1f));
    appWidgetView.setImageViewBitmap(R.id.button_toggle_play_pause, createBitmap(Util.getTintedVectorDrawable(context, R.drawable.ic_play_arrow_white_24dp, MaterialValueHelper.getSecondaryTextColor(context, true)), 1f));

    linkButtons(context, appWidgetView);
    pushUpdate(context, appWidgetIds, appWidgetView);
}
 
开发者ID:h4h13,项目名称:RetroMusicPlayer,代码行数:17,代码来源:AppWidgetCard.java

示例11: getViewAt

import android.widget.RemoteViews; //导入方法依赖的package包/类
@Override
public RemoteViews getViewAt(int position) {
    RemoteViews remoteViews = new RemoteViews(mContext.getPackageName(), R.layout.queue_widget_listview_layout);
    if (position <= getCount()) {

        String songTitle = songs.get(position)._title;

        ImageSize imageSize = new ImageSize(75, 75);

        long songDurationInMillis = 0;
        try {
            songDurationInMillis = songs.get(position)._duration;
        } catch (Exception e) {
        }

        remoteViews.setTextViewText(R.id.listViewSubText, songTitle);
        remoteViews.setTextViewText(R.id.listViewRightSubText, MusicUtils.convertMillisToMinsSecs(songDurationInMillis));


        Bitmap bitmap = ImageLoader.getInstance().loadImageSync(String.valueOf(MusicUtils.getAlbumArtUri(mApp.getService().getSongList().get(position)._albumId)), imageSize);
        if (bitmap != null) {
            remoteViews.setImageViewBitmap(R.id.listViewLeftIcon, bitmap);
        } else {
            remoteViews.setImageViewResource(R.id.listViewLeftIcon, R.mipmap.ic_launcher);
        }

    }


  /* This intent latches itself onto the pendingIntentTemplate from
 * LargeWidgetProvider.java and adds the extra "INDEX" argument to it. */
    Intent fillInIntent = new Intent();
    fillInIntent.putExtra("INDEX", position);
    remoteViews.setOnClickFillInIntent(R.id.listViewParent, fillInIntent);

    return remoteViews;
}
 
开发者ID:reyanshmishra,项目名称:Rey-MusicPlayer,代码行数:38,代码来源:QueueWidgetService.java

示例12: createBigRemoteViews

import android.widget.RemoteViews; //导入方法依赖的package包/类
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;
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:11,代码来源:LetvPushService.java

示例13: setCommonView

import android.widget.RemoteViews; //导入方法依赖的package包/类
private void setCommonView(RemoteViews view) {

        final String name = currentSong.getTitle();
        final String arts = currentSong.getArtist();
        final Bitmap cover = createCover(currentSong.getAlbum_path());

        view.setImageViewBitmap(R.id.play_notify_cover, cover);

        view.setTextViewText(R.id.play_notify_name, name);
        view.setTextViewText(R.id.play_notify_arts, arts + " - " + name);

        view.setImageViewResource(R.id.play_notify_play,
                play ? R.drawable.ic_pause
                        : R.drawable.ic_play_arrow);

    }
 
开发者ID:DuanJiaNing,项目名称:Musicoco,代码行数:17,代码来源:PlayNotifyManager.java

示例14: performUpdate

import android.widget.RemoteViews; //导入方法依赖的package包/类
/**
 * Update all active widget instances by pushing changes
 */
public void performUpdate(final MusicService service, final int[] appWidgetIds) {
    final RemoteViews appWidgetView = new RemoteViews(service.getPackageName(), R.layout.app_widget_small);

    final boolean isPlaying = service.isPlaying();
    final Song song = service.getCurrentSong();

    // Set the titles and artwork
    if (TextUtils.isEmpty(song.title) && TextUtils.isEmpty(song.artistName)) {
        appWidgetView.setViewVisibility(R.id.media_titles, View.INVISIBLE);
    } else {
        if (TextUtils.isEmpty(song.title) || TextUtils.isEmpty(song.artistName)) {
            appWidgetView.setTextViewText(R.id.text_separator, "");
        } else {
            appWidgetView.setTextViewText(R.id.text_separator, "•");
        }

        appWidgetView.setViewVisibility(R.id.media_titles, View.VISIBLE);
        appWidgetView.setTextViewText(R.id.title, song.title);
        appWidgetView.setTextViewText(R.id.text, song.artistName);
    }

    // Set correct drawable for pause state
    int playPauseRes = isPlaying ? R.drawable.ic_pause_white_24dp : R.drawable.ic_play_arrow_white_24dp;
    appWidgetView.setImageViewBitmap(R.id.button_toggle_play_pause, createBitmap(Util.getTintedVectorDrawable(service, playPauseRes, MaterialValueHelper.getSecondaryTextColor(service, false)), 1f));

    // Set prev/next button drawables
    appWidgetView.setImageViewBitmap(R.id.button_next, createBitmap(Util.getTintedVectorDrawable(service, R.drawable.ic_skip_next_white_24dp, MaterialValueHelper.getSecondaryTextColor(service, false)), 1f));
    appWidgetView.setImageViewBitmap(R.id.button_prev, createBitmap(Util.getTintedVectorDrawable(service, R.drawable.ic_skip_previous_white_24dp, MaterialValueHelper.getSecondaryTextColor(service, false)), 1f));

    // Link actions buttons to intents
    linkButtons(service, appWidgetView);

    // Load the album cover async and push the update on completion
    final Context appContext = service.getApplicationContext();
    final int widgetImageSize = service.getResources().getDimensionPixelSize(R.dimen.app_widget_small_image_size);
    service.runOnUiThread(new Runnable() {
        @Override
        public void run() {
            if (target != null) {
                Glide.clear(target);
            }
            target = SongGlideRequest.Builder.from(Glide.with(appContext), song)
                    .checkIgnoreMediaStore(appContext)
                    .asBitmap().build()
                    .into(new SimpleTarget<Bitmap>(widgetImageSize, widgetImageSize) {
                        @Override
                        public void onResourceReady(Bitmap resource, GlideAnimation<? super Bitmap> glideAnimation) {
                            update(resource);
                        }

                        @Override
                        public void onLoadFailed(Exception e, Drawable errorDrawable) {
                            super.onLoadFailed(e, errorDrawable);
                            update(null);
                        }

                        private void update(@Nullable Bitmap bitmap) {
                            appWidgetView.setViewVisibility(R.id.image, View.VISIBLE);
                            if (bitmap == null) {
                                appWidgetView.setImageViewResource(R.id.image, R.drawable.default_album_art);
                            } else {
                                appWidgetView.setImageViewBitmap(R.id.image, bitmap);
                            }
                            pushUpdate(appContext, appWidgetIds, appWidgetView);
                        }
                    });
        }
    });
}
 
开发者ID:aliumujib,项目名称:Orin,代码行数:73,代码来源:AppWidgetSmall.java

示例15: onUpdate

import android.widget.RemoteViews; //导入方法依赖的package包/类
@Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
    for (int widgetId : appWidgetIds) {
        RemoteViews remoteViews = new RemoteViews(context.getPackageName(),
                R.layout.extensive_widget);

        Intent intent = new Intent(context, AlarmReceiver.class);
        PendingIntent pendingIntent = PendingIntent.getBroadcast(context,
                0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
        remoteViews.setOnClickPendingIntent(R.id.widgetButtonRefresh, pendingIntent);

        Intent intent2 = new Intent(context, MainActivity.class);
        PendingIntent pendingIntent2 = PendingIntent.getActivity(context, 0, intent2, 0);
        remoteViews.setOnClickPendingIntent(R.id.widgetRoot, pendingIntent2);

        SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
        Weather widgetWeather = new Weather();
        if(!sp.getString("lastToday", "").equals("")) {
            widgetWeather = parseWidgetJson(sp.getString("lastToday", ""), context);
        }
        else {
            try {
                pendingIntent2.send();
            } catch (PendingIntent.CanceledException e) {
                e.printStackTrace();
            }
            return;
        }

        DateFormat timeFormat = android.text.format.DateFormat.getTimeFormat(context);

        remoteViews.setTextViewText(R.id.widgetCity, widgetWeather.getCity() + ", " + widgetWeather.getCountry());
        remoteViews.setTextViewText(R.id.widgetTemperature, widgetWeather.getTemperature());
        remoteViews.setTextViewText(R.id.widgetDescription, widgetWeather.getDescription());
        remoteViews.setTextViewText(R.id.widgetWind, widgetWeather.getWind());
        remoteViews.setTextViewText(R.id.widgetPressure, widgetWeather.getPressure());
        remoteViews.setTextViewText(R.id.widgetHumidity, context.getString(R.string.humidity) + ": " + widgetWeather.getHumidity() + " %");
        remoteViews.setTextViewText(R.id.widgetSunrise, context.getString(R.string.sunrise) + ": " + timeFormat.format(widgetWeather.getSunrise())); //
        remoteViews.setTextViewText(R.id.widgetSunset, context.getString(R.string.sunset) + ": " + timeFormat.format(widgetWeather.getSunset()));
        remoteViews.setTextViewText(R.id.widgetLastUpdate, widgetWeather.getLastUpdated());
        remoteViews.setImageViewBitmap(R.id.widgetIcon, getWeatherIcon(widgetWeather.getIcon(), context));

        appWidgetManager.updateAppWidget(widgetId, remoteViews);
    }
}
 
开发者ID:hichemcesar24,项目名称:Weather-Android,代码行数:46,代码来源:ExtensiveWidgetProvider.java


注:本文中的android.widget.RemoteViews.setImageViewBitmap方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。