Ejemplo n.º 1
0
  @Override
  public void loadTaskListContent(boolean requery) {
    super.loadTaskListContent(requery);
    int count = taskAdapter.getCursor().getCount();

    if (tagData != null
        && sortFlags <= SortHelper.FLAG_REVERSE_SORT
        && count != tagData.getValue(TagData.TASK_COUNT)) {
      tagData.setValue(TagData.TASK_COUNT, count);
      tagDataService.save(tagData);
    }
  }
Ejemplo n.º 2
0
  /**
   * Get details for this tag
   *
   * @param tagData
   * @throws IOException
   * @throws JSONException
   */
  public void fetchTag(final TagData tagData) throws IOException, JSONException {
    JSONObject result;
    if (!checkForToken()) return;

    if (tagData.getValue(TagData.REMOTE_ID) == 0)
      result =
          actFmInvoker.invoke("tag_show", "name", tagData.getValue(TagData.NAME), "token", token);
    else
      result =
          actFmInvoker.invoke(
              "tag_show", "id", tagData.getValue(TagData.REMOTE_ID), "token", token);

    JsonHelper.tagFromJson(result, tagData);
    Flags.set(Flags.SUPPRESS_SYNC);
    tagDataService.save(tagData);
  }
Ejemplo n.º 3
0
  @Override
  protected void onNewIntent(Intent intent) {
    super.onNewIntent(intent);

    synchronized (this) {
      if (dataLoaded) return;
      dataLoaded = true;
    }

    String tag = getIntent().getStringExtra(EXTRA_TAG_NAME);
    long remoteId = getIntent().getLongExtra(EXTRA_TAG_REMOTE_ID, 0);

    if (tag == null && remoteId == 0) return;

    TodorooCursor<TagData> cursor =
        tagDataService.query(
            Query.select(TagData.PROPERTIES)
                .where(
                    Criterion.or(
                        TagData.NAME.eq(tag),
                        Criterion.and(TagData.REMOTE_ID.gt(0), TagData.REMOTE_ID.eq(remoteId)))));
    try {
      tagData = new TagData();
      if (cursor.getCount() == 0) {
        tagData.setValue(TagData.NAME, tag);
        tagData.setValue(TagData.REMOTE_ID, remoteId);
        tagDataService.save(tagData);
      } else {
        cursor.moveToFirst();
        tagData.readFromCursor(cursor);
      }
    } finally {
      cursor.close();
    }

    String fetchKey = LAST_FETCH_KEY + tagData.getId();
    long lastFetchDate = Preferences.getLong(fetchKey, 0);
    if (DateUtilities.now() > lastFetchDate + 300000L) {
      refreshData(false, false);
      Preferences.setLong(fetchKey, DateUtilities.now());
    }

    setUpUpdateList();
    setUpMemberPage();
  }
Ejemplo n.º 4
0
  private void saveSettings() {
    String oldName = tagData.getValue(TagData.NAME);
    String newName = tagName.getText().toString();

    if (!oldName.equals(newName)) {
      tagData.setValue(TagData.NAME, newName);
      TagService.getInstance().rename(oldName, newName);
      tagData.setFlag(TagData.FLAGS, TagData.FLAG_EMERGENT, false);
    }

    JSONArray members = tagMembers.toJSONArray();
    tagData.setValue(TagData.MEMBERS, members.toString());
    tagData.setValue(TagData.MEMBER_COUNT, members.length());
    Flags.set(Flags.TOAST_ON_SAVE);
    tagDataService.save(tagData);

    refreshMembersPage();
  }
Ejemplo n.º 5
0
  @SuppressWarnings("nls")
  private void readTagData(JSONArray tags) throws JSONException {
    ArrayList<Metadata> metadata = new ArrayList<Metadata>();
    for (int i = 0; i < tags.length(); i++) {
      JSONObject tagObject = tags.getJSONObject(i);
      TagData tagData = tagDataService.getTag(tagObject.getString("name"), TagData.ID);
      if (tagData == null) tagData = new TagData();
      ActFmSyncService.JsonHelper.tagFromJson(tagObject, tagData);
      tagDataService.save(tagData);

      Metadata tagMeta = new Metadata();
      tagMeta.setValue(Metadata.KEY, TagService.KEY);
      tagMeta.setValue(TagService.TAG, tagData.getValue(TagData.NAME));
      tagMeta.setValue(TagService.REMOTE_ID, tagData.getValue(TagData.REMOTE_ID));
      metadata.add(tagMeta);
    }

    metadataService.synchronizeMetadata(
        task.getId(), metadata, MetadataCriteria.withKey(TagService.KEY));
  }