Java Code Examples for org.telegram.tgnet.TLRPC#TL_channels_getParticipants

The following examples show how to use org.telegram.tgnet.TLRPC#TL_channels_getParticipants . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ChannelAdminLogActivity.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
private void loadAdmins() {
    TLRPC.TL_channels_getParticipants req = new TLRPC.TL_channels_getParticipants();
    req.channel = MessagesController.getInputChannel(currentChat);
    req.filter = new TLRPC.TL_channelParticipantsAdmins();
    req.offset = 0;
    req.limit = 200;
    int reqId = ConnectionsManager.getInstance(currentAccount).sendRequest(req, new RequestDelegate() {
        @Override
        public void run(final TLObject response, final TLRPC.TL_error error) {
            AndroidUtilities.runOnUIThread(new Runnable() {
                @Override
                public void run() {
                    if (error == null) {
                        TLRPC.TL_channels_channelParticipants res = (TLRPC.TL_channels_channelParticipants) response;
                        MessagesController.getInstance(currentAccount).putUsers(res.users, false);
                        admins = res.participants;
                        if (visibleDialog instanceof AdminLogFilterAlert) {
                            ((AdminLogFilterAlert) visibleDialog).setCurrentAdmins(admins);
                        }
                    }
                }
            });
        }
    });
    ConnectionsManager.getInstance(currentAccount).bindRequestToGuid(reqId, classGuid);
}
 
Example 2
Source File: ChannelAdminLogActivity.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
private void loadAdmins() {
    TLRPC.TL_channels_getParticipants req = new TLRPC.TL_channels_getParticipants();
    req.channel = MessagesController.getInputChannel(currentChat);
    req.filter = new TLRPC.TL_channelParticipantsAdmins();
    req.offset = 0;
    req.limit = 200;
    int reqId = ConnectionsManager.getInstance(currentAccount).sendRequest(req, new RequestDelegate() {
        @Override
        public void run(final TLObject response, final TLRPC.TL_error error) {
            AndroidUtilities.runOnUIThread(new Runnable() {
                @Override
                public void run() {
                    if (error == null) {
                        TLRPC.TL_channels_channelParticipants res = (TLRPC.TL_channels_channelParticipants) response;
                        MessagesController.getInstance(currentAccount).putUsers(res.users, false);
                        admins = res.participants;
                        if (visibleDialog instanceof AdminLogFilterAlert) {
                            ((AdminLogFilterAlert) visibleDialog).setCurrentAdmins(admins);
                        }
                    }
                }
            });
        }
    });
    ConnectionsManager.getInstance(currentAccount).bindRequestToGuid(reqId, classGuid);
}
 
Example 3
Source File: ChannelAdminLogActivity.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
private void loadAdmins() {
    TLRPC.TL_channels_getParticipants req = new TLRPC.TL_channels_getParticipants();
    req.channel = MessagesController.getInputChannel(currentChat);
    req.filter = new TLRPC.TL_channelParticipantsAdmins();
    req.offset = 0;
    req.limit = 200;
    int reqId = ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
        if (error == null) {
            TLRPC.TL_channels_channelParticipants res = (TLRPC.TL_channels_channelParticipants) response;
            MessagesController.getInstance(currentAccount).putUsers(res.users, false);
            admins = res.participants;
            if (visibleDialog instanceof AdminLogFilterAlert) {
                ((AdminLogFilterAlert) visibleDialog).setCurrentAdmins(admins);
            }
        }
    }));
    ConnectionsManager.getInstance(currentAccount).bindRequestToGuid(reqId, classGuid);
}
 
Example 4
Source File: ChannelAdminLogActivity.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
private void loadAdmins() {
    TLRPC.TL_channels_getParticipants req = new TLRPC.TL_channels_getParticipants();
    req.channel = MessagesController.getInputChannel(currentChat);
    req.filter = new TLRPC.TL_channelParticipantsAdmins();
    req.offset = 0;
    req.limit = 200;
    int reqId = ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
        if (error == null) {
            TLRPC.TL_channels_channelParticipants res = (TLRPC.TL_channels_channelParticipants) response;
            MessagesController.getInstance(currentAccount).putUsers(res.users, false);
            admins = res.participants;
            if (visibleDialog instanceof AdminLogFilterAlert) {
                ((AdminLogFilterAlert) visibleDialog).setCurrentAdmins(admins);
            }
        }
    }));
    ConnectionsManager.getInstance(currentAccount).bindRequestToGuid(reqId, classGuid);
}
 
Example 5
Source File: ProfileActivity.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void run()
{
    if (!isRunning || !isLoadingUsers || isLoading || isCompleted)
        return;

    isLoading = true;
    final TLRPC.TL_channels_getParticipants req = new TLRPC.TL_channels_getParticipants();
    req.channel = MessagesController.getInstance(currentAccount).getInputChannel(chat_id);
    req.filter = new TLRPC.TL_channelParticipantsRecent();
    req.offset = chatParticipantsList.size();
    req.limit = 200;
    int reqId = ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() ->
    {
        isLoading = false;

        if (!isRunning || !isLoadingUsers)
            return;

        if (error == null)
        {
            TLRPC.TL_channels_channelParticipants res = (TLRPC.TL_channels_channelParticipants) response;
            MessagesController.getInstance(currentAccount).putUsers(res.users, false);
            isCompleted = res.users.size() < 200;

            if (req.offset == 0)
            {
                info.participants = new TLRPC.TL_chatParticipants();
                MessagesStorage.getInstance(currentAccount).putUsersAndChats(res.users, null, true, true);
                MessagesStorage.getInstance(currentAccount).updateChannelUsers(chat_id, res.participants);
            }

            int currentTime = ConnectionsManager.getInstance(currentAccount).getCurrentTime();
            for (int a = 0; a < res.participants.size(); a++)
            {
                TLRPC.TL_chatChannelParticipant participant = new TLRPC.TL_chatChannelParticipant();
                participant.channelParticipant = res.participants.get(a);
                participant.inviter_id = participant.channelParticipant.inviter_id;
                participant.user_id = participant.channelParticipant.user_id;
                participant.date = participant.channelParticipant.date;

                if (participantsMap.indexOfKey(participant.user_id) < 0)
                {
                    info.participants.participants.add(participant);
                    participantsMap.put(participant.user_id, participant);
                    chatParticipantsList.add(participant);

                    if (isParticipantAdmin(participant))
                        chatAdminParticipantsList.add(participant);
                    else
                        tmpChatAdminParticipantsList.add(participant);

                    if (isParticipantOnline(participant, currentTime))
                        chatOnlineParticipantsList.add(participant);
                    else
                        tmpChatOnlineParticipantsList.add(participant);
                }
            }
        }
        else
            isCompleted = true;

        if (isCompleted)
        {
            isLoadingUsers = false;
            if (!tmpChatAdminParticipantsList.isEmpty())
            {
                sortParticipants(chatAdminParticipantsList);
                chatAdminParticipantsList.addAll(tmpChatAdminParticipantsList);
                tmpChatAdminParticipantsList.clear();
            }

            if (!tmpChatOnlineParticipantsList.isEmpty())
            {
                sortParticipants(chatOnlineParticipantsList);
                chatOnlineParticipantsList.addAll(tmpChatOnlineParticipantsList);
                tmpChatOnlineParticipantsList.clear();
            }
        }

        updateOnlineCount();
        updateRowsIds();

        if (listAdapter != null)
            listAdapter.notifyDataSetChanged();

        if (isLoadingUsers && !isCompleted && membersSortType != MembersSortType.Default)
            AndroidUtilities.runOnUIThread(loadParticipantRunnable);
    }));
    ConnectionsManager.getInstance(currentAccount).bindRequestToGuid(reqId, classGuid);
}
 
Example 6
Source File: ChannelEditActivity.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
private void getChannelParticipants(boolean reload) {
    if (loadingUsers || participantsMap == null || info == null) {
        return;
    }
    loadingUsers = true;
    final int delay = participantsMap.size() != 0 && reload ? 300 : 0;

    final TLRPC.TL_channels_getParticipants req = new TLRPC.TL_channels_getParticipants();
    req.channel = MessagesController.getInstance(currentAccount).getInputChannel(chat_id);
    req.filter = new TLRPC.TL_channelParticipantsRecent();
    req.offset = reload ? 0 : participantsMap.size();
    req.limit = 200;
    int reqId = ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
        if (error == null) {
            TLRPC.TL_channels_channelParticipants res = (TLRPC.TL_channels_channelParticipants) response;
            MessagesController.getInstance(currentAccount).putUsers(res.users, false);
            if (res.users.size() < 200) {
                usersEndReached = true;
            }
            if (req.offset == 0) {
                participantsMap.clear();
                info.participants = new TLRPC.TL_chatParticipants();
                MessagesStorage.getInstance(currentAccount).putUsersAndChats(res.users, null, true, true);
                MessagesStorage.getInstance(currentAccount).updateChannelUsers(chat_id, res.participants);
            }
            for (int a = 0; a < res.participants.size(); a++) {
                TLRPC.TL_chatChannelParticipant participant = new TLRPC.TL_chatChannelParticipant();
                participant.channelParticipant = res.participants.get(a);
                participant.inviter_id = participant.channelParticipant.inviter_id;
                participant.user_id = participant.channelParticipant.user_id;
                participant.date = participant.channelParticipant.date;
                if (participantsMap.indexOfKey(participant.user_id) < 0) {
                    info.participants.participants.add(participant);
                    participantsMap.put(participant.user_id, participant);
                }
            }
        }
        loadingUsers = false;
        NotificationCenter.getInstance(currentAccount).postNotificationName(NotificationCenter.chatInfoDidLoaded, info, 0, true, null);
    }, delay));
    ConnectionsManager.getInstance(currentAccount).bindRequestToGuid(reqId, classGuid);
}
 
Example 7
Source File: ProfileActivity.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void run()
{
    if (!isRunning || !isLoadingUsers || isLoading || isCompleted)
        return;

    isLoading = true;
    final TLRPC.TL_channels_getParticipants req = new TLRPC.TL_channels_getParticipants();
    req.channel = MessagesController.getInstance(currentAccount).getInputChannel(chat_id);
    req.filter = new TLRPC.TL_channelParticipantsRecent();
    req.offset = chatParticipantsList.size();
    req.limit = 200;
    int reqId = ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() ->
    {
        isLoading = false;

        if (!isRunning || !isLoadingUsers)
            return;

        if (error == null)
        {
            TLRPC.TL_channels_channelParticipants res = (TLRPC.TL_channels_channelParticipants) response;
            MessagesController.getInstance(currentAccount).putUsers(res.users, false);
            isCompleted = res.users.size() < 200;

            if (req.offset == 0)
            {
                info.participants = new TLRPC.TL_chatParticipants();
                MessagesStorage.getInstance(currentAccount).putUsersAndChats(res.users, null, true, true);
                MessagesStorage.getInstance(currentAccount).updateChannelUsers(chat_id, res.participants);
            }

            int currentTime = ConnectionsManager.getInstance(currentAccount).getCurrentTime();
            for (int a = 0; a < res.participants.size(); a++)
            {
                TLRPC.TL_chatChannelParticipant participant = new TLRPC.TL_chatChannelParticipant();
                participant.channelParticipant = res.participants.get(a);
                participant.inviter_id = participant.channelParticipant.inviter_id;
                participant.user_id = participant.channelParticipant.user_id;
                participant.date = participant.channelParticipant.date;

                if (participantsMap.indexOfKey(participant.user_id) < 0)
                {
                    info.participants.participants.add(participant);
                    participantsMap.put(participant.user_id, participant);
                    chatParticipantsList.add(participant);

                    if (isParticipantAdmin(participant))
                        chatAdminParticipantsList.add(participant);
                    else
                        tmpChatAdminParticipantsList.add(participant);

                    if (isParticipantOnline(participant, currentTime))
                        chatOnlineParticipantsList.add(participant);
                    else
                        tmpChatOnlineParticipantsList.add(participant);
                }
            }
        }
        else
            isCompleted = true;

        if (isCompleted)
        {
            isLoadingUsers = false;
            if (!tmpChatAdminParticipantsList.isEmpty())
            {
                sortParticipants(chatAdminParticipantsList);
                chatAdminParticipantsList.addAll(tmpChatAdminParticipantsList);
                tmpChatAdminParticipantsList.clear();
            }

            if (!tmpChatOnlineParticipantsList.isEmpty())
            {
                sortParticipants(chatOnlineParticipantsList);
                chatOnlineParticipantsList.addAll(tmpChatOnlineParticipantsList);
                tmpChatOnlineParticipantsList.clear();
            }
        }

        updateOnlineCount();
        updateRowsIds();

        if (listAdapter != null)
            listAdapter.notifyDataSetChanged();

        if (isLoadingUsers && !isCompleted && membersSortType != MembersSortType.Default)
            AndroidUtilities.runOnUIThread(loadParticipantRunnable);
    }));
    ConnectionsManager.getInstance(currentAccount).bindRequestToGuid(reqId, classGuid);
}
 
Example 8
Source File: ChannelEditActivity.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
private void getChannelParticipants(boolean reload) {
    if (loadingUsers || participantsMap == null || info == null) {
        return;
    }
    loadingUsers = true;
    final int delay = participantsMap.size() != 0 && reload ? 300 : 0;

    final TLRPC.TL_channels_getParticipants req = new TLRPC.TL_channels_getParticipants();
    req.channel = MessagesController.getInstance(currentAccount).getInputChannel(chat_id);
    req.filter = new TLRPC.TL_channelParticipantsRecent();
    req.offset = reload ? 0 : participantsMap.size();
    req.limit = 200;
    int reqId = ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
        if (error == null) {
            TLRPC.TL_channels_channelParticipants res = (TLRPC.TL_channels_channelParticipants) response;
            MessagesController.getInstance(currentAccount).putUsers(res.users, false);
            if (res.users.size() < 200) {
                usersEndReached = true;
            }
            if (req.offset == 0) {
                participantsMap.clear();
                info.participants = new TLRPC.TL_chatParticipants();
                MessagesStorage.getInstance(currentAccount).putUsersAndChats(res.users, null, true, true);
                MessagesStorage.getInstance(currentAccount).updateChannelUsers(chat_id, res.participants);
            }
            for (int a = 0; a < res.participants.size(); a++) {
                TLRPC.TL_chatChannelParticipant participant = new TLRPC.TL_chatChannelParticipant();
                participant.channelParticipant = res.participants.get(a);
                participant.inviter_id = participant.channelParticipant.inviter_id;
                participant.user_id = participant.channelParticipant.user_id;
                participant.date = participant.channelParticipant.date;
                if (participantsMap.indexOfKey(participant.user_id) < 0) {
                    info.participants.participants.add(participant);
                    participantsMap.put(participant.user_id, participant);
                }
            }
        }
        loadingUsers = false;
        NotificationCenter.getInstance(currentAccount).postNotificationName(NotificationCenter.chatInfoDidLoaded, info, 0, true, null);
    }, delay));
    ConnectionsManager.getInstance(currentAccount).bindRequestToGuid(reqId, classGuid);
}