fix crash in setting time zone

Summary: Fix a NPE when trying to set the time zone.

Test: Set the time zone. See it update without crashing.

Change-Id: I01c394f1a682844babc8119c86348b140eeb18ec
Signed-off-by: Abhishek Gadewar <abhishekgadewar@meta.com>
This commit is contained in:
Abhishek Gadewar
2024-05-09 22:54:00 -07:00
parent 9a492ca3cb
commit 772b19f6ca

View File

@@ -164,7 +164,9 @@ public abstract class BaseTimeZonePicker extends InstrumentedFragment
@Override
public boolean onMenuItemActionExpand(MenuItem item) {
// To prevent a large space on tool bar.
mAppBarLayout.setExpanded(false /*expanded*/, false /*animate*/);
if (mAppBarLayout != null) {
mAppBarLayout.setExpanded(false /*expanded*/, false /*animate*/);
}
// To prevent user can expand the collapsing tool bar view.
ViewCompat.setNestedScrollingEnabled(mRecyclerView, false);
return true;
@@ -173,7 +175,9 @@ public abstract class BaseTimeZonePicker extends InstrumentedFragment
@Override
public boolean onMenuItemActionCollapse(MenuItem item) {
// We keep the collapsed status after user cancel the search function.
mAppBarLayout.setExpanded(false /*expanded*/, false /*animate*/);
if (mAppBarLayout != null) {
mAppBarLayout.setExpanded(false /*expanded*/, false /*animate*/);
}
ViewCompat.setNestedScrollingEnabled(mRecyclerView, true);
return true;
}
@@ -196,6 +200,10 @@ public abstract class BaseTimeZonePicker extends InstrumentedFragment
}
private void autoSetCollapsingToolbarLayoutScrolling() {
if (mAppBarLayout == null) {
return;
}
CoordinatorLayout.LayoutParams params =
(CoordinatorLayout.LayoutParams) mAppBarLayout.getLayoutParams();
AppBarLayout.Behavior behavior = new AppBarLayout.Behavior();