Search in sources :

Example 1 with TabAdapter

use of app.insti.adapter.TabAdapter in project IITB-App by wncc.

the class UserFragment method populateViews.

private void populateViews() {
    if (getActivity() == null || getView() == null)
        return;
    userProfilePictureImageView = getActivity().findViewById(R.id.user_profile_picture_profile);
    TextView userNameTextView = getActivity().findViewById(R.id.user_name_profile);
    TextView userRollNumberTextView = getActivity().findViewById(R.id.user_rollno_profile);
    final TextView userEmailIDTextView = getActivity().findViewById(R.id.user_email_profile);
    TextView userContactNumberTextView = getActivity().findViewById(R.id.user_contact_no_profile);
    FloatingActionButton userShareFab = getActivity().findViewById(R.id.share_user_button);
    Picasso.get().load(user.getUserProfilePictureUrl()).placeholder(R.drawable.user_placeholder).into(userProfilePictureImageView);
    userProfilePictureImageView.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            zoomImageFromThumb(userProfilePictureImageView);
        }
    });
    mShortAnimationDuration = getResources().getInteger(android.R.integer.config_shortAnimTime);
    if (!showingMin) {
        /* Show tabs */
        getActivity().findViewById(R.id.tab_layout).setVisibility(VISIBLE);
        /* Load lists */
        final List<Role> roleList = user.getUserRoles();
        final List<Body> bodyList = user.getUserFollowedBodies();
        final List<Event> eventList = user.getUserGoingEvents();
        final List<Role> formerRoleList = user.getUserFormerRoles();
        /* Construct user profile */
        final List<CardInterface> profile = new ArrayList<>(roleList);
        for (Role role : formerRoleList) {
            Role temp = new Role(role);
            temp.setRoleName("Former " + role.getRoleName() + " " + role.getRoleYear());
            profile.add(temp);
        }
        profile.addAll(user.getUserAchievements());
        List<Event> eventInterestedList = user.getUserInterestedEvents();
        eventList.removeAll(eventInterestedList);
        eventList.addAll(eventInterestedList);
        GenericRecyclerViewFragment frag1 = GenericRecyclerViewFragment.newInstance(profile);
        BodyRecyclerViewFragment frag2 = BodyRecyclerViewFragment.newInstance(bodyList);
        EventRecyclerViewFragment frag3 = EventRecyclerViewFragment.newInstance(eventList);
        frag1.parentFragment = this;
        frag2.parentFragment = this;
        frag3.parentFragment = this;
        TabAdapter tabAdapter = new TabAdapter(getChildFragmentManager());
        tabAdapter.addFragment(frag1, "Profile");
        tabAdapter.addFragment(frag2, "Following");
        tabAdapter.addFragment(frag3, "Events");
        // Set up the ViewPager with the sections adapter.
        ViewPager viewPager = (ViewPager) getActivity().findViewById(R.id.viewPager);
        viewPager.setAdapter(tabAdapter);
        viewPager.setOffscreenPageLimit(2);
        TabLayout tabLayout = (TabLayout) getActivity().findViewById(R.id.tab_layout);
        tabLayout.setupWithViewPager(viewPager);
        userShareFab.show();
        getActivity().findViewById(R.id.loadingPanel).setVisibility(View.GONE);
    }
    userNameTextView.setText(user.getUserName());
    userRollNumberTextView.setText(user.getUserRollNumber());
    if (user.getUserEmail() != null && !user.getUserEmail().equals("N/A")) {
        userEmailIDTextView.setText(user.getUserEmail());
    } else {
        if (user.getUserRollNumber() != null)
            userEmailIDTextView.setText(user.getUserRollNumber() + "@iitb.ac.in");
    }
    userEmailIDTextView.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            mail((String) userEmailIDTextView.getText());
        }
    });
    if (!"N/A".equals(user.getUserContactNumber())) {
        userContactNumberTextView.setText(user.getUserContactNumber());
        userContactNumberTextView.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                call(user.getUserContactNumber());
            }
        });
    } else {
        userContactNumberTextView.setVisibility(View.GONE);
    }
    userShareFab.setOnClickListener(new View.OnClickListener() {

        String shareUrl = ShareURLMaker.getUserURL(user);

        @Override
        public void onClick(View view) {
            Intent i = new Intent(Intent.ACTION_SEND);
            i.setType("text/plain");
            i.putExtra(Intent.EXTRA_SUBJECT, "Sharing URL");
            i.putExtra(Intent.EXTRA_TEXT, shareUrl);
            startActivity(Intent.createChooser(i, "Share URL"));
        }
    });
}
Also used : CardInterface(app.insti.interfaces.CardInterface) TabAdapter(app.insti.adapter.TabAdapter) ArrayList(java.util.ArrayList) Intent(android.content.Intent) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) ViewPager(androidx.viewpager.widget.ViewPager) Role(app.insti.api.model.Role) TabLayout(com.google.android.material.tabs.TabLayout) FloatingActionButton(com.google.android.material.floatingactionbutton.FloatingActionButton) Event(app.insti.api.model.Event) TextView(android.widget.TextView) Body(app.insti.api.model.Body)

Aggregations

Intent (android.content.Intent)1 View (android.view.View)1 ImageView (android.widget.ImageView)1 TextView (android.widget.TextView)1 ViewPager (androidx.viewpager.widget.ViewPager)1 TabAdapter (app.insti.adapter.TabAdapter)1 Body (app.insti.api.model.Body)1 Event (app.insti.api.model.Event)1 Role (app.insti.api.model.Role)1 CardInterface (app.insti.interfaces.CardInterface)1 FloatingActionButton (com.google.android.material.floatingactionbutton.FloatingActionButton)1 TabLayout (com.google.android.material.tabs.TabLayout)1 ArrayList (java.util.ArrayList)1