|
|
|
|
@ -1,5 +1,7 @@ |
|
|
|
|
package com.fongmi.android.tv.ui.adapter; |
|
|
|
|
|
|
|
|
|
import static java.util.Locale.*; |
|
|
|
|
|
|
|
|
|
import android.view.LayoutInflater; |
|
|
|
|
import android.view.View; |
|
|
|
|
import android.view.ViewGroup; |
|
|
|
|
@ -8,22 +10,53 @@ import androidx.annotation.NonNull; |
|
|
|
|
import androidx.recyclerview.widget.RecyclerView; |
|
|
|
|
|
|
|
|
|
import com.fongmi.android.tv.R; |
|
|
|
|
import com.fongmi.android.tv.Setting; |
|
|
|
|
import com.fongmi.android.tv.databinding.AdapterKeyboardIconBinding; |
|
|
|
|
import com.fongmi.android.tv.databinding.AdapterKeyboardTextBinding; |
|
|
|
|
|
|
|
|
|
import java.util.Arrays; |
|
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public class KeyboardAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> { |
|
|
|
|
|
|
|
|
|
private final OnClickListener mListener; |
|
|
|
|
private final List<Object> mItems; |
|
|
|
|
private List<Object> mItems; |
|
|
|
|
|
|
|
|
|
private List<Object> englishKeys =Arrays.asList( |
|
|
|
|
R.drawable.ic_keyboard_remote |
|
|
|
|
, R.drawable.ic_keyboard_left |
|
|
|
|
, R.drawable.ic_keyboard_right |
|
|
|
|
, R.drawable.ic_keyboard_back |
|
|
|
|
, R.drawable.ic_keyboard_search |
|
|
|
|
, R.drawable.ic_setting_home |
|
|
|
|
, R.drawable.ic_action_zhuyin |
|
|
|
|
, "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z" |
|
|
|
|
, "0", "1", "2", "3", "4", "5", "6", "7", "8", "9"); |
|
|
|
|
|
|
|
|
|
private List<Object> zhuYinKeys =Arrays.asList( |
|
|
|
|
R.drawable.ic_keyboard_remote |
|
|
|
|
, R.drawable.ic_keyboard_left |
|
|
|
|
, R.drawable.ic_keyboard_right |
|
|
|
|
, R.drawable.ic_keyboard_back |
|
|
|
|
, R.drawable.ic_keyboard_search |
|
|
|
|
, R.drawable.ic_setting_home |
|
|
|
|
, R.drawable.ic_action_zhuyin |
|
|
|
|
,"ㄅ", "ㄆ", "ㄇ", "ㄈ", "ㄉ", "ㄊ", "ㄋ", "ㄌ", "ㄍ", "ㄎ", "ㄏ", "ㄐ", "ㄑ", "ㄒ", |
|
|
|
|
"ㄓ", "ㄔ", "ㄕ", "ㄖ", "ㄗ", "ㄘ", "ㄙ", "ㄚ", "ㄛ", "ㄜ", "ㄝ", "ㄞ", "ㄟ", "ㄠ", "ㄡ", "ㄢ", "ㄣ", |
|
|
|
|
"ㄤ", "ㄥ", "ㄦ", "ㄧ", "ㄨ", "ㄩ" |
|
|
|
|
, "0", "1", "2", "3", "4", "5", "6", "7", "8", "9"); |
|
|
|
|
|
|
|
|
|
public KeyboardAdapter(OnClickListener listener) { |
|
|
|
|
this.mItems = Arrays.asList(R.drawable.ic_keyboard_remote, R.drawable.ic_keyboard_left, R.drawable.ic_keyboard_right, R.drawable.ic_keyboard_back, R.drawable.ic_keyboard_search, R.drawable.ic_setting_home, "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9"); |
|
|
|
|
if(Setting.getLanguage()==2){ |
|
|
|
|
this.mItems = zhuYinKeys; |
|
|
|
|
}else{ |
|
|
|
|
this.mItems = englishKeys; |
|
|
|
|
} |
|
|
|
|
this.mListener = listener; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public interface OnClickListener { |
|
|
|
|
|
|
|
|
|
void onTextClick(String text); |
|
|
|
|
@ -33,6 +66,19 @@ public class KeyboardAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolde |
|
|
|
|
boolean onLongClick(int resId); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void updateKeyList(List<Object> newKeys) { |
|
|
|
|
this.mItems = newKeys; |
|
|
|
|
notifyDataSetChanged(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public List<Object> getEnglishKeys() { |
|
|
|
|
return englishKeys; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public List<Object> getZhuYinKeys() { |
|
|
|
|
return zhuYinKeys; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public int getItemViewType(int position) { |
|
|
|
|
return mItems.get(position) instanceof String ? 0 : 1; |
|
|
|
|
|