mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-25 09:17:44 +00:00
parent
bea9922840
commit
3effe77830
@ -37,6 +37,7 @@ public class EmojiDrawer extends Fragment {
|
|||||||
private EmojiEditText composeText;
|
private EmojiEditText composeText;
|
||||||
private KeyboardAwareLinearLayout container;
|
private KeyboardAwareLinearLayout container;
|
||||||
private ViewPager pager;
|
private ViewPager pager;
|
||||||
|
private List<EmojiPageModel> models;
|
||||||
private PagerSlidingTabStrip strip;
|
private PagerSlidingTabStrip strip;
|
||||||
private RecentEmojiPageModel recentModel;
|
private RecentEmojiPageModel recentModel;
|
||||||
|
|
||||||
@ -61,6 +62,7 @@ public class EmojiDrawer extends Fragment {
|
|||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
final View v = inflater.inflate(R.layout.emoji_drawer, container, false);
|
final View v = inflater.inflate(R.layout.emoji_drawer, container, false);
|
||||||
initializeResources(v);
|
initializeResources(v);
|
||||||
|
initializePageModels(getArguments().getInt("categories"), getArguments().getInt("icons"));
|
||||||
initializeEmojiGrid();
|
initializeEmojiGrid();
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
@ -98,30 +100,31 @@ public class EmojiDrawer extends Fragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void initializeEmojiGrid() {
|
private void initializeEmojiGrid() {
|
||||||
|
|
||||||
pager.setAdapter(new EmojiPagerAdapter(getActivity(),
|
pager.setAdapter(new EmojiPagerAdapter(getActivity(),
|
||||||
getFragmentManager(),
|
getFragmentManager(),
|
||||||
getPageModels(getArguments().getInt("categories"),
|
models,
|
||||||
getArguments().getInt("icons")),
|
|
||||||
new EmojiSelectionListener() {
|
new EmojiSelectionListener() {
|
||||||
@Override public void onEmojiSelected(int emojiCode) {
|
@Override public void onEmojiSelected(int emojiCode) {
|
||||||
recentModel.onCodePointSelected(emojiCode);
|
recentModel.onCodePointSelected(emojiCode);
|
||||||
composeText.insertEmoji(emojiCode);
|
composeText.insertEmoji(emojiCode);
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
if (recentModel.getCodePoints().length == 0) {
|
||||||
|
pager.setCurrentItem(1);
|
||||||
|
}
|
||||||
strip.setViewPager(pager);
|
strip.setViewPager(pager);
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<EmojiPageModel> getPageModels(@ArrayRes int pagesRes, @ArrayRes int iconsRes) {
|
private void initializePageModels(@ArrayRes int pagesRes, @ArrayRes int iconsRes) {
|
||||||
final int[] icons = ResUtil.getResourceIds(getActivity(), iconsRes);
|
final int[] icons = ResUtil.getResourceIds(getActivity(), iconsRes);
|
||||||
final int[] pages = ResUtil.getResourceIds(getActivity(), pagesRes);
|
final int[] pages = ResUtil.getResourceIds(getActivity(), pagesRes);
|
||||||
final List<EmojiPageModel> models = new LinkedList<>();
|
this.models = new LinkedList<>();
|
||||||
recentModel = new RecentEmojiPageModel(getActivity());
|
this.recentModel = new RecentEmojiPageModel(getActivity());
|
||||||
models.add(recentModel);
|
this.models.add(recentModel);
|
||||||
for (int i = 0; i < icons.length; i++) {
|
for (int i = 0; i < icons.length; i++) {
|
||||||
models.add(new StaticEmojiPageModel(icons[i], getResources().getIntArray(pages[i])));
|
this.models.add(new StaticEmojiPageModel(icons[i], getResources().getIntArray(pages[i])));
|
||||||
}
|
}
|
||||||
return models;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class EmojiPagerAdapter extends FragmentStatePagerAdapter
|
public static class EmojiPagerAdapter extends FragmentStatePagerAdapter
|
||||||
|
Loading…
x
Reference in New Issue
Block a user