Search in sources :

Example 11 with Word

use of pri.weiqiang.liyujapanese.mvp.bean.dic.Word in project MyJapanese by 54wall.

the class WordsFragment method setData.

@Override
public void setData(List<Word> data) {
    adapter = new WordsRecyclerAdapter(getContext(), data, isExpandable);
    mRecyclerView.setAdapter(adapter);
    LayoutAnimationHelper.getInstance().playLayoutAnimation(mRecyclerView, LayoutAnimationHelper.getInstance().getAnimationSetFromBottom(), LayoutAnimationController.ORDER_NORMAL);
    adapter.setOnItemClickListener(new WordsRecyclerAdapter.OnItemClickListener() {

        @Override
        public void onItemClick(Word bean) {
        }
    });
}
Also used : Word(pri.weiqiang.liyujapanese.mvp.bean.dic.Word) WordsRecyclerAdapter(pri.weiqiang.liyujapanese.ui.adapter.WordsRecyclerAdapter)

Example 12 with Word

use of pri.weiqiang.liyujapanese.mvp.bean.dic.Word in project LiYuJapanese by 54wall.

the class FavWordsFragment method setData.

@Override
public void setData(List<Word> data) {
    adapter = new FavWordsRecyclerAdapter(getContext(), data, isExpandable);
    mRecyclerView.setAdapter(adapter);
    LayoutAnimationHelper.getInstance().playLayoutAnimation(mRecyclerView, LayoutAnimationHelper.getInstance().getAnimationSetFromBottom(), LayoutAnimationController.ORDER_NORMAL);
    adapter.setOnItemClickListener(new FavWordsRecyclerAdapter.OnItemClickListener() {

        @Override
        public void onItemClick(Word bean) {
        }
    });
}
Also used : Word(pri.weiqiang.liyujapanese.mvp.bean.dic.Word) FavWordsRecyclerAdapter(pri.weiqiang.liyujapanese.ui.adapter.FavWordsRecyclerAdapter)

Example 13 with Word

use of pri.weiqiang.liyujapanese.mvp.bean.dic.Word in project LiYuJapanese by 54wall.

the class DBManager method getAllFav.

public synchronized List<Word> getAllFav() {
    Log.e(TAG, "getAllFav!!!!");
    // 收藏这个表,因为经常更新,所以即使mFavList不为null也不能直接使用
    if (isTableExist(DatabaseHelper.DB_TABLE_FAV)) {
        SQLiteDatabase db = DatabaseHelper.getInstance(BaseApplication.getInstance()).getReadableDatabase();
        // Cursor cursor = db.rawQuery("select * from " + DatabaseHelper.DB_TABLE_FAV, null);
        Cursor cursor = db.query(DatabaseHelper.DB_TABLE_FAV, null, null, null, null, null, null);
        mFavList = new ArrayList<>();
        Word item;
        while (cursor.moveToNext()) {
            int id = cursor.getInt(cursor.getColumnIndex("_id"));
            String book_id = cursor.getString(cursor.getColumnIndex("book_id"));
            String lesson_id = cursor.getString(cursor.getColumnIndex("lesson_id"));
            String word = cursor.getString(cursor.getColumnIndex("word"));
            String phonetic = cursor.getString(cursor.getColumnIndex("phonetic"));
            String translation = cursor.getString(cursor.getColumnIndex("translation"));
            int fav = cursor.getInt(cursor.getColumnIndex("fav"));
            int cache = cursor.getInt(cursor.getColumnIndex("cache"));
            item = new Word(id, book_id, lesson_id, word, phonetic, translation, fav, cache);
            Log.e(TAG, "getAllFav word:" + item.toString());
            mFavList.add(item);
        }
        cursor.close();
        db.close();
    }
    return mFavList;
}
Also used : Word(pri.weiqiang.liyujapanese.mvp.bean.dic.Word) SQLiteDatabase(android.database.sqlite.SQLiteDatabase) Cursor(android.database.Cursor)

Example 14 with Word

use of pri.weiqiang.liyujapanese.mvp.bean.dic.Word in project LiYuJapanese by 54wall.

the class DBManager method getFav.

public synchronized List<Word> getFav(String lessonId) {
    Log.e(TAG, "getAllFav!!!!");
    // 收藏这个表,因为经常更新,所以即使mFavList不为null也不能直接使用
    if (isTableExist(DatabaseHelper.DB_TABLE_FAV)) {
        SQLiteDatabase db = DatabaseHelper.getInstance(BaseApplication.getInstance()).getReadableDatabase();
        // Cursor cursor = db.rawQuery("select * from " + DatabaseHelper.DB_TABLE_FAV, null);
        Cursor cursor = db.query(DatabaseHelper.DB_TABLE_FAV, null, null, null, null, null, null);
        mFavList = new ArrayList<>();
        Word item;
        while (cursor.moveToNext()) {
            String lesson_id = cursor.getString(cursor.getColumnIndex("lesson_id"));
            if (lesson_id.equals(lessonId)) {
                int id = cursor.getInt(cursor.getColumnIndex("_id"));
                String book_id = cursor.getString(cursor.getColumnIndex("book_id"));
                String word = cursor.getString(cursor.getColumnIndex("word"));
                String phonetic = cursor.getString(cursor.getColumnIndex("phonetic"));
                String translation = cursor.getString(cursor.getColumnIndex("translation"));
                int fav = cursor.getInt(cursor.getColumnIndex("fav"));
                int cache = cursor.getInt(cursor.getColumnIndex("cache"));
                item = new Word(id, book_id, lesson_id, word, phonetic, translation, fav, cache);
                Log.e(TAG, "getAllFav word:" + item.toString());
                mFavList.add(item);
            }
        }
        cursor.close();
        db.close();
    }
    return mFavList;
}
Also used : Word(pri.weiqiang.liyujapanese.mvp.bean.dic.Word) SQLiteDatabase(android.database.sqlite.SQLiteDatabase) Cursor(android.database.Cursor)

Aggregations

Word (pri.weiqiang.liyujapanese.mvp.bean.dic.Word)14 Cursor (android.database.Cursor)6 SQLiteDatabase (android.database.sqlite.SQLiteDatabase)6 ObservableEmitter (io.reactivex.ObservableEmitter)4 ObservableOnSubscribe (io.reactivex.ObservableOnSubscribe)4 Disposable (io.reactivex.disposables.Disposable)4 FavWordsRecyclerAdapter (pri.weiqiang.liyujapanese.ui.adapter.FavWordsRecyclerAdapter)2 WordsRecyclerAdapter (pri.weiqiang.liyujapanese.ui.adapter.WordsRecyclerAdapter)2