Messaging: Further code improvements
* Remove redundant casts * getParcelable(ArrayList|Exra) without class argument is deprecated * ViewPager.setOnPageChangeListener -> addOnPageChangeListener * RecyclerView.setOnScrollListener -> addOnScrollListener * Remove unused initializations * Remove unused code Change-Id: I21beb6c90c675a4f2cfd7e3d5ebbd18b745f5911
This commit is contained in:
@@ -195,8 +195,7 @@ public class ComposeMessageView extends LinearLayout
|
||||
@Override
|
||||
protected void onFinishInflate() {
|
||||
super.onFinishInflate();
|
||||
mComposeEditText = (PlainTextEditText) findViewById(
|
||||
R.id.compose_message_text);
|
||||
mComposeEditText = findViewById(R.id.compose_message_text);
|
||||
mComposeEditText.setOnEditorActionListener(this);
|
||||
mComposeEditText.addTextChangedListener(this);
|
||||
mComposeEditText.setOnFocusChangeListener((v, hasFocus) -> {
|
||||
@@ -216,7 +215,7 @@ public class ComposeMessageView extends LinearLayout
|
||||
new LengthFilter(MmsConfig.get(ParticipantData.DEFAULT_SELF_SUB_ID)
|
||||
.getMaxTextLimit()) });
|
||||
|
||||
mSelfSendIcon = (SimIconView) findViewById(R.id.self_send_icon);
|
||||
mSelfSendIcon = findViewById(R.id.self_send_icon);
|
||||
mSelfSendIcon.setOnClickListener(v -> {
|
||||
boolean shown = mInputManager.toggleSimSelector(true /* animate */,
|
||||
getSelfSubscriptionListEntry());
|
||||
@@ -233,8 +232,7 @@ public class ComposeMessageView extends LinearLayout
|
||||
return true;
|
||||
});
|
||||
|
||||
mComposeSubjectText = (PlainTextEditText) findViewById(
|
||||
R.id.compose_subject_text);
|
||||
mComposeSubjectText = findViewById(R.id.compose_subject_text);
|
||||
// We need the listener to change the avatar to the send button when the user starts
|
||||
// typing a subject without a message.
|
||||
mComposeSubjectText.addTextChangedListener(this);
|
||||
@@ -244,7 +242,7 @@ public class ComposeMessageView extends LinearLayout
|
||||
new LengthFilter(MmsConfig.get(ParticipantData.DEFAULT_SELF_SUB_ID)
|
||||
.getMaxSubjectLength())});
|
||||
|
||||
mDeleteSubjectButton = (ImageButton) findViewById(R.id.delete_subject_button);
|
||||
mDeleteSubjectButton = findViewById(R.id.delete_subject_button);
|
||||
mDeleteSubjectButton.setOnClickListener(clickView -> {
|
||||
hideSubjectEditor();
|
||||
mComposeSubjectText.setText(null);
|
||||
@@ -253,7 +251,7 @@ public class ComposeMessageView extends LinearLayout
|
||||
|
||||
mSubjectView = findViewById(R.id.subject_view);
|
||||
|
||||
mSendButton = (ImageButton) findViewById(R.id.send_message_button);
|
||||
mSendButton = findViewById(R.id.send_message_button);
|
||||
mSendButton.setOnClickListener(clickView ->
|
||||
sendMessageInternal(true /* checkMessageSize */));
|
||||
mSendButton.setOnLongClickListener(arg0 -> {
|
||||
@@ -284,18 +282,17 @@ public class ComposeMessageView extends LinearLayout
|
||||
}
|
||||
});
|
||||
|
||||
mAttachMediaButton =
|
||||
(ImageButton) findViewById(R.id.attach_media_button);
|
||||
mAttachMediaButton = findViewById(R.id.attach_media_button);
|
||||
mAttachMediaButton.setOnClickListener(clickView -> {
|
||||
// Showing the media picker is treated as starting to compose the message.
|
||||
mInputManager.showHideMediaPicker(true /* show */, true /* animate */);
|
||||
});
|
||||
|
||||
mAttachmentPreview = (AttachmentPreview) findViewById(R.id.attachment_draft_view);
|
||||
mAttachmentPreview = findViewById(R.id.attachment_draft_view);
|
||||
mAttachmentPreview.setComposeMessageView(this);
|
||||
|
||||
mMessageBodySize = (TextView) findViewById(R.id.message_body_size);
|
||||
mMmsIndicator = (TextView) findViewById(R.id.mms_indicator);
|
||||
mMessageBodySize = findViewById(R.id.message_body_size);
|
||||
mMmsIndicator = findViewById(R.id.mms_indicator);
|
||||
}
|
||||
|
||||
private void hideAttachmentsWhenShowingSims(final boolean simPickerVisible) {
|
||||
|
||||
@@ -71,7 +71,8 @@ public class ConversationActivity extends BugleActionBarActivity
|
||||
|
||||
// Do our best to restore UI state from saved instance state.
|
||||
if (savedInstanceState != null) {
|
||||
mUiState = savedInstanceState.getParcelable(SAVED_INSTANCE_STATE_UI_STATE_KEY);
|
||||
mUiState = savedInstanceState.getParcelable(SAVED_INSTANCE_STATE_UI_STATE_KEY,
|
||||
ConversationActivityUiState.class);
|
||||
} else {
|
||||
if (intent.
|
||||
getBooleanExtra(UIIntents.UI_INTENT_EXTRA_GOTO_CONVERSATION_LIST, false)) {
|
||||
@@ -321,7 +322,7 @@ public class ConversationActivity extends BugleActionBarActivity
|
||||
conversationFragment, ConversationFragment.FRAGMENT_TAG);
|
||||
}
|
||||
final MessageData draftData = intent.getParcelableExtra(
|
||||
UIIntents.UI_INTENT_EXTRA_DRAFT_DATA);
|
||||
UIIntents.UI_INTENT_EXTRA_DRAFT_DATA, MessageData.class);
|
||||
if (!needContactPickerFragment) {
|
||||
// Once the user has committed the audience,remove the draft data from the
|
||||
// intent to prevent reuse
|
||||
|
||||
@@ -507,7 +507,7 @@ public class ConversationFragment extends Fragment implements ConversationDataLi
|
||||
public View onCreateView(final LayoutInflater inflater, final ViewGroup container,
|
||||
final Bundle savedInstanceState) {
|
||||
final View view = inflater.inflate(R.layout.conversation_fragment, container, false);
|
||||
mRecyclerView = (RecyclerView) view.findViewById(android.R.id.list);
|
||||
mRecyclerView = view.findViewById(android.R.id.list);
|
||||
final LinearLayoutManager manager = new LinearLayoutManager(getActivity());
|
||||
manager.setStackFromEnd(true);
|
||||
manager.setReverseLayout(false);
|
||||
@@ -529,16 +529,14 @@ public class ConversationFragment extends Fragment implements ConversationDataLi
|
||||
!data.getIsIncoming() &&
|
||||
timeSinceSend < MESSAGE_ANIMATION_MAX_WAIT) {
|
||||
final ConversationMessageBubbleView messageBubble =
|
||||
(ConversationMessageBubbleView) view
|
||||
.findViewById(R.id.message_content);
|
||||
view.findViewById(R.id.message_content);
|
||||
final Rect startRect = UiUtils.getMeasuredBoundsOnScreen(mComposeMessageView);
|
||||
final View composeBubbleView = mComposeMessageView.findViewById(
|
||||
R.id.compose_message_text);
|
||||
final Rect composeBubbleRect =
|
||||
UiUtils.getMeasuredBoundsOnScreen(composeBubbleView);
|
||||
final AttachmentPreview attachmentView =
|
||||
(AttachmentPreview) mComposeMessageView.findViewById(
|
||||
R.id.attachment_draft_view);
|
||||
mComposeMessageView.findViewById(R.id.attachment_draft_view);
|
||||
final Rect attachmentRect = UiUtils.getMeasuredBoundsOnScreen(attachmentView);
|
||||
if (attachmentView.getVisibility() == View.VISIBLE) {
|
||||
startRect.top = attachmentRect.top;
|
||||
@@ -594,7 +592,8 @@ public class ConversationFragment extends Fragment implements ConversationDataLi
|
||||
mRecyclerView.setAdapter(mAdapter);
|
||||
|
||||
if (savedInstanceState != null) {
|
||||
mListState = savedInstanceState.getParcelable(SAVED_INSTANCE_STATE_LIST_VIEW_STATE_KEY);
|
||||
mListState = savedInstanceState.getParcelable(SAVED_INSTANCE_STATE_LIST_VIEW_STATE_KEY,
|
||||
Parcelable.class);
|
||||
}
|
||||
|
||||
mConversationComposeDivider = view.findViewById(R.id.conversation_compose_divider);
|
||||
@@ -604,8 +603,7 @@ public class ConversationFragment extends Fragment implements ConversationDataLi
|
||||
UiUtils.isRtlMode() ? ConversationFastScroller.POSITION_LEFT_SIDE :
|
||||
ConversationFastScroller.POSITION_RIGHT_SIDE);
|
||||
|
||||
mComposeMessageView = (ComposeMessageView)
|
||||
view.findViewById(R.id.message_compose_view_container);
|
||||
mComposeMessageView = view.findViewById(R.id.message_compose_view_container);
|
||||
// Bind the compose message view to the DraftMessageData
|
||||
mComposeMessageView.bind(DataModel.get().createDraftMessageData(
|
||||
mBinding.getData().getConversationId()), this);
|
||||
@@ -1436,7 +1434,7 @@ public class ConversationFragment extends Fragment implements ConversationDataLi
|
||||
|
||||
@Override
|
||||
public SimSelectorView getSimSelectorView() {
|
||||
return (SimSelectorView) getView().findViewById(R.id.sim_selector);
|
||||
return getView().findViewById(R.id.sim_selector);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1516,8 +1514,7 @@ public class ConversationFragment extends Fragment implements ConversationDataLi
|
||||
actionBar.setCustomView(customView);
|
||||
}
|
||||
|
||||
final TextView conversationNameView =
|
||||
(TextView) customView.findViewById(R.id.conversation_title);
|
||||
final TextView conversationNameView = customView.findViewById(R.id.conversation_title);
|
||||
final String conversationName = getConversationName();
|
||||
if (!TextUtils.isEmpty(conversationName)) {
|
||||
// RTL : To format conversation title if it happens to be phone numbers.
|
||||
|
||||
@@ -54,7 +54,7 @@ public class ConversationMessageBubbleView extends LinearLayout {
|
||||
@Override
|
||||
protected void onFinishInflate() {
|
||||
super.onFinishInflate();
|
||||
mBubbleBackground = (ViewGroup) findViewById(R.id.message_text_and_info);
|
||||
mBubbleBackground = findViewById(R.id.message_text_and_info);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -124,37 +124,37 @@ public class ConversationMessageView extends FrameLayout implements View.OnClick
|
||||
@Override
|
||||
protected void onFinishInflate() {
|
||||
super.onFinishInflate();
|
||||
mContactIconView = (ContactIconView) findViewById(R.id.conversation_icon);
|
||||
mContactIconView = findViewById(R.id.conversation_icon);
|
||||
mContactIconView.setOnLongClickListener(view -> {
|
||||
ConversationMessageView.this.performLongClick();
|
||||
return true;
|
||||
});
|
||||
|
||||
mMessageAttachmentsView = (LinearLayout) findViewById(R.id.message_attachments);
|
||||
mMultiAttachmentView = (MultiAttachmentLayout) findViewById(R.id.multiple_attachments);
|
||||
mMessageAttachmentsView = findViewById(R.id.message_attachments);
|
||||
mMultiAttachmentView = findViewById(R.id.multiple_attachments);
|
||||
mMultiAttachmentView.setOnAttachmentClickListener(this);
|
||||
|
||||
mMessageImageView = (AsyncImageView) findViewById(R.id.message_image);
|
||||
mMessageImageView = findViewById(R.id.message_image);
|
||||
mMessageImageView.setOnClickListener(this);
|
||||
mMessageImageView.setOnLongClickListener(this);
|
||||
|
||||
mMessageTextView = (TextView) findViewById(R.id.message_text);
|
||||
mMessageTextView = findViewById(R.id.message_text);
|
||||
mMessageTextView.setOnClickListener(this);
|
||||
IgnoreLinkLongClickHelper.ignoreLinkLongClick(mMessageTextView, this);
|
||||
|
||||
mStatusTextView = (TextView) findViewById(R.id.message_status);
|
||||
mTitleTextView = (TextView) findViewById(R.id.message_title);
|
||||
mMmsInfoTextView = (TextView) findViewById(R.id.mms_info);
|
||||
mMessageTitleLayout = (LinearLayout) findViewById(R.id.message_title_layout);
|
||||
mSenderNameTextView = (TextView) findViewById(R.id.message_sender_name);
|
||||
mMessageBubble = (ConversationMessageBubbleView) findViewById(R.id.message_content);
|
||||
mStatusTextView = findViewById(R.id.message_status);
|
||||
mTitleTextView = findViewById(R.id.message_title);
|
||||
mMmsInfoTextView = findViewById(R.id.mms_info);
|
||||
mMessageTitleLayout = findViewById(R.id.message_title_layout);
|
||||
mSenderNameTextView = findViewById(R.id.message_sender_name);
|
||||
mMessageBubble = findViewById(R.id.message_content);
|
||||
mSubjectView = findViewById(R.id.subject_container);
|
||||
mSubjectLabel = (TextView) mSubjectView.findViewById(R.id.subject_label);
|
||||
mSubjectText = (TextView) mSubjectView.findViewById(R.id.subject_text);
|
||||
mSubjectLabel = mSubjectView.findViewById(R.id.subject_label);
|
||||
mSubjectText = mSubjectView.findViewById(R.id.subject_text);
|
||||
mDeliveredBadge = findViewById(R.id.smsDeliveredBadge);
|
||||
mMessageMetadataView = (ViewGroup) findViewById(R.id.message_metadata);
|
||||
mMessageTextAndInfoView = (ViewGroup) findViewById(R.id.message_text_and_info);
|
||||
mSimNameView = (TextView) findViewById(R.id.sim_name);
|
||||
mMessageMetadataView = findViewById(R.id.message_metadata);
|
||||
mMessageTextAndInfoView = findViewById(R.id.message_text_and_info);
|
||||
mSimNameView = findViewById(R.id.sim_name);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -882,8 +882,8 @@ public class ConversationMessageView extends FrameLayout implements View.OnClick
|
||||
|
||||
private void updateTextAppearance() {
|
||||
int messageColorResId;
|
||||
int statusColorResId = -1;
|
||||
int infoColorResId = -1;
|
||||
int statusColorResId;
|
||||
int infoColorResId;
|
||||
int timestampColorResId;
|
||||
int subjectLabelColorResId;
|
||||
if (isSelected()) {
|
||||
|
||||
@@ -57,7 +57,7 @@ public class MessageDetailsDialog {
|
||||
private static String getMessageDetails(final Context context,
|
||||
final ConversationMessageData data,
|
||||
final ConversationParticipantsData participants, final ParticipantData self) {
|
||||
String messageDetails = null;
|
||||
String messageDetails;
|
||||
if (data.getIsSms()) {
|
||||
messageDetails = getSmsMessageDetails(data, participants, self);
|
||||
} else {
|
||||
|
||||
@@ -47,9 +47,9 @@ public class SimSelectorItemView extends LinearLayout {
|
||||
@Override
|
||||
protected void onFinishInflate() {
|
||||
super.onFinishInflate();
|
||||
mNameTextView = (TextView) findViewById(R.id.name);
|
||||
mDetailsTextView = (TextView) findViewById(R.id.details);
|
||||
mSimIconView = (SimIconView) findViewById(R.id.sim_icon);
|
||||
mNameTextView = findViewById(R.id.name);
|
||||
mDetailsTextView = findViewById(R.id.details);
|
||||
mSimIconView = findViewById(R.id.sim_icon);
|
||||
setOnClickListener(v -> mHost.onSimItemClicked(mData));
|
||||
}
|
||||
|
||||
|
||||
@@ -60,7 +60,7 @@ public class SimSelectorView extends FrameLayout implements SimSelectorItemView.
|
||||
@Override
|
||||
protected void onFinishInflate() {
|
||||
super.onFinishInflate();
|
||||
mSimListView = (ListView) findViewById(R.id.sim_list);
|
||||
mSimListView = findViewById(R.id.sim_list);
|
||||
mSimListView.setAdapter(mAdapter);
|
||||
|
||||
// Clicking anywhere outside the switcher list should dismiss.
|
||||
|
||||
Reference in New Issue
Block a user