org.telegram.messenger.WebFile Java Examples

The following examples show how to use org.telegram.messenger.WebFile. 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: ContextLinkCell.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
private void didPressedButton() {
    if (documentAttachType == DOCUMENT_ATTACH_TYPE_AUDIO || documentAttachType == DOCUMENT_ATTACH_TYPE_MUSIC) {
        if (buttonState == 0) {
            if (MediaController.getInstance().playMessage(currentMessageObject)) {
                buttonState = 1;
                radialProgress.setBackground(getDrawableForCurrentState(), false, false);
                invalidate();
            }
        } else if (buttonState == 1) {
            boolean result = MediaController.getInstance().pauseMessage(currentMessageObject);
            if (result) {
                buttonState = 0;
                radialProgress.setBackground(getDrawableForCurrentState(), false, false);
                invalidate();
            }
        } else if (buttonState == 2) {
            radialProgress.setProgress(0, false);
            if (documentAttach != null) {
                FileLoader.getInstance(currentAccount).loadFile(documentAttach, true, 0);
            } else if (inlineResult.content instanceof TLRPC.TL_webDocument) {
                FileLoader.getInstance(currentAccount).loadFile(WebFile.createWithWebDocument(inlineResult.content), true, 1);
            }
            buttonState = 4;
            radialProgress.setBackground(getDrawableForCurrentState(), true, false);
            invalidate();
        } else if (buttonState == 4) {
            if (documentAttach != null) {
                FileLoader.getInstance(currentAccount).cancelLoadFile(documentAttach);
            } else if (inlineResult.content instanceof TLRPC.TL_webDocument) {
                FileLoader.getInstance(currentAccount).cancelLoadFile(WebFile.createWithWebDocument(inlineResult.content));
            }
            buttonState = 2;
            radialProgress.setBackground(getDrawableForCurrentState(), false, false);
            invalidate();
        }
    }
}
 
Example #2
Source File: ContextLinkCell.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
private void didPressedButton() {
    if (documentAttachType == DOCUMENT_ATTACH_TYPE_AUDIO || documentAttachType == DOCUMENT_ATTACH_TYPE_MUSIC) {
        if (buttonState == 0) {
            if (MediaController.getInstance().playMessage(currentMessageObject)) {
                buttonState = 1;
                radialProgress.setBackground(getDrawableForCurrentState(), false, false);
                invalidate();
            }
        } else if (buttonState == 1) {
            boolean result = MediaController.getInstance().pauseMessage(currentMessageObject);
            if (result) {
                buttonState = 0;
                radialProgress.setBackground(getDrawableForCurrentState(), false, false);
                invalidate();
            }
        } else if (buttonState == 2) {
            radialProgress.setProgress(0, false);
            if (documentAttach != null) {
                FileLoader.getInstance(currentAccount).loadFile(documentAttach, true, 0);
            } else if (inlineResult.content instanceof TLRPC.TL_webDocument) {
                FileLoader.getInstance(currentAccount).loadFile(WebFile.createWithWebDocument(inlineResult.content), true, 1);
            }
            buttonState = 4;
            radialProgress.setBackground(getDrawableForCurrentState(), true, false);
            invalidate();
        } else if (buttonState == 4) {
            if (documentAttach != null) {
                FileLoader.getInstance(currentAccount).cancelLoadFile(documentAttach);
            } else if (inlineResult.content instanceof TLRPC.TL_webDocument) {
                FileLoader.getInstance(currentAccount).cancelLoadFile(WebFile.createWithWebDocument(inlineResult.content));
            }
            buttonState = 2;
            radialProgress.setBackground(getDrawableForCurrentState(), false, false);
            invalidate();
        }
    }
}
 
Example #3
Source File: PaymentInfoCell.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
public void setInvoice(TLRPC.TL_messageMediaInvoice invoice, String botname) {
    nameTextView.setText(invoice.title);
    detailTextView.setText(invoice.description);
    detailExTextView.setText(botname);

    int maxPhotoWidth;
    if (AndroidUtilities.isTablet()) {
        maxPhotoWidth = (int) (AndroidUtilities.getMinTabletSide() * 0.7f);
    } else {
        maxPhotoWidth = (int) (Math.min(AndroidUtilities.displaySize.x, AndroidUtilities.displaySize.y) * 0.7f);
    }
    int width = 640;
    int height = 360;
    float scale = width / (float) (maxPhotoWidth - AndroidUtilities.dp(2));
    width /= scale;
    height /= scale;
    if (invoice.photo != null && invoice.photo.mime_type.startsWith("image/")) {
        nameTextView.setLayoutParams(LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, LocaleController.isRTL ? 10 : 123, 9, LocaleController.isRTL ? 123 : 10, 0));
        detailTextView.setLayoutParams(LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, LocaleController.isRTL ? 10 : 123, 33, LocaleController.isRTL ? 123 : 10, 0));
        detailExTextView.setLayoutParams(LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, LocaleController.isRTL ? 10 : 123, 90, LocaleController.isRTL ? 123 : 10, 0));
        imageView.setVisibility(VISIBLE);
        String filter = String.format(Locale.US, "%d_%d", width, height);
        imageView.getImageReceiver().setImage(ImageLocation.getForWebFile(WebFile.createWithWebDocument(invoice.photo)), filter, null, null, -1, null, invoice, 1);
    } else {
        nameTextView.setLayoutParams(LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, 17, 9, 17, 0));
        detailTextView.setLayoutParams(LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, 17, 33, 17, 0));
        detailExTextView.setLayoutParams(LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, 17, 90, 17, 0));
        imageView.setVisibility(GONE);
    }
}
 
Example #4
Source File: ContextLinkCell.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
private void didPressedButton() {
    if (documentAttachType == DOCUMENT_ATTACH_TYPE_AUDIO || documentAttachType == DOCUMENT_ATTACH_TYPE_MUSIC) {
        if (buttonState == 0) {
            if (MediaController.getInstance().playMessage(currentMessageObject)) {
                buttonState = 1;
                radialProgress.setIcon(getIconForCurrentState(), false, true);
                invalidate();
            }
        } else if (buttonState == 1) {
            boolean result = MediaController.getInstance().pauseMessage(currentMessageObject);
            if (result) {
                buttonState = 0;
                radialProgress.setIcon(getIconForCurrentState(), false, true);
                invalidate();
            }
        } else if (buttonState == 2) {
            radialProgress.setProgress(0, false);
            if (documentAttach != null) {
                FileLoader.getInstance(currentAccount).loadFile(documentAttach, inlineResult, 1, 0);
            } else if (inlineResult.content instanceof TLRPC.TL_webDocument) {
                FileLoader.getInstance(currentAccount).loadFile(WebFile.createWithWebDocument(inlineResult.content), 1, 1);
            }
            buttonState = 4;
            radialProgress.setIcon(getIconForCurrentState(), false, true);
            invalidate();
        } else if (buttonState == 4) {
            if (documentAttach != null) {
                FileLoader.getInstance(currentAccount).cancelLoadFile(documentAttach);
            } else if (inlineResult.content instanceof TLRPC.TL_webDocument) {
                FileLoader.getInstance(currentAccount).cancelLoadFile(WebFile.createWithWebDocument(inlineResult.content));
            }
            buttonState = 2;
            radialProgress.setIcon(getIconForCurrentState(), false, true);
            invalidate();
        }
    }
}
 
Example #5
Source File: PaymentInfoCell.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
public void setInvoice(TLRPC.TL_messageMediaInvoice invoice, String botname) {
    nameTextView.setText(invoice.title);
    detailTextView.setText(invoice.description);
    detailExTextView.setText(botname);

    int maxPhotoWidth;
    if (AndroidUtilities.isTablet()) {
        maxPhotoWidth = (int) (AndroidUtilities.getMinTabletSide() * 0.7f);
    } else {
        maxPhotoWidth = (int) (Math.min(AndroidUtilities.displaySize.x, AndroidUtilities.displaySize.y) * 0.7f);
    }
    int width = 640;
    int height = 360;
    float scale = width / (float) (maxPhotoWidth - AndroidUtilities.dp(2));
    width /= scale;
    height /= scale;
    if (invoice.photo != null && invoice.photo.mime_type.startsWith("image/")) {
        nameTextView.setLayoutParams(LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, LocaleController.isRTL ? 10 : 123, 9, LocaleController.isRTL ? 123 : 10, 0));
        detailTextView.setLayoutParams(LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, LocaleController.isRTL ? 10 : 123, 33, LocaleController.isRTL ? 123 : 10, 0));
        detailExTextView.setLayoutParams(LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, LocaleController.isRTL ? 10 : 123, 90, LocaleController.isRTL ? 123 : 10, 0));
        imageView.setVisibility(VISIBLE);
        String filter = String.format(Locale.US, "%d_%d", width, height);
        imageView.getImageReceiver().setImage(ImageLocation.getForWebFile(WebFile.createWithWebDocument(invoice.photo)), filter, null, null, -1, null, invoice, 1);
    } else {
        nameTextView.setLayoutParams(LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, 17, 9, 17, 0));
        detailTextView.setLayoutParams(LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, 17, 33, 17, 0));
        detailExTextView.setLayoutParams(LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, 17, 90, 17, 0));
        imageView.setVisibility(GONE);
    }
}
 
Example #6
Source File: ContextLinkCell.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
private void didPressedButton() {
    if (documentAttachType == DOCUMENT_ATTACH_TYPE_AUDIO || documentAttachType == DOCUMENT_ATTACH_TYPE_MUSIC) {
        if (buttonState == 0) {
            if (MediaController.getInstance().playMessage(currentMessageObject)) {
                buttonState = 1;
                radialProgress.setIcon(getIconForCurrentState(), false, true);
                invalidate();
            }
        } else if (buttonState == 1) {
            boolean result = MediaController.getInstance().pauseMessage(currentMessageObject);
            if (result) {
                buttonState = 0;
                radialProgress.setIcon(getIconForCurrentState(), false, true);
                invalidate();
            }
        } else if (buttonState == 2) {
            radialProgress.setProgress(0, false);
            if (documentAttach != null) {
                FileLoader.getInstance(currentAccount).loadFile(documentAttach, inlineResult, 1, 0);
            } else if (inlineResult.content instanceof TLRPC.TL_webDocument) {
                FileLoader.getInstance(currentAccount).loadFile(WebFile.createWithWebDocument(inlineResult.content), 1, 1);
            }
            buttonState = 4;
            radialProgress.setIcon(getIconForCurrentState(), false, true);
            invalidate();
        } else if (buttonState == 4) {
            if (documentAttach != null) {
                FileLoader.getInstance(currentAccount).cancelLoadFile(documentAttach);
            } else if (inlineResult.content instanceof TLRPC.TL_webDocument) {
                FileLoader.getInstance(currentAccount).cancelLoadFile(WebFile.createWithWebDocument(inlineResult.content));
            }
            buttonState = 2;
            radialProgress.setIcon(getIconForCurrentState(), false, true);
            invalidate();
        }
    }
}