Search in sources :

Example 1 with Role

use of app.insti.api.model.Role in project IITB-App by wncc.

the class BodyFragment method displayBody.

private void displayBody() {
    /* Skip if we're already destroyed */
    if (getActivity() == null || getView() == null)
        return;
    if (body != min_body)
        bodyDisplayed = true;
    bodyPicture = (ImageView) getActivity().findViewById(R.id.body_picture);
    /* Load only low res image if transition is not completed */
    if (transitionEnded) {
        Utils.loadImageWithPlaceholder(bodyPicture, body.getBodyImageURL());
    } else {
        Picasso.get().load(Utils.resizeImageUrl(body.getBodyImageURL())).into(bodyPicture);
    }
    /* Skip for min body */
    if (body == min_body) {
        return;
    }
    bodyPicture.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            zoomImageFromThumb(bodyPicture);
            final FloatingActionButton fab = getView().findViewById(R.id.edit_fab);
            fab.hide();
        }
    });
    mShortAnimationDuration = getResources().getInteger(android.R.integer.config_shortAnimTime);
    final List<Role> roles = body.getBodyRoles();
    final List<User> users = new ArrayList<>();
    for (Role role : roles) {
        if (role.getRoleUsersDetail() != null) {
            for (User user : role.getRoleUsersDetail()) {
                user.setCurrentRole(role.getRoleName());
                users.add(user);
            }
        }
    }
    final List<CardInterface> cards = new ArrayList<>();
    cards.add(new BodyHeadCard(body));
    addWithTitleCard(cards, body.getBodyEvents(), "Events");
    addWithTitleCard(cards, users, "People");
    addWithTitleCard(cards, body.getBodyChildren(), "Organizations");
    addWithTitleCard(cards, body.getBodyParents(), "Part of");
    final RecyclerView recyclerView = (RecyclerView) getActivity().findViewById(R.id.body_recycler_view);
    GenericAdapter genericAdapter = new GenericAdapter(cards, this);
    recyclerView.setAdapter(genericAdapter);
    recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
    getActivity().findViewById(R.id.loadingPanel).setVisibility(View.GONE);
    /* Show update button if role */
    if (((MainActivity) getActivity()).editBodyAccess(body)) {
        final FloatingActionButton fab = getView().findViewById(R.id.edit_fab);
        fab.show();
        recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {

            @Override
            public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
                super.onScrolled(recyclerView, dx, dy);
                if (dy > 0)
                    fab.hide();
                else
                    fab.show();
            }
        });
        fab.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                WebViewFragment webViewFragment = new WebViewFragment();
                Bundle bundle = new Bundle();
                bundle.putString(Constants.WV_TYPE, Constants.WV_TYPE_UPDATE_BODY);
                bundle.putString(Constants.WV_ID, body.getBodyID());
                webViewFragment.setArguments(bundle);
                ((MainActivity) getActivity()).updateFragment(webViewFragment);
            }
        });
    }
}
Also used : CardInterface(app.insti.interfaces.CardInterface) User(app.insti.api.model.User) Bundle(android.os.Bundle) ArrayList(java.util.ArrayList) MainActivity(app.insti.activity.MainActivity) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) ImageView(android.widget.ImageView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) Point(android.graphics.Point) Role(app.insti.api.model.Role) FloatingActionButton(com.google.android.material.floatingactionbutton.FloatingActionButton) RecyclerView(androidx.recyclerview.widget.RecyclerView) GenericAdapter(app.insti.adapter.GenericAdapter) BodyHeadCard(app.insti.utils.BodyHeadCard)

Example 2 with Role

use of app.insti.api.model.Role in project IITB-App by wncc.

the class GenericAdapter method onClick.

@Override
public void onClick(CardInterface cardInterface, Fragment fragment, View view) {
    if (cardInterface instanceof Event) {
        Utils.openEventFragment((Event) cardInterface, fragment, view.findViewById(R.id.object_picture));
    } else if (cardInterface instanceof Body) {
        Utils.openBodyFragment((Body) cardInterface, fragment, view.findViewById(R.id.object_picture));
    } else if (cardInterface instanceof User) {
        Utils.openUserFragment((User) cardInterface, fragment, view.findViewById(R.id.object_picture));
    } else if (cardInterface instanceof Role) {
        Utils.openBodyFragment(((Role) cardInterface).getRoleBodyDetails(), fragment, view.findViewById(R.id.object_picture));
    } else if (cardInterface instanceof Achievement) {
        Achievement a = (Achievement) cardInterface;
        if (a.getAchievementEvent() != null) {
            a.getAchievementEvent().setEventBodies(new ArrayList<>());
            a.getAchievementEvent().getEventBodies().add(a.getAchievementBody());
            Utils.openEventFragment(a.getAchievementEvent(), fragment, view.findViewById(R.id.object_picture));
        } else {
            Utils.openBodyFragment(a.getAchievementBody(), fragment, view.findViewById(R.id.object_picture));
        }
    } else if (cardInterface instanceof OfferedAchievement) {
        WebViewFragment webViewFragment = new WebViewFragment();
        Bundle bundle = new Bundle();
        bundle.putString(Constants.WV_TYPE, Constants.WV_TYPE_NEW_OFFERED_ACHIEVEMENT);
        bundle.putString(Constants.WV_ID, ((OfferedAchievement) cardInterface).getAchievementID());
        webViewFragment.setArguments(bundle);
        Utils.updateFragment(webViewFragment, fragment.getActivity());
    }
}
Also used : Role(app.insti.api.model.Role) WebViewFragment(app.insti.fragment.WebViewFragment) User(app.insti.api.model.User) OfferedAchievement(app.insti.api.model.OfferedAchievement) Bundle(android.os.Bundle) Event(app.insti.api.model.Event) Achievement(app.insti.api.model.Achievement) OfferedAchievement(app.insti.api.model.OfferedAchievement) Body(app.insti.api.model.Body)

Example 3 with Role

use of app.insti.api.model.Role 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

Role (app.insti.api.model.Role)3 Bundle (android.os.Bundle)2 View (android.view.View)2 ImageView (android.widget.ImageView)2 Body (app.insti.api.model.Body)2 Event (app.insti.api.model.Event)2 User (app.insti.api.model.User)2 CardInterface (app.insti.interfaces.CardInterface)2 FloatingActionButton (com.google.android.material.floatingactionbutton.FloatingActionButton)2 ArrayList (java.util.ArrayList)2 Intent (android.content.Intent)1 Point (android.graphics.Point)1 TextView (android.widget.TextView)1 LinearLayoutManager (androidx.recyclerview.widget.LinearLayoutManager)1 RecyclerView (androidx.recyclerview.widget.RecyclerView)1 ViewPager (androidx.viewpager.widget.ViewPager)1 MainActivity (app.insti.activity.MainActivity)1 GenericAdapter (app.insti.adapter.GenericAdapter)1 TabAdapter (app.insti.adapter.TabAdapter)1 Achievement (app.insti.api.model.Achievement)1