Search in sources :

Example 1 with Filter

use of com.hippo.ehviewer.dao.Filter in project EhViewer by seven332.

the class GalleryDetailScene method addTagFilter.

private void addTagFilter(String tag) {
    Filter filter = new Filter();
    filter.mode = EhFilter.MODE_TAG;
    filter.text = tag;
    EhFilter.getInstance().addFilter(filter);
    showTip(R.string.filter_added, LENGTH_SHORT);
}
Also used : Filter(com.hippo.ehviewer.dao.Filter) EhFilter(com.hippo.ehviewer.client.EhFilter)

Example 2 with Filter

use of com.hippo.ehviewer.dao.Filter in project EhViewer by seven332.

the class GalleryDetailScene method showBlockUploaderDialog.

private void showBlockUploaderDialog() {
    Context context = getContext2();
    if (null == context) {
        return;
    }
    final String uploader = getUploader();
    if (null == uploader) {
        return;
    }
    new AlertDialog.Builder(context).setMessage(getString(R.string.block_the_uploader, uploader)).setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            if (DialogInterface.BUTTON_POSITIVE != which) {
                return;
            }
            Filter filter = new Filter();
            filter.mode = EhFilter.MODE_UPLOADER;
            filter.text = uploader;
            EhFilter.getInstance().addFilter(filter);
            showTip(R.string.filter_added, LENGTH_SHORT);
        }
    }).show();
}
Also used : Context(android.content.Context) AlertDialog(android.support.v7.app.AlertDialog) DialogInterface(android.content.DialogInterface) Filter(com.hippo.ehviewer.dao.Filter) EhFilter(com.hippo.ehviewer.client.EhFilter)

Example 3 with Filter

use of com.hippo.ehviewer.dao.Filter in project EhViewer by seven332.

the class EhDB method importDB.

/**
 * @param file The db file
 * @return error string, null for no error
 */
public static synchronized String importDB(Context context, File file) {
    try {
        SQLiteDatabase db = SQLiteDatabase.openDatabase(file.getPath(), null, SQLiteDatabase.NO_LOCALIZED_COLLATORS);
        int newVersion = DaoMaster.SCHEMA_VERSION;
        int oldVersion = db.getVersion();
        if (oldVersion < newVersion) {
            upgradeDB(db, oldVersion);
            db.setVersion(newVersion);
        } else if (oldVersion > newVersion) {
            return context.getString(R.string.cant_read_the_file);
        }
        DaoMaster daoMaster = new DaoMaster(db);
        DaoSession session = daoMaster.newSession();
        // Downloads
        DownloadManager manager = EhApplication.getDownloadManager(context);
        List<DownloadInfo> downloadInfoList = session.getDownloadsDao().queryBuilder().list();
        manager.addDownload(downloadInfoList);
        // Download label
        List<DownloadLabel> downloadLabelList = session.getDownloadLabelDao().queryBuilder().list();
        manager.addDownloadLabel(downloadLabelList);
        // Download dirname
        List<DownloadDirname> downloadDirnameList = session.getDownloadDirnameDao().queryBuilder().list();
        for (DownloadDirname dirname : downloadDirnameList) {
            putDownloadDirname(dirname.getGid(), dirname.getDirname());
        }
        // History
        List<HistoryInfo> historyInfoList = session.getHistoryDao().queryBuilder().list();
        putHistoryInfo(historyInfoList);
        // QuickSearch
        List<QuickSearch> quickSearchList = session.getQuickSearchDao().queryBuilder().list();
        List<QuickSearch> currentQuickSearchList = sDaoSession.getQuickSearchDao().queryBuilder().list();
        for (QuickSearch quickSearch : quickSearchList) {
            String name = quickSearch.name;
            for (QuickSearch q : currentQuickSearchList) {
                if (ObjectUtils.equal(q.name, name)) {
                    // The same name
                    name = null;
                    break;
                }
            }
            if (null == name) {
                continue;
            }
            insertQuickSearch(quickSearch);
        }
        // LocalFavorites
        List<LocalFavoriteInfo> localFavoriteInfoList = session.getLocalFavoritesDao().queryBuilder().list();
        for (LocalFavoriteInfo info : localFavoriteInfoList) {
            putLocalFavorites(info);
        }
        // Bookmarks
        // TODO
        // Filter
        List<Filter> filterList = session.getFilterDao().queryBuilder().list();
        List<Filter> currentFilterList = sDaoSession.getFilterDao().queryBuilder().list();
        for (Filter filter : filterList) {
            if (!currentFilterList.contains(filter)) {
                addFilter(filter);
            }
        }
        return null;
    } catch (Exception e) {
        // Ignore
        return context.getString(R.string.cant_read_the_file);
    }
}
Also used : LocalFavoriteInfo(com.hippo.ehviewer.dao.LocalFavoriteInfo) DownloadDirname(com.hippo.ehviewer.dao.DownloadDirname) DownloadManager(com.hippo.ehviewer.download.DownloadManager) IOException(java.io.IOException) DaoMaster(com.hippo.ehviewer.dao.DaoMaster) SQLiteDatabase(android.database.sqlite.SQLiteDatabase) Filter(com.hippo.ehviewer.dao.Filter) DownloadInfo(com.hippo.ehviewer.dao.DownloadInfo) QuickSearch(com.hippo.ehviewer.dao.QuickSearch) DownloadLabel(com.hippo.ehviewer.dao.DownloadLabel) HistoryInfo(com.hippo.ehviewer.dao.HistoryInfo) DaoSession(com.hippo.ehviewer.dao.DaoSession)

Aggregations

Filter (com.hippo.ehviewer.dao.Filter)3 EhFilter (com.hippo.ehviewer.client.EhFilter)2 Context (android.content.Context)1 DialogInterface (android.content.DialogInterface)1 SQLiteDatabase (android.database.sqlite.SQLiteDatabase)1 AlertDialog (android.support.v7.app.AlertDialog)1 DaoMaster (com.hippo.ehviewer.dao.DaoMaster)1 DaoSession (com.hippo.ehviewer.dao.DaoSession)1 DownloadDirname (com.hippo.ehviewer.dao.DownloadDirname)1 DownloadInfo (com.hippo.ehviewer.dao.DownloadInfo)1 DownloadLabel (com.hippo.ehviewer.dao.DownloadLabel)1 HistoryInfo (com.hippo.ehviewer.dao.HistoryInfo)1 LocalFavoriteInfo (com.hippo.ehviewer.dao.LocalFavoriteInfo)1 QuickSearch (com.hippo.ehviewer.dao.QuickSearch)1 DownloadManager (com.hippo.ehviewer.download.DownloadManager)1 IOException (java.io.IOException)1