org.xutils.ex.DbException Java Examples

The following examples show how to use org.xutils.ex.DbException. 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 File: DownLoadModelImp.java    From AndroidDownload with 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 File: PhotoManager.java    From DelegateAdapter with 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 File: ComicDBHelper.java    From HHComicViewer with 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 File: ComicDBHelper.java    From HHComicViewer with 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 File: DownloadThreadDBHelper.java    From HHComicViewer with 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 File: DownloadThreadDBHelper.java    From HHComicViewer with Apache License 2.0 5 votes vote down vote up
public synchronized void deleteAllChapterThread(long chid) {
    WhereBuilder builder = WhereBuilder.b("chid", "=", chid);
    try {
        sDb.delete(ThreadInfo.class, builder);
    } catch (DbException e) {
        e.printStackTrace();
    }
}
 
Example #7
Source File: PhotoManager.java    From DelegateAdapter with 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();
    }
}
 
Example #8
Source File: ComicDBHelper.java    From HHComicViewer with Apache License 2.0 5 votes vote down vote up
public List<Comic> findMarkedComics() {
    List<Comic> markedComics = null;
    try {
        markedComics = sDb.selector(Comic.class).where("is_mark", "=", true).orderBy("last_read_time", true).findAll();
    } catch (DbException e) {
        e.printStackTrace();
    }
    return markedComics;
}
 
Example #9
Source File: ComicDBHelper.java    From HHComicViewer with Apache License 2.0 5 votes vote down vote up
public List<Comic> findDownloadedComics() {
    List<Comic> downloadedComics = null;
    try {
        downloadedComics = sDb.selector(Comic.class).where("is_download", "=", true).findAll();
    } catch (DbException e) {
        e.printStackTrace();
    }
    return downloadedComics;
}
 
Example #10
Source File: ComicDBHelper.java    From HHComicViewer with Apache License 2.0 5 votes vote down vote up
private Comic findByCidInTable(int cid) {
    Comic comic = null;
    try {
        comic = sDb.selector(Comic.class).where("cid", "=", cid).findFirst();
    } catch (DbException e) {
        e.printStackTrace();
    }
    return comic;
}
 
Example #11
Source File: ComicDBHelper.java    From HHComicViewer with Apache License 2.0 5 votes vote down vote up
public List<Comic> findAll() {
    List<Comic> comics = null;
    try {
        comics = sDb.selector(Comic.class).orderBy("last_read_time", true).limit(100).findAll();
    } catch (DbException e) {
        e.printStackTrace();
    }
    return comics;
}
 
Example #12
Source File: DownloadThreadDBHelper.java    From HHComicViewer with Apache License 2.0 5 votes vote down vote up
public synchronized void add(ThreadInfo threadInfo) {
    try {
        sDb.save(threadInfo);
    } catch (DbException e) {
        e.printStackTrace();
    }
}
 
Example #13
Source File: DownloadThreadDBHelper.java    From HHComicViewer with Apache License 2.0 5 votes vote down vote up
public synchronized void update(ThreadInfo threadInfo) {
    try {
        sDb.update(threadInfo);
    } catch (DbException e) {
        e.printStackTrace();
    }
}
 
Example #14
Source File: ComicChapterDBHelper.java    From HHComicViewer with Apache License 2.0 5 votes vote down vote up
@Deprecated
public List<ComicChapter> findAll() {
    List<ComicChapter> comicChapters = new ArrayList<>();
    try {
        comicChapters = sDb.findAll(ComicChapter.class);
    } catch (DbException e) {
        e.printStackTrace();
    }
    return comicChapters;
}
 
Example #15
Source File: DownloadThreadDBHelper.java    From HHComicViewer with Apache License 2.0 5 votes vote down vote up
public List<ThreadInfo> findAll() {
    List<ThreadInfo> threadInfos = new ArrayList<>();
    try {
        sDb.findAll(ThreadInfo.class);
    } catch (DbException e) {
        e.printStackTrace();
        return null;
    }
    return threadInfos;
}
 
Example #16
Source File: ComicChapterDBHelper.java    From HHComicViewer with Apache License 2.0 5 votes vote down vote up
public List<ComicChapter> findUnFinishedChapters() {
    List<ComicChapter> unFinishedChapters = null;
    try {
        unFinishedChapters = sDb.selector(ComicChapter.class)
                .where("download_status", "!=", Constants.DOWNLOAD_FINISHED).findAll();
        if (unFinishedChapters != null && unFinishedChapters.size() != 0) {
            Collections.sort(unFinishedChapters);
        }
    } catch (DbException e) {
        e.printStackTrace();
    }
    return unFinishedChapters;
}
 
Example #17
Source File: ComicChapterDBHelper.java    From HHComicViewer with Apache License 2.0 5 votes vote down vote up
public ComicChapter findByChapterId(long chid) {
    ComicChapter chapter = null;
    try {
        chapter = sDb.selector(ComicChapter.class).where("chid", "=", chid).findFirst();
    } catch (DbException e) {
        e.printStackTrace();
    }
    return chapter;
}
 
Example #18
Source File: ComicChapterDBHelper.java    From HHComicViewer with Apache License 2.0 5 votes vote down vote up
public synchronized void add(ComicChapter comicChapter) {
    try {
        sDb.save(comicChapter);
    } catch (DbException e) {
        e.printStackTrace();
    }
}
 
Example #19
Source File: ComicChapterDBHelper.java    From HHComicViewer with Apache License 2.0 5 votes vote down vote up
public synchronized void delete(ComicChapter comicChapter) {
    WhereBuilder builder = WhereBuilder.b("chid", "=", comicChapter.getChid());
    try {
        sDb.delete(ComicChapter.class, builder);
    } catch (DbException e) {
        e.printStackTrace();
    }
}
 
Example #20
Source File: ComicChapterDBHelper.java    From HHComicViewer with Apache License 2.0 5 votes vote down vote up
public synchronized void update(ComicChapter comicChapter) {
    try {
        sDb.update(comicChapter);
    } catch (DbException e) {
        e.printStackTrace();
    }
}
 
Example #21
Source File: ComicChapterDBHelper.java    From HHComicViewer with Apache License 2.0 5 votes vote down vote up
public synchronized void updateProgress(ComicChapter comicChapter) {
    try {
        sDb.update(comicChapter, "download_position");
    } catch (DbException e) {
        e.printStackTrace();
    }
}
 
Example #22
Source File: ComicChapterDBHelper.java    From HHComicViewer with Apache License 2.0 5 votes vote down vote up
public synchronized void deleteComicChapterOneComic(int cid) {
    WhereBuilder builder = WhereBuilder.b("cid", "=", cid);
    try {
        sDb.delete(ThreadInfo.class, builder);
    } catch (DbException e) {
        e.printStackTrace();
    }
}
 
Example #23
Source File: ComicChapterDBHelper.java    From HHComicViewer with Apache License 2.0 5 votes vote down vote up
public List<ComicChapter> findByComicCid(int cid) {
    List<ComicChapter> comicChapters = null;
    try {
        comicChapters = sDb.selector(ComicChapter.class).where("cid", "=", cid).findAll();
        if (comicChapters != null) {
            Collections.sort(comicChapters);
        }
    } catch (DbException e) {
        e.printStackTrace();
    }
    return comicChapters;
}
 
Example #24
Source File: AppSettingModelImp.java    From AndroidDownload with 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 #25
Source File: TaskModelImp.java    From AndroidDownload with 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 #26
Source File: AppSettingModelImp.java    From AndroidDownload with 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 #27
Source File: AppSettingModelImp.java    From AndroidDownload with 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 #28
Source File: AppSettingModelImp.java    From AndroidDownload with 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 #29
Source File: AppSettingModelImp.java    From AndroidDownload with 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 #30
Source File: AppSettingModelImp.java    From AndroidDownload with 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;
}