Search in sources :

Example 1 with CircularProgressBar

use of fr.castorflex.android.circularprogressbar.CircularProgressBar in project actor-platform by actorapp.

the class MembersFragment method onCreateView.

@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View res = inflater.inflate(R.layout.fragment_members, container, false);
    int groupId = getArguments().getInt("groupId");
    adapter = new MembersAdapter(getContext(), groupId);
    GroupVM groupVM = groups().get(groupId);
    RecyclerListView list = (RecyclerListView) res.findViewById(R.id.items);
    Boolean canInvite = groupVM.getIsCanInviteMembers().get();
    Boolean canInviteViaLink = groupVM.getIsCanInviteViaLink().get();
    if (canInvite || canInviteViaLink) {
        LinearLayout header = new LinearLayout(getActivity());
        list.addHeaderView(header);
        if (canInvite) {
            TextView addMmemberTV = new TextView(getContext());
            addMmemberTV.setBackgroundResource(R.drawable.selector);
            addMmemberTV.setTextSize(16);
            addMmemberTV.setPadding(Screen.dp(72), 0, 0, 0);
            addMmemberTV.setGravity(Gravity.CENTER_VERTICAL);
            addMmemberTV.setText(groupVM.getGroupType() == GroupType.CHANNEL ? R.string.channel_add_member : R.string.group_add_member);
            addMmemberTV.setTextColor(ActorSDK.sharedActor().style.getTextPrimaryColor());
            addMmemberTV.setOnClickListener(view -> {
                startActivity(new Intent(getActivity(), AddMemberActivity.class).putExtra(Intents.EXTRA_GROUP_ID, groupId));
            });
            header.addView(addMmemberTV, ViewGroup.LayoutParams.MATCH_PARENT, Screen.dp(58));
        }
        if (canInvite && canInviteViaLink) {
            header.addView(new DividerView(getActivity()), ViewGroup.LayoutParams.MATCH_PARENT, 1);
        }
        if (canInviteViaLink) {
            TextView shareLinkTV = new TextView(getContext());
            shareLinkTV.setBackgroundResource(R.drawable.selector);
            shareLinkTV.setTextSize(16);
            shareLinkTV.setPadding(Screen.dp(72), 0, 0, 0);
            shareLinkTV.setGravity(Gravity.CENTER_VERTICAL);
            shareLinkTV.setTextColor(ActorSDK.sharedActor().style.getTextPrimaryColor());
            shareLinkTV.setText(R.string.invite_link_action_share);
            shareLinkTV.setOnClickListener(view -> Intents.inviteLink(groupId, getActivity()));
            header.addView(shareLinkTV, ViewGroup.LayoutParams.MATCH_PARENT, Screen.dp(58));
        }
    }
    footer = new LinearLayout(getActivity());
    footer.setVisibility(View.INVISIBLE);
    list.addFooterView(footer);
    CircularProgressBar botProgressView = new CircularProgressBar(getActivity());
    int padding = Screen.dp(16);
    botProgressView.setPadding(padding, padding, padding, padding);
    botProgressView.setIndeterminate(true);
    FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(Screen.dp(72), Screen.dp(72));
    params.gravity = Gravity.CENTER;
    FrameLayout cont = new FrameLayout(getActivity());
    cont.addView(botProgressView, params);
    footer.addView(cont, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
    list.setAdapter(adapter);
    list.setOnItemClickListener((parent, view, position, id) -> {
        Object item = parent.getItemAtPosition(position);
        if (item != null && item instanceof GroupMember) {
            GroupMember groupMember = (GroupMember) item;
            if (groupMember.getUid() != myUid()) {
                UserVM userVM = users().get(groupMember.getUid());
                if (userVM != null) {
                    startActivity(Intents.openPrivateDialog(userVM.getId(), true, getActivity()));
                }
            }
        }
    });
    list.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {

        @Override
        public boolean onItemLongClick(AdapterView<?> adapterView, View view, int i, long l) {
            Object item = adapterView.getItemAtPosition(i);
            if (item != null && item instanceof GroupMember) {
                GroupMember groupMember = (GroupMember) item;
                if (groupMember.getUid() != myUid()) {
                    UserVM userVM = users().get(groupMember.getUid());
                    if (userVM != null) {
                        adapter.onMemberClick(groupVM, userVM, groupMember.isAdministrator(), groupMember.getInviterUid() == myUid(), (BaseActivity) getActivity());
                        return true;
                    }
                }
            }
            return false;
        }
    });
    progressView = (CircularProgressBar) res.findViewById(R.id.loadingProgress);
    progressView.setIndeterminate(true);
    return res;
}
Also used : MembersAdapter(im.actor.sdk.controllers.group.view.MembersAdapter) GroupMember(im.actor.core.entity.GroupMember) GroupVM(im.actor.core.viewmodel.GroupVM) DividerView(im.actor.sdk.view.DividerView) CircularProgressBar(fr.castorflex.android.circularprogressbar.CircularProgressBar) Intent(android.content.Intent) RecyclerListView(im.actor.sdk.view.adapters.RecyclerListView) RecyclerListView(im.actor.sdk.view.adapters.RecyclerListView) View(android.view.View) AdapterView(android.widget.AdapterView) DividerView(im.actor.sdk.view.DividerView) TextView(android.widget.TextView) UserVM(im.actor.core.viewmodel.UserVM) FrameLayout(android.widget.FrameLayout) BaseActivity(im.actor.sdk.controllers.activity.BaseActivity) TextView(android.widget.TextView) AdapterView(android.widget.AdapterView) LinearLayout(android.widget.LinearLayout) Nullable(android.support.annotation.Nullable)

Aggregations

Intent (android.content.Intent)1 Nullable (android.support.annotation.Nullable)1 View (android.view.View)1 AdapterView (android.widget.AdapterView)1 FrameLayout (android.widget.FrameLayout)1 LinearLayout (android.widget.LinearLayout)1 TextView (android.widget.TextView)1 CircularProgressBar (fr.castorflex.android.circularprogressbar.CircularProgressBar)1 GroupMember (im.actor.core.entity.GroupMember)1 GroupVM (im.actor.core.viewmodel.GroupVM)1 UserVM (im.actor.core.viewmodel.UserVM)1 BaseActivity (im.actor.sdk.controllers.activity.BaseActivity)1 MembersAdapter (im.actor.sdk.controllers.group.view.MembersAdapter)1 DividerView (im.actor.sdk.view.DividerView)1 RecyclerListView (im.actor.sdk.view.adapters.RecyclerListView)1