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

The following examples show how to use org.telegram.tgnet.TLRPC#TL_inputChannelEmpty . 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: ChannelCreateActivity.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
public ChannelCreateActivity(Bundle args) {
    super(args);
    currentStep = args.getInt("step", 0);
    if (currentStep == 0) {
        avatarDrawable = new AvatarDrawable();
        imageUpdater = new ImageUpdater();

        TLRPC.TL_channels_checkUsername req = new TLRPC.TL_channels_checkUsername();
        req.username = "1";
        req.channel = new TLRPC.TL_inputChannelEmpty();
        ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> canCreatePublic = error == null || !error.text.equals("CHANNELS_ADMIN_PUBLIC_TOO_MUCH")));
    } else {
        if (currentStep == 1) {
            canCreatePublic = args.getBoolean("canCreatePublic", true);
            isPrivate = !canCreatePublic;
            if (!canCreatePublic) {
                loadAdminedChannels();
            }
        }
        chatId = args.getInt("chat_id", 0);
    }
}
 
Example 2
Source File: ChannelCreateActivity.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
public ChannelCreateActivity(Bundle args) {
    super(args);
    currentStep = args.getInt("step", 0);
    if (currentStep == 0) {
        avatarDrawable = new AvatarDrawable();
        imageUpdater = new ImageUpdater();

        TLRPC.TL_channels_checkUsername req = new TLRPC.TL_channels_checkUsername();
        req.username = "1";
        req.channel = new TLRPC.TL_inputChannelEmpty();
        ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> canCreatePublic = error == null || !error.text.equals("CHANNELS_ADMIN_PUBLIC_TOO_MUCH")));
    } else {
        if (currentStep == 1) {
            canCreatePublic = args.getBoolean("canCreatePublic", true);
            isPrivate = !canCreatePublic;
            if (!canCreatePublic) {
                loadAdminedChannels();
            }
        }
        chatId = args.getInt("chat_id", 0);
    }
}
 
Example 3
Source File: ChannelCreateActivity.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
public ChannelCreateActivity(Bundle args) {
    super(args);
    currentStep = args.getInt("step", 0);
    if (currentStep == 0) {
        avatarDrawable = new AvatarDrawable();
        imageUpdater = new ImageUpdater();

        TLRPC.TL_channels_checkUsername req = new TLRPC.TL_channels_checkUsername();
        req.username = "1";
        req.channel = new TLRPC.TL_inputChannelEmpty();
        ConnectionsManager.getInstance(currentAccount).sendRequest(req, new RequestDelegate() {
            @Override
            public void run(TLObject response, final TLRPC.TL_error error) {
                AndroidUtilities.runOnUIThread(new Runnable() {
                    @Override
                    public void run() {
                        canCreatePublic = error == null || !error.text.equals("CHANNELS_ADMIN_PUBLIC_TOO_MUCH");
                    }
                });
            }
        });
    } else {
        if (currentStep == 1) {
            canCreatePublic = args.getBoolean("canCreatePublic", true);
            isPrivate = !canCreatePublic;
            if (!canCreatePublic) {
                loadAdminedChannels();
            }
        }
        chatId = args.getInt("chat_id", 0);
    }
}
 
Example 4
Source File: ChannelCreateActivity.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
public ChannelCreateActivity(Bundle args) {
    super(args);
    currentStep = args.getInt("step", 0);
    if (currentStep == 0) {
        avatarDrawable = new AvatarDrawable();
        imageUpdater = new ImageUpdater();

        TLRPC.TL_channels_checkUsername req = new TLRPC.TL_channels_checkUsername();
        req.username = "1";
        req.channel = new TLRPC.TL_inputChannelEmpty();
        ConnectionsManager.getInstance(currentAccount).sendRequest(req, new RequestDelegate() {
            @Override
            public void run(TLObject response, final TLRPC.TL_error error) {
                AndroidUtilities.runOnUIThread(new Runnable() {
                    @Override
                    public void run() {
                        canCreatePublic = error == null || !error.text.equals("CHANNELS_ADMIN_PUBLIC_TOO_MUCH");
                    }
                });
            }
        });
    } else {
        if (currentStep == 1) {
            canCreatePublic = args.getBoolean("canCreatePublic", true);
            isPrivate = !canCreatePublic;
            if (!canCreatePublic) {
                loadAdminedChannels();
            }
        }
        chatId = args.getInt("chat_id", 0);
    }
}
 
Example 5
Source File: ChatEditTypeActivity.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
@Override
public boolean onFragmentCreate() {
    currentChat = getMessagesController().getChat(chatId);
    if (currentChat == null) {
        currentChat = getMessagesStorage().getChatSync(chatId);
        if (currentChat != null) {
            getMessagesController().putChat(currentChat, true);
        } else {
            return false;
        }
        if (info == null) {
            info = getMessagesStorage().loadChatInfo(chatId, new CountDownLatch(1), false, false);
            if (info == null) {
                return false;
            }
        }
    }
    isPrivate = !isForcePublic && TextUtils.isEmpty(currentChat.username);
    isChannel = ChatObject.isChannel(currentChat) && !currentChat.megagroup;
    if (isForcePublic && TextUtils.isEmpty(currentChat.username) || isPrivate && currentChat.creator) {
        TLRPC.TL_channels_checkUsername req = new TLRPC.TL_channels_checkUsername();
        req.username = "1";
        req.channel = new TLRPC.TL_inputChannelEmpty();
        getConnectionsManager().sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
            canCreatePublic = error == null || !error.text.equals("CHANNELS_ADMIN_PUBLIC_TOO_MUCH");
            if (!canCreatePublic) {
                loadAdminedChannels();
            }
        }));
    }
    getNotificationCenter().addObserver(this, NotificationCenter.chatInfoDidLoad);
    return super.onFragmentCreate();
}
 
Example 6
Source File: ChatEditTypeActivity.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
@Override
public boolean onFragmentCreate() {
    currentChat = getMessagesController().getChat(chatId);
    if (currentChat == null) {
        currentChat = getMessagesStorage().getChatSync(chatId);
        if (currentChat != null) {
            getMessagesController().putChat(currentChat, true);
        } else {
            return false;
        }
        if (info == null) {
            info = getMessagesStorage().loadChatInfo(chatId, new CountDownLatch(1), false, false);
            if (info == null) {
                return false;
            }
        }
    }
    isPrivate = !isForcePublic && TextUtils.isEmpty(currentChat.username);
    isChannel = ChatObject.isChannel(currentChat) && !currentChat.megagroup;
    if (isForcePublic && TextUtils.isEmpty(currentChat.username) || isPrivate && currentChat.creator) {
        TLRPC.TL_channels_checkUsername req = new TLRPC.TL_channels_checkUsername();
        req.username = "1";
        req.channel = new TLRPC.TL_inputChannelEmpty();
        getConnectionsManager().sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
            canCreatePublic = error == null || !error.text.equals("CHANNELS_ADMIN_PUBLIC_TOO_MUCH");
            if (!canCreatePublic) {
                loadAdminedChannels();
            }
        }));
    }
    getNotificationCenter().addObserver(this, NotificationCenter.chatInfoDidLoad);
    return super.onFragmentCreate();
}