Commit a882d272 authored by Becky Zhou's avatar Becky Zhou Committed by Commit Bot

Fix java.lang.IndexOutOfBoundsException in theme preference

Fix a crash introduced from http://crrev/c/1556779

Bug: 942771
Change-Id: I86e05da12c15447a9ad5f551b5e39683778e3f23
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1570920Reviewed-by: default avatarMatthew Jones <mdjones@chromium.org>
Commit-Queue: Becky Zhou <huayinz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#651823}
parent 9deaebef
......@@ -14,6 +14,7 @@ import org.chromium.chrome.browser.preferences.themes.ThemePreferences.ThemeSett
import org.chromium.chrome.browser.widget.RadioButtonWithDescription;
import java.util.ArrayList;
import java.util.Collections;
/**
* A radio button group Preference used for Themes. Currently, it has 3 options: System default,
......@@ -29,7 +30,9 @@ public class RadioButtonGroupThemePreference
// Inflating from XML.
setLayoutResource(R.layout.radio_button_group_theme_preference);
mButtons = new ArrayList<>(ThemeSetting.NUM_ENTRIES);
// Initialize entries with null objects so that calling ArrayList#set() would not throw
// java.lang.IndexOutOfBoundsException.
mButtons = new ArrayList<>(Collections.nCopies(ThemeSetting.NUM_ENTRIES, null));
}
/**
......
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