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

The following examples show how to use org.telegram.tgnet.TLRPC#TL_inputStickeredMediaPhoto . 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: StickersAlert.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
public StickersAlert(Context context, TLRPC.Photo photo) {
    super(context, false);
    parentActivity = (Activity) context;
    final TLRPC.TL_messages_getAttachedStickers req = new TLRPC.TL_messages_getAttachedStickers();
    TLRPC.TL_inputStickeredMediaPhoto inputStickeredMediaPhoto = new TLRPC.TL_inputStickeredMediaPhoto();
    inputStickeredMediaPhoto.id = new TLRPC.TL_inputPhoto();
    inputStickeredMediaPhoto.id.id = photo.id;
    inputStickeredMediaPhoto.id.access_hash = photo.access_hash;
    req.media = inputStickeredMediaPhoto;
    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() {
                    reqId = 0;
                    if (error == null) {
                        TLRPC.Vector vector = (TLRPC.Vector) response;
                        if (vector.objects.isEmpty()) {
                            dismiss();
                        } else if (vector.objects.size() == 1) {
                            TLRPC.StickerSetCovered set = (TLRPC.StickerSetCovered) vector.objects.get(0);
                            inputStickerSet = new TLRPC.TL_inputStickerSetID();
                            inputStickerSet.id = set.set.id;
                            inputStickerSet.access_hash = set.set.access_hash;
                            loadStickerSet();
                        } else {
                            stickerSetCovereds = new ArrayList<>();
                            for (int a = 0; a < vector.objects.size(); a++) {
                                stickerSetCovereds.add((TLRPC.StickerSetCovered) vector.objects.get(a));
                            }
                            gridView.setLayoutParams(LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, Gravity.TOP | Gravity.LEFT, 0, 0, 0, 48));
                            titleTextView.setVisibility(View.GONE);
                            shadow[0].setVisibility(View.GONE);
                            adapter.notifyDataSetChanged();
                        }
                    } else {
                        AlertsCreator.processError(currentAccount, error, parentFragment, req);
                        dismiss();
                    }
                }
            });
        }
    });
    init(context);
}
 
Example 2
Source File: StickersAlert.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
public StickersAlert(Context context, TLRPC.Photo photo) {
    super(context, false);
    parentActivity = (Activity) context;
    final TLRPC.TL_messages_getAttachedStickers req = new TLRPC.TL_messages_getAttachedStickers();
    TLRPC.TL_inputStickeredMediaPhoto inputStickeredMediaPhoto = new TLRPC.TL_inputStickeredMediaPhoto();
    inputStickeredMediaPhoto.id = new TLRPC.TL_inputPhoto();
    inputStickeredMediaPhoto.id.id = photo.id;
    inputStickeredMediaPhoto.id.access_hash = photo.access_hash;
    req.media = inputStickeredMediaPhoto;
    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() {
                    reqId = 0;
                    if (error == null) {
                        TLRPC.Vector vector = (TLRPC.Vector) response;
                        if (vector.objects.isEmpty()) {
                            dismiss();
                        } else if (vector.objects.size() == 1) {
                            TLRPC.StickerSetCovered set = (TLRPC.StickerSetCovered) vector.objects.get(0);
                            inputStickerSet = new TLRPC.TL_inputStickerSetID();
                            inputStickerSet.id = set.set.id;
                            inputStickerSet.access_hash = set.set.access_hash;
                            loadStickerSet();
                        } else {
                            stickerSetCovereds = new ArrayList<>();
                            for (int a = 0; a < vector.objects.size(); a++) {
                                stickerSetCovereds.add((TLRPC.StickerSetCovered) vector.objects.get(a));
                            }
                            gridView.setLayoutParams(LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, Gravity.TOP | Gravity.LEFT, 0, 0, 0, 48));
                            titleTextView.setVisibility(View.GONE);
                            shadow[0].setVisibility(View.GONE);
                            adapter.notifyDataSetChanged();
                        }
                    } else {
                        AlertsCreator.processError(currentAccount, error, parentFragment, req);
                        dismiss();
                    }
                }
            });
        }
    });
    init(context);
}
 
Example 3
Source File: StickersAlert.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
public StickersAlert(Context context, Object parentObject, TLObject object) {
    super(context, false);
    parentActivity = (Activity) context;
    final TLRPC.TL_messages_getAttachedStickers req = new TLRPC.TL_messages_getAttachedStickers();
    if (object instanceof TLRPC.Photo) {
        TLRPC.Photo photo = (TLRPC.Photo) object;
        TLRPC.TL_inputStickeredMediaPhoto inputStickeredMediaPhoto = new TLRPC.TL_inputStickeredMediaPhoto();
        inputStickeredMediaPhoto.id = new TLRPC.TL_inputPhoto();
        inputStickeredMediaPhoto.id.id = photo.id;
        inputStickeredMediaPhoto.id.access_hash = photo.access_hash;
        inputStickeredMediaPhoto.id.file_reference = photo.file_reference;
        if (inputStickeredMediaPhoto.id.file_reference == null) {
            inputStickeredMediaPhoto.id.file_reference = new byte[0];
        }
        req.media = inputStickeredMediaPhoto;
    } else if (object instanceof TLRPC.Document) {
        TLRPC.Document document = (TLRPC.Document) object;
        TLRPC.TL_inputStickeredMediaDocument inputStickeredMediaDocument = new TLRPC.TL_inputStickeredMediaDocument();
        inputStickeredMediaDocument.id = new TLRPC.TL_inputDocument();
        inputStickeredMediaDocument.id.id = document.id;
        inputStickeredMediaDocument.id.access_hash = document.access_hash;
        inputStickeredMediaDocument.id.file_reference = document.file_reference;
        if (inputStickeredMediaDocument.id.file_reference == null) {
            inputStickeredMediaDocument.id.file_reference = new byte[0];
        }
        req.media = inputStickeredMediaDocument;
    }
    RequestDelegate requestDelegate = (response, error) -> AndroidUtilities.runOnUIThread(() -> {
        reqId = 0;
        if (error == null) {
            TLRPC.Vector vector = (TLRPC.Vector) response;
            if (vector.objects.isEmpty()) {
                dismiss();
            } else if (vector.objects.size() == 1) {
                TLRPC.StickerSetCovered set = (TLRPC.StickerSetCovered) vector.objects.get(0);
                inputStickerSet = new TLRPC.TL_inputStickerSetID();
                inputStickerSet.id = set.set.id;
                inputStickerSet.access_hash = set.set.access_hash;
                loadStickerSet();
            } else {
                stickerSetCovereds = new ArrayList<>();
                for (int a = 0; a < vector.objects.size(); a++) {
                    stickerSetCovereds.add((TLRPC.StickerSetCovered) vector.objects.get(a));
                }
                gridView.setLayoutParams(LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, Gravity.TOP | Gravity.LEFT, 0, 0, 0, 48));
                titleTextView.setVisibility(View.GONE);
                shadow[0].setVisibility(View.GONE);
                adapter.notifyDataSetChanged();
            }
        } else {
            AlertsCreator.processError(currentAccount, error, parentFragment, req);
            dismiss();
        }
    });
    reqId = ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> {
        if (error != null && FileRefController.isFileRefError(error.text) && parentObject != null) {
            FileRefController.getInstance(currentAccount).requestReference(parentObject, req, requestDelegate);
            return;
        }
        requestDelegate.run(response, error);
    });
    init(context);
}
 
Example 4
Source File: StickersAlert.java    From Telegram with GNU General Public License v2.0 4 votes vote down vote up
public StickersAlert(Context context, Object parentObject, TLObject object) {
    super(context, false);
    parentActivity = (Activity) context;
    final TLRPC.TL_messages_getAttachedStickers req = new TLRPC.TL_messages_getAttachedStickers();
    if (object instanceof TLRPC.Photo) {
        TLRPC.Photo photo = (TLRPC.Photo) object;
        TLRPC.TL_inputStickeredMediaPhoto inputStickeredMediaPhoto = new TLRPC.TL_inputStickeredMediaPhoto();
        inputStickeredMediaPhoto.id = new TLRPC.TL_inputPhoto();
        inputStickeredMediaPhoto.id.id = photo.id;
        inputStickeredMediaPhoto.id.access_hash = photo.access_hash;
        inputStickeredMediaPhoto.id.file_reference = photo.file_reference;
        if (inputStickeredMediaPhoto.id.file_reference == null) {
            inputStickeredMediaPhoto.id.file_reference = new byte[0];
        }
        req.media = inputStickeredMediaPhoto;
    } else if (object instanceof TLRPC.Document) {
        TLRPC.Document document = (TLRPC.Document) object;
        TLRPC.TL_inputStickeredMediaDocument inputStickeredMediaDocument = new TLRPC.TL_inputStickeredMediaDocument();
        inputStickeredMediaDocument.id = new TLRPC.TL_inputDocument();
        inputStickeredMediaDocument.id.id = document.id;
        inputStickeredMediaDocument.id.access_hash = document.access_hash;
        inputStickeredMediaDocument.id.file_reference = document.file_reference;
        if (inputStickeredMediaDocument.id.file_reference == null) {
            inputStickeredMediaDocument.id.file_reference = new byte[0];
        }
        req.media = inputStickeredMediaDocument;
    }
    RequestDelegate requestDelegate = (response, error) -> AndroidUtilities.runOnUIThread(() -> {
        reqId = 0;
        if (error == null) {
            TLRPC.Vector vector = (TLRPC.Vector) response;
            if (vector.objects.isEmpty()) {
                dismiss();
            } else if (vector.objects.size() == 1) {
                TLRPC.StickerSetCovered set = (TLRPC.StickerSetCovered) vector.objects.get(0);
                inputStickerSet = new TLRPC.TL_inputStickerSetID();
                inputStickerSet.id = set.set.id;
                inputStickerSet.access_hash = set.set.access_hash;
                loadStickerSet();
            } else {
                stickerSetCovereds = new ArrayList<>();
                for (int a = 0; a < vector.objects.size(); a++) {
                    stickerSetCovereds.add((TLRPC.StickerSetCovered) vector.objects.get(a));
                }
                gridView.setLayoutParams(LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, Gravity.TOP | Gravity.LEFT, 0, 0, 0, 48));
                titleTextView.setVisibility(View.GONE);
                shadow[0].setVisibility(View.GONE);
                adapter.notifyDataSetChanged();
            }
        } else {
            AlertsCreator.processError(currentAccount, error, parentFragment, req);
            dismiss();
        }
    });
    reqId = ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> {
        if (error != null && FileRefController.isFileRefError(error.text) && parentObject != null) {
            FileRefController.getInstance(currentAccount).requestReference(parentObject, req, requestDelegate);
            return;
        }
        requestDelegate.run(response, error);
    });
    init(context);
}