зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1557661 java.lang.NullPointerException: at org.mozilla.gecko.home.TabMenuStripLayout.onPageSelected(TabMenuStripLayout.java) r=VladBaicu
Fixed an issue where we were trying to set some attributes on a null object due to the fact that the view had not finished rendering. Differential Revision: https://phabricator.services.mozilla.com/D35515 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
46bc26a8bb
Коммит
46f3d5ee22
|
@ -123,20 +123,20 @@ class TabMenuStripLayout extends ThemedLinearLayout
|
|||
}
|
||||
|
||||
void onPageSelected(final int position) {
|
||||
if (selectedView != null) {
|
||||
selectedView.setTextColor(inactiveTextColor);
|
||||
}
|
||||
|
||||
selectedView = (TextView) getChildAt(position);
|
||||
selectedView.setTextColor(activeTextColor);
|
||||
|
||||
// Callback to measure and draw the strip after the view is visible.
|
||||
ViewTreeObserver vto = selectedView.getViewTreeObserver();
|
||||
ViewTreeObserver vto = getViewTreeObserver();
|
||||
if (vto.isAlive()) {
|
||||
vto.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
|
||||
@Override
|
||||
public void onGlobalLayout() {
|
||||
selectedView.getViewTreeObserver().removeGlobalOnLayoutListener(this);
|
||||
// let's ensure that we are calling this only once
|
||||
vto.removeOnGlobalLayoutListener(this);
|
||||
if (selectedView != null) {
|
||||
selectedView.setTextColor(inactiveTextColor);
|
||||
}
|
||||
|
||||
selectedView = (TextView) getChildAt(position);
|
||||
selectedView.setTextColor(activeTextColor);
|
||||
|
||||
if (strip != null) {
|
||||
boolean isLayoutRtl = ViewCompat.getLayoutDirection(selectedView) == ViewCompat.LAYOUT_DIRECTION_RTL;
|
||||
|
|
Загрузка…
Ссылка в новой задаче