Skip to content

Commit 2885fc7

Browse files
afohrmandsn5ft
authored andcommitted
Remove field prefixes from bottom nav code in the widget package.
This is part 2 of a change that removes field prefixes from code related to bottom nav. PiperOrigin-RevId: 181229750
1 parent 15fa53b commit 2885fc7

File tree

1 file changed

+58
-59
lines changed

1 file changed

+58
-59
lines changed

lib/java/android/support/design/widget/BottomNavigationView.java

Lines changed: 58 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -101,14 +101,13 @@ public class BottomNavigationView extends FrameLayout {
101101

102102
private static final int MENU_PRESENTER_ID = 1;
103103

104-
private final MenuBuilder mMenu;
105-
private final BottomNavigationMenuView mMenuView;
106-
private final BottomNavigationPresenter mPresenter = new BottomNavigationPresenter();
107-
private MenuInflater mMenuInflater;
108-
109-
private OnNavigationItemSelectedListener mSelectedListener;
110-
private OnNavigationItemReselectedListener mReselectedListener;
104+
private final MenuBuilder menu;
105+
private final BottomNavigationMenuView menuView;
106+
private final BottomNavigationPresenter presenter = new BottomNavigationPresenter();
107+
private MenuInflater menuInflater;
111108

109+
private OnNavigationItemSelectedListener selectedListener;
110+
private OnNavigationItemReselectedListener reselectedListener;
112111

113112
public BottomNavigationView(Context context) {
114113
this(context, null);
@@ -124,20 +123,20 @@ public BottomNavigationView(Context context, AttributeSet attrs, int defStyleAtt
124123
ThemeEnforcement.checkAppCompatTheme(context);
125124

126125
// Create the menu
127-
mMenu = new BottomNavigationMenu(context);
126+
this.menu = new BottomNavigationMenu(context);
128127

129-
mMenuView = new BottomNavigationMenuView(context);
128+
menuView = new BottomNavigationMenuView(context);
130129
FrameLayout.LayoutParams params =
131130
new FrameLayout.LayoutParams(
132131
ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
133132
params.gravity = Gravity.CENTER;
134-
mMenuView.setLayoutParams(params);
133+
menuView.setLayoutParams(params);
135134

136-
mPresenter.setBottomNavigationMenuView(mMenuView);
137-
mPresenter.setId(MENU_PRESENTER_ID);
138-
mMenuView.setPresenter(mPresenter);
139-
mMenu.addMenuPresenter(mPresenter);
140-
mPresenter.initForMenu(getContext(), mMenu);
135+
presenter.setBottomNavigationMenuView(menuView);
136+
presenter.setId(MENU_PRESENTER_ID);
137+
menuView.setPresenter(presenter);
138+
this.menu.addMenuPresenter(presenter);
139+
presenter.initForMenu(getContext(), this.menu);
141140

142141
// Custom attributes
143142
TintTypedArray a =
@@ -149,15 +148,15 @@ public BottomNavigationView(Context context, AttributeSet attrs, int defStyleAtt
149148
R.style.Widget_Design_BottomNavigationView);
150149

151150
if (a.hasValue(R.styleable.BottomNavigationView_itemIconTint)) {
152-
mMenuView.setIconTintList(a.getColorStateList(R.styleable.BottomNavigationView_itemIconTint));
151+
menuView.setIconTintList(a.getColorStateList(R.styleable.BottomNavigationView_itemIconTint));
153152
} else {
154-
mMenuView.setIconTintList(createDefaultColorStateList(android.R.attr.textColorSecondary));
153+
menuView.setIconTintList(createDefaultColorStateList(android.R.attr.textColorSecondary));
155154
}
156155
if (a.hasValue(R.styleable.BottomNavigationView_itemTextColor)) {
157-
mMenuView.setItemTextColor(
156+
menuView.setItemTextColor(
158157
a.getColorStateList(R.styleable.BottomNavigationView_itemTextColor));
159158
} else {
160-
mMenuView.setItemTextColor(createDefaultColorStateList(android.R.attr.textColorSecondary));
159+
menuView.setItemTextColor(createDefaultColorStateList(android.R.attr.textColorSecondary));
161160
}
162161
if (a.hasValue(R.styleable.BottomNavigationView_elevation)) {
163162
ViewCompat.setElevation(
@@ -167,7 +166,7 @@ public BottomNavigationView(Context context, AttributeSet attrs, int defStyleAtt
167166
@ShiftingMode
168167
int shiftingMode =
169168
a.getInt(R.styleable.BottomNavigationView_shiftingMode, ShiftingMode.SHIFTING_MODE_AUTO);
170-
mMenuView.setShiftingMode(shiftingMode);
169+
menuView.setShiftingMode(shiftingMode);
171170
}
172171

173172
setLabelVisibilityMode(
@@ -178,27 +177,27 @@ public BottomNavigationView(Context context, AttributeSet attrs, int defStyleAtt
178177
a.getBoolean(R.styleable.BottomNavigationView_itemHorizontalTranslation, true));
179178

180179
int itemBackground = a.getResourceId(R.styleable.BottomNavigationView_itemBackground, 0);
181-
mMenuView.setItemBackgroundRes(itemBackground);
180+
menuView.setItemBackgroundRes(itemBackground);
182181

183182
if (a.hasValue(R.styleable.BottomNavigationView_menu)) {
184183
inflateMenu(a.getResourceId(R.styleable.BottomNavigationView_menu, 0));
185184
}
186185
a.recycle();
187186

188-
addView(mMenuView, params);
187+
addView(menuView, params);
189188
if (Build.VERSION.SDK_INT < 21) {
190189
addCompatibilityTopDivider(context);
191190
}
192191

193-
mMenu.setCallback(
192+
this.menu.setCallback(
194193
new MenuBuilder.Callback() {
195194
@Override
196195
public boolean onMenuItemSelected(MenuBuilder menu, MenuItem item) {
197-
if (mReselectedListener != null && item.getItemId() == getSelectedItemId()) {
198-
mReselectedListener.onNavigationItemReselected(item);
196+
if (reselectedListener != null && item.getItemId() == getSelectedItemId()) {
197+
reselectedListener.onNavigationItemReselected(item);
199198
return true; // item is already selected
200199
}
201-
return mSelectedListener != null && !mSelectedListener.onNavigationItemSelected(item);
200+
return selectedListener != null && !selectedListener.onNavigationItemSelected(item);
202201
}
203202

204203
@Override
@@ -216,7 +215,7 @@ public void onMenuModeChange(MenuBuilder menu) {}
216215
*/
217216
public void setOnNavigationItemSelectedListener(
218217
@Nullable OnNavigationItemSelectedListener listener) {
219-
mSelectedListener = listener;
218+
selectedListener = listener;
220219
}
221220

222221
/**
@@ -228,13 +227,13 @@ public void setOnNavigationItemSelectedListener(
228227
*/
229228
public void setOnNavigationItemReselectedListener(
230229
@Nullable OnNavigationItemReselectedListener listener) {
231-
mReselectedListener = listener;
230+
reselectedListener = listener;
232231
}
233232

234233
/** Returns the {@link Menu} instance associated with this bottom navigation bar. */
235234
@NonNull
236235
public Menu getMenu() {
237-
return mMenu;
236+
return menu;
238237
}
239238

240239
/**
@@ -245,10 +244,10 @@ public Menu getMenu() {
245244
* @param resId ID of a menu resource to inflate
246245
*/
247246
public void inflateMenu(int resId) {
248-
mPresenter.setUpdateSuspended(true);
249-
getMenuInflater().inflate(resId, mMenu);
250-
mPresenter.setUpdateSuspended(false);
251-
mPresenter.updateMenuView(true);
247+
presenter.setUpdateSuspended(true);
248+
getMenuInflater().inflate(resId, menu);
249+
presenter.setUpdateSuspended(false);
250+
presenter.updateMenuView(true);
252251
}
253252

254253
/** @return The maximum number of items that can be shown in BottomNavigationView. */
@@ -264,7 +263,7 @@ public int getMaxItemCount() {
264263
*/
265264
@Nullable
266265
public ColorStateList getItemIconTintList() {
267-
return mMenuView.getIconTintList();
266+
return menuView.getIconTintList();
268267
}
269268

270269
/**
@@ -274,7 +273,7 @@ public ColorStateList getItemIconTintList() {
274273
* @attr ref R.styleable#BottomNavigationView_itemIconTint
275274
*/
276275
public void setItemIconTintList(@Nullable ColorStateList tint) {
277-
mMenuView.setIconTintList(tint);
276+
menuView.setIconTintList(tint);
278277
}
279278

280279
/**
@@ -287,7 +286,7 @@ public void setItemIconTintList(@Nullable ColorStateList tint) {
287286
*/
288287
@Nullable
289288
public ColorStateList getItemTextColor() {
290-
return mMenuView.getItemTextColor();
289+
return menuView.getItemTextColor();
291290
}
292291

293292
/**
@@ -298,7 +297,7 @@ public ColorStateList getItemTextColor() {
298297
* @attr ref R.styleable#BottomNavigationView_itemTextColor
299298
*/
300299
public void setItemTextColor(@Nullable ColorStateList textColor) {
301-
mMenuView.setItemTextColor(textColor);
300+
menuView.setItemTextColor(textColor);
302301
}
303302

304303
/**
@@ -309,7 +308,7 @@ public void setItemTextColor(@Nullable ColorStateList textColor) {
309308
*/
310309
@DrawableRes
311310
public int getItemBackgroundResource() {
312-
return mMenuView.getItemBackgroundRes();
311+
return menuView.getItemBackgroundRes();
313312
}
314313

315314
/**
@@ -319,7 +318,7 @@ public int getItemBackgroundResource() {
319318
* @attr ref R.styleable#BottomNavigationView_itemBackground
320319
*/
321320
public void setItemBackgroundResource(@DrawableRes int resId) {
322-
mMenuView.setItemBackgroundRes(resId);
321+
menuView.setItemBackgroundRes(resId);
323322
}
324323

325324
/**
@@ -329,7 +328,7 @@ public void setItemBackgroundResource(@DrawableRes int resId) {
329328
*/
330329
@IdRes
331330
public int getSelectedItemId() {
332-
return mMenuView.getSelectedItemId();
331+
return menuView.getSelectedItemId();
333332
}
334333

335334
/**
@@ -339,9 +338,9 @@ public int getSelectedItemId() {
339338
* @see #getSelectedItemId()
340339
*/
341340
public void setSelectedItemId(@IdRes int itemId) {
342-
MenuItem item = mMenu.findItem(itemId);
341+
MenuItem item = menu.findItem(itemId);
343342
if (item != null) {
344-
if (!mMenu.performItemAction(item, mPresenter, 0)) {
343+
if (!menu.performItemAction(item, presenter, 0)) {
345344
item.setChecked(true);
346345
}
347346
}
@@ -357,7 +356,7 @@ public void setSelectedItemId(@IdRes int itemId) {
357356
@Deprecated
358357
@ShiftingMode
359358
public int getShiftingMode() {
360-
return mMenuView.getShiftingMode();
359+
return menuView.getShiftingMode();
361360
}
362361

363362
/**
@@ -380,9 +379,9 @@ public int getShiftingMode() {
380379
*/
381380
@Deprecated
382381
public void setShiftingMode(@ShiftingMode int shiftingMode) {
383-
if (mMenuView.getShiftingMode() != shiftingMode) {
384-
mMenuView.setShiftingMode(shiftingMode);
385-
mPresenter.updateMenuView(false /* cleared */);
382+
if (menuView.getShiftingMode() != shiftingMode) {
383+
menuView.setShiftingMode(shiftingMode);
384+
presenter.updateMenuView(false /* cleared */);
386385
}
387386
}
388387

@@ -401,9 +400,9 @@ public void setShiftingMode(@ShiftingMode int shiftingMode) {
401400
* @see #getLabelVisibilityMode()
402401
*/
403402
public void setLabelVisibilityMode(@LabelVisibilityMode int labelVisibilityMode) {
404-
if (mMenuView.getLabelVisibilityMode() != labelVisibilityMode) {
405-
mMenuView.setLabelVisibilityMode(labelVisibilityMode);
406-
mPresenter.updateMenuView(false);
403+
if (menuView.getLabelVisibilityMode() != labelVisibilityMode) {
404+
menuView.setLabelVisibilityMode(labelVisibilityMode);
405+
presenter.updateMenuView(false);
407406
}
408407
}
409408

@@ -433,7 +432,7 @@ public void setLabelVisibilityModeResource(@IntegerRes int labelVisibilityModeId
433432
*/
434433
@LabelVisibilityMode
435434
public int getLabelVisibilityMode() {
436-
return mMenuView.getLabelVisibilityMode();
435+
return menuView.getLabelVisibilityMode();
437436
}
438437

439438
/**
@@ -443,9 +442,9 @@ public int getLabelVisibilityMode() {
443442
* @see #getItemHorizontalTranslation()
444443
*/
445444
public void setItemHorizontalTranslation(boolean itemHorizontalTranslation) {
446-
if (mMenuView.getItemHorizontalTranslation() != itemHorizontalTranslation) {
447-
mMenuView.setItemHorizontalTranslation(itemHorizontalTranslation);
448-
mPresenter.updateMenuView(false);
445+
if (menuView.getItemHorizontalTranslation() != itemHorizontalTranslation) {
446+
menuView.setItemHorizontalTranslation(itemHorizontalTranslation);
447+
presenter.updateMenuView(false);
449448
}
450449
}
451450

@@ -466,7 +465,7 @@ public void setItemHorizontalTranslation(@BoolRes int itemHorizontalTranslation)
466465
* @see #setItemHorizontalTranslation(boolean)
467466
*/
468467
public boolean getItemHorizontalTranslation() {
469-
return mMenuView.getItemHorizontalTranslation();
468+
return menuView.getItemHorizontalTranslation();
470469
}
471470

472471
/** Listener for handling selection events on bottom navigation items. */
@@ -507,10 +506,10 @@ private void addCompatibilityTopDivider(Context context) {
507506
}
508507

509508
private MenuInflater getMenuInflater() {
510-
if (mMenuInflater == null) {
511-
mMenuInflater = new SupportMenuInflater(getContext());
509+
if (menuInflater == null) {
510+
menuInflater = new SupportMenuInflater(getContext());
512511
}
513-
return mMenuInflater;
512+
return menuInflater;
514513
}
515514

516515
private ColorStateList createDefaultColorStateList(int baseColorThemeAttr) {
@@ -538,7 +537,7 @@ protected Parcelable onSaveInstanceState() {
538537
Parcelable superState = super.onSaveInstanceState();
539538
SavedState savedState = new SavedState(superState);
540539
savedState.menuPresenterState = new Bundle();
541-
mMenu.savePresenterStates(savedState.menuPresenterState);
540+
menu.savePresenterStates(savedState.menuPresenterState);
542541
return savedState;
543542
}
544543

@@ -550,7 +549,7 @@ protected void onRestoreInstanceState(Parcelable state) {
550549
}
551550
SavedState savedState = (SavedState) state;
552551
super.onRestoreInstanceState(savedState.getSuperState());
553-
mMenu.restorePresenterStates(savedState.menuPresenterState);
552+
menu.restorePresenterStates(savedState.menuPresenterState);
554553
}
555554

556555
static class SavedState extends AbsSavedState {

0 commit comments

Comments
 (0)