Search in sources :

Example 1 with PendingCommandSerializer

use of com.fsck.k9.controller.PendingCommandSerializer in project k-9 by k9mail.

the class MigrationTo60 method migratePendingCommands.

public static void migratePendingCommands(SQLiteDatabase db) {
    List<PendingCommand> pendingCommands = new ArrayList<>();
    if (columnExists(db, "pending_commands", "arguments")) {
        for (OldPendingCommand oldPendingCommand : getPendingCommands(db)) {
            PendingCommand newPendingCommand = migratePendingCommand(oldPendingCommand);
            pendingCommands.add(newPendingCommand);
        }
        db.execSQL("DROP TABLE IF EXISTS pending_commands");
        db.execSQL("CREATE TABLE pending_commands (" + "id INTEGER PRIMARY KEY, " + "command TEXT, " + "data TEXT" + ")");
        PendingCommandSerializer pendingCommandSerializer = PendingCommandSerializer.getInstance();
        for (PendingCommand pendingCommand : pendingCommands) {
            ContentValues cv = new ContentValues();
            cv.put("command", pendingCommand.getCommandName());
            cv.put("data", pendingCommandSerializer.serialize(pendingCommand));
            db.insert("pending_commands", "command", cv);
        }
    }
}
Also used : ContentValues(android.content.ContentValues) ArrayList(java.util.ArrayList) PendingCommandSerializer(com.fsck.k9.controller.PendingCommandSerializer) PendingCommand(com.fsck.k9.controller.MessagingControllerCommands.PendingCommand)

Aggregations

ContentValues (android.content.ContentValues)1 PendingCommand (com.fsck.k9.controller.MessagingControllerCommands.PendingCommand)1 PendingCommandSerializer (com.fsck.k9.controller.PendingCommandSerializer)1 ArrayList (java.util.ArrayList)1