FileDocCategorySizeDatePackage
PhotoAppWidgetProvider.javaAPI DocAndroid 1.5 API8321Wed May 06 22:42:42 BST 2009com.android.camera

PhotoAppWidgetProvider

public class PhotoAppWidgetProvider extends android.appwidget.AppWidgetProvider
Simple widget to show a user-selected picture.

Fields Summary
static final String
TAG
static final boolean
LOGD
Constructors Summary
Methods Summary
static android.widget.RemoteViewsbuildUpdate(android.content.Context context, int appWidgetId, com.android.camera.PhotoAppWidgetProvider$PhotoDatabaseHelper helper)
Load photo for given widget and build {@link RemoteViews} for it.

        RemoteViews views = null;
        Bitmap bitmap = helper.getPhoto(appWidgetId);
        if (bitmap != null) {
            views = new RemoteViews(context.getPackageName(), R.layout.photo_frame);
            views.setImageViewBitmap(R.id.photo, bitmap);
        }
        return views;
    
public voidonDeleted(android.content.Context context, int[] appWidgetIds)

        // Clean deleted photos out of our database
        PhotoDatabaseHelper helper = new PhotoDatabaseHelper(context);
        for (int appWidgetId : appWidgetIds) {
            helper.deletePhoto(appWidgetId);
        }
        helper.close();
    
public voidonUpdate(android.content.Context context, android.appwidget.AppWidgetManager appWidgetManager, int[] appWidgetIds)

    
    
            
        // Update each requested appWidgetId with its unique photo
        PhotoDatabaseHelper helper = new PhotoDatabaseHelper(context);
        for (int appWidgetId : appWidgetIds) {
            int[] specificAppWidget = new int[] { appWidgetId };
            RemoteViews views = buildUpdate(context, appWidgetId, helper);
            if (LOGD) Log.d(TAG, "sending out views="+views+" for id="+appWidgetId);
            appWidgetManager.updateAppWidget(specificAppWidget, views);
        }
        helper.close();