From 256652050c8c047d1879621805f028454e83b677 Mon Sep 17 00:00:00 2001 From: Ben Komalo Date: Thu, 28 Apr 2011 16:54:26 -0700 Subject: [PATCH] Genericize UiUtilities.getView Change-Id: I7142d4a57170e3074dc896149bf95ed6d2677bdd --- .../android/email/activity/MessageCompose.java | 18 +++++++++--------- .../android/email/activity/UiUtilities.java | 10 ++++++---- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/src/com/android/email/activity/MessageCompose.java b/src/com/android/email/activity/MessageCompose.java index 0da3470ab..99959e52d 100644 --- a/src/com/android/email/activity/MessageCompose.java +++ b/src/com/android/email/activity/MessageCompose.java @@ -467,18 +467,18 @@ public class MessageCompose extends Activity implements OnClickListener, OnFocus } private void initViews() { - mFromView = (TextView) UiUtilities.getView(this, R.id.from); - mToView = (MultiAutoCompleteTextView) UiUtilities.getView(this, R.id.to); - mCcView = (MultiAutoCompleteTextView) UiUtilities.getView(this, R.id.cc); - mBccView = (MultiAutoCompleteTextView) UiUtilities.getView(this, R.id.bcc); + mFromView = UiUtilities.getView(this, R.id.from); + mToView = UiUtilities.getView(this, R.id.to); + mCcView = UiUtilities.getView(this, R.id.cc); + mBccView = UiUtilities.getView(this, R.id.bcc); mCcBccContainer = UiUtilities.getView(this, R.id.cc_bcc_container); - mSubjectView = (EditText) UiUtilities.getView(this, R.id.subject); - mMessageContentView = (EditText) UiUtilities.getView(this, R.id.message_content); - mAttachments = (LinearLayout) UiUtilities.getView(this, R.id.attachments); + mSubjectView = UiUtilities.getView(this, R.id.subject); + mMessageContentView = UiUtilities.getView(this, R.id.message_content); + mAttachments = UiUtilities.getView(this, R.id.attachments); mAttachmentContainer = UiUtilities.getView(this, R.id.attachment_container); mQuotedTextBar = UiUtilities.getView(this, R.id.quoted_text_bar); - mIncludeQuotedTextCheckBox = (CheckBox) UiUtilities.getView(this, R.id.include_quoted_text); - mQuotedText = (WebView) UiUtilities.getView(this, R.id.quoted_text); + mIncludeQuotedTextCheckBox = UiUtilities.getView(this, R.id.include_quoted_text); + mQuotedText = UiUtilities.getView(this, R.id.quoted_text); TextWatcher watcher = new TextWatcher() { public void beforeTextChanged(CharSequence s, int start, diff --git a/src/com/android/email/activity/UiUtilities.java b/src/com/android/email/activity/UiUtilities.java index 951246089..f55878b2f 100644 --- a/src/com/android/email/activity/UiUtilities.java +++ b/src/com/android/email/activity/UiUtilities.java @@ -69,15 +69,17 @@ public class UiUtilities { /** * Same as {@link Activity#findViewById}, but crashes if there's no view. */ - public static View getView(Activity parent, int viewId) { - return checkView(parent.findViewById(viewId)); + @SuppressWarnings("unchecked") + public static T getView(Activity parent, int viewId) { + return (T) checkView(parent.findViewById(viewId)); } /** * Same as {@link View#findViewById}, but crashes if there's no view. */ - public static View getView(View parent, int viewId) { - return checkView(parent.findViewById(viewId)); + @SuppressWarnings("unchecked") + public static T getView(View parent, int viewId) { + return (T) checkView(parent.findViewById(viewId)); } private static View checkView(View v) {