Java Code Examples for android.appwidget.AppWidgetProviderInfo#loadPreviewImage()

The following examples show how to use android.appwidget.AppWidgetProviderInfo#loadPreviewImage() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DashboardController.java    From Taskbar with Apache License 2.0 5 votes vote down vote up
private void addPlaceholder(int cellId) {
    FrameLayout placeholder = cells.get(cellId).findViewById(R.id.placeholder);
    SharedPreferences pref = U.getSharedPreferences(context);
    String providerName = pref.getString("dashboard_widget_" + cellId + "_provider", "null");

    if(!providerName.equals("null")) {
        ImageView imageView = placeholder.findViewById(R.id.placeholder_image);
        ComponentName componentName = ComponentName.unflattenFromString(providerName);

        List<AppWidgetProviderInfo> providerInfoList = mAppWidgetManager.getInstalledProvidersForProfile(Process.myUserHandle());
        for(AppWidgetProviderInfo info : providerInfoList) {
            if(info.provider.equals(componentName)) {
                Drawable drawable = info.loadPreviewImage(context, -1);
                if(drawable == null) drawable = info.loadIcon(context, -1);

                ColorMatrix matrix = new ColorMatrix();
                matrix.setSaturation(0);

                imageView.setImageDrawable(drawable);
                imageView.setColorFilter(new ColorMatrixColorFilter(matrix));
                break;
            }
        }
    }

    placeholder.setVisibility(View.VISIBLE);
}
 
Example 2
Source File: AppWidgetManagerCompatVL.java    From Trebuchet with GNU General Public License v3.0 4 votes vote down vote up
@Override
public Drawable loadPreview(AppWidgetProviderInfo info) {
    return info.loadPreviewImage(mContext, 0);
}
 
Example 3
Source File: AppWidgetManagerCompatVL.java    From LB-Launcher with Apache License 2.0 4 votes vote down vote up
@Override
public Drawable loadPreview(AppWidgetProviderInfo info) {
    return info.loadPreviewImage(mContext, 0);
}