use of com.ichi2.anim.ActivityTransitionAnimation.Direction.START in project Anki-Android by ankidroid.
the class SchedTest method test_reorderV1.
@Test
public void test_reorderV1() throws Exception {
Collection col = getColV1();
// add a note with default deck
Note note = col.newNote();
note.setItem("Front", "one");
col.addNote(note);
Note note2 = col.newNote();
note2.setItem("Front", "two");
col.addNote(note2);
assertEquals(2, note2.cards().get(0).getDue());
boolean found = false;
// 50/50 chance of being reordered
for (int i = 0; i < 20; i++) {
col.getSched().randomizeCards(1);
if (note.cards().get(0).getDue() != note.getId()) {
found = true;
break;
}
}
assertTrue(found);
col.getSched().orderCards(1);
assertEquals(1, note.cards().get(0).getDue());
// shifting
Note note3 = col.newNote();
note3.setItem("Front", "three");
col.addNote(note3);
Note note4 = col.newNote();
note4.setItem("Front", "four");
col.addNote(note4);
assertEquals(1, note.cards().get(0).getDue());
assertEquals(2, note2.cards().get(0).getDue());
assertEquals(3, note3.cards().get(0).getDue());
assertEquals(4, note4.cards().get(0).getDue());
/* todo sortCard
col.getSched().sortCards(new long [] {note3.cards().get(0).getId(), note4.cards().get(0).getId()}, start=1, shift=true);
assertEquals(3, note.cards().get(0).getDue());
assertEquals(4, note2.cards().get(0).getDue());
assertEquals(1, note3.cards().get(0).getDue());
assertEquals(2, note4.cards().get(0).getDue());
*/
}
use of com.ichi2.anim.ActivityTransitionAnimation.Direction.START in project Anki-Android by ankidroid.
the class TemplateTest method missingExclamation.
@Test
@Config(qualifiers = "en")
public void missingExclamation() {
// Ankidroid used not to display fields whose name start with !
HashMap<String, String> context = new HashMap<>();
String rendered = render("{{!Front}}", context);
assertThat(rendered, is(notNullValue()));
assertThat(rendered, containsString("there is no field called '!Front'"));
}
use of com.ichi2.anim.ActivityTransitionAnimation.Direction.START in project Anki-Android by ankidroid.
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<>(ids.size());
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.anim.ActivityTransitionAnimation.Direction.START in project Anki-Android by ankidroid.
the class SchedV2 method _fillDyn.
/**
* Whether the filtered deck is empty
* Overriden
*/
private int _fillDyn(Deck deck) {
int start = -100000;
int total = 0;
List<Long> ids;
JSONArray terms = deck.getJSONArray("terms");
for (JSONArray term : terms.jsonArrayIterable()) {
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, new SortOrder.AfterSqlOrderBy(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;
}
use of com.ichi2.anim.ActivityTransitionAnimation.Direction.START in project Anki-Android by ankidroid.
the class IntentHandler method handleFileImport.
private void handleFileImport(Intent intent, Intent reloadIntent, String action) {
Timber.i("Handling file import");
ImportResult importResult = ImportUtils.handleFileImport(this, intent);
// Start DeckPicker if we correctly processed ACTION_VIEW
if (importResult.isSuccess()) {
Timber.d("onCreate() import successful");
reloadIntent.setAction(action);
reloadIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(reloadIntent);
AnkiActivity.finishActivityWithFade(this);
} else {
Timber.i("File import failed");
// Don't import the file if it didn't load properly or doesn't have apkg extension
ImportUtils.showImportUnsuccessfulDialog(this, importResult.getHumanReadableMessage(), true);
}
}
Aggregations