Merge pull request #2924 from qkolj/backbut-npe

Fix NPE when selecting Go to page for the first time
This commit is contained in:
H. Lehmann 2018-11-30 22:09:25 +01:00 committed by GitHub
commit d5ce405162
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 7 deletions

View File

@ -232,8 +232,7 @@ public class PreferenceController implements SharedPreferences.OnSharedPreferenc
if (newValue.equals("page")) {
final Context context = ui.getActivity();
final String[] navTitles = context.getResources().getStringArray(R.array.back_button_go_to_pages);
final String[] navTags = new String[3];
System.arraycopy(MainActivity.NAV_DRAWER_TAGS, 0, navTags, 0, 3);
final String[] navTags = context.getResources().getStringArray(R.array.back_button_go_to_pages_tags);
final String choice[] = { UserPreferences.getBackButtonGoToPage() };
AlertDialog.Builder builder = new AlertDialog.Builder(context);
@ -243,11 +242,7 @@ public class PreferenceController implements SharedPreferences.OnSharedPreferenc
choice[0] = navTags[i];
}
});
builder.setPositiveButton(R.string.confirm_label, (dialogInterface, i) -> {
if (!choice[0].equals(UserPreferences.getBackButtonGoToPage())) {
UserPreferences.setBackButtonGoToPage(choice[0]);
}
});
builder.setPositiveButton(R.string.confirm_label, (dialogInterface, i) -> UserPreferences.setBackButtonGoToPage(choice[0]));
builder.setNegativeButton(R.string.cancel_label, null);
builder.create().show();
return true;

View File

@ -299,4 +299,10 @@
<item>@string/episodes_label</item>
<item>@string/subscriptions_label</item>
</string-array>
<string-array name="back_button_go_to_pages_tags">
<item>QueueFragment</item>
<item>EpisodesFragment</item>
<item>SubscriptionFragment</item>
</string-array>
</resources>