Search in sources :

Example 11 with GojuonItem

use of pri.weiqiang.liyujapanese.mvp.bean.gojuon.GojuonItem in project MyJapanese by 54wall.

the class DBManager method getZhuoYinWithoutHeader.

public List<GojuonItem> getZhuoYinWithoutHeader() {
    if (zhuoYinWithoutHeader == null) {
        zhuoYinWithoutHeader = new ArrayList<>();
        List<GojuonItem> query = getZhuoYin();
        for (GojuonItem item : query) {
            if (item.getRow() != 0 && item.getColumn() != 0 && item.isExisted()) {
                zhuoYinWithoutHeader.add(item);
            }
        }
    }
    return zhuoYinWithoutHeader;
}
Also used : GojuonItem(pri.weiqiang.liyujapanese.mvp.bean.gojuon.GojuonItem)

Example 12 with GojuonItem

use of pri.weiqiang.liyujapanese.mvp.bean.gojuon.GojuonItem in project MyJapanese by 54wall.

the class DBManager method query.

public synchronized List<GojuonItem> query() {
    if (query == null) {
        SQLiteDatabase db = DatabaseHelper.getInstance(BaseApplication.getInstance()).getReadableDatabase();
        // Cursor cursor = db.rawQuery("select * from " + DatabaseHelper.DB_TABLE_GOJUON, null);
        Cursor cursor = db.query(DatabaseHelper.DB_TABLE_GOJUON, null, null, null, null, null, null);
        query = new ArrayList<>();
        GojuonItem item;
        while (cursor.moveToNext()) {
            int id = cursor.getInt(cursor.getColumnIndex("id"));
            int row = cursor.getInt(cursor.getColumnIndex("row"));
            int column = cursor.getInt(cursor.getColumnIndex("column"));
            String hiragana = cursor.getString(cursor.getColumnIndex("hiragana"));
            String katakana = cursor.getString(cursor.getColumnIndex("katakana"));
            String rome = cursor.getString(cursor.getColumnIndex("rome"));
            int category = cursor.getInt(cursor.getColumnIndex("category"));
            int type = cursor.getInt(cursor.getColumnIndex("type"));
            boolean existed = cursor.getInt(cursor.getColumnIndex("existed")) == 1;
            item = new GojuonItem(id, row, column, hiragana, katakana, rome, category, type, existed);
            query.add(item);
        }
        cursor.close();
        db.close();
    }
    return query;
}
Also used : SQLiteDatabase(android.database.sqlite.SQLiteDatabase) Cursor(android.database.Cursor) GojuonItem(pri.weiqiang.liyujapanese.mvp.bean.gojuon.GojuonItem)

Example 13 with GojuonItem

use of pri.weiqiang.liyujapanese.mvp.bean.gojuon.GojuonItem in project MyJapanese by 54wall.

the class DBManager method getQingYinWithoutHeader.

public List<GojuonItem> getQingYinWithoutHeader() {
    if (qingYinWithoutHeader == null) {
        qingYinWithoutHeader = new ArrayList<>();
        List<GojuonItem> query = getQingYin();
        for (GojuonItem item : query) {
            if (item.getRow() != 0 && item.getColumn() != 0 && item.isExisted()) {
                qingYinWithoutHeader.add(item);
            }
        }
    }
    return qingYinWithoutHeader;
}
Also used : GojuonItem(pri.weiqiang.liyujapanese.mvp.bean.gojuon.GojuonItem)

Example 14 with GojuonItem

use of pri.weiqiang.liyujapanese.mvp.bean.gojuon.GojuonItem in project MyJapanese by 54wall.

the class DBManager method getAoYin.

public List<GojuonItem> getAoYin() {
    if (aoYin == null) {
        aoYin = new ArrayList<>();
        List<GojuonItem> query = query();
        for (GojuonItem item : query) {
            if (item.getCategory() == Constants.CATEGORY_AOYIN) {
                aoYin.add(item);
            }
        }
        Collections.sort(aoYin, new GojuonItemComporator());
    }
    return aoYin;
}
Also used : GojuonItemComporator(pri.weiqiang.liyujapanese.comparator.GojuonItemComporator) GojuonItem(pri.weiqiang.liyujapanese.mvp.bean.gojuon.GojuonItem)

Example 15 with GojuonItem

use of pri.weiqiang.liyujapanese.mvp.bean.gojuon.GojuonItem in project MyJapanese by 54wall.

the class DBManager method getZhuoYin.

public List<GojuonItem> getZhuoYin() {
    if (zhuoYin == null) {
        zhuoYin = new ArrayList<>();
        List<GojuonItem> query = query();
        for (GojuonItem item : query) {
            if (item.getCategory() == Constants.CATEGORY_ZHUOYIN) {
                zhuoYin.add(item);
            }
        }
        Collections.sort(zhuoYin, new GojuonItemComporator());
    }
    return zhuoYin;
}
Also used : GojuonItemComporator(pri.weiqiang.liyujapanese.comparator.GojuonItemComporator) GojuonItem(pri.weiqiang.liyujapanese.mvp.bean.gojuon.GojuonItem)

Aggregations

GojuonItem (pri.weiqiang.liyujapanese.mvp.bean.gojuon.GojuonItem)28 GojuonItemComporator (pri.weiqiang.liyujapanese.comparator.GojuonItemComporator)6 View (android.view.View)4 TextView (android.widget.TextView)4 ImageDialog (pri.weiqaing.common.widget.dialog.ImageDialog)4 GojuonGif (pri.weiqiang.liyujapanese.mvp.bean.gojuon.GojuonGif)4 Cursor (android.database.Cursor)2 SQLiteDatabase (android.database.sqlite.SQLiteDatabase)2 RecyclerView (androidx.recyclerview.widget.RecyclerView)2 ObservableEmitter (io.reactivex.ObservableEmitter)2 ObservableOnSubscribe (io.reactivex.ObservableOnSubscribe)2 Disposable (io.reactivex.disposables.Disposable)2 ArrayList (java.util.ArrayList)2 GojuonRecyclerAdapter (pri.weiqiang.liyujapanese.ui.adapter.GojuonRecyclerAdapter)2 MemorySwipeAdapter (pri.weiqiang.liyujapanese.ui.adapter.MemorySwipeAdapter)2