Commit 796a0bc0 authored by Newton Allen's avatar Newton Allen

Fix crash on BLU Life Play devices related to switch preferences.

ChromeSwitchPreference uses setWidgetLayoutResource() to show a Material
switch, but on BLU Life Play devices, this has no effect and the default
switch is shown instead. As a result ChromeSwitchPreference.onBindView()
couldn't find the Material switch and was crashing with a NPE. This
fixes the crash by adding a null check, though these devices will still
show a non-material switch.

BUG=451447
R=dtrainor@chromium.org

Review URL: https://codereview.chromium.org/894873004

Cr-Commit-Position: refs/heads/master@{#314250}
parent d08c144c
......@@ -50,8 +50,14 @@ public class ChromeSwitchPreference extends SwitchPreference {
@Override
protected void onBindView(View view) {
super.onBindView(view);
ChromeSwitchCompat switchView = (ChromeSwitchCompat) view.findViewById(R.id.switch_widget);
switchView.setChecked(isChecked());
// On BLU Life Play devices SwitchPreference.setWidgetLayoutResource() does nothing. As a
// result, the user will see a non-material Switch and switchView will be null, hence the
// null check below. http://crbug.com/451447
if (switchView != null) {
switchView.setChecked(isChecked());
}
TextView title = (TextView) view.findViewById(android.R.id.title);
title.setSingleLine(false);
......
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