@Override public void handleMessage(Message msg) { super.handleMessage(msg); switch (msg.what) { case StringUtils.START_GET_BILL_COMMENT_SUCCESSFULLY: // App.dismissDialog(); commentList = BillCommentUtils.getBillCommentList(StringUtils.FRAGMENT_BILL_COMMENT); commentAdapter.refresh(commentList); srlComment.setRefreshing(false); isRefreshing = false; break; case StringUtils.START_GET_BILL_COMMENT_FAILED: Snackbar.make(rvComment, R.string.please_check_your_network, Snackbar.LENGTH_SHORT) .show(); srlComment.setRefreshing(false); isRefreshing = false; break; case StringUtils.START_POST_BILL_COMMENT_SUCCESSFULLY: BillCommentUtils.clearList(StringUtils.FRAGMENT_BILL_COMMENT); BillCommentUtils.startGetBillCommentTransaction( StringUtils.FRAGMENT_BILL_COMMENT, handler, bill.getObjectId()); App.dismissDialog(); break; case StringUtils.START_POST_BILL_COMMENT_FAILED: App.dismissDialog(); Snackbar.make(rvComment, R.string.please_check_your_network, Snackbar.LENGTH_SHORT) .show(); break; } }
@Override public void onRefresh() { srlComment.setRefreshing(true); BillCommentUtils.clearList(StringUtils.FRAGMENT_BILL_COMMENT); BillCommentUtils.startGetBillCommentTransaction( StringUtils.FRAGMENT_BILL_COMMENT, handler, bill.getObjectId()); }
/** 初始化根布局 */ private void initView() { srlComment = (SwipeRefreshLayout) rootView.findViewById(R.id.comment_srl_comment); rvComment = (RecyclerView) rootView.findViewById(R.id.comment_rv_comment); commentAdapter = new CommentAdapter(getActivity(), commentList); rvComment.setAdapter(commentAdapter); rvComment.setLayoutManager(new LinearLayoutManager(getActivity())); rvComment.setItemAnimator(new DefaultItemAnimator()); commentAutoTvComment = (AutoCompleteTextView) rootView.findViewById(R.id.comment_autotv_comment); commentBtrCommiteComment = (ButtonRectangle) rootView.findViewById(R.id.comment_btr_commitecomment); srlComment.setOnRefreshListener(this); srlComment.setRefreshing(true); isRefreshing = true; BillCommentUtils.clearList(StringUtils.FRAGMENT_BILL_COMMENT); BillCommentUtils.startGetBillCommentTransaction( StringUtils.FRAGMENT_BILL_COMMENT, handler, bill.getObjectId()); rvComment.setOnTouchListener( new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { if (isRefreshing) { return true; } else { return false; } } }); }
/** 尝试发表 */ private void attempCommitComment() throws AVException { String comment = commentAutoTvComment.getText().toString(); BillComment billComment = new BillComment(); billComment.setContent(commentAutoTvComment.getText().toString()); billComment.setPublisher(User.getInstance().getUserName()); billComment.setWhichBill(bill.getObjectId()); billComment.setCreatAt(TimeUtils.getCurrentTimeMillis()); if (!comment.equals("")) { BillCommentUtils.startPostBillCommentTransaction( StringUtils.FRAGMENT_BILL_COMMENT, handler, billComment, bill.getObjectId()); App.showDialog(getActivity()); commentAutoTvComment.setText(""); } }