use of devlight.io.library.ntb.NavigationTabBar in project NavigationTabBar by Devlight.
the class HorizontalCoordinatorNtbActivity method initUI.
private void initUI() {
final ViewPager viewPager = (ViewPager) findViewById(R.id.vp_horizontal_ntb);
viewPager.setAdapter(new PagerAdapter() {
@Override
public int getCount() {
return 5;
}
@Override
public boolean isViewFromObject(final View view, final Object object) {
return view.equals(object);
}
@Override
public void destroyItem(final View container, final int position, final Object object) {
((ViewPager) container).removeView((View) object);
}
@Override
public Object instantiateItem(final ViewGroup container, final int position) {
final View view = LayoutInflater.from(getBaseContext()).inflate(R.layout.item_vp_list, null, false);
final RecyclerView recyclerView = (RecyclerView) view.findViewById(R.id.rv);
recyclerView.setHasFixedSize(true);
recyclerView.setLayoutManager(new LinearLayoutManager(getBaseContext(), LinearLayoutManager.VERTICAL, false));
recyclerView.setAdapter(new RecycleAdapter());
container.addView(view);
return view;
}
});
final String[] colors = getResources().getStringArray(R.array.default_preview);
final NavigationTabBar navigationTabBar = (NavigationTabBar) findViewById(R.id.ntb_horizontal);
final ArrayList<NavigationTabBar.Model> models = new ArrayList<>();
models.add(new NavigationTabBar.Model.Builder(getResources().getDrawable(R.drawable.ic_first), Color.parseColor(colors[0])).title("Heart").build());
models.add(new NavigationTabBar.Model.Builder(getResources().getDrawable(R.drawable.ic_second), Color.parseColor(colors[1])).title("Cup").build());
models.add(new NavigationTabBar.Model.Builder(getResources().getDrawable(R.drawable.ic_third), Color.parseColor(colors[2])).title("Diploma").build());
models.add(new NavigationTabBar.Model.Builder(getResources().getDrawable(R.drawable.ic_fourth), Color.parseColor(colors[3])).title("Flag").build());
models.add(new NavigationTabBar.Model.Builder(getResources().getDrawable(R.drawable.ic_fifth), Color.parseColor(colors[4])).title("Medal").build());
navigationTabBar.setModels(models);
navigationTabBar.setViewPager(viewPager, 2);
//IMPORTANT: ENABLE SCROLL BEHAVIOUR IN COORDINATOR LAYOUT
navigationTabBar.setBehaviorEnabled(true);
navigationTabBar.setOnTabBarSelectedIndexListener(new NavigationTabBar.OnTabBarSelectedIndexListener() {
@Override
public void onStartTabSelected(final NavigationTabBar.Model model, final int index) {
}
@Override
public void onEndTabSelected(final NavigationTabBar.Model model, final int index) {
model.hideBadge();
}
});
navigationTabBar.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@Override
public void onPageScrolled(final int position, final float positionOffset, final int positionOffsetPixels) {
}
@Override
public void onPageSelected(final int position) {
}
@Override
public void onPageScrollStateChanged(final int state) {
}
});
final CoordinatorLayout coordinatorLayout = (CoordinatorLayout) findViewById(R.id.parent);
findViewById(R.id.fab).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(final View v) {
for (int i = 0; i < navigationTabBar.getModels().size(); i++) {
final NavigationTabBar.Model model = navigationTabBar.getModels().get(i);
navigationTabBar.postDelayed(new Runnable() {
@Override
public void run() {
final String title = String.valueOf(new Random().nextInt(15));
if (!model.isBadgeShowed()) {
model.setBadgeTitle(title);
model.showBadge();
} else
model.updateBadgeTitle(title);
}
}, i * 100);
}
coordinatorLayout.postDelayed(new Runnable() {
@Override
public void run() {
final Snackbar snackbar = Snackbar.make(navigationTabBar, "Coordinator NTB", Snackbar.LENGTH_SHORT);
snackbar.getView().setBackgroundColor(Color.parseColor("#9b92b3"));
((TextView) snackbar.getView().findViewById(R.id.snackbar_text)).setTextColor(Color.parseColor("#423752"));
snackbar.show();
}
}, 1000);
}
});
final CollapsingToolbarLayout collapsingToolbarLayout = (CollapsingToolbarLayout) findViewById(R.id.toolbar);
collapsingToolbarLayout.setExpandedTitleColor(Color.parseColor("#009F90AF"));
collapsingToolbarLayout.setCollapsedTitleTextColor(Color.parseColor("#9f90af"));
}
use of devlight.io.library.ntb.NavigationTabBar in project NavigationTabBar by Devlight.
the class HorizontalNtbActivity method initUI.
private void initUI() {
final ViewPager viewPager = (ViewPager) findViewById(R.id.vp_horizontal_ntb);
viewPager.setAdapter(new PagerAdapter() {
@Override
public int getCount() {
return 5;
}
@Override
public boolean isViewFromObject(final View view, final Object object) {
return view.equals(object);
}
@Override
public void destroyItem(final View container, final int position, final Object object) {
((ViewPager) container).removeView((View) object);
}
@Override
public Object instantiateItem(final ViewGroup container, final int position) {
final View view = LayoutInflater.from(getBaseContext()).inflate(R.layout.item_vp, null, false);
final TextView txtPage = (TextView) view.findViewById(R.id.txt_vp_item_page);
txtPage.setText(String.format("Page #%d", position));
container.addView(view);
return view;
}
});
final String[] colors = getResources().getStringArray(R.array.default_preview);
final NavigationTabBar navigationTabBar = (NavigationTabBar) findViewById(R.id.ntb_horizontal);
final ArrayList<NavigationTabBar.Model> models = new ArrayList<>();
models.add(new NavigationTabBar.Model.Builder(getResources().getDrawable(R.drawable.ic_first), Color.parseColor(colors[0])).selectedIcon(getResources().getDrawable(R.drawable.ic_sixth)).title("Heart").badgeTitle("NTB").build());
models.add(new NavigationTabBar.Model.Builder(getResources().getDrawable(R.drawable.ic_second), Color.parseColor(colors[1])).title("Cup").badgeTitle("with").build());
models.add(new NavigationTabBar.Model.Builder(getResources().getDrawable(R.drawable.ic_third), Color.parseColor(colors[2])).selectedIcon(getResources().getDrawable(R.drawable.ic_seventh)).title("Diploma").badgeTitle("state").build());
models.add(new NavigationTabBar.Model.Builder(getResources().getDrawable(R.drawable.ic_fourth), Color.parseColor(colors[3])).title("Flag").badgeTitle("icon").build());
models.add(new NavigationTabBar.Model.Builder(getResources().getDrawable(R.drawable.ic_fifth), Color.parseColor(colors[4])).selectedIcon(getResources().getDrawable(R.drawable.ic_eighth)).title("Medal").badgeTitle("777").build());
navigationTabBar.setModels(models);
navigationTabBar.setViewPager(viewPager, 2);
navigationTabBar.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@Override
public void onPageScrolled(final int position, final float positionOffset, final int positionOffsetPixels) {
}
@Override
public void onPageSelected(final int position) {
navigationTabBar.getModels().get(position).hideBadge();
}
@Override
public void onPageScrollStateChanged(final int state) {
}
});
navigationTabBar.postDelayed(new Runnable() {
@Override
public void run() {
for (int i = 0; i < navigationTabBar.getModels().size(); i++) {
final NavigationTabBar.Model model = navigationTabBar.getModels().get(i);
navigationTabBar.postDelayed(new Runnable() {
@Override
public void run() {
model.showBadge();
}
}, i * 100);
}
}
}, 500);
}
use of devlight.io.library.ntb.NavigationTabBar in project NavigationTabBar by Devlight.
the class TopHorizontalNtbActivity method initUI.
private void initUI() {
final ViewPager viewPager = (ViewPager) findViewById(R.id.vp_horizontal_ntb);
viewPager.setAdapter(new PagerAdapter() {
@Override
public int getCount() {
return 5;
}
@Override
public boolean isViewFromObject(final View view, final Object object) {
return view.equals(object);
}
@Override
public void destroyItem(final View container, final int position, final Object object) {
((ViewPager) container).removeView((View) object);
}
@Override
public Object instantiateItem(final ViewGroup container, final int position) {
final View view = LayoutInflater.from(getBaseContext()).inflate(R.layout.item_vp_list, null, false);
final RecyclerView recyclerView = (RecyclerView) view.findViewById(R.id.rv);
recyclerView.setHasFixedSize(true);
recyclerView.setLayoutManager(new LinearLayoutManager(getBaseContext(), LinearLayoutManager.VERTICAL, false));
recyclerView.setAdapter(new RecycleAdapter());
container.addView(view);
return view;
}
});
final String[] colors = getResources().getStringArray(R.array.default_preview);
final NavigationTabBar navigationTabBar = (NavigationTabBar) findViewById(R.id.ntb_horizontal);
final ArrayList<NavigationTabBar.Model> models = new ArrayList<>();
models.add(new NavigationTabBar.Model.Builder(getResources().getDrawable(R.drawable.ic_first), Color.parseColor(colors[0])).title("Heart").build());
models.add(new NavigationTabBar.Model.Builder(getResources().getDrawable(R.drawable.ic_second), Color.parseColor(colors[1])).title("Cup").build());
models.add(new NavigationTabBar.Model.Builder(getResources().getDrawable(R.drawable.ic_third), Color.parseColor(colors[2])).title("Diploma").build());
models.add(new NavigationTabBar.Model.Builder(getResources().getDrawable(R.drawable.ic_fourth), Color.parseColor(colors[3])).title("Flag").build());
models.add(new NavigationTabBar.Model.Builder(getResources().getDrawable(R.drawable.ic_fifth), Color.parseColor(colors[4])).title("Medal").build());
navigationTabBar.setModels(models);
navigationTabBar.setViewPager(viewPager, 2);
navigationTabBar.post(new Runnable() {
@Override
public void run() {
final View viewPager = findViewById(R.id.vp_horizontal_ntb);
((ViewGroup.MarginLayoutParams) viewPager.getLayoutParams()).topMargin = (int) -navigationTabBar.getBadgeMargin();
viewPager.requestLayout();
}
});
navigationTabBar.setOnTabBarSelectedIndexListener(new NavigationTabBar.OnTabBarSelectedIndexListener() {
@Override
public void onStartTabSelected(final NavigationTabBar.Model model, final int index) {
}
@Override
public void onEndTabSelected(final NavigationTabBar.Model model, final int index) {
model.hideBadge();
}
});
findViewById(R.id.mask).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(final View v) {
for (int i = 0; i < navigationTabBar.getModels().size(); i++) {
final NavigationTabBar.Model model = navigationTabBar.getModels().get(i);
navigationTabBar.postDelayed(new Runnable() {
@Override
public void run() {
final String title = String.valueOf(new Random().nextInt(15));
if (!model.isBadgeShowed()) {
model.setBadgeTitle(title);
model.showBadge();
} else
model.updateBadgeTitle(title);
}
}, i * 100);
}
}
});
}
use of devlight.io.library.ntb.NavigationTabBar in project NavigationTabBar by Devlight.
the class VerticalNtbActivity method initUI.
private void initUI() {
final ViewPager viewPager = (ViewPager) findViewById(R.id.vp_vertical_ntb);
viewPager.setAdapter(new PagerAdapter() {
@Override
public int getCount() {
return 8;
}
@Override
public boolean isViewFromObject(final View view, final Object object) {
return view.equals(object);
}
@Override
public void destroyItem(final View container, final int position, final Object object) {
((ViewPager) container).removeView((View) object);
}
@Override
public Object instantiateItem(final ViewGroup container, final int position) {
final View view = LayoutInflater.from(getBaseContext()).inflate(R.layout.item_vp, null, false);
final TextView txtPage = (TextView) view.findViewById(R.id.txt_vp_item_page);
txtPage.setText(String.format("Page #%d", position));
container.addView(view);
return view;
}
});
final String[] colors = getResources().getStringArray(R.array.vertical_ntb);
final NavigationTabBar navigationTabBar = (NavigationTabBar) findViewById(R.id.ntb_vertical);
final ArrayList<NavigationTabBar.Model> models = new ArrayList<>();
models.add(new NavigationTabBar.Model.Builder(getResources().getDrawable(R.drawable.ic_first), Color.parseColor(colors[0])).selectedIcon(getResources().getDrawable(R.drawable.ic_eighth)).build());
models.add(new NavigationTabBar.Model.Builder(getResources().getDrawable(R.drawable.ic_second), Color.parseColor(colors[1])).selectedIcon(getResources().getDrawable(R.drawable.ic_eighth)).build());
models.add(new NavigationTabBar.Model.Builder(getResources().getDrawable(R.drawable.ic_third), Color.parseColor(colors[2])).selectedIcon(getResources().getDrawable(R.drawable.ic_eighth)).build());
models.add(new NavigationTabBar.Model.Builder(getResources().getDrawable(R.drawable.ic_fourth), Color.parseColor(colors[3])).selectedIcon(getResources().getDrawable(R.drawable.ic_eighth)).build());
models.add(new NavigationTabBar.Model.Builder(getResources().getDrawable(R.drawable.ic_fifth), Color.parseColor(colors[4])).selectedIcon(getResources().getDrawable(R.drawable.ic_eighth)).build());
models.add(new NavigationTabBar.Model.Builder(getResources().getDrawable(R.drawable.ic_sixth), Color.parseColor(colors[5])).selectedIcon(getResources().getDrawable(R.drawable.ic_eighth)).build());
models.add(new NavigationTabBar.Model.Builder(getResources().getDrawable(R.drawable.ic_seventh), Color.parseColor(colors[6])).selectedIcon(getResources().getDrawable(R.drawable.ic_eighth)).build());
models.add(new NavigationTabBar.Model.Builder(getResources().getDrawable(R.drawable.ic_eighth), Color.parseColor(colors[7])).selectedIcon(getResources().getDrawable(R.drawable.ic_eighth)).build());
navigationTabBar.setModels(models);
navigationTabBar.setViewPager(viewPager, 4);
}
use of devlight.io.library.ntb.NavigationTabBar in project NavigationTabBar by Devlight.
the class SamplesNtbActivity method initUI.
private void initUI() {
final NavigationTabBar ntbSample1 = (NavigationTabBar) findViewById(R.id.ntb_sample_1);
final ArrayList<NavigationTabBar.Model> models1 = new ArrayList<>();
models1.add(new NavigationTabBar.Model.Builder(getResources().getDrawable(R.drawable.ic_first), Color.WHITE).build());
models1.add(new NavigationTabBar.Model.Builder(getResources().getDrawable(R.drawable.ic_second), Color.LTGRAY).build());
models1.add(new NavigationTabBar.Model.Builder(getResources().getDrawable(R.drawable.ic_third), Color.GRAY).build());
models1.add(new NavigationTabBar.Model.Builder(getResources().getDrawable(R.drawable.ic_fourth), Color.DKGRAY).build());
ntbSample1.setModels(models1);
final NavigationTabBar ntbSample2 = (NavigationTabBar) findViewById(R.id.ntb_sample_2);
final ArrayList<NavigationTabBar.Model> models2 = new ArrayList<>();
models2.add(new NavigationTabBar.Model.Builder(getResources().getDrawable(R.drawable.ic_seventh), Color.YELLOW).build());
models2.add(new NavigationTabBar.Model.Builder(getResources().getDrawable(R.drawable.ic_sixth), Color.YELLOW).build());
models2.add(new NavigationTabBar.Model.Builder(getResources().getDrawable(R.drawable.ic_fifth), Color.YELLOW).build());
models2.add(new NavigationTabBar.Model.Builder(getResources().getDrawable(R.drawable.ic_eighth), Color.YELLOW).build());
models2.add(new NavigationTabBar.Model.Builder(getResources().getDrawable(R.drawable.ic_second), Color.YELLOW).build());
ntbSample2.setModels(models2);
ntbSample2.setModelIndex(3, true);
final NavigationTabBar ntbSample3 = (NavigationTabBar) findViewById(R.id.ntb_sample_3);
final ArrayList<NavigationTabBar.Model> models3 = new ArrayList<>();
models3.add(new NavigationTabBar.Model.Builder(getResources().getDrawable(R.drawable.ic_seventh), Color.RED).build());
models3.add(new NavigationTabBar.Model.Builder(getResources().getDrawable(R.drawable.ic_seventh), Color.RED).build());
models3.add(new NavigationTabBar.Model.Builder(getResources().getDrawable(R.drawable.ic_seventh), Color.RED).build());
ntbSample3.setModels(models3);
ntbSample3.setModelIndex(1, true);
final NavigationTabBar ntbSample4 = (NavigationTabBar) findViewById(R.id.ntb_sample_4);
final int bgColor = Color.parseColor("#423752");
final ArrayList<NavigationTabBar.Model> models4 = new ArrayList<>();
models4.add(new NavigationTabBar.Model.Builder(getResources().getDrawable(R.drawable.ic_fifth), bgColor).build());
models4.add(new NavigationTabBar.Model.Builder(getResources().getDrawable(R.drawable.ic_first), bgColor).build());
models4.add(new NavigationTabBar.Model.Builder(getResources().getDrawable(R.drawable.ic_fourth), bgColor).build());
models4.add(new NavigationTabBar.Model.Builder(getResources().getDrawable(R.drawable.ic_sixth), bgColor).build());
models4.add(new NavigationTabBar.Model.Builder(getResources().getDrawable(R.drawable.ic_third), bgColor).build());
ntbSample4.setModels(models4);
ntbSample4.setModelIndex(2, true);
final NavigationTabBar ntbSample5 = (NavigationTabBar) findViewById(R.id.ntb_sample_5);
final ArrayList<NavigationTabBar.Model> models5 = new ArrayList<>();
models5.add(new NavigationTabBar.Model.Builder(getResources().getDrawable(R.drawable.ic_fifth), Color.WHITE).build());
models5.add(new NavigationTabBar.Model.Builder(getResources().getDrawable(R.drawable.ic_first), Color.WHITE).build());
models5.add(new NavigationTabBar.Model.Builder(getResources().getDrawable(R.drawable.ic_fourth), Color.WHITE).build());
models5.add(new NavigationTabBar.Model.Builder(getResources().getDrawable(R.drawable.ic_sixth), Color.WHITE).build());
ntbSample5.setModels(models5);
ntbSample5.setModelIndex(2, true);
ntbSample5.setOnTabBarSelectedIndexListener(new NavigationTabBar.OnTabBarSelectedIndexListener() {
@Override
public void onStartTabSelected(final NavigationTabBar.Model model, final int index) {
}
@Override
public void onEndTabSelected(final NavigationTabBar.Model model, final int index) {
Toast.makeText(SamplesNtbActivity.this, String.format("onEndTabSelected #%d", index), Toast.LENGTH_SHORT).show();
}
});
final NavigationTabBar ntbSample6 = (NavigationTabBar) findViewById(R.id.ntb_sample_6);
final ArrayList<NavigationTabBar.Model> models6 = new ArrayList<>();
models6.add(new NavigationTabBar.Model.Builder(getResources().getDrawable(R.drawable.ic_fifth), randomColor()).build());
models6.add(new NavigationTabBar.Model.Builder(getResources().getDrawable(R.drawable.ic_first), randomColor()).build());
models6.add(new NavigationTabBar.Model.Builder(getResources().getDrawable(R.drawable.ic_fourth), randomColor()).build());
models6.add(new NavigationTabBar.Model.Builder(getResources().getDrawable(R.drawable.ic_sixth), randomColor()).build());
ntbSample6.setModels(models6);
}
Aggregations