Exemplo n.º 1
0
 public static void saveAppWidgetId(Context context, int appWidgetId) {
   SharedPreferences preferences = context.getSharedPreferences("appWidget", 0);
   String str = preferences.getString("allAppWidgetId", null);
   List<Integer> ids = null;
   if (str == null) {
     ids = new LinkedList<Integer>();
   } else {
     ids = ListTools.praseIntegerList(str);
   }
   if (!ids.contains(appWidgetId)) {
     ids.add(appWidgetId);
     SharedPreferences.Editor editor = preferences.edit();
     String store = ListTools.listToString(ids);
     editor.putString("allAppWidgetId", store);
     editor.commit();
     Log.i(Constants.TAG, "[AppWidgetDao saveAppWidgetId] store:" + store);
   }
 }
Exemplo n.º 2
0
  public static void removeAppWidgetId(Context context, int appWidgetId) {
    SharedPreferences preferences = context.getSharedPreferences("appWidget", 0);
    String str = preferences.getString("allAppWidgetId", null);
    Flog.d(Constants.TAG, "ShortcutWidget removeAppWidgetId str:" + str);
    if (str == null || "".equals(str)) return;
    List<Integer> ids = ListTools.praseIntegerList(str);

    if (ids.contains(appWidgetId)) {
      ids.remove((Integer) appWidgetId);
      if (ids.size() <= 0) {
        SharedPreferences.Editor editor = preferences.edit();
        editor.putString("allAppWidgetId", null);
        editor.commit();
      } else {
        SharedPreferences.Editor editor = preferences.edit();
        String store = ListTools.listToString(ids);
        Flog.d(Constants.TAG, "ShortcutWidget removeAppWidgetId store:" + store);
        editor.putString("allAppWidgetId", store);
        editor.commit();
      }
    }
  }