use of pri.weiqiang.liyujapanese.mvp.bean.gojuon.GojuonItem in project MyJapanese by 54wall.
the class GojuonFragmentModelImpl method getData.
@Override
public void getData(final int category, Consumer<List<GojuonItem>> consumer) {
Disposable disposable = Observable.create(new ObservableOnSubscribe<List<GojuonItem>>() {
@Override
public void subscribe(ObservableEmitter<List<GojuonItem>> emitter) throws Exception {
List<GojuonItem> list;
switch(category) {
case Constants.CATEGORY_QINGYIN:
list = DBManager.getInstance().getQingYin();
break;
case Constants.CATEGORY_ZHUOYIN:
list = DBManager.getInstance().getZhuoYin();
break;
case Constants.CATEGORY_AOYIN:
list = DBManager.getInstance().getAoYin();
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.GojuonItem in project MyJapanese by 54wall.
the class PuzzleActivityPresenterImpl method loadData.
@Override
public void loadData() {
List<GojuonItem> items = model.getItems();
List<GojuonItem> jams = new ArrayList<>();
GojuonItem current = items.get(0);
jams.add(items.get(1));
jams.add(items.get(2));
jams.add(items.get(3));
view.setData(current, jams);
}
use of pri.weiqiang.liyujapanese.mvp.bean.gojuon.GojuonItem in project MyJapanese by 54wall.
the class MemoryFragment method setData.
@Override
public void setData(List<GojuonItem> data) {
if (adapter == null) {
adapter = new MemorySwipeAdapter(data);
adapter.setOnWriteButtonClickListener(new MemorySwipeAdapter.OnWriteButtonClickListener() {
@Override
public void onClick(GojuonItem item) {
GojuonGif gif = GifManager.getInstance().getJPGif(item.getRome());
if (gif != null) {
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();
}
}
});
adapter.setOnYinButtonClickListener(new MemorySwipeAdapter.OnYinButtonClickListener() {
@Override
public void onClick(GojuonItem item) {
SoundPoolManager.getInstance().play(item.getRome());
}
});
}
adapter.setList(data);
mSwipeFlingAdapterView.setAdapter(adapter);
}
use of pri.weiqiang.liyujapanese.mvp.bean.gojuon.GojuonItem in project MyJapanese by 54wall.
the class GojuonRecyclerAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(final ViewHolder holder, int position) {
GojuonItem item = list.get(position);
if (BaseApplication.TYPE_MING == Constants.TYPE_HIRAGANA) {
holder.tv_jiaming.setText(item.getHiragana());
} else {
holder.tv_jiaming.setText(item.getKatakana());
}
if (holder.tv_rome != null) {
holder.tv_rome.setText(item.getRome());
}
holder.item = item;
if (getItemViewType(position) == Constants.TYPE_ITEM && holder.item.isExisted()) {
holder.view.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (onItemClickListener != null) {
onItemClickListener.onClick(holder.item);
}
}
});
if (holder.item.getCategory() != Constants.CATEGORY_AOYIN) {
holder.view.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
if (onItemLongClickListener != null) {
onItemLongClickListener.onLongClick(holder.item);
}
return true;
}
});
}
}
}
use of pri.weiqiang.liyujapanese.mvp.bean.gojuon.GojuonItem in project LiYuJapanese by 54wall.
the class MemoryFragment method setData.
@Override
public void setData(List<GojuonItem> data) {
if (adapter == null) {
adapter = new MemorySwipeAdapter(data);
adapter.setOnWriteButtonClickListener(new MemorySwipeAdapter.OnWriteButtonClickListener() {
@Override
public void onClick(GojuonItem item) {
GojuonGif gif = GifManager.getInstance().getJPGif(item.getRome());
if (gif != null) {
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();
}
}
});
adapter.setOnYinButtonClickListener(new MemorySwipeAdapter.OnYinButtonClickListener() {
@Override
public void onClick(GojuonItem item) {
SoundPoolManager.getInstance().play(item.getRome());
}
});
}
adapter.setList(data);
mSwipeFlingAdapterView.setAdapter(adapter);
}
Aggregations