Пример #1
0
 @Override
 public void onCreate() {
   widgetSettingsStorage = new WidgetSettingsStorage(context);
   widgetSettingsStorage.open();
   todoItemsStorage = new TodoItemsStorage(context);
   todoItemsStorage.open();
 }
Пример #2
0
  @Override
  public void onDestroy() {
    if (widgetSettingsStorage != null) {
      widgetSettingsStorage.close();
      widgetSettingsStorage = null;
    }

    if (todoItemsStorage != null) {
      todoItemsStorage.close();
      todoItemsStorage = null;
    }

    items = null;
  }
Пример #3
0
  @Override
  public void onDataSetChanged() {
    if (widgetSettingsStorage != null
        && todoItemsStorage != null
        && widgetId != AppWidgetManager.INVALID_APPWIDGET_ID) {

      WidgetSettings widgetSettings = widgetSettingsStorage.load(widgetId);
      int tagID = widgetSettings.tagID;

      items = new ArrayList<>();

      Cursor cursor = todoItemsStorage.getByTagCursor(tagID, widgetSettings.sortingMode);
      if (cursor.moveToFirst()) {
        do {
          TodoItem item = todoItemsStorage.loadTodoItemFromCursor(cursor);
          if (showItem(item, widgetSettings)) {
            items.add(item);
          }
        } while (cursor.moveToNext());
      }
      cursor.close();
    }
  }