Skip to content
Permalink
Browse files

Catch exception noted in crash logs

```
Caused by: java.lang.ArrayIndexOutOfBoundsException:
  at com.gelakinetic.mtgfam.fragments.SearchViewFragment.parseForm (SearchViewFragment.java:721)
  at com.gelakinetic.mtgfam.fragments.SearchViewFragment.onPause (SearchViewFragment.java:492)
  at android.support.v4.app.Fragment.performPause (Fragment.java:2531)
  at android.support.v4.app.FragmentManagerImpl.moveToState (FragmentManager.java:1485)
  at android.support.v4.app.FragmentManagerImpl.moveFragmentToExpectedState (FragmentManager.java:1759)
  at android.support.v4.app.FragmentManagerImpl.moveToState (FragmentManager.java:1827)
  at android.support.v4.app.FragmentManagerImpl.dispatchStateChange (FragmentManager.java:3244)
  at android.support.v4.app.FragmentManagerImpl.dispatchPause (FragmentManager.java:3216)
  at android.support.v4.app.FragmentController.dispatchPause (FragmentController.java:228)
  at android.support.v4.app.FragmentActivity.onPause (FragmentActivity.java:447)
  at android.app.Activity.performPause (Activity.java:7143)
  at android.app.Instrumentation.callActivityOnPause (Instrumentation.java:1408)
  at android.app.ActivityThread.performPauseActivityIfNeeded (ActivityThread.java:3901)
  ```
  • Loading branch information...
AEFeinstein committed Aug 7, 2018
1 parent 069d632 commit 525d11e05fc8d0c4337f71360160cfa2d086d1d5
Showing with 14 additions and 6 deletions.
  1. +14 −6 mobile/src/main/java/com/gelakinetic/mtgfam/fragments/SearchViewFragment.java
@@ -489,7 +489,11 @@ public String getItem(int position) {
public void onPause() {
super.onPause();
// Save the search criteria
PreferenceAdapter.setSearchViewCriteria(getContext(), parseForm());
try {
PreferenceAdapter.setSearchViewCriteria(getContext(), parseForm());
} catch (ArrayIndexOutOfBoundsException | NullPointerException e) {
/* Eat it */
}
}

/**
@@ -526,17 +530,21 @@ public void onSaveInstanceState(@NonNull Bundle outState) {
private void doSearch() {
Bundle args = new Bundle();
args.putBoolean(CRITERIA_FLAG, true);
PreferenceAdapter.setSearchCriteria(getContext(), parseForm());
ResultListFragment rlFrag = new ResultListFragment();
startNewFragment(rlFrag, args);
try {
PreferenceAdapter.setSearchCriteria(getContext(), parseForm());
ResultListFragment rlFrag = new ResultListFragment();
startNewFragment(rlFrag, args);
} catch (ArrayIndexOutOfBoundsException | NullPointerException e) {
SnackbarWrapper.makeAndShowText(getActivity(), R.string.judges_corner_error, SnackbarWrapper.LENGTH_SHORT);
}
}

/**
* This function combs through all the UI elements and returns a SearchCriteria with the current search options
*
* @return a SearchCriteria with what the user wants to search for
*/
private SearchCriteria parseForm() {
private SearchCriteria parseForm() throws ArrayIndexOutOfBoundsException, NullPointerException {
SearchCriteria searchCriteria = new SearchCriteria();

/* Because Android Studio whines */
@@ -835,7 +843,7 @@ private void persistOptions() {
ObjectOutputStream os = new ObjectOutputStream(fileStream);
os.writeObject(parseForm());
os.close();
} catch (IOException e) {
} catch (IOException | ArrayIndexOutOfBoundsException | NullPointerException e) {
SnackbarWrapper.makeAndShowText(this.getActivity(), R.string.search_toast_cannot_save, SnackbarWrapper.LENGTH_LONG);
}
}

0 comments on commit 525d11e

Please sign in to comment.
You can’t perform that action at this time.