Beispiel #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();
              }
            }
          }
        });
  }
Beispiel #2
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_msg_center);

    mToolbar = (CommonToolbar) findViewById(R.id.layout_title_bar);
    mToolbar.setToolbarTitle(R.string.msg_center_title);
    mToolbar.setOptionMenuVisible(false);

    mMessageLv = (ListView) findViewById(R.id.msg_center_lv);
    mMessageLv.setOnItemClickListener(this);

    mEmptyView = findViewById(R.id.msg_center_empty_ll);

    mFeedbackTv = (RippleView) findViewById(R.id.msg_center_feedback_tv);
    mFeedbackTv.setOnClickListener(this);

    mAdapter = new MsgCenterAdapter(mMessageLv, mEmptyView);
    mMessageLv.setAdapter(mAdapter);

    ThreadManager.executeOnNetworkThread(
        new Runnable() {
          @Override
          public void run() {
            MsgCenterFetchJob.checkCacheAndRequest(null);
          }
        });
    handlerIntent();
  }
Beispiel #3
0
  @Override
  public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
    final Message msg = (Message) mAdapter.getItem(position);
    if (msg == null) return;

    String descPrefix = null;
    if (msg.isCategoryFaq()) {
      descPrefix = "faq_";
    } else if (msg.isCategoryActivity()) {
      descPrefix = "act_";
    } else if (msg.isCategoryUpdate()) {
      descPrefix = "upd_";
    }
    if (descPrefix != null) {}
    MsgCenterBrowserActivity.startMsgCenterWeb(
        this, msg.title, msg.jumpUrl, msg.isCategoryUpdate());
    ThreadManager.executeOnFileThread(
        new Runnable() {
          @Override
          public void run() {
            MsgCenterTable table = new MsgCenterTable();
            table.readMessage(msg);
          }
        });
    try {
      final MsgCenterAdapter.MsgCenterHolder holder =
          (MsgCenterAdapter.MsgCenterHolder) view.getTag();
      if (holder != null) {
        ThreadManager.getUiThreadHandler()
            .postDelayed(
                new Runnable() {
                  @Override
                  public void run() {
                    holder.unread.setVisibility(View.GONE);
                    holder.title.setPadding(0, 0, 0, 0);
                  }
                },
                200);
      }
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
Beispiel #4
0
 /** Commit feedbacks if any in db */
 public void tryCommit() {
   if (mCommitIndex < 0) {
     mCommitIndex = 0;
     ThreadManager.executeOnAsyncThread(mCommitTask);
   }
 }