Commit 9c8e6855 authored by Mohamed Heikal's avatar Mohamed Heikal Committed by Commit Bot

[Android] Fix NPE if onTrimMemory called before UI inflation completed

onTrimMemory tries to get a reference to the ControlContainer view and
calls getToolbarResourceAdapter().dropCachedBitmap() on it. If the UI
has not finished inflation yet, then the
findViewById(R.id.control_container) returns null causing a crash.

This cl adds a null check before calling methods on the
ControlContainer.

Bug: 853682
Change-Id: I621d21a92509c0c3211da99841cd59991cb38813
Reviewed-on: https://chromium-review.googlesource.com/1106900Reviewed-by: default avatarYaron Friedman <yfriedman@chromium.org>
Commit-Queue: Mohamed Heikal <mheikal@chromium.org>
Cr-Commit-Position: refs/heads/master@{#568616}
parent 8d29f711
......@@ -2468,7 +2468,9 @@ public abstract class ChromeActivity extends AsyncInitializationActivity
private void clearToolbarResourceCache() {
ControlContainer controlContainer = (ControlContainer) findViewById(R.id.control_container);
controlContainer.getToolbarResourceAdapter().dropCachedBitmap();
if (controlContainer != null) {
controlContainer.getToolbarResourceAdapter().dropCachedBitmap();
}
}
@Override
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment