Esempio n. 1
0
 @Override
 public void onClick(View v) {
   switch (v.getId()) {
     case R.id.detail_del_btn:
       bookInfo.deleteInBackground(
           new DeleteCallback() {
             @Override
             public void done(AVException e) {
               if (e == null) {
                 showToast("删除成功");
                 setResult(0);
                 finish();
               } else {
                 LogUtil.d("del: " + e.getMessage());
                 showToast("删除失败,请稍后重试");
               }
             }
           });
       break;
     case R.id.detail_save_btn:
       saveBookInfo();
       break;
     case R.id.back_img:
       finish();
       break;
   }
 }
Esempio n. 2
0
 private void initData() {
   Intent intent = getIntent();
   Bundle b = intent.getBundleExtra("bundle");
   bookInfo = b.getParcelable("bookinfo");
   loginUser = StatusService.getInstance().getUser();
   if (loginUser.getUsername().equals(bookInfo.getOwner())) {
     isOwner = true;
   } else {
     isOwner = false;
   }
   mContext = this;
 }
Esempio n. 3
0
  private void initView() {
    tvName = (EditText) findViewById(R.id.detail_bookname);
    tvAuthor = (EditText) findViewById(R.id.detail_bookauthor);
    tvPublisher = (EditText) findViewById(R.id.detail_bookpublisher);
    tvSummary = (EditText) findViewById(R.id.detail_booksummary);
    tvPhone = (TextView) findViewById(R.id.detail_owner_phone);
    statusChk = (CheckBox) findViewById(R.id.detail_bookstatuscheckbox);
    btnDel = (Button) findViewById(R.id.detail_del_btn);
    btnSave = (Button) findViewById(R.id.detail_save_btn);

    tvName.setText(bookInfo.getName());
    tvAuthor.setText(bookInfo.getAuthor());
    tvSummary.setText(bookInfo.getSummary());
    tvPhone.setText(bookInfo.getPhone());
    tvPublisher.setText(bookInfo.getPublisher());
    statusChk.setChecked(bookInfo.getStatus());

    findViewById(R.id.back_img).setOnClickListener(this);
  }
Esempio n. 4
0
  private void saveBookInfo() {
    bookInfo.setName(tvName.getText().toString());
    bookInfo.setAuthor(tvAuthor.getText().toString());
    bookInfo.setOwner(loginUser.getUsername());
    bookInfo.setPublisher(tvPublisher.getText().toString());
    bookInfo.setSummary(tvSummary.getText().toString());
    bookInfo.setStatus(statusChk.isChecked());

    bookInfo.saveInBackground(
        new SaveCallback() {
          @Override
          public void done(AVException e) {
            if (e == null) {
              LogUtil.d("save compelte");
              showToast("保存成功");
              finish();
            } else {
              LogUtil.d("error " + e.getCode() + "in " + e.getCause());
              showToast("保存出错,请稍后重试");
            }
          }
        });
  }