Search in sources :

Example 6 with GojuonMemory

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

the class DBManager method getGojuonChengyu.

public synchronized List<GojuonMemory> getGojuonChengyu() {
    if (gojuonMemoryChengyu == 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);
        gojuonMemoryChengyu = new ArrayList<>();
        GojuonMemory item;
        while (cursor.moveToNext()) {
            int id = cursor.getInt(cursor.getColumnIndex("id"));
            String chengyu = cursor.getString(cursor.getColumnIndex("chengyu"));
            if (chengyu != null) {
                String hiragana = cursor.getString(cursor.getColumnIndex("hiragana"));
                String katakana = cursor.getString(cursor.getColumnIndex("katakana"));
                String rome = cursor.getString(cursor.getColumnIndex("rome"));
                String memory = cursor.getString(cursor.getColumnIndex("memory"));
                item = new GojuonMemory(id, hiragana, katakana, rome, memory, chengyu);
                gojuonMemoryChengyu.add(item);
            }
        }
        cursor.close();
        db.close();
    }
    return gojuonMemoryChengyu;
}
Also used : SQLiteDatabase(android.database.sqlite.SQLiteDatabase) GojuonMemory(pri.weiqiang.liyujapanese.mvp.bean.gojuon.GojuonMemory) Cursor(android.database.Cursor)

Example 7 with GojuonMemory

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

the class GojuonMemoryFragment method setData.

@Override
public void setData(List<GojuonMemory> data) {
    Log.e(TAG, "setData!!");
    adapter = new GojuonMemoryRecyclerAdapter(category_gojuon_memory, data);
    adapter.setOnItemClickListener(new GojuonMemoryRecyclerAdapter.OnItemClickListener() {

        @Override
        public void onClick(GojuonMemory bean) {
            Log.e(TAG, "onItemClick bean:" + bean.getRome() + ":" + bean.getKatakana());
            SoundPoolManager.getInstance().play(bean.getRome());
        }
    });
    adapter.setOnItemLongClickListener(new GojuonMemoryRecyclerAdapter.OnItemLongClickListener() {

        @Override
        public void onLongClick(GojuonMemory item) {
            Log.e(TAG, "onLongClick item:" + item.getRome() + ":" + item.getKatakana());
            GojuonGif gif = GifManager.getInstance().getJPGif(item.getRome());
            if (gif != null) {
                if (BaseApplication.TYPE_MING == Constants.TYPE_HIRAGANA) {
                    new ImageDialog.Builder(getContext()).setResId(gif.getHiragana()).override((int) ResourceUtils.getDimension(getContext(), R.dimen.dialog_width), (int) ResourceUtils.getDimension(getContext(), R.dimen.dialog_height)).create().show();
                } else {
                    new ImageDialog.Builder(getContext()).setResId(gif.getKatakana()).override((int) ResourceUtils.getDimension(getContext(), R.dimen.dialog_width), (int) ResourceUtils.getDimension(getContext(), R.dimen.dialog_height)).create().show();
                }
            }
        }
    });
    mRecyclerView.setAdapter(adapter);
}
Also used : ImageDialog(pri.weiqaing.common.widget.dialog.ImageDialog) GojuonMemory(pri.weiqiang.liyujapanese.mvp.bean.gojuon.GojuonMemory) GojuonGif(pri.weiqiang.liyujapanese.mvp.bean.gojuon.GojuonGif) GojuonMemoryRecyclerAdapter(pri.weiqiang.liyujapanese.ui.adapter.GojuonMemoryRecyclerAdapter)

Example 8 with GojuonMemory

use of pri.weiqiang.liyujapanese.mvp.bean.gojuon.GojuonMemory in project LiYuJapanese by 54wall.

the class GojuonMemoryFragment method setData.

@Override
public void setData(List<GojuonMemory> data) {
    Log.e(TAG, "setData!!");
    adapter = new GojuonMemoryRecyclerAdapter(category_gojuon_memory, data);
    adapter.setOnItemClickListener(new GojuonMemoryRecyclerAdapter.OnItemClickListener() {

        @Override
        public void onClick(GojuonMemory bean) {
            Log.e(TAG, "onItemClick bean:" + bean.getRome() + ":" + bean.getKatakana());
            SoundPoolManager.getInstance().play(bean.getRome());
        }
    });
    adapter.setOnItemLongClickListener(new GojuonMemoryRecyclerAdapter.OnItemLongClickListener() {

        @Override
        public void onLongClick(GojuonMemory item) {
            Log.e(TAG, "onLongClick item:" + item.getRome() + ":" + item.getKatakana());
            GojuonGif gif = GifManager.getInstance().getJPGif(item.getRome());
            if (gif != null) {
                if (BaseApplication.TYPE_MING == Constants.TYPE_HIRAGANA) {
                    new ImageDialog.Builder(getContext()).setResId(gif.getHiragana()).override((int) ResourceUtils.getDimension(getContext(), R.dimen.dialog_width), (int) ResourceUtils.getDimension(getContext(), R.dimen.dialog_height)).create().show();
                } else {
                    new ImageDialog.Builder(getContext()).setResId(gif.getKatakana()).override((int) ResourceUtils.getDimension(getContext(), R.dimen.dialog_width), (int) ResourceUtils.getDimension(getContext(), R.dimen.dialog_height)).create().show();
                }
            }
        }
    });
    mRecyclerView.setAdapter(adapter);
}
Also used : ImageDialog(pri.weiqaing.common.widget.dialog.ImageDialog) GojuonMemory(pri.weiqiang.liyujapanese.mvp.bean.gojuon.GojuonMemory) GojuonGif(pri.weiqiang.liyujapanese.mvp.bean.gojuon.GojuonGif) GojuonMemoryRecyclerAdapter(pri.weiqiang.liyujapanese.ui.adapter.GojuonMemoryRecyclerAdapter)

Aggregations

GojuonMemory (pri.weiqiang.liyujapanese.mvp.bean.gojuon.GojuonMemory)8 Cursor (android.database.Cursor)4 SQLiteDatabase (android.database.sqlite.SQLiteDatabase)4 ObservableEmitter (io.reactivex.ObservableEmitter)2 ObservableOnSubscribe (io.reactivex.ObservableOnSubscribe)2 Disposable (io.reactivex.disposables.Disposable)2 ImageDialog (pri.weiqaing.common.widget.dialog.ImageDialog)2 GojuonGif (pri.weiqiang.liyujapanese.mvp.bean.gojuon.GojuonGif)2 GojuonMemoryRecyclerAdapter (pri.weiqiang.liyujapanese.ui.adapter.GojuonMemoryRecyclerAdapter)2