Search in sources :

Example 1 with GojuonItem

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

the class DBManager method getAoYinWithoutHeader.

public List<GojuonItem> getAoYinWithoutHeader() {
    if (aoYinWithoutHeader == null) {
        aoYinWithoutHeader = new ArrayList<>();
        List<GojuonItem> query = getAoYin();
        for (GojuonItem item : query) {
            if (item.getRow() != 0 && item.getColumn() != 0 && item.isExisted()) {
                aoYinWithoutHeader.add(item);
            }
        }
    }
    return aoYinWithoutHeader;
}
Also used : GojuonItem(pri.weiqiang.liyujapanese.mvp.bean.gojuon.GojuonItem)

Example 2 with GojuonItem

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

the class DBManager method getQingYin.

public synchronized List<GojuonItem> getQingYin() {
    if (qingYin == null) {
        qingYin = new ArrayList<>();
        List<GojuonItem> query = query();
        for (GojuonItem item : query) {
            if (item.getCategory() == Constants.CATEGORY_QINGYIN) {
                qingYin.add(item);
            }
        }
        Collections.sort(qingYin, new GojuonItemComporator());
    }
    return qingYin;
}
Also used : GojuonItemComporator(pri.weiqiang.liyujapanese.comparator.GojuonItemComporator) GojuonItem(pri.weiqiang.liyujapanese.mvp.bean.gojuon.GojuonItem)

Example 3 with GojuonItem

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

the class DBManager method addHeaderString.

public void addHeaderString(List<GojuonItem> list, int row, int column) {
    for (int i = 1; i < column; i++) {
        GojuonItem item = list.get(i);
        String hiragana = item.getHiragana();
        String katakana = item.getKatakana();
        item.setHiragana(hiragana + ResourceUtils.getString(BaseApplication.getInstance(), R.string.column));
        item.setKatakana(katakana + ResourceUtils.getString(BaseApplication.getInstance(), R.string.column));
    }
    for (int i = 1; i < row; i++) {
        GojuonItem item = list.get(i * column);
        String hiragana = item.getHiragana();
        String katakana = item.getKatakana();
        item.setHiragana(hiragana + ResourceUtils.getString(BaseApplication.getInstance(), R.string.row));
        item.setKatakana(katakana + ResourceUtils.getString(BaseApplication.getInstance(), R.string.row));
    }
}
Also used : GojuonItem(pri.weiqiang.liyujapanese.mvp.bean.gojuon.GojuonItem)

Example 4 with GojuonItem

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

the class GojuonFragment method setData.

@Override
public void setData(List<GojuonItem> data) {
    adapter = new GojuonRecyclerAdapter(data);
    adapter.setOnItemClickListener(new GojuonRecyclerAdapter.OnItemClickListener() {

        @Override
        public void onClick(GojuonItem item) {
            SoundPoolManager.getInstance().play(item.getRome());
        }
    });
    adapter.setOnItemLongClickListener(new GojuonRecyclerAdapter.OnItemLongClickListener() {

        @Override
        public void onLongClick(GojuonItem 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) GojuonRecyclerAdapter(pri.weiqiang.liyujapanese.ui.adapter.GojuonRecyclerAdapter) GojuonGif(pri.weiqiang.liyujapanese.mvp.bean.gojuon.GojuonGif) GojuonItem(pri.weiqiang.liyujapanese.mvp.bean.gojuon.GojuonItem)

Example 5 with GojuonItem

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

the class MemorySwipeAdapter method getView.

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    ViewHolder holder;
    final GojuonItem item = list.get(position);
    if (convertView == null) {
        convertView = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_memory, parent, false);
        holder = new ViewHolder();
        holder.tv_rome = convertView.findViewById(R.id.tv_rome);
        holder.btn_yin = convertView.findViewById(R.id.btn_yin);
        holder.btn_write = convertView.findViewById(R.id.btn_write);
        holder.tv_hiragana = convertView.findViewById(R.id.tv_hiragana);
        holder.tv_katakana = convertView.findViewById(R.id.tv_katakana);
        convertView.setTag(holder);
    } else {
        holder = (ViewHolder) convertView.getTag();
    }
    holder.tv_rome.setText(item.getRome());
    if (item.getCategory() == Constants.CATEGORY_AOYIN) {
        holder.tv_hiragana.setTextSize(ResourceUtils.getDimension(parent.getContext(), R.dimen.memory_item_text_size_mini));
    } else {
        holder.tv_hiragana.setTextSize(ResourceUtils.getDimension(parent.getContext(), R.dimen.memory_item_text_size));
    }
    holder.tv_hiragana.setText(item.getHiragana());
    holder.tv_katakana.setText(item.getKatakana());
    holder.btn_yin.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (onYinButtonClickListener != null) {
                onYinButtonClickListener.onClick(item);
            }
        }
    });
    if (item.getCategory() == Constants.CATEGORY_AOYIN) {
        holder.btn_write.setEnabled(false);
    } else {
        holder.btn_write.setEnabled(true);
        holder.btn_write.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                if (onWriteButtonClickListener != null) {
                    onWriteButtonClickListener.onClick(item);
                }
            }
        });
    }
    return convertView;
}
Also used : TextView(android.widget.TextView) View(android.view.View) GojuonItem(pri.weiqiang.liyujapanese.mvp.bean.gojuon.GojuonItem)

Aggregations

GojuonItem (pri.weiqiang.liyujapanese.mvp.bean.gojuon.GojuonItem)28 GojuonItemComporator (pri.weiqiang.liyujapanese.comparator.GojuonItemComporator)6 View (android.view.View)4 TextView (android.widget.TextView)4 ImageDialog (pri.weiqaing.common.widget.dialog.ImageDialog)4 GojuonGif (pri.weiqiang.liyujapanese.mvp.bean.gojuon.GojuonGif)4 Cursor (android.database.Cursor)2 SQLiteDatabase (android.database.sqlite.SQLiteDatabase)2 RecyclerView (androidx.recyclerview.widget.RecyclerView)2 ObservableEmitter (io.reactivex.ObservableEmitter)2 ObservableOnSubscribe (io.reactivex.ObservableOnSubscribe)2 Disposable (io.reactivex.disposables.Disposable)2 ArrayList (java.util.ArrayList)2 GojuonRecyclerAdapter (pri.weiqiang.liyujapanese.ui.adapter.GojuonRecyclerAdapter)2 MemorySwipeAdapter (pri.weiqiang.liyujapanese.ui.adapter.MemorySwipeAdapter)2