use of android.support.design.widget.TabLayout in project MadMax by deviz92.
the class DetailFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
// create the view to return
View mainView = null;
// get the bundle
Bundle bundle = this.getArguments();
// the listener will be the GroupDetailActivity or the FriendDetailActivity
setInterface((OnItemClickInterface) getActivity());
databaseReference = FirebaseDatabase.getInstance().getReference();
// when an item in the list will be clicked the onListItemClicked will be called
groupsViewAdapter = new GroupsViewAdapter(this.getContext(), this, groups, DetailFragment.TAG);
if (activityName.equals("FriendDetailActivity")) {
Log.d(TAG, "FriendDetailActivity per RecylerView");
// Inflate the layout for this fragment
mainView = inflater.inflate(R.layout.skeleton_list_friend, container, false);
RecyclerView.ItemDecoration divider = new InsetDivider.Builder(getContext()).orientation(InsetDivider.VERTICAL_LIST).dividerHeight(getResources().getDimensionPixelSize(R.dimen.divider_height)).color(ContextCompat.getColor(getContext(), R.color.colorDivider)).insets(getResources().getDimensionPixelSize(R.dimen.divider_inset), 0).overlay(true).build();
recyclerView = (RecyclerView) mainView.findViewById(R.id.rv_skeleton);
layoutManager = new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, false);
recyclerView.setLayoutManager(layoutManager);
recyclerView.addItemDecoration(divider);
recyclerView.setAdapter(groupsViewAdapter);
// Extract data from bundle
friendID = bundle.getString("friendID");
// Show shared groups
databaseReference.child("users").child(MainActivity.getCurrentUser().getID()).child("friends").child(friendID).child("sharedGroups").addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
for (DataSnapshot sharedGroupSnapshot : dataSnapshot.getChildren()) {
FirebaseUtils.getInstance().getGroup(sharedGroupSnapshot.getKey(), groups, groupsViewAdapter);
}
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
} else if (activityName.equals("GroupDetailActivity")) {
groupID = bundle.getString("groupID");
mainView = inflater.inflate(R.layout.fragment_group_detail, container, false);
fab = (FloatingActionButton) getActivity().findViewById(R.id.fab);
fab.setImageResource(android.R.drawable.ic_input_add);
TabLayout tabLayout = (TabLayout) mainView.findViewById(R.id.tab_layout);
tabLayout.addTab(tabLayout.newTab().setText(R.string.expenses));
tabLayout.addTab(tabLayout.newTab().setText(R.string.members));
tabLayout.addTab(tabLayout.newTab().setText(R.string.activities));
tabLayout.setTabGravity(TabLayout.GRAVITY_FILL);
updateFab(0);
final ViewPager viewPager = (ViewPager) mainView.findViewById(R.id.main_view_pager);
final DetailFragment.PagerAdapter adapter = new DetailFragment.PagerAdapter(getActivity().getSupportFragmentManager(), tabLayout.getTabCount());
viewPager.setAdapter(adapter);
viewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout));
tabLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
@Override
public void onTabSelected(TabLayout.Tab tab) {
Log.d(TAG, "selected tab " + tab.getPosition());
updateFab(tab.getPosition());
viewPager.setCurrentItem(tab.getPosition());
}
@Override
public void onTabUnselected(TabLayout.Tab tab) {
}
@Override
public void onTabReselected(TabLayout.Tab tab) {
}
});
}
return mainView;
}
use of android.support.design.widget.TabLayout in project MadMax by deviz92.
the class LoginSignUpActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// the first time user open the app the default preferences must be setted up
PreferenceManager.setDefaultValues(this, R.layout.preferences, false);
Log.i(TAG, "onCreate");
FirebaseUtils.getInstance().setUp();
// getting Intent from invitation
Intent startingIntent = getIntent();
// prepare intent for MainActivity
goToMain = new Intent(getApplicationContext(), MainActivity.class);
goToMain.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
String action = startingIntent.getAction();
Log.d(TAG, "action " + action);
// retrieving data from the intent inviterID & groupToBeAddedID as the group ID where to add the current user
if (startingIntent.hasExtra("inviterID")) {
// to be used to set the current user as friend of the inviter
Log.d(TAG, "there is an invite");
inviterID = startingIntent.getStringExtra("inviterID");
startingIntent.removeExtra("inviterID");
goToMain.putExtra("inviterID", inviterID);
} else
inviterID = null;
if (startingIntent.hasExtra("groupToBeAddedID")) {
groupToBeAddedID = startingIntent.getStringExtra("groupToBeAddedID");
startingIntent.removeExtra("groupToBeAddedID");
goToMain.putExtra("groupToBeAddedID", groupToBeAddedID);
} else
groupToBeAddedID = null;
// insert tabs and current fragment in the main layout
setContentView(R.layout.activity_log_in_signup);
// for adding custom font to the title of the app
TextView titleTextView = (TextView) findViewById(R.id.title);
Typeface mycustomfont = Typeface.createFromAsset(getAssets(), "fonts/Lobster-Regular.ttf");
titleTextView.setTypeface(mycustomfont);
// for adding custom background image
ImageView background = (ImageView) findViewById(R.id.background);
Glide.with(this).load(R.drawable.background).centerCrop().diskCacheStrategy(DiskCacheStrategy.ALL).into(background);
// findViewById(R.id.activity_log_in_signup_layout).setOnClickListener(this);
TabLayout tabLayout = (TabLayout) findViewById(R.id.tab_layout);
tabLayout.addTab(tabLayout.newTab().setText(R.string.login));
tabLayout.addTab(tabLayout.newTab().setText(R.string.signup));
tabLayout.setTabGravity(TabLayout.GRAVITY_FILL);
viewPager = (ViewPager) findViewById(R.id.main_view_pager);
adapter = new PagerAdapter(getSupportFragmentManager(), tabLayout.getTabCount());
viewPager.setAdapter(adapter);
viewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout));
viewPager.setCurrentItem(0);
tabLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
@Override
public void onTabSelected(TabLayout.Tab tab) {
Log.d(TAG, String.valueOf(tab.getPosition()));
viewPager.setCurrentItem(tab.getPosition());
}
@Override
public void onTabUnselected(TabLayout.Tab tab) {
}
@Override
public void onTabReselected(TabLayout.Tab tab) {
}
});
}
use of android.support.design.widget.TabLayout in project Varis-Android by dkhmelenko.
the class RepoDetailsActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_repo_details);
ButterKnife.bind(this);
TravisApp.instance().activityInjector().inject(this);
initToolbar();
// setting view pager
ViewPager vpPager = (ViewPager) findViewById(R.id.repo_details_view_pager);
mAdapterViewPager = new PagerAdapter(getSupportFragmentManager());
vpPager.setAdapter(mAdapterViewPager);
vpPager.setOffscreenPageLimit(PagerAdapter.ITEMS_COUNT);
TabLayout tabLayout = (TabLayout) findViewById(R.id.repo_details_view_tabs);
tabLayout.setupWithViewPager(vpPager);
}
use of android.support.design.widget.TabLayout in project Varis-Android by dkhmelenko.
the class RepoDetailsActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
AndroidInjection.inject(this);
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_repo_details);
ButterKnife.bind(this);
initToolbar();
// setting view pager
ViewPager vpPager = findViewById(R.id.repo_details_view_pager);
mAdapterViewPager = new PagerAdapter(getSupportFragmentManager());
vpPager.setAdapter(mAdapterViewPager);
vpPager.setOffscreenPageLimit(PagerAdapter.ITEMS_COUNT);
TabLayout tabLayout = findViewById(R.id.repo_details_view_tabs);
tabLayout.setupWithViewPager(vpPager);
}
use of android.support.design.widget.TabLayout in project RecyclerViewUndoSwipe by HoneyNeutrons.
the class MainActivity method setTabs.
private void setTabs() {
TabLayout tabLayout = (TabLayout) findViewById(R.id.tabLayout);
assert tabLayout != null;
tabLayout.addTab(tabLayout.newTab().setText("TAB1"));
tabLayout.addTab(tabLayout.newTab().setText("TAB2"));
tabLayout.addTab(tabLayout.newTab().setText("TAB3"));
// TabLayout font & size
ViewGroup vg = (ViewGroup) tabLayout.getChildAt(0);
int tabsCount = vg.getChildCount();
for (int j = 0; j < tabsCount; j++) {
ViewGroup vgTab = (ViewGroup) vg.getChildAt(j);
int tabChildsCount = vgTab.getChildCount();
for (int i = 0; i < tabChildsCount; i++) {
View tabViewChild = vgTab.getChildAt(i);
if (tabViewChild instanceof TextView) {
((TextView) tabViewChild).setTypeface(Typefaces.getRobotoBlack(this));
((TextView) tabViewChild).setTextSize(3);
}
}
}
}
Aggregations