use of pri.weiqiang.liyujapanese.mvp.bean.dic.Word in project LiYuJapanese by 54wall.
the class DBManager method queryWord.
public synchronized List<Word> queryWord(String lesson) {
Log.e(TAG, "queryWord lesson:" + lesson);
SQLiteDatabase db = DatabaseHelper.getInstance(BaseApplication.getInstance()).getReadableDatabase();
String selection = "lesson_id=?";
String[] selectionArgs = new String[] { lesson };
Cursor cursor = db.query(DatabaseHelper.DB_TABLE_WORDS, null, selection, selectionArgs, null, null, null);
mWordList = 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, "word:" + item.toString());
mWordList.add(item);
}
cursor.close();
db.close();
return mWordList;
}
use of pri.weiqiang.liyujapanese.mvp.bean.dic.Word in project LiYuJapanese 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) {
}
});
}
use of pri.weiqiang.liyujapanese.mvp.bean.dic.Word in project MyJapanese by 54wall.
the class DBManager method queryWord.
public synchronized List<Word> queryWord(String lesson) {
Log.e(TAG, "queryWord lesson:" + lesson);
SQLiteDatabase db = DatabaseHelper.getInstance(BaseApplication.getInstance()).getReadableDatabase();
String selection = "lesson_id=?";
String[] selectionArgs = new String[] { lesson };
Cursor cursor = db.query(DatabaseHelper.DB_TABLE_WORDS, null, selection, selectionArgs, null, null, null);
mWordList = 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, "word:" + item.toString());
mWordList.add(item);
}
cursor.close();
db.close();
return mWordList;
}
use of pri.weiqiang.liyujapanese.mvp.bean.dic.Word in project MyJapanese by 54wall.
the class FavWordsFragmentModelImpl method getData.
@Override
public void getData(Consumer<List<Word>> consumer, Consumer<Throwable> throwable, final String lessonId) {
Disposable disposable = Observable.create(new ObservableOnSubscribe<List<Word>>() {
@Override
public void subscribe(ObservableEmitter<List<Word>> emitter) throws Exception {
List<Word> list;
list = DBManager.getInstance().getFav(lessonId);
if (list == null) {
Log.e(TAG, "list == null");
// emitter.onError(new Exception());//经常报这个错误io.reactivex.exceptions.OnErrorNotImplementedException
} else {
emitter.onNext(list);
}
emitter.onComplete();
}
}).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(consumer, throwable);
mCompositeDisposable.add(disposable);
}
use of pri.weiqiang.liyujapanese.mvp.bean.dic.Word in project MyJapanese 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) {
}
});
}
Aggregations