Search in sources :

Example 41 with TaskData

use of com.ichi2.async.TaskData in project AnkiChinaAndroid by ankichinateam.

the class DeckPickerCheckDatabaseListenerTest method validResultWithValidDataWillDisplayMessageBox.

@Test
public void validResultWithValidDataWillDisplayMessageBox() {
    CheckDatabaseResult validData = validData();
    TaskData result = validResultWithData(validData);
    execute(result);
    assertThat("Load Failed dialog should not be shown if invalid data is supplied", !impl.didDisplayDialogLoadFailed());
    assertThat("Dialog should be displayed", impl.didDisplayMessage());
}
Also used : CheckDatabaseResult(com.ichi2.libanki.Collection.CheckDatabaseResult) TaskData(com.ichi2.async.TaskData) Test(org.junit.Test)

Example 42 with TaskData

use of com.ichi2.async.TaskData in project AnkiChinaAndroid by ankichinateam.

the class DeckPickerCheckDatabaseListenerTest method failedResultWithEmptyDataWillDisplayFailedDialog.

@Test
public void failedResultWithEmptyDataWillDisplayFailedDialog() {
    TaskData result = failedResultWithData();
    execute(result);
    assertThat("Load Failed dialog should be shown if empty data is supplied", impl.didDisplayDialogLoadFailed());
}
Also used : TaskData(com.ichi2.async.TaskData) Test(org.junit.Test)

Example 43 with TaskData

use of com.ichi2.async.TaskData in project AnkiChinaAndroid by ankichinateam.

the class DeckPickerCheckDatabaseListenerTest method validResultWithFailedDatabaseWillShowFailedDialog.

@Test
public void validResultWithFailedDatabaseWillShowFailedDialog() {
    CheckDatabaseResult failedDb = failedDatabase();
    TaskData result = validResultWithData(failedDb);
    execute(result);
    assertThat("Load Failed dialog should be shown if failed data is supplied", impl.didDisplayDialogLoadFailed());
    assertThat("Locked Database dialog should be shown if Db was locked", !impl.didDisplayLockedDialog());
    assertThat("Dialog should not be displayed", !impl.didDisplayMessage());
}
Also used : CheckDatabaseResult(com.ichi2.libanki.Collection.CheckDatabaseResult) TaskData(com.ichi2.async.TaskData) Test(org.junit.Test)

Example 44 with TaskData

use of com.ichi2.async.TaskData in project AnkiChinaAndroid by ankichinateam.

the class DeckPickerCheckDatabaseListenerTest method validResultWithEmptyDataWillDoNothing.

@Test
public void validResultWithEmptyDataWillDoNothing() {
    TaskData result = validResultWithData();
    execute(result);
    assertThat("Nothing should be shown if valid, but no data supplied", !impl.didDisplayDialogLoadFailed());
    assertThat("Nothing should be shown if valid, but no data supplied", !impl.didDisplayLockedDialog());
    assertThat("Nothing should be shown if valid, but no data supplied", !impl.didDisplayMessage());
}
Also used : TaskData(com.ichi2.async.TaskData) Test(org.junit.Test)

Example 45 with TaskData

use of com.ichi2.async.TaskData in project Anki-Android by Ramblurr.

the class DeckTask method doInBackgroundSaveCollection.

private TaskData doInBackgroundSaveCollection(TaskData... params) {
    Log.i(AnkiDroidApp.TAG, "doInBackgroundSaveCollection");
    Collection col = params[0].getCollection();
    if (col != null) {
        try {
            col.save();
        } catch (RuntimeException e) {
            Log.e(AnkiDroidApp.TAG, "Error on saving deck in background: " + e);
        }
    }
    return null;
}
Also used : Collection(com.ichi2.libanki.Collection)

Aggregations

Collection (com.ichi2.libanki.Collection)67 TaskData (com.ichi2.async.TaskData)46 JSONObject (com.ichi2.utils.JSONObject)35 Card (com.ichi2.libanki.Card)16 JSONException (com.ichi2.utils.JSONException)15 ArrayList (java.util.ArrayList)14 JSONObject (org.json.JSONObject)13 Resources (android.content.res.Resources)12 HashMap (java.util.HashMap)12 SharedPreferences (android.content.SharedPreferences)11 Deck (com.ichi2.libanki.Deck)11 Intent (android.content.Intent)10 View (android.view.View)9 TextView (android.widget.TextView)9 ConfirmationDialog (com.ichi2.anki.dialogs.ConfirmationDialog)9 TaskListener (com.ichi2.async.TaskListener)9 Map (java.util.Map)9 VisibleForTesting (androidx.annotation.VisibleForTesting)8 CollectionTask (com.ichi2.async.CollectionTask)8 IOException (java.io.IOException)8