private void attemptToSelectComment() { FragmentManager fm = getSupportFragmentManager(); CommentFragment f = (CommentFragment) fm.findFragmentById(R.id.commentDetail); if (f != null && f.isInLayout()) { commentList.shouldSelectAfterLoad = true; } }
public CommentFragmentController(CommentFragment fragment, View view) { super(fragment, view); liveChannelList = realm .where(LiveChannelComment.class) .equalTo(LiveChannelComment.FIELD_LIVE_CHANNEL_ID, fragment.id) .findAll(); liveChannelList.sort(LiveChannelComment.FIELD_DATE, false); adapter = new CommentLiveChannelAdapter(context, liveChannelList); fragment.setupCommentList(adapter); fragment.updateList(adapter); getComments(); }
@Override public void onCommentSelected(Comment comment) { FragmentManager fm = getSupportFragmentManager(); CommentFragment f = (CommentFragment) fm.findFragmentById(R.id.commentDetail); if (comment != null) { if (f == null || !f.isInLayout()) { WordPress.currentComment = comment; FragmentTransaction ft = fm.beginTransaction(); ft.hide(commentList); f = new CommentFragment(); ft.add(R.id.commentDetailFragmentContainer, f); ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE); ft.addToBackStack(null); ft.commitAllowingStateLoss(); mMenuDrawer.setDrawerIndicatorEnabled(false); } else { f.loadComment(comment); } } }
@Override public void onCommentStatusChanged(final String status) { if (WordPress.currentComment != null) { final int commentID = WordPress.currentComment.commentID; if (status.equals("approve") || status.equals("hold") || status.equals("spam")) { showDialog(ID_DIALOG_MODERATING); new Thread() { public void run() { Looper.prepare(); changeCommentStatus(status, commentID); } }.start(); } else if (status.equals("delete")) { Thread action3 = new Thread() { public void run() { AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(CommentsActivity.this); dialogBuilder.setTitle(getResources().getText(R.string.confirm_delete)); dialogBuilder.setMessage(getResources().getText(R.string.confirm_delete_data)); dialogBuilder.setPositiveButton( getString(R.string.yes), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { showDialog(ID_DIALOG_DELETING); // pop out of the detail view if on a smaller screen FragmentManager fm = getSupportFragmentManager(); CommentFragment f = (CommentFragment) fm.findFragmentById(R.id.commentDetail); if (f == null) { fm.popBackStack(); } new Thread() { public void run() { deleteComment(commentID); } }.start(); } }); dialogBuilder.setNegativeButton( getString(R.string.no), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { // Don't delete Comment } }); dialogBuilder.setCancelable(true); if (!isFinishing()) { dialogBuilder.create().show(); } } }; runOnUiThread(action3); } else if (status.equals("reply")) { Intent i = new Intent(CommentsActivity.this, AddCommentActivity.class); i.putExtra("commentID", commentID); i.putExtra("postID", WordPress.currentComment.postID); startActivityForResult(i, 0); } else if (status.equals("clear")) { FragmentManager fm = getSupportFragmentManager(); CommentFragment f = (CommentFragment) fm.findFragmentById(R.id.commentDetail); if (f != null) { f.clearContent(); } } } }