use of com.ichi2.anki.CardBrowser.Column.DECK in project AnkiChinaAndroid by ankichinateam.
the class SchedV2 method _moveToDyn.
protected void _moveToDyn(long did, @NonNull List<Long> ids, int start) {
Deck deck = mCol.getDecks().get(did);
ArrayList<Object[]> data = new ArrayList<>();
int u = mCol.usn();
int due = start;
for (Long id : ids) {
data.add(new Object[] { did, due, u, id });
due += 1;
}
String queue = "";
if (!deck.getBoolean("resched")) {
queue = ", queue = " + Consts.QUEUE_TYPE_REV + "";
}
mCol.getDb().executeMany("UPDATE cards SET odid = did, " + "odue = due, did = ?, due = (case when due <= 0 then due else ? end), usn = ? " + queue + " WHERE id = ?", data);
}
use of com.ichi2.anki.CardBrowser.Column.DECK in project AnkiChinaAndroid by ankichinateam.
the class SchedV2 method rebuildDyn.
// Note: The original returns an integer result. We return List<Long> with that number to satisfy the
// interface requirements. The result isn't used anywhere so this isn't a problem.
// Overridden, because upstream implements exactly the same method in two different way for unknown reason
@Nullable
public List<Long> rebuildDyn(long did) {
if (did == 0) {
did = mCol.getDecks().selected();
}
Deck deck = mCol.getDecks().get(did);
if (deck.getInt("dyn") == 0) {
Timber.e("error: deck is not a filtered deck");
return null;
}
// move any existing cards back first, then fill
emptyDyn(did);
int cnt = _fillDyn(deck);
if (cnt == 0) {
return null;
}
// and change to our new deck
mCol.getDecks().select(did);
return Collections.singletonList((long) cnt);
}
use of com.ichi2.anki.CardBrowser.Column.DECK in project AnkiChinaAndroid by ankichinateam.
the class SchedV2 method _updateStats.
public void _updateStats(@NonNull Card card, @NonNull String type, long cnt) {
String key = type + "Today";
long did = card.getDid();
List<Deck> list = mCol.getDecks().parents(did);
list.add(mCol.getDecks().get(did));
for (Deck g : list) {
JSONArray a = g.getJSONArray(key);
// add
a.put(1, a.getLong(1) + cnt);
mCol.getDecks().save(g);
}
}
use of com.ichi2.anki.CardBrowser.Column.DECK in project AnkiChinaAndroid by ankichinateam.
the class SchedV2 method _lapseConf.
// Overridden: different delays for filtered cards.
@NonNull
protected JSONObject _lapseConf(@NonNull Card card) {
DeckConfig conf = _cardConf(card);
// normal deck
if (card.getODid() == 0) {
return conf.getJSONObject("lapse");
}
// dynamic deck; override some attributes, use original deck for others
DeckConfig oconf = mCol.getDecks().confForDid(card.getODid());
JSONObject dict = new JSONObject();
// original deck
dict.put("minInt", oconf.getJSONObject("lapse").getInt("minInt"));
dict.put("leechFails", oconf.getJSONObject("lapse").getInt("leechFails"));
dict.put("leechAction", oconf.getJSONObject("lapse").getInt("leechAction"));
dict.put("mult", oconf.getJSONObject("lapse").getDouble("mult"));
dict.put("delays", oconf.getJSONObject("lapse").getJSONArray("delays"));
// overrides
dict.put("resched", conf.getBoolean("resched"));
return dict;
}
use of com.ichi2.anki.CardBrowser.Column.DECK in project AnkiChinaAndroid by ankichinateam.
the class SchedV2 method _fillDyn.
/**
* Whether the filtered deck is empty
* Overriden
*/
private int _fillDyn(Deck deck) {
int start = -100000;
int total = 0;
JSONArray terms;
List<Long> ids;
terms = deck.getJSONArray("terms");
for (int i = 0; i < terms.length(); i++) {
JSONArray term = terms.getJSONArray(i);
String search = term.getString(0);
int limit = term.getInt(1);
int order = term.getInt(2);
String orderlimit = _dynOrder(order, limit);
if (!TextUtils.isEmpty(search.trim())) {
search = String.format(Locale.US, "(%s)", search);
}
search = String.format(Locale.US, "%s -is:suspended -is:buried -deck:filtered", search);
ids = mCol.findCards(search, orderlimit);
if (ids.isEmpty()) {
return total;
}
// move the cards over
mCol.log(deck.getLong("id"), ids);
_moveToDyn(deck.getLong("id"), ids, start + total);
total += ids.size();
}
return total;
}
Aggregations