Example #1
0
  /**
   * Commit feedbacks with user input
   *
   * @param category
   * @param email
   * @param content
   */
  public void tryCommit(final String category, final String email, final String content) {
    mCommitIndex = MAX_COMMIT_COUNT;
    ThreadManager.executeOnAsyncThread(
        new Runnable() {
          @Override
          public void run() {
            boolean success = false;
            try {
              ContentValues values = new ContentValues();
              values.put(KEY_CONTENT, content);
              values.put(KEY_EMAIL, email);
              values.put(KEY_CATEGORY, category);
              values.put(KEY_TIME, System.currentTimeMillis() + "");

              Uri uri =
                  AppMasterApplication.getInstance()
                      .getContentResolver()
                      .insert(Constants.FEEDBACK_URI, values);
              long id = ContentUris.parseId(uri);
              if (id > -1) {
                mCommitIndex = -1;
                success = true;
              }
            } catch (Exception e) {
            } finally {
              if (success) {
                tryCommit();
              }
            }
          }
        });
  }
Example #2
0
 /** Commit feedbacks if any in db */
 public void tryCommit() {
   if (mCommitIndex < 0) {
     mCommitIndex = 0;
     ThreadManager.executeOnAsyncThread(mCommitTask);
   }
 }