NullPointerException and NumberFormatException
This commit is contained in:
@@ -500,15 +500,19 @@ public class MainActivity extends AppCompatActivity
|
||||
case FRAGMENT_CANTEENS_DETAILS:
|
||||
getCanteenBrowser().getCanteens(success -> {
|
||||
int size = mNavigationView.getMenu().size();
|
||||
Canteen canteen = success.getCanteen(Integer.parseInt(mFragmentData));
|
||||
//noinspection ConstantConditions
|
||||
String title = canteen == null ? null : canteen.getName();
|
||||
for (int k = 0; k < size; k++) {
|
||||
MenuItem menuItem = mNavigationView.getMenu().getItem(k);
|
||||
if (menuItem.getTitle().equals(title)) {
|
||||
menuItem.setChecked(true);
|
||||
break;
|
||||
try {
|
||||
Canteen canteen = success.getCanteen(Integer.parseInt(mFragmentData));
|
||||
//noinspection ConstantConditions
|
||||
String title = canteen == null ? null : canteen.getName();
|
||||
for (int k = 0; k < size; k++) {
|
||||
MenuItem menuItem = mNavigationView.getMenu().getItem(k);
|
||||
if (menuItem.getTitle().equals(title)) {
|
||||
menuItem.setChecked(true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}, log::e);
|
||||
return;
|
||||
|
||||
@@ -53,14 +53,16 @@ public class PrefsFragment extends PreferenceFragmentCompat implements SharedPre
|
||||
|
||||
if (getActivity() != null && getActivity() instanceof MainActivity) {
|
||||
CustomAccountManager accountManager = ((MainActivity) getActivity()).getAccountManager();
|
||||
Account accountByType = accountManager.getAccountByType(AccountGeneral.ACCOUNT_TYPE);
|
||||
if (accountByType != null) {
|
||||
ContentResolver.setSyncAutomatically(accountByType, KVVContentProvider.PROVIDER_NAME, true);
|
||||
ContentResolver.addPeriodicSync(
|
||||
accountByType,
|
||||
KVVContentProvider.PROVIDER_NAME,
|
||||
Bundle.EMPTY,
|
||||
Long.parseLong(Preferences.getStringArray(getActivity(), R.array.pref_sync_frequency)));
|
||||
if (accountManager != null) {
|
||||
Account accountByType = accountManager.getAccountByType(AccountGeneral.ACCOUNT_TYPE);
|
||||
if (accountByType != null) {
|
||||
ContentResolver.setSyncAutomatically(accountByType, KVVContentProvider.PROVIDER_NAME, true);
|
||||
ContentResolver.addPeriodicSync(
|
||||
accountByType,
|
||||
KVVContentProvider.PROVIDER_NAME,
|
||||
Bundle.EMPTY,
|
||||
Long.parseLong(Preferences.getStringArray(getActivity(), R.array.pref_sync_frequency)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user