コード例 #1
0
  private String getQuery(Context context) {
    if (SubtasksHelper.isTagFilter(filter)) {
      ((FilterWithCustomIntent) filter).customTaskList =
          new ComponentName(
              context,
              TagViewFragment.class); // In case legacy widget was created with subtasks fragment
    }

    SharedPreferences publicPrefs = AstridPreferences.getPublicPrefs(context);
    int flags = publicPrefs.getInt(SortHelper.PREF_SORT_FLAGS, 0);
    flags |= SortHelper.FLAG_SHOW_RECENTLY_COMPLETED;
    int sort = publicPrefs.getInt(SortHelper.PREF_SORT_SORT, 0);
    if (sort == 0) {
      sort = SortHelper.SORT_WIDGET;
    }

    String query =
        SortHelper.adjustQueryForFlagsAndSort(filter.getSqlQuery(), flags, sort)
            .replaceAll("LIMIT \\d+", "");

    String tagName = Preferences.getStringValue(WidgetConfigActivity.PREF_TITLE + widgetId);

    return SubtasksHelper.applySubtasksToWidgetFilter(filter, query, tagName, 0);
  }
コード例 #2
0
ファイル: TaskListFragment.java プロジェクト: kflux/tasks
 protected void initializeTaskListMetadata() {
   TagData td = getActiveTagData();
   String tdId;
   if (td == null) {
     String filterId = null;
     String prefId = null;
     if (isInbox) {
       filterId = TaskListMetadata.FILTER_ID_ALL;
       prefId = SubtasksUpdater.ACTIVE_TASKS_ORDER;
     } else if (isTodayFilter) {
       filterId = TaskListMetadata.FILTER_ID_TODAY;
       prefId = SubtasksUpdater.TODAY_TASKS_ORDER;
     }
     if (!TextUtils.isEmpty(filterId)) {
       taskListMetadata = taskListMetadataDao.fetchByTagId(filterId, TaskListMetadata.PROPERTIES);
       if (taskListMetadata == null) {
         String defaultOrder = preferences.getStringValue(prefId);
         if (TextUtils.isEmpty(defaultOrder)) {
           defaultOrder = "[]"; // $NON-NLS-1$
         }
         defaultOrder = SubtasksHelper.convertTreeToRemoteIds(taskService, defaultOrder);
         taskListMetadata = new TaskListMetadata();
         taskListMetadata.setFilter(filterId);
         taskListMetadata.setTaskIDs(defaultOrder);
         taskListMetadataDao.createNew(taskListMetadata);
       }
     }
   } else {
     tdId = td.getUuid();
     taskListMetadata =
         taskListMetadataDao.fetchByTagId(td.getUuid(), TaskListMetadata.PROPERTIES);
     if (taskListMetadata == null && !RemoteModel.isUuidEmpty(tdId)) {
       taskListMetadata = new TaskListMetadata();
       taskListMetadata.setTagUUID(tdId);
       taskListMetadataDao.createNew(taskListMetadata);
     }
   }
   postLoadTaskListMetadata();
 }