Skip to content

Commit

Permalink
Don't rely on onCreateOptionsMenu items in onCreate, Fixes #4977
Browse files Browse the repository at this point in the history
This may not be related to 27.0.2->27.1.1 support lib lifecycle changes,
and it may be present in other objects or have a better solution but this
fixes crash on opening CardBrowser with an empty collection
  • Loading branch information
mikehardy authored and timrae committed Sep 20, 2018
1 parent da1f19c commit 7c4878b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions AnkiDroid/src/main/java/com/ichi2/anki/CardBrowser.java
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,7 @@ protected void onResume() {

@Override
public boolean onCreateOptionsMenu(final Menu menu) {
Timber.d("onCreateOptionsMenu()");
mActionBarMenu = menu;
if (!mInMultiSelectMode) {
// restore drawer click listener and icon
Expand Down Expand Up @@ -1359,9 +1360,9 @@ public void onPreExecute() {
@Override
public void onPostExecute(TaskData result) {
if (result != null && mCards != null) {
Timber.i("CardBrowser:: Completed doInBackgroundSearchCards Successfuly");
Timber.i("CardBrowser:: Completed doInBackgroundSearchCards Successfully");
updateList();
if (!mSearchView.isIconified()) {
if ((mSearchView != null) && !mSearchView.isIconified()) {
UIUtils.showSimpleSnackbar(CardBrowser.this, getSubtitleText(), true);
}
}
Expand Down
4 changes: 2 additions & 2 deletions AnkiDroid/src/main/java/com/ichi2/async/DeckTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -217,14 +217,14 @@ protected TaskData doInBackground(TaskData... params) {
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
// We have been interrupted, return immediately.
Timber.e(e, "interrupted while waiting for previous task: %d", mPreviousTask.mType);
Timber.d(e, "interrupted while waiting for previous task: %d", mPreviousTask.mType);
return null;
} catch (ExecutionException e) {
// Ignore failures in the previous task.
Timber.e(e, "previously running task failed with exception: %d", mPreviousTask.mType);
} catch (CancellationException e) {
// Ignore cancellation of previous task
Timber.e(e, "previously running task was cancelled: %d", mPreviousTask.mType);
Timber.d(e, "previously running task was cancelled: %d", mPreviousTask.mType);
}
}
sLatestInstance = this;
Expand Down

0 comments on commit 7c4878b

Please sign in to comment.