Skip to content

Commit

Permalink
Remove unnecessary casts on calls to findViewById
Browse files Browse the repository at this point in the history
Just frameworks/ this time. More paths to come.

Bug: 24137209
Test: make -j32
Change-Id: Iff27abd26fa43296ac2fff8f534fc6742d2ae80c
  • Loading branch information
alanv committed Apr 14, 2017
1 parent 5879aa4 commit 51efddb
Show file tree
Hide file tree
Showing 191 changed files with 523 additions and 523 deletions.
2 changes: 1 addition & 1 deletion core/java/android/accounts/ChooseAccountActivity.java
Expand Up @@ -77,7 +77,7 @@ public void onCreate(Bundle savedInstanceState) {
setContentView(R.layout.choose_account);

// Setup the list
ListView list = (ListView) findViewById(android.R.id.list);
ListView list = findViewById(android.R.id.list);
// Use an existing ListAdapter that will map an array of strings to TextViews
list.setAdapter(new AccountArrayAdapter(this,
android.R.layout.simple_list_item_1, mAccountInfos));
Expand Down
2 changes: 1 addition & 1 deletion core/java/android/accounts/ChooseAccountTypeActivity.java
Expand Up @@ -99,7 +99,7 @@ public void onCreate(Bundle savedInstanceState) {

setContentView(R.layout.choose_account_type);
// Setup the list
ListView list = (ListView) findViewById(android.R.id.list);
ListView list = findViewById(android.R.id.list);
// Use an existing ListAdapter that will map an array of strings to TextViews
list.setAdapter(new AccountArrayAdapter(this,
android.R.layout.simple_list_item_1, mAuthenticatorInfosToDisplay));
Expand Down
6 changes: 3 additions & 3 deletions core/java/android/accounts/ChooseTypeAndAccountActivity.java
Expand Up @@ -248,7 +248,7 @@ public void onCreate(Bundle savedInstanceState) {
populateUIAccountList(listItems);

// Only enable "OK" button if something has been selected.
mOkButton = (Button) findViewById(android.R.id.button2);
mOkButton = findViewById(android.R.id.button2);
mOkButton.setEnabled(mSelectedItemIndex != SELECTED_ITEM_NONE);
}

Expand Down Expand Up @@ -592,7 +592,7 @@ private Set<Account> getAllowableAccountSet(final Intent intent) {
* If not specified then makes the description invisible.
*/
private void overrideDescriptionIfSupplied(String descriptionOverride) {
TextView descriptionView = (TextView) findViewById(R.id.description);
TextView descriptionView = findViewById(R.id.description);
if (!TextUtils.isEmpty(descriptionOverride)) {
descriptionView.setText(descriptionOverride);
} else {
Expand All @@ -605,7 +605,7 @@ private void overrideDescriptionIfSupplied(String descriptionOverride) {
* based on {@code mSelectedItemIndex} member variable.
*/
private final void populateUIAccountList(String[] listItems) {
ListView list = (ListView) findViewById(android.R.id.list);
ListView list = findViewById(android.R.id.list);
list.setAdapter(new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_single_choice, listItems));
list.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
Expand Down
Expand Up @@ -84,7 +84,7 @@ protected void onCreate(Bundle savedInstanceState) {
return;
}

final TextView authTokenTypeView = (TextView) findViewById(R.id.authtoken_type);
final TextView authTokenTypeView = findViewById(R.id.authtoken_type);
authTokenTypeView.setVisibility(View.GONE);

final AccountManagerCallback<String> callback = new AccountManagerCallback<String>() {
Expand Down Expand Up @@ -116,7 +116,7 @@ public void run() {
findViewById(R.id.allow_button).setOnClickListener(this);
findViewById(R.id.deny_button).setOnClickListener(this);

LinearLayout packagesListView = (LinearLayout) findViewById(R.id.packages_list);
LinearLayout packagesListView = findViewById(R.id.packages_list);

for (String pkg : packages) {
String packageLabel;
Expand Down
2 changes: 1 addition & 1 deletion core/java/android/app/AlertDialog.java
Expand Up @@ -48,7 +48,7 @@
* and add your view to it:
*
* <pre>
* FrameLayout fl = (FrameLayout) findViewById(android.R.id.custom);
* FrameLayout fl = findViewById(android.R.id.custom);
* fl.addView(myView, new LayoutParams(MATCH_PARENT, WRAP_CONTENT));
* </pre>
*
Expand Down
4 changes: 2 additions & 2 deletions core/java/android/app/SearchDialog.java
Expand Up @@ -165,7 +165,7 @@ private void createContentView() {
setContentView(com.android.internal.R.layout.search_bar);

// get the view elements for local access
mSearchView = (SearchView) findViewById(com.android.internal.R.id.search_view);
mSearchView = findViewById(com.android.internal.R.id.search_view);
mSearchView.setIconified(false);
mSearchView.setOnCloseListener(mOnCloseListener);
mSearchView.setOnQueryTextListener(mOnQueryChangeListener);
Expand All @@ -184,7 +184,7 @@ public void onClick(View v) {
mBadgeLabel = (TextView) mSearchView.findViewById(com.android.internal.R.id.search_badge);
mSearchAutoComplete = (AutoCompleteTextView)
mSearchView.findViewById(com.android.internal.R.id.search_src_text);
mAppIcon = (ImageView) findViewById(com.android.internal.R.id.search_app_icon);
mAppIcon = findViewById(com.android.internal.R.id.search_app_icon);
mSearchPlate = mSearchView.findViewById(com.android.internal.R.id.search_plate);
mWorkingSpinner = getContext().getDrawable(com.android.internal.R.drawable.search_spinner);
// TODO: Restore the spinner for slow suggestion lookups
Expand Down
2 changes: 1 addition & 1 deletion core/java/android/app/TabActivity.java
Expand Up @@ -108,7 +108,7 @@ protected void onSaveInstanceState(Bundle outState) {
@Override
public void onContentChanged() {
super.onContentChanged();
mTabHost = (TabHost) findViewById(com.android.internal.R.id.tabhost);
mTabHost = findViewById(com.android.internal.R.id.tabhost);

if (mTabHost == null) {
throw new RuntimeException(
Expand Down
Expand Up @@ -41,6 +41,6 @@ public ExtractEditLayout(Context context, AttributeSet attrs) {
@Override
public void onFinishInflate() {
super.onFinishInflate();
mExtractActionButton = (Button) findViewById(com.android.internal.R.id.inputExtractAction);
mExtractActionButton = findViewById(com.android.internal.R.id.inputExtractAction);
}
}
4 changes: 2 additions & 2 deletions core/java/android/view/NotificationHeaderView.java
Expand Up @@ -94,8 +94,8 @@ protected void onFinishInflate() {
super.onFinishInflate();
mAppName = findViewById(com.android.internal.R.id.app_name_text);
mHeaderText = findViewById(com.android.internal.R.id.header_text);
mExpandButton = (ImageView) findViewById(com.android.internal.R.id.expand_button);
mIcon = (CachingIconView) findViewById(com.android.internal.R.id.icon);
mExpandButton = findViewById(com.android.internal.R.id.expand_button);
mIcon = findViewById(com.android.internal.R.id.icon);
mProfileBadge = findViewById(com.android.internal.R.id.profile_badge);
}

Expand Down
2 changes: 1 addition & 1 deletion core/java/android/view/View.java
Expand Up @@ -321,7 +321,7 @@
* </pre></li>
* <li>From the onCreate method of an Activity, find the Button
* <pre class="prettyprint">
* Button myButton = (Button) findViewById(R.id.my_button);
* Button myButton = findViewById(R.id.my_button);
* </pre></li>
* </ul>
* <p>
Expand Down
2 changes: 1 addition & 1 deletion core/java/android/view/ViewStub.java
Expand Up @@ -58,7 +58,7 @@
* The preferred way to perform the inflation of the layout resource is the following:
*
* <pre>
* ViewStub stub = (ViewStub) findViewById(R.id.stub);
* ViewStub stub = findViewById(R.id.stub);
* View inflated = stub.inflate();
* </pre>
*
Expand Down
4 changes: 2 additions & 2 deletions core/java/android/widget/AppSecurityPermissions.java
Expand Up @@ -151,8 +151,8 @@ public void setPermission(MyPermissionGroupInfo grp, MyPermissionInfo perm,
mShowRevokeUI = showRevokeUI;
mPackageName = packageName;

ImageView permGrpIcon = (ImageView) findViewById(R.id.perm_icon);
TextView permNameView = (TextView) findViewById(R.id.perm_name);
ImageView permGrpIcon = findViewById(R.id.perm_icon);
TextView permNameView = findViewById(R.id.perm_name);

PackageManager pm = getContext().getPackageManager();
Drawable icon = null;
Expand Down
2 changes: 1 addition & 1 deletion core/java/android/widget/Button.java
Expand Up @@ -37,7 +37,7 @@
*
* setContentView(R.layout.content_layout_id);
*
* final Button button = (Button) findViewById(R.id.button_id);
* final Button button = findViewById(R.id.button_id);
* button.setOnClickListener(new View.OnClickListener() {
* public void onClick(View v) {
* // Perform action on click
Expand Down
6 changes: 3 additions & 3 deletions core/java/android/widget/DayPickerView.java
Expand Up @@ -124,13 +124,13 @@ public DayPickerView(Context context, @Nullable AttributeSet attrs, int defStyle
addView(child);
}

mPrevButton = (ImageButton) findViewById(R.id.prev);
mPrevButton = findViewById(R.id.prev);
mPrevButton.setOnClickListener(mOnClickListener);

mNextButton = (ImageButton) findViewById(R.id.next);
mNextButton = findViewById(R.id.next);
mNextButton.setOnClickListener(mOnClickListener);

mViewPager = (ViewPager) findViewById(R.id.day_picker_view_pager);
mViewPager = findViewById(R.id.day_picker_view_pager);
mViewPager.setAdapter(mAdapter);
mViewPager.setOnPageChangeListener(mOnPageChangedListener);

Expand Down
2 changes: 1 addition & 1 deletion core/java/android/widget/MultiAutoCompleteTextView.java
Expand Up @@ -43,7 +43,7 @@
*
* ArrayAdapter&lt;String&gt; adapter = new ArrayAdapter&lt;String&gt;(this,
* android.R.layout.simple_dropdown_item_1line, COUNTRIES);
* MultiAutoCompleteTextView textView = (MultiAutoCompleteTextView) findViewById(R.id.edit);
* MultiAutoCompleteTextView textView = findViewById(R.id.edit);
* textView.setAdapter(adapter);
* textView.setTokenizer(new MultiAutoCompleteTextView.CommaTokenizer());
* }
Expand Down
6 changes: 3 additions & 3 deletions core/java/android/widget/NumberPicker.java
Expand Up @@ -706,7 +706,7 @@ public boolean onLongClick(View v) {

// increment button
if (!mHasSelectorWheel) {
mIncrementButton = (ImageButton) findViewById(R.id.increment);
mIncrementButton = findViewById(R.id.increment);
mIncrementButton.setOnClickListener(onClickListener);
mIncrementButton.setOnLongClickListener(onLongClickListener);
} else {
Expand All @@ -715,15 +715,15 @@ public boolean onLongClick(View v) {

// decrement button
if (!mHasSelectorWheel) {
mDecrementButton = (ImageButton) findViewById(R.id.decrement);
mDecrementButton = findViewById(R.id.decrement);
mDecrementButton.setOnClickListener(onClickListener);
mDecrementButton.setOnLongClickListener(onLongClickListener);
} else {
mDecrementButton = null;
}

// input text
mInputText = (EditText) findViewById(R.id.numberpicker_input);
mInputText = findViewById(R.id.numberpicker_input);
mInputText.setOnFocusChangeListener(new OnFocusChangeListener() {
public void onFocusChange(View v, boolean hasFocus) {
if (hasFocus) {
Expand Down
4 changes: 2 additions & 2 deletions core/java/android/widget/TabHost.java
Expand Up @@ -136,7 +136,7 @@ public TabSpec newTabSpec(@NonNull String tag) {
mTabHost.addTab(TAB_TAG_1, "Hello, world!", "Tab 1");
*/
public void setup() {
mTabWidget = (TabWidget) findViewById(com.android.internal.R.id.tabs);
mTabWidget = findViewById(com.android.internal.R.id.tabs);
if (mTabWidget == null) {
throw new RuntimeException(
"Your TabHost must have a TabWidget whose id attribute is 'android.R.id.tabs'");
Expand Down Expand Up @@ -171,7 +171,7 @@ public void onTabSelectionChanged(int tabIndex, boolean clicked) {
}
});

mTabContent = (FrameLayout) findViewById(com.android.internal.R.id.tabcontent);
mTabContent = findViewById(com.android.internal.R.id.tabcontent);
if (mTabContent == null) {
throw new RuntimeException(
"Your TabHost must have a FrameLayout whose id attribute is "
Expand Down
14 changes: 7 additions & 7 deletions core/java/android/widget/TextInputTimePickerView.java
Expand Up @@ -76,12 +76,12 @@ public TextInputTimePickerView(Context context, AttributeSet attrs, int defStyle

inflate(context, R.layout.time_picker_text_input_material, this);

mHourEditText = (EditText) findViewById(R.id.input_hour);
mMinuteEditText = (EditText) findViewById(R.id.input_minute);
mInputSeparatorView = (TextView) findViewById(R.id.input_separator);
mErrorLabel = (TextView) findViewById(R.id.label_error);
mHourLabel = (TextView) findViewById(R.id.label_hour);
mMinuteLabel = (TextView) findViewById(R.id.label_minute);
mHourEditText = findViewById(R.id.input_hour);
mMinuteEditText = findViewById(R.id.input_minute);
mInputSeparatorView = findViewById(R.id.input_separator);
mErrorLabel = findViewById(R.id.label_error);
mHourLabel = findViewById(R.id.label_hour);
mMinuteLabel = findViewById(R.id.label_minute);

mHourEditText.addTextChangedListener(new TextWatcher() {
@Override
Expand Down Expand Up @@ -109,7 +109,7 @@ public void afterTextChanged(Editable editable) {
}
});

mAmPmSpinner = (Spinner) findViewById(R.id.am_pm_spinner);
mAmPmSpinner = findViewById(R.id.am_pm_spinner);
final String[] amPmStrings = TimePicker.getAmPmStrings(context);
ArrayAdapter<CharSequence> adapter =
new ArrayAdapter<CharSequence>(context, R.layout.simple_spinner_dropdown_item);
Expand Down
4 changes: 2 additions & 2 deletions core/java/android/widget/TwoLineListItem.java
Expand Up @@ -70,8 +70,8 @@ public TwoLineListItem(Context context, AttributeSet attrs, int defStyleAttr, in
protected void onFinishInflate() {
super.onFinishInflate();

mText1 = (TextView) findViewById(com.android.internal.R.id.text1);
mText2 = (TextView) findViewById(com.android.internal.R.id.text2);
mText1 = findViewById(com.android.internal.R.id.text1);
mText2 = findViewById(com.android.internal.R.id.text2);
}

/**
Expand Down
Expand Up @@ -59,7 +59,7 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
String component = Settings.Secure.getString(getContentResolver(),
Settings.Secure.ACCESSIBILITY_BUTTON_TARGET_COMPONENT);
if (TextUtils.isEmpty(component)) {
TextView prompt = (TextView) findViewById(R.id.accessibility_button_prompt);
TextView prompt = findViewById(R.id.accessibility_button_prompt);
prompt.setVisibility(View.VISIBLE);
}

Expand All @@ -78,7 +78,7 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
finish();
}

GridView gridview = (GridView) findViewById(R.id.accessibility_button_chooser_grid);
GridView gridview = findViewById(R.id.accessibility_button_chooser_grid);
gridview.setAdapter(new TargetAdapter());
gridview.setOnItemClickListener((parent, view, position, id) -> {
onTargetSelected(mTargets.get(position));
Expand Down
16 changes: 8 additions & 8 deletions core/java/com/android/internal/app/ResolverActivity.java
Expand Up @@ -287,7 +287,7 @@ protected void onCreate(Bundle savedInstanceState, Intent intent,
return;
}

final ResolverDrawerLayout rdl = (ResolverDrawerLayout) findViewById(R.id.contentPanel);
final ResolverDrawerLayout rdl = findViewById(R.id.contentPanel);
if (rdl != null) {
rdl.setOnDismissedListener(new ResolverDrawerLayout.OnDismissedListener() {
@Override
Expand Down Expand Up @@ -922,10 +922,10 @@ public boolean configureContentView(List<Intent> payloadIntents, Intent[] initia
}


mAdapterView = (AbsListView) findViewById(R.id.resolver_list);
mAdapterView = findViewById(R.id.resolver_list);

if (count == 0 && mAdapter.mPlaceholderCount == 0) {
final TextView emptyView = (TextView) findViewById(R.id.empty);
final TextView emptyView = findViewById(R.id.empty);
emptyView.setVisibility(View.VISIBLE);
mAdapterView.setVisibility(View.GONE);
} else {
Expand Down Expand Up @@ -959,7 +959,7 @@ public void onPrepareAdapterView(AbsListView adapterView, ResolveListAdapter ada

public void setTitleAndIcon() {
if (mAdapter.getCount() == 0 && mAdapter.mPlaceholderCount == 0) {
final TextView titleView = (TextView) findViewById(R.id.title);
final TextView titleView = findViewById(R.id.title);
if (titleView != null) {
titleView.setVisibility(View.GONE);
}
Expand All @@ -970,14 +970,14 @@ public void setTitleAndIcon() {
: getTitleForAction(getTargetIntent().getAction(), mDefaultTitleResId);

if (!TextUtils.isEmpty(title)) {
final TextView titleView = (TextView) findViewById(R.id.title);
final TextView titleView = findViewById(R.id.title);
if (titleView != null) {
titleView.setText(title);
}
setTitle(title);

// Try to initialize the title icon if we have a view for it and a title to match
final ImageView titleIcon = (ImageView) findViewById(R.id.title_icon);
final ImageView titleIcon = findViewById(R.id.title_icon);
if (titleIcon != null) {
ApplicationInfo ai = null;
try {
Expand All @@ -994,7 +994,7 @@ public void setTitleAndIcon() {
}
}

final ImageView iconView = (ImageView) findViewById(R.id.icon);
final ImageView iconView = findViewById(R.id.icon);
final DisplayResolveInfo iconInfo = mAdapter.getFilteredItem();
if (iconView != null && iconInfo != null) {
new LoadIconIntoViewTask(iconInfo, iconView).execute();
Expand All @@ -1003,7 +1003,7 @@ public void setTitleAndIcon() {

public void resetAlwaysOrOnceButtonBar() {
if (mSupportsAlwaysUseOption) {
final ViewGroup buttonLayout = (ViewGroup) findViewById(R.id.button_bar);
final ViewGroup buttonLayout = findViewById(R.id.button_bar);
if (buttonLayout != null) {
buttonLayout.setVisibility(View.VISIBLE);
mAlwaysButton = (Button) buttonLayout.findViewById(R.id.button_always);
Expand Down
2 changes: 1 addition & 1 deletion core/java/com/android/internal/policy/DecorView.java
Expand Up @@ -1688,7 +1688,7 @@ public void onAnimationEnd(Animator animation) {
}
};
} else {
ViewStub stub = (ViewStub) findViewById(R.id.action_mode_bar_stub);
ViewStub stub = findViewById(R.id.action_mode_bar_stub);
if (stub != null) {
mPrimaryActionModeView = (ActionBarContextView) stub.inflate();
mPrimaryActionModePopup = null;
Expand Down
8 changes: 4 additions & 4 deletions core/java/com/android/internal/policy/PhoneWindow.java
Expand Up @@ -1593,7 +1593,7 @@ protected void onIntChanged(int featureId, int value) {
if (featureId == FEATURE_PROGRESS || featureId == FEATURE_INDETERMINATE_PROGRESS) {
updateProgressBars(value);
} else if (featureId == FEATURE_CUSTOM_TITLE) {
FrameLayout titleContainer = (FrameLayout) findViewById(R.id.title_container);
FrameLayout titleContainer = findViewById(R.id.title_container);
if (titleContainer != null) {
mLayoutInflater.inflate(value, titleContainer);
}
Expand Down Expand Up @@ -2690,7 +2690,7 @@ private void installDecor() {
invalidatePanelMenu(FEATURE_ACTION_BAR);
}
} else {
mTitleView = (TextView) findViewById(R.id.title);
mTitleView = findViewById(R.id.title);
if (mTitleView != null) {
if ((getLocalFeatures() & (1 << FEATURE_NO_TITLE)) != 0) {
final View titleContainer = findViewById(R.id.title_container);
Expand Down Expand Up @@ -2967,7 +2967,7 @@ private ProgressBar getCircularProgressBar(boolean shouldInstallDecor) {
if (mContentParent == null && shouldInstallDecor) {
installDecor();
}
mCircularProgressBar = (ProgressBar) findViewById(R.id.progress_circular);
mCircularProgressBar = findViewById(R.id.progress_circular);
if (mCircularProgressBar != null) {
mCircularProgressBar.setVisibility(View.INVISIBLE);
}
Expand All @@ -2981,7 +2981,7 @@ private ProgressBar getHorizontalProgressBar(boolean shouldInstallDecor) {
if (mContentParent == null && shouldInstallDecor) {
installDecor();
}
mHorizontalProgressBar = (ProgressBar) findViewById(R.id.progress_horizontal);
mHorizontalProgressBar = findViewById(R.id.progress_horizontal);
if (mHorizontalProgressBar != null) {
mHorizontalProgressBar.setVisibility(View.INVISIBLE);
}
Expand Down

0 comments on commit 51efddb

Please sign in to comment.