Пример #1
0
    private Filter getFilter(int widgetId) {
      // base our filter off the inbox filter, replace stuff if we have it
      Filter filter = CoreFilterExposer.buildInboxFilter(getResources());
      String sql = Preferences.getStringValue(WidgetConfigActivity.PREF_SQL + widgetId);
      if (sql != null) filter.sqlQuery = sql;
      String title = Preferences.getStringValue(WidgetConfigActivity.PREF_TITLE + widgetId);
      if (title != null) filter.title = title;
      String contentValues =
          Preferences.getStringValue(WidgetConfigActivity.PREF_VALUES + widgetId);
      if (contentValues != null)
        filter.valuesForNewTasks =
            AndroidUtilities.contentValuesFromSerializedString(contentValues);

      return filter;
    }
Пример #2
0
  /**
   * Loads action item from the given intent
   *
   * @param intent
   */
  @SuppressWarnings("nls")
  protected void loadItem(Intent intent) {
    if (model != null) {
      // came from bundle
      isNewTask = (model.getValue(Task.TITLE).length() == 0);
      return;
    }

    long idParam = intent.getLongExtra(TOKEN_ID, -1L);

    database.openForReading();
    if (idParam > -1L) {
      model = taskService.fetchById(idParam, Task.PROPERTIES);
    }

    // not found by id or was never passed an id
    if (model == null) {
      String valuesAsString = intent.getStringExtra(TOKEN_VALUES);
      ContentValues values = null;
      try {
        if (valuesAsString != null)
          values = AndroidUtilities.contentValuesFromSerializedString(valuesAsString);
      } catch (Exception e) {
        // oops, can't serialize
      }
      model = TaskListActivity.createWithValues(values, null, taskService, metadataService);
    }

    if (model.getValue(Task.TITLE).length() == 0) {
      StatisticsService.reportEvent("create-task");
      isNewTask = true;

      // set deletion date until task gets a title
      model.setValue(Task.DELETION_DATE, DateUtilities.now());
    } else {
      StatisticsService.reportEvent("edit-task");
    }

    if (model == null) {
      exceptionService.reportError("task-edit-no-task", new NullPointerException("model"));
      finish();
      return;
    }

    // clear notification
    Notifications.cancelNotifications(model.getId());
  }