Search in sources :

Example 1 with DownloadAdapter

use of com.zhan_dui.adapters.DownloadAdapter in project AnimeTaste by daimajia.

the class DownloadService method onCreate.

@Override
public void onCreate() {
    super.onCreate();
    missionAdapter = new DownloadAdapter(this);
}
Also used : DownloadAdapter(com.zhan_dui.adapters.DownloadAdapter)

Example 2 with DownloadAdapter

use of com.zhan_dui.adapters.DownloadAdapter 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)

Aggregations

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