Search in sources :

Example 76 with TabLayout

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;
}
Also used : GroupsViewAdapter(com.polito.mad17.madmax.activities.groups.GroupsViewAdapter) Bundle(android.os.Bundle) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) DataSnapshot(com.google.firebase.database.DataSnapshot) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) ViewPager(android.support.v4.view.ViewPager) FragmentPagerAdapter(android.support.v4.app.FragmentPagerAdapter) DatabaseError(com.google.firebase.database.DatabaseError) TabLayout(android.support.design.widget.TabLayout) FloatingActionButton(android.support.design.widget.FloatingActionButton) RecyclerView(android.support.v7.widget.RecyclerView) ValueEventListener(com.google.firebase.database.ValueEventListener)

Example 77 with TabLayout

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) {
        }
    });
}
Also used : Typeface(android.graphics.Typeface) TabLayout(android.support.design.widget.TabLayout) Intent(android.content.Intent) TextView(android.widget.TextView) MainActivity(com.polito.mad17.madmax.activities.MainActivity) ImageView(android.widget.ImageView) FragmentPagerAdapter(android.support.v4.app.FragmentPagerAdapter)

Example 78 with TabLayout

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);
}
Also used : TabLayout(android.support.design.widget.TabLayout) ViewPager(android.support.v4.view.ViewPager) SmartFragmentStatePagerAdapter(com.khmelenko.lab.varis.adapter.SmartFragmentStatePagerAdapter)

Example 79 with TabLayout

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);
}
Also used : TabLayout(android.support.design.widget.TabLayout) ViewPager(android.support.v4.view.ViewPager) SmartFragmentStatePagerAdapter(com.khmelenko.lab.varis.adapter.SmartFragmentStatePagerAdapter)

Example 80 with TabLayout

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);
            }
        }
    }
}
Also used : TabLayout(android.support.design.widget.TabLayout) ViewGroup(android.view.ViewGroup) TextView(android.widget.TextView) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) View(android.view.View)

Aggregations

TabLayout (android.support.design.widget.TabLayout)82 View (android.view.View)36 ViewPager (android.support.v4.view.ViewPager)31 Toolbar (android.support.v7.widget.Toolbar)19 Intent (android.content.Intent)16 TextView (android.widget.TextView)15 ActionBar (android.support.v7.app.ActionBar)12 RecyclerView (android.support.v7.widget.RecyclerView)12 ImageView (android.widget.ImageView)11 Fragment (android.support.v4.app.Fragment)10 NavigationView (android.support.design.widget.NavigationView)8 Test (org.junit.Test)8 Bundle (android.os.Bundle)7 FloatingActionButton (android.support.design.widget.FloatingActionButton)7 UiController (android.support.test.espresso.UiController)7 ViewAction (android.support.test.espresso.ViewAction)7 ViewGroup (android.view.ViewGroup)7 AppBarLayout (android.support.design.widget.AppBarLayout)6 MenuItem (android.view.MenuItem)6 FragmentPagerAdapter (android.support.v4.app.FragmentPagerAdapter)5