Search in sources :

Example 1 with Delete

use of com.activeandroid.query.Delete in project AnimeTaste by daimajia.

the class DownloadRecord method deleteAll.

public static void deleteAll() {
    List<DownloadRecord> records = new Select().from(DownloadRecord.class).execute();
    for (int i = 0; i < records.size(); i++) {
        DownloadRecord r = records.get(i);
        String p = r.SaveDir + r.SaveFileName;
        File f = new File(p);
        if (f.exists() && f.isFile()) {
            f.delete();
        }
    }
    new Delete().from(DownloadRecord.class).execute();
}
Also used : Delete(com.activeandroid.query.Delete) Select(com.activeandroid.query.Select) File(java.io.File)

Example 2 with Delete

use of com.activeandroid.query.Delete in project xDrip-plus by jamorham.

the class UploaderQueue method cleanQueue.

public static void cleanQueue() {
    // delete all completed records > 24 hours old
    fixUpTable();
    try {
        new Delete().from(UploaderQueue.class).where("timestamp < ?", JoH.tsl() - 86400000L).where("bitfield_wanted == bitfield_complete").execute();
        // delete everything > 7 days old
        new Delete().from(UploaderQueue.class).where("timestamp < ?", JoH.tsl() - 86400000L * 7L).execute();
    } catch (Exception e) {
        UserError.Log.d(TAG, "Exception cleaning uploader queue: " + e);
    }
    last_cleanup = JoH.tsl();
}
Also used : Delete(com.activeandroid.query.Delete) JSONException(org.json.JSONException)

Example 3 with Delete

use of com.activeandroid.query.Delete in project AnimeTaste by daimajia.

the class DownloadActivity method onItemLongClick.

@Override
public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
    Object obj = mDownloadList.getAdapter().getItem(position);
    if (obj instanceof Mission) {
        final Mission m = (Mission) obj;
        show(R.string.tip, getString(R.string.stop_mission, m.getSaveName()), new DialogInterface.OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {
                mBinder.stopMission(m.getMissionID());
            }
        });
    } else if (obj instanceof DownloadRecord) {
        final DownloadRecord r = (DownloadRecord) obj;
        String msg = getString(R.string.surely_delete, r.Name);
        show(R.string.tip, msg, new DialogInterface.OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {
                String path = r.SaveDir + r.SaveFileName;
                File f = new File(path);
                if (f.exists() && f.isFile()) {
                    f.delete();
                }
                new Delete().from(DownloadRecord.class).where("AnimationId = ?", r.AnimationId).executeSingle();
                DownloadAdapter adapter = (DownloadAdapter) mDownloadList.getAdapter();
                adapter.reloadData();
            }
        });
    }
    return true;
}
Also used : Delete(com.activeandroid.query.Delete) DialogInterface(android.content.DialogInterface) Mission(com.zhan_dui.download.alfred.missions.Mission) DownloadAdapter(com.zhan_dui.adapters.DownloadAdapter) File(java.io.File) DownloadRecord(com.zhan_dui.model.DownloadRecord)

Example 4 with Delete

use of com.activeandroid.query.Delete in project xDrip by NightscoutFoundation.

the class UploaderQueue method cleanQueue.

public static void cleanQueue() {
    // delete all completed records > 24 hours old
    fixUpTable();
    try {
        new Delete().from(UploaderQueue.class).where("timestamp < ?", JoH.tsl() - 86400000L).where("bitfield_wanted == bitfield_complete").execute();
        // delete everything > 7 days old
        new Delete().from(UploaderQueue.class).where("timestamp < ?", JoH.tsl() - 86400000L * 7L).execute();
    } catch (Exception e) {
        UserError.Log.d(TAG, "Exception cleaning uploader queue: " + e);
    }
    last_cleanup = JoH.tsl();
}
Also used : Delete(com.activeandroid.query.Delete) JSONException(org.json.JSONException)

Example 5 with Delete

use of com.activeandroid.query.Delete in project ActiveAndroid by pardom.

the class Model method delete.

// Convenience methods
public static void delete(Class<? extends Model> type, long id) {
    TableInfo tableInfo = Cache.getTableInfo(type);
    new Delete().from(type).where(tableInfo.getIdName() + "=?", id).execute();
}
Also used : Delete(com.activeandroid.query.Delete)

Aggregations

Delete (com.activeandroid.query.Delete)5 File (java.io.File)2 JSONException (org.json.JSONException)2 DialogInterface (android.content.DialogInterface)1 Select (com.activeandroid.query.Select)1 DownloadAdapter (com.zhan_dui.adapters.DownloadAdapter)1 Mission (com.zhan_dui.download.alfred.missions.Mission)1 DownloadRecord (com.zhan_dui.model.DownloadRecord)1