Skip to content

Commit

Permalink
Avoid loading collections when not needed
Browse files Browse the repository at this point in the history
Collection loading logic was a bit disjointed between super- and
sub-class, this puts it one place, and makes sure we won't load
the collection unless we're going to actually create the activity

This is the final part that Fixes #4987
  • Loading branch information
mikehardy authored and timrae committed Oct 16, 2018
1 parent bb4af60 commit aa26dbe
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -823,8 +823,6 @@ protected void onCreate(Bundle savedInstanceState) {

View mainView = findViewById(android.R.id.content);
initNavigationDrawer(mainView);
// Open collection asynchronously
startLoadingCollection();
}

protected int getContentViewAttr(int fullscreenMode) {
Expand Down
5 changes: 4 additions & 1 deletion AnkiDroid/src/main/java/com/ichi2/anki/Previewer.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,19 @@ public class Previewer extends AbstractFlashcardViewer {
@Override
protected void onCreate(Bundle savedInstanceState) {
Timber.d("onCreate()");
super.onCreate(savedInstanceState);

mCardList = getIntent().getLongArrayExtra("cardList");
mIndex = getIntent().getIntExtra("index", -1);
if (mCardList.length == 0 || mIndex < 0 || mIndex > mCardList.length - 1) {
Timber.e("Previewer started with empty card list or invalid index");
finishWithoutAnimation();
return;
}
super.onCreate(savedInstanceState);
showBackIcon();
// Ensure navigation drawer can't be opened. Various actions in the drawer cause crashes.
disableDrawerSwipe();
startLoadingCollection();
}

@Override
Expand Down
3 changes: 2 additions & 1 deletion AnkiDroid/src/main/java/com/ichi2/anki/Reviewer.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,14 @@ public class Reviewer extends AbstractFlashcardViewer {
@Override
protected void onCreate(Bundle savedInstanceState) {
Timber.d("onCreate()");
super.onCreate(savedInstanceState);

if (Intent.ACTION_VIEW.equals(getIntent().getAction())) {
Timber.d("onCreate() :: received Intent with action = %s", getIntent().getAction());
selectDeckFromExtra();
}

super.onCreate(savedInstanceState);
startLoadingCollection();
}

private void selectDeckFromExtra() {
Expand Down

0 comments on commit aa26dbe

Please # to comment.