use of pri.weiqiang.liyujapanese.mvp.bean.gojuon.GojuonMemory in project MyJapanese by 54wall.
the class DBManager method getGojuonMemory.
public synchronized List<GojuonMemory> getGojuonMemory() {
if (gojuonMemoryList == 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);
gojuonMemoryList = new ArrayList<>();
GojuonMemory item;
while (cursor.moveToNext()) {
int id = cursor.getInt(cursor.getColumnIndex("id"));
String memory = cursor.getString(cursor.getColumnIndex("memory"));
if (memory != null) {
String hiragana = cursor.getString(cursor.getColumnIndex("hiragana"));
String katakana = cursor.getString(cursor.getColumnIndex("katakana"));
String rome = cursor.getString(cursor.getColumnIndex("rome"));
String chengyu = cursor.getString(cursor.getColumnIndex("chengyu"));
item = new GojuonMemory(id, hiragana, katakana, rome, memory, chengyu);
gojuonMemoryList.add(item);
}
}
cursor.close();
db.close();
}
return gojuonMemoryList;
}
use of pri.weiqiang.liyujapanese.mvp.bean.gojuon.GojuonMemory in project MyJapanese by 54wall.
the class GojuonMemoryFragmentModelImpl method getData.
@Override
public void getData(final int category, Consumer<List<GojuonMemory>> consumer) {
Disposable disposable = Observable.create(new ObservableOnSubscribe<List<GojuonMemory>>() {
@Override
public void subscribe(ObservableEmitter<List<GojuonMemory>> emitter) throws Exception {
List<GojuonMemory> list;
switch(category) {
case Constants.GOJUON_MEMORY:
list = DBManager.getInstance().getGojuonMemory();
break;
case Constants.GOJUON_CHENGYU:
list = DBManager.getInstance().getGojuonChengyu();
break;
default:
list = null;
break;
}
if (list == null) {
emitter.onError(new Exception());
} else {
emitter.onNext(list);
}
emitter.onComplete();
}
}).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(consumer);
mCompositeDisposable.add(disposable);
}
use of pri.weiqiang.liyujapanese.mvp.bean.gojuon.GojuonMemory in project LiYuJapanese by 54wall.
the class GojuonMemoryFragmentModelImpl method getData.
@Override
public void getData(final int category, Consumer<List<GojuonMemory>> consumer) {
Disposable disposable = Observable.create(new ObservableOnSubscribe<List<GojuonMemory>>() {
@Override
public void subscribe(ObservableEmitter<List<GojuonMemory>> emitter) throws Exception {
List<GojuonMemory> list;
switch(category) {
case Constants.GOJUON_MEMORY:
list = DBManager.getInstance().getGojuonMemory();
break;
case Constants.GOJUON_CHENGYU:
list = DBManager.getInstance().getGojuonChengyu();
break;
default:
list = null;
break;
}
if (list == null) {
emitter.onError(new Exception());
} else {
emitter.onNext(list);
}
emitter.onComplete();
}
}).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(consumer);
mCompositeDisposable.add(disposable);
}
use of pri.weiqiang.liyujapanese.mvp.bean.gojuon.GojuonMemory in project LiYuJapanese 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;
}
use of pri.weiqiang.liyujapanese.mvp.bean.gojuon.GojuonMemory in project LiYuJapanese by 54wall.
the class DBManager method getGojuonMemory.
public synchronized List<GojuonMemory> getGojuonMemory() {
if (gojuonMemoryList == 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);
gojuonMemoryList = new ArrayList<>();
GojuonMemory item;
while (cursor.moveToNext()) {
int id = cursor.getInt(cursor.getColumnIndex("id"));
String memory = cursor.getString(cursor.getColumnIndex("memory"));
if (memory != null) {
String hiragana = cursor.getString(cursor.getColumnIndex("hiragana"));
String katakana = cursor.getString(cursor.getColumnIndex("katakana"));
String rome = cursor.getString(cursor.getColumnIndex("rome"));
String chengyu = cursor.getString(cursor.getColumnIndex("chengyu"));
item = new GojuonMemory(id, hiragana, katakana, rome, memory, chengyu);
gojuonMemoryList.add(item);
}
}
cursor.close();
db.close();
}
return gojuonMemoryList;
}
Aggregations