Java Code Examples for org.xutils.ex.DbException

The following examples show how to use org.xutils.ex.DbException. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: AndroidDownload   Source File: DownLoadModelImp.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public Boolean deleTask(DownloadTaskEntity task, Boolean deleFile) {
    try {
        DBTools.getInstance().db().delete(task);
        if(deleFile){
            if(task.getFile()){
                FileTools.deleteFile(task.getLocalPath()+ File.separator+task.getmFileName());
            }else{
                FileTools.deleteDir(task.getLocalPath());
            }
        }
    } catch (DbException e) {
        e.printStackTrace();
        return false;
    }
    return true;
}
 
Example 2
Source Project: DelegateAdapter   Source File: PhotoManager.java    License: Apache License 2.0 6 votes vote down vote up
public boolean isDownloadComplete (Photo photo) {
    try {
        PhotoEntity entity = mDb.selector(PhotoEntity.class).where("id", "=", photo.id).findFirst();
        List<PhotoEntity> entities = mDb.selector(PhotoEntity.class).findAll();
        if (entities != null) {
            for (PhotoEntity p : entities) {
                Log.v(TAG, "isDownloadComplete p.id=" + p.id);
            }
        }
        Log.v(TAG, "isDownloadComplete entity=" + entity);
        if (entity == null) {
            return false;
        }
        if (entity.state == PhotoEntity.STATE_FINISHED) {
            return getFile(photo).exists();
        }
    } catch (DbException e) {
        e.printStackTrace();
    }
    return false;
}
 
Example 3
Source Project: HHComicViewer   Source File: ComicDBHelper.java    License: Apache License 2.0 6 votes vote down vote up
public synchronized void add(Comic comic) {
    try {
        if (comic.isMark() || comic.isDownload()) {
            if (comic.getChapterNameList() == null || "".equals(comic.getChapterNameList())) {
                comic.saveChapterNameList();
            }
            if (comic.getChapterIdList() == null || "".equals(comic.getChapterIdList())) {
                comic.saveChapterIdList();
            }
        }
        if (comic.isUpdate()) {
            comic.saveChapterNameList();
            comic.saveChapterIdList();
        }
        sDb.save(comic);
    } catch (DbException e) {
        e.printStackTrace();
    }
}
 
Example 4
Source Project: HHComicViewer   Source File: ComicDBHelper.java    License: Apache License 2.0 6 votes vote down vote up
public synchronized void update(Comic comic) {
    try {
        if (comic.isMark() || comic.isDownload()) {
            if (comic.getChapterNameList() == null || "".equals(comic.getChapterNameList())) {
                comic.saveChapterNameList();
            }
            if (comic.getChapterIdList() == null || "".equals(comic.getChapterIdList())) {
                comic.saveChapterIdList();
            }
        }
        if (comic.isUpdate()) {
            comic.saveChapterNameList();
            comic.saveChapterIdList();
            comic.setUpdate(false);
        }
        sDb.update(comic);
    } catch (DbException e) {
        e.printStackTrace();
    }
}
 
Example 5
Source Project: HHComicViewer   Source File: DownloadThreadDBHelper.java    License: Apache License 2.0 6 votes vote down vote up
public List<ThreadInfo> findByChapterUrl(long chid) {
    List<ThreadInfo> threadInfos = new ArrayList<>();
    ThreadInfo threadInfo;
    try {
        List<DbModel> dbModels = sDb.findDbModelAll(new SqlInfo("select * from thread_info where chid = " +
                "'" + chid + "'"));
        for (DbModel dbModel : dbModels) {
            threadInfo = new ThreadInfo();
            threadInfo.setId(dbModel.getInt("id"));
            threadInfo.setThreadPosition(dbModel.getInt("thread_position"));
            threadInfo.setThreadCount(dbModel.getInt("thread_count"));
            threadInfo.setDownloadPosition(dbModel.getInt("download_position"));
            threadInfo.setLength(dbModel.getInt("length"));
            threadInfo.setFinished(dbModel.getInt("finished"));
            threadInfo.setChid(dbModel.getLong("chid"));
            threadInfos.add(threadInfo);
        }
    } catch (DbException e) {
        e.printStackTrace();
        return null;
    }
    return threadInfos;
}
 
Example 6
Source Project: AndroidDownload   Source File: AppSettingModelImp.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public List<AppSettingEntity> findAllSetting() {
    try {
        return DBTools.getInstance().db().findAll(AppSettingEntity.class);
    } catch (DbException e) {
        e.printStackTrace();
    }
    return null;
}
 
Example 7
Source Project: AndroidDownload   Source File: AppSettingModelImp.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void saveOrUploadSteeing(AppSettingEntity setting) {
    try {
        DBTools.getInstance().db().saveOrUpdate(setting);
    } catch (DbException e) {
        e.printStackTrace();
    }
}
 
Example 8
Source Project: AndroidDownload   Source File: AppSettingModelImp.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public AppSettingEntity getSavePath() {
    try {
       return DBTools.getInstance().db().selector(AppSettingEntity.class).where("key","=", Const.SAVE_PATH_KEY).findFirst();
    } catch (DbException e) {
        e.printStackTrace();
    }
    return null;
}
 
Example 9
Source Project: AndroidDownload   Source File: AppSettingModelImp.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public AppSettingEntity getDownCount() {
    try {
        return DBTools.getInstance().db().selector(AppSettingEntity.class).where("key","=", Const.DOWN_COUNT_KEY).findFirst();
    } catch (DbException e) {
        e.printStackTrace();
    }
    return null;
}
 
Example 10
Source Project: AndroidDownload   Source File: AppSettingModelImp.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public AppSettingEntity getMobileNet() {
    try {
        return DBTools.getInstance().db().selector(AppSettingEntity.class).where("key","=", Const.MOBILE_NET_KEY).findFirst();
    } catch (DbException e) {
        e.printStackTrace();
    }
    return null;
}
 
Example 11
Source Project: AndroidDownload   Source File: AppSettingModelImp.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public AppSettingEntity getDownNotify() {
    try {
        return DBTools.getInstance().db().selector(AppSettingEntity.class).where("key","=", Const.DOWN_NOTIFY_KEY).findFirst();
    } catch (DbException e) {
        e.printStackTrace();
    }
    return null;
}
 
Example 12
Source Project: AndroidDownload   Source File: PlayerVideoModelImp.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public List<PlayerVideoEntity> findAllVideo(){
    try {
        return DBTools.getInstance().db().selector(PlayerVideoEntity.class).findAll();
    } catch (DbException e) {
        e.printStackTrace();
    }
    return null;
}
 
Example 13
Source Project: AndroidDownload   Source File: PlayerVideoModelImp.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public List<PlayerVideoEntity> findVideoByPath(String path) {
    try {
        return DBTools.getInstance().db().selector(PlayerVideoEntity.class).where("localPath", "=", path).findAll();
    } catch (DbException e) {
        e.printStackTrace();
    }
    return null;
}
 
Example 14
Source Project: AndroidDownload   Source File: PlayerVideoModelImp.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public PlayerVideoEntity findVideoById(int id) {
    try {
        return DBTools.getInstance().db().findById(PlayerVideoEntity.class,id);
    } catch (DbException e) {
        e.printStackTrace();
    }
    return null;
}
 
Example 15
Source Project: AndroidDownload   Source File: PlayerVideoModelImp.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public PlayerVideoEntity saveOrUpdata(PlayerVideoEntity video) {
    try {
        DBTools.getInstance().db().saveOrUpdate(video);
    } catch (DbException e) {
        e.printStackTrace();
    }
    return video;
}
 
Example 16
Source Project: AndroidDownload   Source File: PlayerVideoModelImp.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public PlayerVideoEntity upDataVideo(PlayerVideoEntity video) {
    try {
        DBTools.getInstance().db().saveOrUpdate(video);
    } catch (DbException e) {
        e.printStackTrace();
    }
    return video;
}
 
Example 17
Source Project: AndroidDownload   Source File: PlayerVideoModelImp.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public Boolean deleVideo(PlayerVideoEntity video) {
    try {
        DBTools.getInstance().db().delete(video);
        return true;
    } catch (DbException e) {
        e.printStackTrace();
    }
    return false;
}
 
Example 18
Source Project: AndroidDownload   Source File: TaskModelImp.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public List<DownloadTaskEntity> findAllTask(){
    try {
        return DBTools.getInstance().db().selector(DownloadTaskEntity.class).findAll();
    } catch (DbException e) {
        e.printStackTrace();
    }
    return null;
}
 
Example 19
Source Project: AndroidDownload   Source File: TaskModelImp.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public DownloadTaskEntity findTaskById(int id) {
    try {
        return DBTools.getInstance().db().findById(DownloadTaskEntity.class,id);
    } catch (DbException e) {
        e.printStackTrace();
    }
    return null;
}
 
Example 20
Source Project: AndroidDownload   Source File: TaskModelImp.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public List<DownloadTaskEntity> findTaskByUrl(String url) {
    try {
        return DBTools.getInstance().db().selector(DownloadTaskEntity.class).where("url", "=", url).findAll();
    } catch (DbException e) {
        e.printStackTrace();
    }
    return null;
}
 
Example 21
Source Project: AndroidDownload   Source File: TaskModelImp.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public List<DownloadTaskEntity> findTaskByHash(String hash) {
    try {
        return DBTools.getInstance().db().selector(DownloadTaskEntity.class).where("hash", "=", hash).findAll();
    } catch (DbException e) {
        e.printStackTrace();
    }
    return null;
}
 
Example 22
Source Project: AndroidDownload   Source File: TaskModelImp.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public List<DownloadTaskEntity> findLoadingTask() {
    try {
        return DBTools.getInstance().db().selector(DownloadTaskEntity.class)
                .where("mTaskStatus", "<>", Const.DOWNLOAD_SUCCESS)
                .orderBy("createDate",true)
                .findAll();
    } catch (DbException e) {
        e.printStackTrace();
    }
    return null;
}
 
Example 23
Source Project: AndroidDownload   Source File: TaskModelImp.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public List<DownloadTaskEntity> findDowningTask() {
    try {
        return DBTools.getInstance().db().selector(DownloadTaskEntity.class)
                .where("mTaskStatus", "in",new int[]{ Const.DOWNLOAD_LOADING,Const.DOWNLOAD_CONNECTION})
                .and("taskId", "<>", 0)
               // .and("mTaskStatus", "=", Const.DOWNLOAD_FAIL)
                .findAll();
    } catch (DbException e) {
        e.printStackTrace();
    }
    return null;
}
 
Example 24
Source Project: AndroidDownload   Source File: TaskModelImp.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public List<DownloadTaskEntity> findSuccessTask() {
    try {
        return DBTools.getInstance().db().selector(DownloadTaskEntity.class)
                .where("mTaskStatus", "=", Const.DOWNLOAD_SUCCESS)
                .orderBy("createDate",true)
                .findAll();
    } catch (DbException e) {
        e.printStackTrace();
    }
    return null;
}
 
Example 25
Source Project: AndroidDownload   Source File: TaskModelImp.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public DownloadTaskEntity upDataTask(DownloadTaskEntity task) {
    try {
        DBTools.getInstance().db().saveOrUpdate(task);
    } catch (DbException e) {
        e.printStackTrace();
    }
    return task;
}
 
Example 26
Source Project: AndroidDownload   Source File: TaskModelImp.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public Boolean deleTask(DownloadTaskEntity task) {
    try {
        DBTools.getInstance().db().delete(task);
        return true;
    } catch (DbException e) {
        e.printStackTrace();
    }
    return false;
}
 
Example 27
Source Project: AndroidDownload   Source File: DownLoadModelImp.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public Boolean startTorrentTask(DownloadTaskEntity bt) {
    String path=bt.getUrl();
    try {
        DBTools.getInstance().db().delete(bt);
    } catch (DbException e) {
        e.printStackTrace();
    }
    return startTorrentTask(path,null);
}
 
Example 28
Source Project: AndroidDownload   Source File: DownLoadModelImp.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public Boolean stopTask(DownloadTaskEntity task) {
    try {
        XLTaskHelper.instance(x.app().getApplicationContext()).stopTask(task.getTaskId());
        task.setmTaskStatus(Const.DOWNLOAD_STOP);
        task.setmDownloadSpeed(0);
        task.setmDCDNSpeed(0);
        DBTools.getInstance().db().saveOrUpdate(task);
    } catch (DbException e) {
        e.printStackTrace();
        return false;
    }
    return true;
}
 
Example 29
Source Project: DelegateAdapter   Source File: PhotoManager.java    License: Apache License 2.0 5 votes vote down vote up
public void onStart (Photo photo) {
    Log.v (TAG, "onStart photo.id=" + photo.id);
    PhotoEntity entity = new PhotoEntity(photo);
    entity.state = PhotoEntity.STATE_STARTED;
    try {
        mDb.save(entity);
    } catch (DbException e) {
        e.printStackTrace();
    }
}
 
Example 30
Source Project: DelegateAdapter   Source File: PhotoManager.java    License: Apache License 2.0 5 votes vote down vote up
public void onFinish (Photo photo) {
    Log.v (TAG, "onFinish photo.id=" + photo.id);
    PhotoEntity entity = new PhotoEntity(photo);
    entity.state = PhotoEntity.STATE_FINISHED;
    try {
        mDb.saveOrUpdate(entity);
    } catch (DbException e) {
        e.printStackTrace();
    }
}