private static void deleteStatus(final ABaseFragment fragment, final StatusContent status) { new AlertDialogWrapper.Builder(fragment.getActivity()) .setMessage(R.string.msg_del_status_remind) .setNegativeButton(R.string.cancel, null) .setPositiveButton( R.string.confirm, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { BizFragment.getBizFragment(fragment) .statusDestory( status.getId() + "", new BizFragment.OnStatusDestoryCallback() { @SuppressWarnings({"rawtypes"}) @Override public void onStatusDestory(StatusContent status) { if (fragment instanceof ATimelineFragment) { ARefreshFragment aRefreshFragment = ((ARefreshFragment) fragment); for (Object so : aRefreshFragment.getAdapterItems()) { StatusContent s = (StatusContent) so; if (String.valueOf(s.getId()) .equals(String.valueOf(status.getId()))) { aRefreshFragment.getAdapterItems().remove(s); aRefreshFragment.notifyDataSetChanged(); break; } } } else { if (fragment.getActivity() != null && fragment instanceof TimelineCommentFragment) { Intent data = new Intent(); data.putExtra("status", status.getId()); fragment.getActivity().setResult(Activity.RESULT_OK, data); fragment.getActivity().finish(); } ViewUtils.showMessage(R.string.delete_success); } } @Override public boolean onFaild(TaskException e) { ViewUtils.showMessage(R.string.delete_faild); return true; } }); } }) .show(); }
public static void commentMenuSelected( final ABaseFragment fragment, String selectedItem, final StatusComment comment) { final String[] commentMenuArr = GlobalContext.getInstance().getResources().getStringArray(R.array.cmt_menus); try { int position = 0; for (int i = 0; i < commentMenuArr.length; i++) { if (commentMenuArr[i].equals(selectedItem)) { position = i; break; } } switch (position) { // 复制 case 0: AisenUtils.copyToClipboard(comment.getText()); ViewUtils.showMessage(R.string.msg_text_copyed); break; // 转发 case 1: BizFragment.getBizFragment(fragment).commentRepost(comment); break; // 删除 case 2: new AlertDialogWrapper.Builder(fragment.getActivity()) .setMessage(R.string.msg_del_cmt_remind) .setNegativeButton(R.string.cancel, null) .setPositiveButton( R.string.confirm, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { BizFragment.getBizFragment(fragment) .commentDestory( comment, new BizFragment.OnCommentDestoryCallback() { @SuppressWarnings("unchecked") @Override public void onCommentDestory(StatusComment commnet) { if (fragment instanceof ARefreshFragment) { @SuppressWarnings("rawtypes") ARefreshFragment aRefreshFragment = ((ARefreshFragment) fragment); for (Object so : aRefreshFragment.getAdapterItems()) { StatusComment s = (StatusComment) so; if (s.getId().equals(commnet.getId())) { aRefreshFragment.getAdapterItems().remove(s); aRefreshFragment.notifyDataSetChanged(); break; } } } } }); } }) .show(); break; // 评论 case 3: BizFragment.getBizFragment(fragment).replyComment(comment.getStatus(), comment); break; } } catch (Exception e) { e.printStackTrace(); } }