-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d08acb2
commit a811f84
Showing
5 changed files
with
132 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
AnkiDroid/src/main/java/com/ichi2/libanki/DecksMetaData.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/* | ||
* Copyright (c) 2021 Prateek Singh <[email protected]> | ||
* | ||
* This program is free software; you can redistribute it and/or modify it under | ||
* the terms of the GNU General Public License as published by the Free Software | ||
* Foundation; either version 3 of the License, or (at your option) any later | ||
* version. | ||
* | ||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY | ||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A | ||
* PARTICULAR PURPOSE. See the GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License along with | ||
* this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package com.ichi2.libanki; | ||
|
||
import android.content.Context; | ||
import android.util.Log; | ||
import android.util.Pair; | ||
import android.widget.Toast; | ||
|
||
import com.ichi2.anki.CollectionHelper; | ||
import com.ichi2.libanki.sched.Counts; | ||
import com.ichi2.libanki.sched.DeckDueTreeNode; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
public class DecksMetaData { | ||
|
||
private final Decks mDecks; | ||
private final Collection mCollection; | ||
|
||
public DecksMetaData(Context context) { | ||
mCollection = CollectionHelper.getInstance().getCol(context); | ||
mDecks = mCollection.getDecks(); | ||
} | ||
|
||
/** | ||
* Total number of due cards and their expected time to compete. | ||
* @return Pair of Total Due Cards and Expected time to complete. <br> | ||
* <b>first</b> is due cards. <br> | ||
* <b>second</b> is Expected time. | ||
*/ | ||
public Pair<Integer, Integer> getTotalDueCards() { | ||
Counts total = new Counts(); | ||
// Ensure queues are reset if we cross over to the next day. | ||
mCollection.getSched()._checkDay(); | ||
|
||
// Only count the top-level decks in the total | ||
List<DeckDueTreeNode> nodes = mCollection.getSched().deckDueTree(); | ||
for (DeckDueTreeNode node : nodes) { | ||
total.addNew(node.getNewCount()); | ||
total.addLrn(node.getLrnCount()); | ||
total.addRev(node.getRevCount()); | ||
} | ||
int eta = mCollection.getSched().eta(total, false); | ||
Log.d("AABB", "getAllDeckNames: " + total.count() + " " + eta); | ||
return new Pair<>(total.count(), eta); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters