use of com.waz.zclient.ui.views.tab.TabIndicatorLayout in project wire-android by wireapp.
the class TabbedParticipantBodyFragment method onCreateView.
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup viewGroup, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_participants_single_tabbed, viewGroup, false);
TabIndicatorLayout tabIndicatorLayout = ViewUtils.getView(view, R.id.til_single_participant_tabs);
int color;
if (getControllerFactory().getThemeController().isDarkTheme()) {
color = getResources().getColor(R.color.text__secondary_dark);
} else {
color = getResources().getColor(R.color.text__secondary_light);
}
if (tabIndicatorLayout != null) {
tabIndicatorLayout.setPrimaryColor(color);
}
viewPager = ViewUtils.getView(view, R.id.vp_single_participant_viewpager);
viewPager.setAdapter(new TabbedParticipantPagerAdapter(getActivity(), participantOtrDeviceAdapter, this));
viewPager.addOnPageChangeListener(this);
tabIndicatorLayout.setViewPager(viewPager);
if (savedInstanceState == null) {
if (getControllerFactory().getConversationScreenController().shouldShowDevicesTab()) {
viewPager.setCurrentItem(1);
getControllerFactory().getConversationScreenController().setShowDevicesTab(null);
} else {
int firstPage = getArguments().getInt(ARG__FIRST__PAGE);
viewPager.setCurrentItem(firstPage);
}
}
return view;
}
use of com.waz.zclient.ui.views.tab.TabIndicatorLayout in project wire-android by wireapp.
the class EmojiBottomSheetDialog method init.
private void init(List<String> recent, Set<String> unsupported) {
populateEmojis(recent, unsupported);
final RecyclerView recyclerView = new RecyclerView(getContext());
final EmojiAdapter adapter = new EmojiAdapter(getContext());
final GridLayoutManager layoutManager = new GridLayoutManager(getContext(), getEmojiLayoutManagerSpanCount(), LinearLayoutManager.HORIZONTAL, false);
layoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
@Override
public int getSpanSize(int position) {
return spaces.contains(position) ? getEmojiLayoutManagerSpanCount() : 1;
}
});
LinearLayout ll = new LinearLayout(getContext());
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
// noinspection deprecation
ll.setBackgroundColor(getContext().getResources().getColor(R.color.background_graphite));
} else {
ll.setBackgroundColor(getContext().getResources().getColor(R.color.background_graphite, getContext().getTheme()));
}
ll.setOrientation(LinearLayout.VERTICAL);
final TabIndicatorLayout til = new TabIndicatorLayout(getContext());
int[] labels = new int[3];
labels[0] = R.string.sketch__emoji_keyboard__size_label__small;
labels[1] = R.string.sketch__emoji_keyboard__size_label__medium;
labels[2] = R.string.sketch__emoji_keyboard__size_label__large;
til.setLabels(labels);
til.setSelected(currentEmojiSize.ordinal());
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
// noinspection deprecation
til.setTextColor(getContext().getResources().getColorStateList(R.color.wire__text_color_dark_selector));
// noinspection deprecation
til.setPrimaryColor(getContext().getResources().getColor(R.color.text__primary_dark));
} else {
til.setTextColor(getContext().getResources().getColorStateList(R.color.wire__text_color_dark_selector, getContext().getTheme()));
til.setPrimaryColor(getContext().getResources().getColor(R.color.text__primary_dark, getContext().getTheme()));
}
til.setLabelHeight(getContext().getResources().getDimensionPixelSize(R.dimen.sketch__emoji__keyboard__tab_label_size));
til.setCallback(new TabIndicatorLayout.Callback() {
@Override
public void onItemSelected(int pos) {
til.setSelected(pos);
currentEmojiSize = EmojiSize.values()[pos];
adapter.setEmojiSize(currentEmojiSize);
setRecyclerViewPadding(recyclerView);
layoutManager.setSpanCount(getEmojiLayoutManagerSpanCount());
}
});
ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, getContext().getResources().getDimensionPixelSize(R.dimen.sketch__emoji__keyboard__tab_size));
ll.addView(til, params);
recyclerView.setLayoutManager(layoutManager);
recyclerView.setAdapter(adapter);
ll.addView(recyclerView);
setRecyclerViewPadding(recyclerView);
adapter.setOnEmojiClickListener(new EmojiAdapter.OnEmojiClickListener() {
@Override
public void onEmojiClick(String emoji, EmojiSize emojiSize) {
if (listener != null) {
listener.onEmojiSelected(emoji, emojiSize);
}
dismiss();
}
});
adapter.setEmojis(emojis, currentEmojiSize);
setContentView(ll);
}
Aggregations