Search in sources :

Example 6 with GroupMember

use of im.actor.core.entity.GroupMember in project actor-platform by actorapp.

the class ChatListProcessor method fixLinkifyCustomLinks.

private boolean fixLinkifyCustomLinks(Spannable spannable, Pattern p, boolean isMention) {
    Matcher m = p.matcher(spannable.toString());
    boolean res = false;
    while (m.find()) {
        boolean found = false;
        String nick = "";
        UserVM user;
        int userId = 0;
        if (isGroup) {
            for (GroupMember member : group.getMembers().get()) {
                user = users().get(member.getUid());
                nick = user.getNick().get();
                if (nick != null && !nick.isEmpty() && nick.equals(m.group().substring(1, m.group().length()))) {
                    userId = user.getId();
                    found = true;
                    break;
                }
            }
        }
        if (isMention && !found) {
            return false;
        }
        URLSpan span = (isMention && isGroup && found) ? new MentionSpan(nick, userId, false) : new BaseUrlSpan(m.group(), false);
        spannable.setSpan(span, m.start(), m.end(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        res = true;
    }
    return res;
}
Also used : GroupMember(im.actor.core.entity.GroupMember) UserVM(im.actor.core.viewmodel.UserVM) Matcher(java.util.regex.Matcher) MentionSpan(im.actor.sdk.controllers.conversation.view.MentionSpan) BaseUrlSpan(im.actor.sdk.view.BaseUrlSpan) SpannableString(android.text.SpannableString) URLSpan(android.text.style.URLSpan)

Example 7 with GroupMember

use of im.actor.core.entity.GroupMember in project actor-platform by actorapp.

the class MessagesModule method updateMessage.

public Promise<Void> updateMessage(final Peer peer, final String message, final long rid) {
    context().getTypingModule().onMessageSent(peer);
    ArrayList<Integer> mentions = new ArrayList<>();
    TextContent content = TextContent.create(message, null, mentions);
    if (peer.getPeerType() == PeerType.GROUP) {
        Group group = groups().getValue(peer.getPeerId());
        String lowText = message.toLowerCase();
        for (GroupMember member : group.getMembers()) {
            User user = users().getValue(member.getUid());
            if (user.getNick() != null) {
                String nick = "@" + user.getNick().toLowerCase();
                // TODO: Better filtering
                if (lowText.contains(nick + ":") || lowText.contains(nick + " ") || lowText.contains(" " + nick) || lowText.endsWith(nick) || lowText.equals(nick)) {
                    mentions.add(user.getUid());
                }
            }
        }
    }
    ApiMessage editMessage = new ApiTextMessage(message, content.getMentions(), content.getTextMessageEx());
    return buildOutPeer(peer).flatMap(apiOutPeer -> api(new RequestUpdateMessage(apiOutPeer, rid, editMessage))).flatMap(responseSeqDate -> updates().applyUpdate(responseSeqDate.getSeq(), responseSeqDate.getState(), new UpdateMessageContentChanged(new ApiPeer(peer.getPeerType().toApi(), peer.getPeerId()), rid, editMessage)));
}
Also used : RequestMessageSetReaction(im.actor.core.api.rpc.RequestMessageSetReaction) DialogsInt(im.actor.core.modules.messaging.dialogs.DialogsInt) ModuleContext(im.actor.core.modules.ModuleContext) ConversationVM(im.actor.core.viewmodel.ConversationVM) FastThumb(im.actor.core.entity.content.FastThumb) RequestDeleteChat(im.actor.core.api.rpc.RequestDeleteChat) UpdateChatGroupsChanged(im.actor.core.api.updates.UpdateChatGroupsChanged) DialogGroupsVM(im.actor.core.viewmodel.DialogGroupsVM) ResponseReactionsResponse(im.actor.core.api.rpc.ResponseReactionsResponse) JsonContent(im.actor.core.entity.content.JsonContent) SyncKeyValue(im.actor.runtime.storage.SyncKeyValue) RouterInt(im.actor.core.modules.messaging.router.RouterInt) RequestFavouriteDialog(im.actor.core.api.rpc.RequestFavouriteDialog) RequestUnfavouriteDialog(im.actor.core.api.rpc.RequestUnfavouriteDialog) Actor(im.actor.runtime.actors.Actor) ApiPeer(im.actor.core.api.ApiPeer) CommandCallback(im.actor.core.viewmodel.CommandCallback) MessageDeleteActor(im.actor.core.modules.messaging.actions.MessageDeleteActor) TextContent(im.actor.core.entity.content.TextContent) Sticker(im.actor.core.entity.Sticker) RpcInternalException(im.actor.core.network.RpcInternalException) ApiTextMessage(im.actor.core.api.ApiTextMessage) UpdateReactionsUpdate(im.actor.core.api.updates.UpdateReactionsUpdate) Void(im.actor.runtime.actors.messages.Void) ResponseDialogsOrder(im.actor.core.api.rpc.ResponseDialogsOrder) GroupMember(im.actor.core.entity.GroupMember) ArchivedDialogsActor(im.actor.core.modules.messaging.history.ArchivedDialogsActor) ApiOutPeer(im.actor.core.api.ApiOutPeer) MVVMCollection(im.actor.runtime.mvvm.MVVMCollection) ActorSystem.system(im.actor.runtime.actors.ActorSystem.system) DialogsHistoryActor(im.actor.core.modules.messaging.history.DialogsHistoryActor) Nullable(org.jetbrains.annotations.Nullable) CursorReceiverActor(im.actor.core.modules.messaging.actions.CursorReceiverActor) PromiseResolver(im.actor.runtime.promise.PromiseResolver) RequestClearChat(im.actor.core.api.rpc.RequestClearChat) UpdateMessageContentChanged(im.actor.core.api.updates.UpdateMessageContentChanged) Peer(im.actor.core.entity.Peer) Props(im.actor.runtime.actors.Props) Message(im.actor.core.entity.Message) Dialog(im.actor.core.entity.Dialog) NotNull(org.jetbrains.annotations.NotNull) Function(im.actor.runtime.function.Function) ApiPeerType(im.actor.core.api.ApiPeerType) RequestArchiveChat(im.actor.core.api.rpc.RequestArchiveChat) RequestUpdateMessage(im.actor.core.api.rpc.RequestUpdateMessage) ResponseSeq(im.actor.core.api.rpc.ResponseSeq) RequestMessageRemoveReaction(im.actor.core.api.rpc.RequestMessageRemoveReaction) ResponseSeqDate(im.actor.core.api.rpc.ResponseSeqDate) ActorCreator(im.actor.runtime.actors.ActorCreator) Promise(im.actor.runtime.promise.Promise) HashMap(java.util.HashMap) UpdateChatClear(im.actor.core.api.updates.UpdateChatClear) PromiseFunc(im.actor.runtime.promise.PromiseFunc) ArrayList(java.util.ArrayList) ConversationState(im.actor.core.entity.ConversationState) AbsModule(im.actor.core.modules.AbsModule) User(im.actor.core.entity.User) BusSubscriber(im.actor.runtime.eventbus.BusSubscriber) ConversationHistoryActor(im.actor.core.modules.messaging.history.ConversationHistoryActor) PeerChatOpened(im.actor.core.events.PeerChatOpened) RpcCallback(im.actor.core.network.RpcCallback) ActorRef(im.actor.runtime.actors.ActorRef) ListEngine(im.actor.runtime.storage.ListEngine) PeerType(im.actor.core.entity.PeerType) Command(im.actor.core.viewmodel.Command) ConversationHistory(im.actor.core.modules.messaging.history.ConversationHistory) AbsContent(im.actor.core.entity.content.AbsContent) PeerChatPreload(im.actor.core.events.PeerChatPreload) ApiMessage(im.actor.core.api.ApiMessage) Group(im.actor.core.entity.Group) RpcException(im.actor.core.network.RpcException) CursorReaderActor(im.actor.core.modules.messaging.actions.CursorReaderActor) Storage(im.actor.runtime.Storage) DialogsActor(im.actor.core.modules.messaging.dialogs.DialogsActor) SenderActor(im.actor.core.modules.messaging.actions.SenderActor) FileSystemReference(im.actor.runtime.files.FileSystemReference) ResponseLoadArchived(im.actor.core.api.rpc.ResponseLoadArchived) UpdateChatDelete(im.actor.core.api.updates.UpdateChatDelete) Event(im.actor.runtime.eventbus.Event) SeqUpdate(im.actor.core.api.base.SeqUpdate) Group(im.actor.core.entity.Group) GroupMember(im.actor.core.entity.GroupMember) UpdateMessageContentChanged(im.actor.core.api.updates.UpdateMessageContentChanged) User(im.actor.core.entity.User) ApiTextMessage(im.actor.core.api.ApiTextMessage) ArrayList(java.util.ArrayList) ApiMessage(im.actor.core.api.ApiMessage) TextContent(im.actor.core.entity.content.TextContent) RequestUpdateMessage(im.actor.core.api.rpc.RequestUpdateMessage) ApiPeer(im.actor.core.api.ApiPeer)

Example 8 with GroupMember

use of im.actor.core.entity.GroupMember in project actor-platform by actorapp.

the class GroupsModule method loadMembers.

public Promise<GroupMembersSlice> loadMembers(int gid, int limit, byte[] next) {
    return getGroups().getValueAsync(gid).flatMap(group -> api(new RequestLoadMembers(new ApiGroupOutPeer(group.getGroupId(), group.getAccessHash()), limit, next))).chain(r -> updates().loadRequiredPeers(r.getUsers(), new ArrayList<>())).map(r -> {
        ArrayList<GroupMember> members = new ArrayList<>();
        for (ApiMember p : r.getMembers()) {
            boolean isAdmin = p.isAdmin() != null ? p.isAdmin() : false;
            members.add(new GroupMember(p.getUid(), p.getInviterUid(), p.getInviterUid(), isAdmin));
        }
        return new GroupMembersSlice(members, r.getNext());
    });
}
Also used : ModuleContext(im.actor.core.modules.ModuleContext) ApiGroupType(im.actor.core.api.ApiGroupType) RequestKickUser(im.actor.core.api.rpc.RequestKickUser) RequestLoadAdminSettings(im.actor.core.api.rpc.RequestLoadAdminSettings) ResponseInviteUrl(im.actor.core.api.rpc.ResponseInviteUrl) RandomUtils(im.actor.core.util.RandomUtils) RequestEditGroupShortName(im.actor.core.api.rpc.RequestEditGroupShortName) RequestInviteUser(im.actor.core.api.rpc.RequestInviteUser) RequestTransferOwnership(im.actor.core.api.rpc.RequestTransferOwnership) RequestEditGroupTitle(im.actor.core.api.rpc.RequestEditGroupTitle) RequestJoinGroupByPeer(im.actor.core.api.rpc.RequestJoinGroupByPeer) ApiSupportConfiguration(im.actor.core.modules.api.ApiSupportConfiguration) ApiAdminSettings(im.actor.core.api.ApiAdminSettings) RequestGetIntegrationToken(im.actor.core.api.rpc.RequestGetIntegrationToken) Void(im.actor.runtime.actors.messages.Void) RequestRevokeInviteUrl(im.actor.core.api.rpc.RequestRevokeInviteUrl) GroupMember(im.actor.core.entity.GroupMember) ApiOutPeer(im.actor.core.api.ApiOutPeer) RequestCreateGroup(im.actor.core.api.rpc.RequestCreateGroup) MVVMCollection(im.actor.runtime.mvvm.MVVMCollection) ActorSystem.system(im.actor.runtime.actors.ActorSystem.system) RequestLeaveAndDelete(im.actor.core.api.rpc.RequestLeaveAndDelete) GroupAvatarVM(im.actor.core.viewmodel.GroupAvatarVM) List(java.util.List) RequestEditGroupAbout(im.actor.core.api.rpc.RequestEditGroupAbout) Peer(im.actor.core.entity.Peer) ApiUserOutPeer(im.actor.core.api.ApiUserOutPeer) Function(im.actor.runtime.function.Function) ApiPeerType(im.actor.core.api.ApiPeerType) RequestMakeUserAdminObsolete(im.actor.core.api.rpc.RequestMakeUserAdminObsolete) Promise(im.actor.runtime.promise.Promise) HashMap(java.util.HashMap) GroupVM(im.actor.core.viewmodel.GroupVM) ArrayList(java.util.ArrayList) AbsModule(im.actor.core.modules.AbsModule) User(im.actor.core.entity.User) BusSubscriber(im.actor.runtime.eventbus.BusSubscriber) GroupAvatarChangeActor(im.actor.core.modules.profile.avatar.GroupAvatarChangeActor) RequestSaveAdminSettings(im.actor.core.api.rpc.RequestSaveAdminSettings) RequestRevokeIntegrationToken(im.actor.core.api.rpc.RequestRevokeIntegrationToken) GroupMembersSlice(im.actor.core.entity.GroupMembersSlice) PeerChatOpened(im.actor.core.events.PeerChatOpened) ActorRef(im.actor.runtime.actors.ActorRef) RequestDismissUserAdmin(im.actor.core.api.rpc.RequestDismissUserAdmin) PeerType(im.actor.core.entity.PeerType) RequestLeaveGroup(im.actor.core.api.rpc.RequestLeaveGroup) RequestLoadMembers(im.actor.core.api.rpc.RequestLoadMembers) RequestShareHistory(im.actor.core.api.rpc.RequestShareHistory) RequestJoinGroup(im.actor.core.api.rpc.RequestJoinGroup) ApiMember(im.actor.core.api.ApiMember) Group(im.actor.core.entity.Group) PeerInfoOpened(im.actor.core.events.PeerInfoOpened) GroupRouterInt(im.actor.core.modules.groups.router.GroupRouterInt) RequestDeleteGroup(im.actor.core.api.rpc.RequestDeleteGroup) Storage(im.actor.runtime.Storage) ResponseIntegrationToken(im.actor.core.api.rpc.ResponseIntegrationToken) RequestGetGroupInviteUrl(im.actor.core.api.rpc.RequestGetGroupInviteUrl) ApiGroupOutPeer(im.actor.core.api.ApiGroupOutPeer) ResponseVoid(im.actor.core.api.rpc.ResponseVoid) GroupPermissions(im.actor.core.entity.GroupPermissions) KeyValueEngine(im.actor.runtime.storage.KeyValueEngine) Event(im.actor.runtime.eventbus.Event) RequestEditGroupTopic(im.actor.core.api.rpc.RequestEditGroupTopic) Promises(im.actor.runtime.promise.Promises) GroupMember(im.actor.core.entity.GroupMember) RequestLoadMembers(im.actor.core.api.rpc.RequestLoadMembers) ArrayList(java.util.ArrayList) GroupMembersSlice(im.actor.core.entity.GroupMembersSlice) ApiGroupOutPeer(im.actor.core.api.ApiGroupOutPeer) ApiMember(im.actor.core.api.ApiMember)

Example 9 with GroupMember

use of im.actor.core.entity.GroupMember in project actor-platform by actorapp.

the class GroupInfoFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    chatId = getArguments().getInt(EXTRA_CHAT_ID);
    groupVM = groups().get(chatId);
    View res = inflater.inflate(R.layout.fragment_group, container, false);
    listView = (RecyclerListView) res.findViewById(R.id.groupList);
    notMemberView = res.findViewById(R.id.notMember);
    res.setBackgroundColor(style.getMainBackgroundColor());
    // listView.setBackgroundColor(style.getMainBackgroundColor());
    notMemberView.setBackgroundColor(style.getMainBackgroundColor());
    ((TextView) notMemberView.findViewById(R.id.not_member_text)).setTextColor(style.getTextPrimaryColor());
    // 
    // Header
    // 
    // Views
    View header = inflater.inflate(R.layout.fragment_group_header, listView, false);
    TextView title = (TextView) header.findViewById(R.id.title);
    TextView subtitle = (TextView) header.findViewById(R.id.subtitle);
    avatarView = (AvatarView) header.findViewById(R.id.avatar);
    avatarView.init(Screen.dp(48), 22);
    TextView aboutTV = (TextView) header.findViewById(R.id.about);
    View shortNameCont = header.findViewById(R.id.shortNameContainer);
    TextView shortNameView = (TextView) header.findViewById(R.id.shortName);
    TextView shortLinkView = (TextView) header.findViewById(R.id.shortNameLink);
    TextView addMember = (TextView) header.findViewById(R.id.addMemberAction);
    addMember.setText(groupVM.getGroupType() == GroupType.CHANNEL ? R.string.channel_add_member : R.string.group_add_member);
    TextView members = (TextView) header.findViewById(R.id.viewMembersAction);
    TextView leaveAction = (TextView) header.findViewById(R.id.leaveAction);
    TextView administrationAction = (TextView) header.findViewById(R.id.administrationAction);
    View descriptionContainer = header.findViewById(R.id.descriptionContainer);
    SwitchCompat isNotificationsEnabled = (SwitchCompat) header.findViewById(R.id.enableNotifications);
    // Styling
    // ((TextView) header.findViewById(R.id.about_hint)).setTextColor(style.getTextSecondaryColor());
    header.setBackgroundColor(style.getMainBackgroundColor());
    header.findViewById(R.id.avatarContainer).setBackgroundColor(style.getToolBarColor());
    title.setTextColor(style.getProfileTitleColor());
    subtitle.setTextColor(style.getProfileSubtitleColor());
    aboutTV.setTextColor(style.getTextPrimaryColor());
    shortNameView.setTextColor(style.getTextPrimaryColor());
    shortLinkView.setTextColor(style.getTextSecondaryColor());
    // settingsHeaderText.setTextColor(style.getSettingsCategoryTextColor());
    ((TintImageView) header.findViewById(R.id.settings_notification_icon)).setTint(style.getSettingsIconColor());
    ((TintImageView) header.findViewById(R.id.settings_about_icon)).setTint(style.getSettingsIconColor());
    ((TextView) header.findViewById(R.id.settings_notifications_title)).setTextColor(style.getTextPrimaryColor());
    ((TextView) header.findViewById(R.id.addMemberAction)).setTextColor(style.getTextPrimaryColor());
    members.setTextColor(style.getTextPrimaryColor());
    administrationAction.setTextColor(style.getTextPrimaryColor());
    leaveAction.setTextColor(style.getTextDangerColor());
    if (groupVM.getGroupType() == GroupType.CHANNEL) {
        leaveAction.setText(R.string.group_leave_channel);
    } else {
        leaveAction.setText(R.string.group_leave);
    }
    header.findViewById(R.id.after_settings_divider).setBackgroundColor(style.getBackyardBackgroundColor());
    // 
    // Header
    // 
    avatarView.bind(groupVM.getAvatar().get(), groupVM.getName().get(), groupVM.getId());
    avatarView.setOnClickListener(view -> {
        if (groupVM.getAvatar().get() != null) {
            startActivity(ViewAvatarActivity.viewGroupAvatar(chatId, getActivity()));
        }
    });
    bind(groupVM.getName(), name -> {
        title.setText(name);
    });
    bind(groupVM.getMembersCount(), val -> {
        subtitle.setText(messenger().getFormatter().formatGroupMembers(val));
    });
    // About
    bind(groupVM.getAbout(), (about) -> {
        aboutTV.setText(about);
        aboutTV.setVisibility(about != null ? View.VISIBLE : View.GONE);
    });
    bind(groupVM.getShortName(), shortName -> {
        if (shortName != null) {
            shortNameView.setText("@" + shortName);
            String prefix = ActorSDK.sharedActor().getGroupInvitePrefix();
            if (prefix != null) {
                shortLinkView.setText(prefix + shortName);
                shortLinkView.setVisibility(View.VISIBLE);
            } else {
                shortLinkView.setVisibility(View.GONE);
            }
        }
        shortNameCont.setVisibility(shortName != null ? View.VISIBLE : View.GONE);
    });
    final ClipboardManager clipboard = (ClipboardManager) getActivity().getSystemService(Context.CLIPBOARD_SERVICE);
    shortNameCont.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            String link = shortLinkView.getText().toString();
            clipboard.setPrimaryClip(ClipData.newPlainText(null, (link.contains("://") ? "" : "https://") + link));
            Toast.makeText(getActivity(), getString(R.string.invite_link_copied), Toast.LENGTH_SHORT).show();
        }
    });
    bind(groupVM.getAbout(), groupVM.getShortName(), (about, shortName) -> {
        descriptionContainer.setVisibility(about != null || shortName != null ? View.VISIBLE : View.GONE);
    });
    // Notifications
    isNotificationsEnabled.setChecked(messenger().isNotificationsEnabled(Peer.group(chatId)));
    isNotificationsEnabled.setOnCheckedChangeListener((buttonView, isChecked) -> {
        messenger().changeNotificationsEnabled(Peer.group(chatId), isChecked);
    });
    header.findViewById(R.id.notificationsCont).setOnClickListener(v -> {
        isNotificationsEnabled.setChecked(!isNotificationsEnabled.isChecked());
    });
    // Add Member
    bind(groupVM.getIsCanInviteMembers(), (canInvite) -> {
        if (canInvite) {
            addMember.setVisibility(View.VISIBLE);
        } else {
            addMember.setVisibility(View.GONE);
        }
    });
    addMember.setOnClickListener(view -> {
        startActivity(new Intent(getActivity(), AddMemberActivity.class).putExtra(Intents.EXTRA_GROUP_ID, chatId));
    });
    // Administration
    if (groupVM.getIsCanEditAdministration().get() || groupVM.getIsCanDelete().get()) {
        administrationAction.setOnClickListener(view -> {
            startActivity(new Intent(getActivity(), GroupAdminActivity.class).putExtra(Intents.EXTRA_GROUP_ID, chatId));
        });
    } else {
        administrationAction.setVisibility(View.GONE);
    }
    // Async Members
    // Showing member only when members available and async members is enabled
    bind(groupVM.getIsCanViewMembers(), groupVM.getIsAsyncMembers(), (canViewMembers, vm1, isAsync, vm2) -> {
        if (canViewMembers) {
            if (isAsync) {
                members.setVisibility(View.VISIBLE);
                header.findViewById(R.id.after_settings_divider).setVisibility(View.GONE);
            } else {
                members.setVisibility(View.GONE);
                header.findViewById(R.id.after_settings_divider).setVisibility(View.VISIBLE);
            }
        } else {
            members.setVisibility(View.GONE);
            header.findViewById(R.id.after_settings_divider).setVisibility(View.GONE);
        }
    });
    members.setOnClickListener(view -> {
        startActivity(new Intent(getContext(), MembersActivity.class).putExtra(Intents.EXTRA_GROUP_ID, groupVM.getId()));
    });
    // Leave
    bind(groupVM.getIsCanLeave(), canLeave -> {
        if (canLeave) {
            leaveAction.setVisibility(View.VISIBLE);
            leaveAction.setOnClickListener(view1 -> {
                new AlertDialog.Builder(getActivity()).setMessage(getString(groupVM.getGroupType() == GroupType.CHANNEL ? R.string.alert_leave_channel_message : R.string.alert_leave_group_message).replace("%1$s", groupVM.getName().get())).setPositiveButton(R.string.alert_leave_group_yes, (dialog2, which) -> {
                    execute(messenger().leaveAndDeleteGroup(chatId).then(aVoid -> ActorSDK.returnToRoot(getActivity())));
                }).setNegativeButton(R.string.dialog_cancel, null).show().setCanceledOnTouchOutside(true);
            });
        } else {
            leaveAction.setVisibility(View.GONE);
        }
    });
    listView.addHeaderView(header, null, false);
    // 
    // Members
    // 
    groupUserAdapter = new MembersAdapter(getActivity(), getArguments().getInt("groupId"));
    listView.setAdapter(groupUserAdapter);
    listView.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()));
                }
            }
        }
    });
    listView.setOnItemLongClickListener((adapterView, view, i, 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) {
                    groupUserAdapter.onMemberClick(groupVM, userVM, groupMember.isAdministrator(), groupMember.getInviterUid() == myUid(), (BaseActivity) getActivity());
                    return true;
                }
            }
        }
        return false;
    });
    // 
    // Scroll handling
    // 
    listView.setOnScrollListener(new AbsListView.OnScrollListener() {

        @Override
        public void onScrollStateChanged(AbsListView view, int scrollState) {
        }

        @Override
        public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
            if (firstVisibleItem >= 1) {
                updateBar(Integer.MAX_VALUE);
            } else {
                View top = listView.getChildAt(0);
                if (top != null) {
                    updateBar(-top.getTop());
                } else {
                    updateBar(Integer.MAX_VALUE);
                }
            }
        }
    });
    // 
    // Placeholder
    // 
    bind(groupVM.isMember(), (isMember) -> {
        notMemberView.setVisibility(isMember ? View.GONE : View.VISIBLE);
        getActivity().invalidateOptionsMenu();
    });
    // Menu
    bind(groupVM.getIsCanEditInfo(), canEditInfo -> {
        getActivity().invalidateOptionsMenu();
    });
    return res;
}
Also used : ClipboardManager(android.content.ClipboardManager) AlertDialog(android.app.AlertDialog) BaseFragment(im.actor.sdk.controllers.BaseFragment) Bundle(android.os.Bundle) ViewAvatarActivity(im.actor.sdk.controllers.fragment.preview.ViewAvatarActivity) ActorSDKMessenger.groups(im.actor.sdk.util.ActorSDKMessenger.groups) ActorSDKMessenger.messenger(im.actor.sdk.util.ActorSDKMessenger.messenger) AlertListBuilder(im.actor.sdk.util.AlertListBuilder) ColorDrawable(android.graphics.drawable.ColorDrawable) Screen(im.actor.sdk.util.Screen) PhoneNumberUtil(com.google.i18n.phonenumbers.PhoneNumberUtil) RecyclerListView(im.actor.sdk.view.adapters.RecyclerListView) ClipboardManager(android.content.ClipboardManager) View(android.view.View) CommandCallback(im.actor.core.viewmodel.CommandCallback) Intents(im.actor.sdk.controllers.Intents) ActorSDKLauncher(im.actor.sdk.ActorSDKLauncher) Void(im.actor.runtime.actors.messages.Void) GroupMember(im.actor.core.entity.GroupMember) UserPhone(im.actor.core.viewmodel.UserPhone) SwitchCompat(android.support.v7.widget.SwitchCompat) ViewGroup(android.view.ViewGroup) ActorBinder(im.actor.sdk.controllers.ActorBinder) AlertDialog(android.app.AlertDialog) TextView(android.widget.TextView) Peer(im.actor.core.entity.Peer) ActorStyle(im.actor.sdk.ActorStyle) Context(android.content.Context) ActorSDKMessenger.myUid(im.actor.sdk.util.ActorSDKMessenger.myUid) TintImageView(im.actor.sdk.view.TintImageView) Intent(android.content.Intent) GroupVM(im.actor.core.viewmodel.GroupVM) MenuItem(android.view.MenuItem) ArrayList(java.util.ArrayList) ClipData(android.content.ClipData) MembersAdapter(im.actor.sdk.controllers.group.view.MembersAdapter) MenuInflater(android.view.MenuInflater) Toast(android.widget.Toast) Menu(android.view.Menu) AvatarView(im.actor.sdk.view.avatar.AvatarView) ActionBar(android.support.v7.app.ActionBar) GroupType(im.actor.core.entity.GroupType) ActorSDK(im.actor.sdk.ActorSDK) LayoutInflater(android.view.LayoutInflater) ActorSDKMessenger.users(im.actor.sdk.util.ActorSDKMessenger.users) AbsListView(android.widget.AbsListView) BaseActivity(im.actor.sdk.controllers.activity.BaseActivity) Color(android.graphics.Color) UserVM(im.actor.core.viewmodel.UserVM) R(im.actor.sdk.R) NumberParseException(com.google.i18n.phonenumbers.NumberParseException) Phonenumber(com.google.i18n.phonenumbers.Phonenumber) MembersAdapter(im.actor.sdk.controllers.group.view.MembersAdapter) GroupMember(im.actor.core.entity.GroupMember) TintImageView(im.actor.sdk.view.TintImageView) AbsListView(android.widget.AbsListView) Intent(android.content.Intent) RecyclerListView(im.actor.sdk.view.adapters.RecyclerListView) View(android.view.View) TextView(android.widget.TextView) TintImageView(im.actor.sdk.view.TintImageView) AvatarView(im.actor.sdk.view.avatar.AvatarView) AbsListView(android.widget.AbsListView) UserVM(im.actor.core.viewmodel.UserVM) TextView(android.widget.TextView) SwitchCompat(android.support.v7.widget.SwitchCompat)

Aggregations

GroupMember (im.actor.core.entity.GroupMember)9 ArrayList (java.util.ArrayList)5 Group (im.actor.core.entity.Group)4 User (im.actor.core.entity.User)4 UserVM (im.actor.core.viewmodel.UserVM)4 Void (im.actor.runtime.actors.messages.Void)4 Peer (im.actor.core.entity.Peer)3 GroupVM (im.actor.core.viewmodel.GroupVM)3 AlertDialog (android.app.AlertDialog)2 Intent (android.content.Intent)2 ApiOutPeer (im.actor.core.api.ApiOutPeer)2 ApiPeerType (im.actor.core.api.ApiPeerType)2 PeerType (im.actor.core.entity.PeerType)2 PeerChatOpened (im.actor.core.events.PeerChatOpened)2 AbsModule (im.actor.core.modules.AbsModule)2 ModuleContext (im.actor.core.modules.ModuleContext)2 CommandCallback (im.actor.core.viewmodel.CommandCallback)2 Storage (im.actor.runtime.Storage)2 ActorRef (im.actor.runtime.actors.ActorRef)2 ActorSystem.system (im.actor.runtime.actors.ActorSystem.system)2