private RemoteViews getRemoteViews(
     Context context, AppWidgetManager appWidgetManager, int appWidgetId) {
   if (mRemoteViews == null) {
     int minWidth = appWidgetManager.getAppWidgetInfo(appWidgetId).minResizeWidth;
     int minHeight = appWidgetManager.getAppWidgetInfo(appWidgetId).minResizeHeight;
     mRemoteViews = getRemoteViews(context, minWidth, minHeight);
   }
   return mRemoteViews;
 }
Example #2
0
 private static void updateWidgets(
     Context context, AppWidgetManager manager, int[] appWidgetIds, boolean nextAccount) {
   Log.d(
       "FinancistoWidget",
       "updateWidgets " + Arrays.toString(appWidgetIds) + " -> " + nextAccount);
   for (int id : appWidgetIds) {
     AppWidgetProviderInfo appWidgetInfo = manager.getAppWidgetInfo(id);
     if (appWidgetInfo != null) {
       int layoutId = appWidgetInfo.initialLayout;
       if (MyPreferences.isWidgetEnabled(context)) {
         long accountId = loadAccountForWidget(context, id);
         Class providerClass = getProviderClass(appWidgetInfo);
         Log.d("FinancistoWidget", "using provider " + providerClass);
         RemoteViews remoteViews =
             nextAccount || accountId == -1
                 ? buildUpdateForNextAccount(context, id, layoutId, providerClass, accountId)
                 : buildUpdateForCurrentAccount(context, id, layoutId, providerClass, accountId);
         manager.updateAppWidget(id, remoteViews);
       } else {
         manager.updateAppWidget(id, noDataUpdate(context, layoutId));
       }
     }
   }
 }