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

The following examples show how to use org.telegram.tgnet.TLRPC#TL_inputStickerSetEmpty . 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: GroupStickersActivity.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
private void saveStickerSet() {
    if (info == null || info.stickerset != null && selectedStickerSet != null && selectedStickerSet.set.id == info.stickerset.id || info.stickerset == null && selectedStickerSet == null) {
        finishFragment();
        return;
    }
    showEditDoneProgress(true);
    TLRPC.TL_channels_setStickers req = new TLRPC.TL_channels_setStickers();
    req.channel = MessagesController.getInstance(currentAccount).getInputChannel(chatId);
    if (selectedStickerSet == null) {
        req.stickerset = new TLRPC.TL_inputStickerSetEmpty();
    } else {
        MessagesController.getEmojiSettings(currentAccount).edit().remove("group_hide_stickers_" + info.id).commit();
        req.stickerset = new TLRPC.TL_inputStickerSetID();
        req.stickerset.id = selectedStickerSet.set.id;
        req.stickerset.access_hash = selectedStickerSet.set.access_hash;
    }
    ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
        if (error == null) {
            if (selectedStickerSet == null) {
                info.stickerset = null;
            } else {
                info.stickerset = selectedStickerSet.set;
                MediaDataController.getInstance(currentAccount).putGroupStickerSet(selectedStickerSet);
            }
            if (info.stickerset == null) {
                info.flags |= 256;
            } else {
                info.flags = info.flags &~ 256;
            }
            MessagesStorage.getInstance(currentAccount).updateChatInfo(info, false);
            NotificationCenter.getInstance(currentAccount).postNotificationName(NotificationCenter.chatInfoDidLoad, info, 0, true, null);
            finishFragment();
        } else {
            Toast.makeText(getParentActivity(), LocaleController.getString("ErrorOccurred", R.string.ErrorOccurred) + "\n" + error.text, Toast.LENGTH_SHORT).show();
            donePressed = false;
            showEditDoneProgress(false);
        }
    }));
}
 
Example 2
Source File: GroupStickersActivity.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
private void saveStickerSet() {
    if (info == null || info.stickerset != null && selectedStickerSet != null && selectedStickerSet.set.id == info.stickerset.id || info.stickerset == null && selectedStickerSet == null) {
        finishFragment();
        return;
    }
    showEditDoneProgress(true);
    TLRPC.TL_channels_setStickers req = new TLRPC.TL_channels_setStickers();
    req.channel = MessagesController.getInstance(currentAccount).getInputChannel(chatId);
    if (selectedStickerSet == null) {
        req.stickerset = new TLRPC.TL_inputStickerSetEmpty();
    } else {
        MessagesController.getEmojiSettings(currentAccount).edit().remove("group_hide_stickers_" + info.id).commit();
        req.stickerset = new TLRPC.TL_inputStickerSetID();
        req.stickerset.id = selectedStickerSet.set.id;
        req.stickerset.access_hash = selectedStickerSet.set.access_hash;
    }
    ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
        if (error == null) {
            if (selectedStickerSet == null) {
                info.stickerset = null;
            } else {
                info.stickerset = selectedStickerSet.set;
                MediaDataController.getInstance(currentAccount).putGroupStickerSet(selectedStickerSet);
            }
            if (info.stickerset == null) {
                info.flags |= 256;
            } else {
                info.flags = info.flags &~ 256;
            }
            MessagesStorage.getInstance(currentAccount).updateChatInfo(info, false);
            NotificationCenter.getInstance(currentAccount).postNotificationName(NotificationCenter.chatInfoDidLoad, info, 0, true, null);
            finishFragment();
        } else {
            Toast.makeText(getParentActivity(), LocaleController.getString("ErrorOccurred", R.string.ErrorOccurred) + "\n" + error.text, Toast.LENGTH_SHORT).show();
            donePressed = false;
            showEditDoneProgress(false);
        }
    }));
}
 
Example 3
Source File: GroupStickersActivity.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
private void saveStickerSet() {
    if (info == null || info.stickerset != null && selectedStickerSet != null && selectedStickerSet.set.id == info.stickerset.id || info.stickerset == null && selectedStickerSet == null) {
        finishFragment();
        return;
    }
    showEditDoneProgress(true);
    TLRPC.TL_channels_setStickers req = new TLRPC.TL_channels_setStickers();
    req.channel = MessagesController.getInstance(currentAccount).getInputChannel(chatId);
    if (selectedStickerSet == null) {
        req.stickerset = new TLRPC.TL_inputStickerSetEmpty();
    } else {
        MessagesController.getEmojiSettings(currentAccount).edit().remove("group_hide_stickers_" + info.id).commit();
        req.stickerset = new TLRPC.TL_inputStickerSetID();
        req.stickerset.id = selectedStickerSet.set.id;
        req.stickerset.access_hash = selectedStickerSet.set.access_hash;
    }
    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) {
                        if (selectedStickerSet == null) {
                            info.stickerset = null;
                        } else {
                            info.stickerset = selectedStickerSet.set;
                            DataQuery.getInstance(currentAccount).putGroupStickerSet(selectedStickerSet);
                        }
                        if (info.stickerset == null) {
                            info.flags |= 256;
                        } else {
                            info.flags = info.flags &~ 256;
                        }
                        MessagesStorage.getInstance(currentAccount).updateChatInfo(info, false);
                        NotificationCenter.getInstance(currentAccount).postNotificationName(NotificationCenter.chatInfoDidLoaded, info, 0, true, null);
                        finishFragment();
                    } else {
                        Toast.makeText(getParentActivity(), LocaleController.getString("ErrorOccurred", R.string.ErrorOccurred) + "\n" + error.text, Toast.LENGTH_SHORT).show();
                        donePressed = false;
                        showEditDoneProgress(false);
                    }
                }
            });
        }
    });
}
 
Example 4
Source File: GroupStickersActivity.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
private void saveStickerSet() {
    if (info == null || info.stickerset != null && selectedStickerSet != null && selectedStickerSet.set.id == info.stickerset.id || info.stickerset == null && selectedStickerSet == null) {
        finishFragment();
        return;
    }
    showEditDoneProgress(true);
    TLRPC.TL_channels_setStickers req = new TLRPC.TL_channels_setStickers();
    req.channel = MessagesController.getInstance(currentAccount).getInputChannel(chatId);
    if (selectedStickerSet == null) {
        req.stickerset = new TLRPC.TL_inputStickerSetEmpty();
    } else {
        MessagesController.getEmojiSettings(currentAccount).edit().remove("group_hide_stickers_" + info.id).commit();
        req.stickerset = new TLRPC.TL_inputStickerSetID();
        req.stickerset.id = selectedStickerSet.set.id;
        req.stickerset.access_hash = selectedStickerSet.set.access_hash;
    }
    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) {
                        if (selectedStickerSet == null) {
                            info.stickerset = null;
                        } else {
                            info.stickerset = selectedStickerSet.set;
                            DataQuery.getInstance(currentAccount).putGroupStickerSet(selectedStickerSet);
                        }
                        if (info.stickerset == null) {
                            info.flags |= 256;
                        } else {
                            info.flags = info.flags &~ 256;
                        }
                        MessagesStorage.getInstance(currentAccount).updateChatInfo(info, false);
                        NotificationCenter.getInstance(currentAccount).postNotificationName(NotificationCenter.chatInfoDidLoaded, info, 0, true, null);
                        finishFragment();
                    } else {
                        Toast.makeText(getParentActivity(), LocaleController.getString("ErrorOccurred", R.string.ErrorOccurred) + "\n" + error.text, Toast.LENGTH_SHORT).show();
                        donePressed = false;
                        showEditDoneProgress(false);
                    }
                }
            });
        }
    });
}