Ejemplo n.º 1
0
  @Click(R.id.bt_activity_advice)
  public void sendAdvice() {
    if (mEditTextAdvice.getText().toString().equals("")) {
      CustomToast.showToast(AdviceActivity.this, "意见不能为空", 2000);
      return;
    }
    progressBar.show();
    AVObject backAdvice = new AVObject("advice");
    backAdvice.put("usernumb", Application.user.getId());
    backAdvice.put("username", Application.user.getName());
    backAdvice.put("From", Application.user.getFromData());
    backAdvice.put("To", Application.user.getToData());
    backAdvice.put("Department", Application.user.getDepartment());
    backAdvice.put("advice", mEditTextAdvice.getText().toString());
    backAdvice.saveInBackground(
        new SaveCallback() {

          @Override
          public void done(AVException e) {
            if (e == null) {
              handler.sendEmptyMessage(0x0001);
            } else {
              handler.sendEmptyMessage(0x0002);
            }
          }
        });
  }
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {

    switch (item.getItemId()) {
      case R.id.action_collect:
        showToast("收藏");
        AVUser user = AVUser.getCurrentUser();
        final AVObject collect = new AVObject("user_collect");
        collect.put("user", user);
        collect.put("event", mDream);
        collect.saveInBackground(
            new SaveCallback() {
              @Override
              public void done(AVException e) {
                if (e == null) {
                  showToast("收藏成功");
                  mDream.increment("collectNum");
                  mDream.saveInBackground();
                }
              }
            });
        break;

      case R.id.action_share:
        showToast("分享");
        break;
      case android.R.id.home:
        finish();
        break;
    }

    return super.onOptionsItemSelected(item);
  }
  @Click(R.id.id_btn_join)
  void join() {

    AVUser user = AVUser.getCurrentUser();
    final AVObject object = new AVObject("user_join");
    object.put("user", user);
    object.put("dream", mDream);
    object.saveInBackground(
        new SaveCallback() {
          @Override
          public void done(AVException e) {
            if (e == null) {
              showToast("保存成功");
              mDream.increment("joinNum");
              mDream.saveInBackground();
            }
          }
        });
  }