Update the Builder to add the title parameter checking

Fixes: 139163212
Test: compilation
Change-Id: Ieccaabff5d01c6d8043505661fa77b1b0a174485
This commit is contained in:
Sunny Shao
2019-08-09 17:04:19 +08:00
parent c422b02f20
commit 8298653417

View File

@@ -99,7 +99,7 @@ public class FooterPreference extends Preference {
* To set the key value of the {@link FooterPreference}.
* @param key The key value.
*/
public Builder setKey(String key) {
public Builder setKey(@NonNull String key) {
mKey = key;
return this;
}
@@ -128,12 +128,13 @@ public class FooterPreference extends Preference {
public FooterPreference build() {
final FooterPreference footerPreference = new FooterPreference(mContext);
footerPreference.setSelectable(false);
if (TextUtils.isEmpty(mTitle)) {
throw new IllegalArgumentException("Footer title cannot be empty!");
}
footerPreference.setTitle(mTitle);
if (!TextUtils.isEmpty(mKey)) {
footerPreference.setKey(mKey);
}
if (!TextUtils.isEmpty(mTitle)) {
footerPreference.setTitle(mTitle);
}
return footerPreference;
}
}