private void retweetOrQuote(AsyncTwitterWrapper twitter, ParcelableStatus status) { final Dialog dialog = getDialog(); if (dialog == null) return; final EditText editComment = ((EditText) dialog.findViewById(R.id.edit_comment)); if (editComment.length() > 0) { final Menu menu = mPopupMenu.getMenu(); final MenuItem quoteOriginalStatus = menu.findItem(R.id.quote_original_status); final MenuItem linkToQuotedStatus = menu.findItem(R.id.link_to_quoted_status); final Uri statusLink; final long inReplyToStatusId; if (!status.is_quote || !quoteOriginalStatus.isChecked()) { inReplyToStatusId = status.id; statusLink = LinkCreator.getTwitterStatusLink(status.user_screen_name, status.id); } else { inReplyToStatusId = status.quoted_id; statusLink = LinkCreator.getTwitterStatusLink(status.quoted_user_screen_name, status.quoted_id); } final String commentText = editComment.getText() + " " + statusLink; twitter.updateStatusAsync( new long[] {status.account_id}, commentText, null, null, linkToQuotedStatus.isChecked() ? inReplyToStatusId : -1, status.is_possibly_sensitive); } else if (isMyRetweet(status)) { twitter.cancelRetweetAsync(status.account_id, status.id, status.my_retweet_id); } else { twitter.retweetStatusAsync(status.account_id, status.id); } }
private void updateTextCount(DialogInterface dialog, CharSequence s, ParcelableStatus status) { if (!(dialog instanceof AlertDialog)) return; final AlertDialog alertDialog = (AlertDialog) dialog; final Button positiveButton = alertDialog.getButton(AlertDialog.BUTTON_POSITIVE); if (positiveButton == null) return; positiveButton.setText(s.length() > 0 ? R.string.comment : R.string.retweet); final String statusLink = LinkCreator.getTwitterStatusLink(status.user_screen_name, status.id).toString(); final StatusTextCountView textCountView = (StatusTextCountView) alertDialog.findViewById(R.id.comment_text_count); textCountView.setTextCount(mValidator.getTweetLength(s + " " + statusLink)); }