PhotoAppWidgetProviderpublic class PhotoAppWidgetProvider extends android.appwidget.AppWidgetProvider Simple widget to show a user-selected picture. |
Fields Summary |
---|
static final String | TAG | static final boolean | LOGD |
Methods Summary |
---|
static android.widget.RemoteViews | buildUpdate(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 void | onDeleted(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 void | onUpdate(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();
|
|