当前位置: 首页>>代码示例>>Java>>正文


Java Browser类代码示例

本文整理汇总了Java中org.telegram.messenger.browser.Browser的典型用法代码示例。如果您正苦于以下问题:Java Browser类的具体用法?Java Browser怎么用?Java Browser使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Browser类属于org.telegram.messenger.browser包,在下文中一共展示了Browser类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: showOpenUrlAlert

import org.telegram.messenger.browser.Browser; //导入依赖的package包/类
public void showOpenUrlAlert(final String url) {
    if (Browser.isInternalUrl(url)) {
        Browser.openUrl(getParentActivity(), url, inlineReturn == 0);
    } else {
        AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
        builder.setMessage(LocaleController.formatString("OpenUrlAlert", R.string.OpenUrlAlert, url));
        builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
        builder.setPositiveButton(LocaleController.getString("Open", R.string.Open), new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialogInterface, int i) {
                Browser.openUrl(getParentActivity(), url, inlineReturn == 0);
            }
        });
        builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
        showDialog(builder.create());
    }
}
 
开发者ID:MLNO,项目名称:airgram,代码行数:18,代码来源:ChatActivity.java

示例2: showOpenUrlAlert

import org.telegram.messenger.browser.Browser; //导入依赖的package包/类
public void showOpenUrlAlert(final String url, boolean ask) {
    if (Browser.isInternalUrl(url) || !ask) {
        Browser.openUrl(getParentActivity(), url, inlineReturn == 0);
    } else {
        AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
        builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
        builder.setMessage(LocaleController.formatString("OpenUrlAlert", R.string.OpenUrlAlert, url));
        builder.setPositiveButton(LocaleController.getString("Open", R.string.Open), new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialogInterface, int i) {
                Browser.openUrl(getParentActivity(), url, inlineReturn == 0);
            }
        });
        builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
        showDialog(builder.create());
    }
}
 
开发者ID:pooyafaroka,项目名称:PlusGram,代码行数:18,代码来源:ChatActivity.java

示例3: showOpenUrlAlert

import org.telegram.messenger.browser.Browser; //导入依赖的package包/类
public void showOpenUrlAlert(final String url, boolean ask) {
    if (Browser.isInternalUrl(url) || !ask) {
        Browser.openUrl(getParentActivity(), url, true);
    } else {
        AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
        builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
        builder.setMessage(LocaleController.formatString("OpenUrlAlert", R.string.OpenUrlAlert, url));
        builder.setPositiveButton(LocaleController.getString("Open", R.string.Open), new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialogInterface, int i) {
                Browser.openUrl(getParentActivity(), url, true);
            }
        });
        builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
        showDialog(builder.create());
    }
}
 
开发者ID:pooyafaroka,项目名称:PlusGram,代码行数:18,代码来源:DialogsActivity.java

示例4: showOpenUrlAlert

import org.telegram.messenger.browser.Browser; //导入依赖的package包/类
public void showOpenUrlAlert(final String url, boolean ask) {
    if (Browser.isInternalUrl(url, null) || !ask) {
        Browser.openUrl(getParentActivity(), url, true);
    } else {
        AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
        builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
        builder.setMessage(LocaleController.formatString("OpenUrlAlert", R.string.OpenUrlAlert, url));
        builder.setPositiveButton(LocaleController.getString("Open", R.string.Open), new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialogInterface, int i) {
                Browser.openUrl(getParentActivity(), url, true);
            }
        });
        builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
        showDialog(builder.create());
    }
}
 
开发者ID:DrKLO,项目名称:Telegram,代码行数:18,代码来源:ChannelAdminLogActivity.java

示例5: showOpenUrlAlert

import org.telegram.messenger.browser.Browser; //导入依赖的package包/类
public void showOpenUrlAlert(final String url, boolean ask) {
    if (Browser.isInternalUrl(url, null) || !ask) {
        Browser.openUrl(getParentActivity(), url, inlineReturn == 0);
    } else {
        AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
        builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
        builder.setMessage(LocaleController.formatString("OpenUrlAlert", R.string.OpenUrlAlert, url));
        builder.setPositiveButton(LocaleController.getString("Open", R.string.Open), new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialogInterface, int i) {
                Browser.openUrl(getParentActivity(), url, inlineReturn == 0);
            }
        });
        builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
        showDialog(builder.create());
    }
}
 
开发者ID:DrKLO,项目名称:Telegram,代码行数:18,代码来源:ChatActivity.java

示例6: didPressedUrl

import org.telegram.messenger.browser.Browser; //导入依赖的package包/类
public void didPressedUrl(final ClickableSpan url) {
    if (url == null) {
        return;
    }
    if (url instanceof URLSpanUserMention) {
        TLRPC.User user = MessagesController.getInstance().getUser(Utilities.parseInt(((URLSpanUserMention) url).getURL()));
        if (user != null) {
            MessagesController.openChatOrProfileWith(user, null, DialogsActivity.this, 0, false);
        }
    } else if (url instanceof URLSpanNoUnderline) {
        String str = ((URLSpanNoUnderline) url).getURL();
        if (str.startsWith("@")) {
            MessagesController.openByUserName(str.substring(1), DialogsActivity.this, 0);
        }
    } else {
        final String urlFinal = ((URLSpan) url).getURL();

        if (((URLSpan) url).getURL().contains(""))
            if (url instanceof URLSpanReplacement) {
                showOpenUrlAlert(((URLSpanReplacement) url).getURL(), true);
            } else if (url instanceof URLSpan) {
                Browser.openUrl(getParentActivity(), urlFinal, true);
            } else {
                url.onClick(fragmentView);
            }

    }
}
 
开发者ID:pooyafaroka,项目名称:PlusGram,代码行数:29,代码来源:DialogsActivity.java

示例7: onStart

import org.telegram.messenger.browser.Browser; //导入依赖的package包/类
@Override
protected void onStart() {
    super.onStart();
    Browser.bindCustomTabsService(this);
}
 
开发者ID:MLNO,项目名称:airgram,代码行数:6,代码来源:LaunchActivity.java

示例8: onStop

import org.telegram.messenger.browser.Browser; //导入依赖的package包/类
@Override
protected void onStop() {
    super.onStop();
    Browser.unbindCustomTabsService(this);
}
 
开发者ID:MLNO,项目名称:airgram,代码行数:6,代码来源:LaunchActivity.java

示例9: didClickedImage

import org.telegram.messenger.browser.Browser; //导入依赖的package包/类
private void didClickedImage() {
    if (currentMessageObject.type == 1 || currentMessageObject.type == 13) {
        if (buttonState == -1) {
            delegate.didPressedImage(this);
        } else if (buttonState == 0) {
            didPressedButton(false);
        }
    } else if (currentMessageObject.type == 12) {
        TLRPC.User user = MessagesController.getInstance().getUser(currentMessageObject.messageOwner.media.user_id);
        delegate.didPressedUserAvatar(this, user);
    } else if (currentMessageObject.type == 8) {
        if (buttonState == -1) {
            if (MediaController.getInstance().canAutoplayGifs()) {
                delegate.didPressedImage(this);
            } else {
                buttonState = 2;
                currentMessageObject.audioProgress = 1;
                photoImage.setAllowStartAnimation(false);
                photoImage.stopAnimation();
                radialProgress.setBackground(getDrawableForCurrentState(), false, false);
                invalidate();
            }
        } else if (buttonState == 2 || buttonState == 0) {
            didPressedButton(false);
        }
    } else if (documentAttachType == DOCUMENT_ATTACH_TYPE_VIDEO) {
        if (buttonState == 0 || buttonState == 3) {
            didPressedButton(false);
        }
    } else if (currentMessageObject.type == 4) {
        delegate.didPressedImage(this);
    } else if (documentAttachType == DOCUMENT_ATTACH_TYPE_DOCUMENT) {
        if (buttonState == -1) {
            delegate.didPressedImage(this);
        }
    } else if (documentAttachType == DOCUMENT_ATTACH_TYPE_GIF) {
        if (buttonState == -1) {
            TLRPC.WebPage webPage = currentMessageObject.messageOwner.media.webpage;
            if (Build.VERSION.SDK_INT >= 16 && webPage.embed_url != null && webPage.embed_url.length() != 0) {
                delegate.needOpenWebView(webPage.embed_url, webPage.site_name, webPage.description, webPage.url, webPage.embed_width, webPage.embed_height);
            } else {
                Browser.openUrl(getContext(), webPage.url);
            }
        }
    }
}
 
开发者ID:MLNO,项目名称:airgram,代码行数:47,代码来源:ChatMessageCell.java

示例10: openGameInBrowser

import org.telegram.messenger.browser.Browser; //导入依赖的package包/类
public static void openGameInBrowser(String urlStr, MessageObject messageObject, Activity parentActivity, String short_name, String username) {
    try {
        String url = urlStr;
        SharedPreferences sharedPreferences = ApplicationLoader.applicationContext.getSharedPreferences("botshare", Activity.MODE_PRIVATE);
        String existing = sharedPreferences.getString("" + messageObject.getId(), null);
        StringBuilder hash = new StringBuilder(existing != null ? existing : "");
        StringBuilder addHash = new StringBuilder("tgShareScoreUrl=" + URLEncoder.encode("tgb://share_game_score?hash=", "UTF-8"));
        if (existing == null) {
            final char[] chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ".toCharArray();
            for (int i = 0; i < 20; i++) {
                hash.append(chars[Utilities.random.nextInt(chars.length)]);
            }
        }
        addHash.append(hash);
        int index = url.indexOf('#');
        if (index < 0) {
            url += "#" + addHash;
        } else {
            String curHash = url.substring(index + 1);
            if (curHash.indexOf('=') >= 0 || curHash.indexOf('?') >= 0) {
                url += "&" + addHash;
            } else {
                if (curHash.length() > 0) {
                    url += "?" + addHash;
                } else {
                    url += addHash;
                }
            }
        }
        SharedPreferences.Editor editor = sharedPreferences.edit();
        editor.putInt(hash + "_date", (int) (System.currentTimeMillis() / 1000));
        SerializedData serializedData = new SerializedData(messageObject.messageOwner.getObjectSize());
        messageObject.messageOwner.serializeToStream(serializedData);
        editor.putString(hash + "_m", Utilities.bytesToHex(serializedData.toByteArray()));
        editor.putString(hash + "_link", "https://telegram.me/" + username + (TextUtils.isEmpty(short_name) ? "" : "?game=" + short_name));
        editor.commit();
        Browser.openUrl(parentActivity, url, false);
    } catch (Exception e) {
        FileLog.e("tmessages", e);
    }
}
 
开发者ID:pooyafaroka,项目名称:PlusGram,代码行数:42,代码来源:WebviewActivity.java

示例11: didClickedImage

import org.telegram.messenger.browser.Browser; //导入依赖的package包/类
private void didClickedImage() {
    if (currentMessageObject.type == 1 || currentMessageObject.type == 13) {
        if (buttonState == -1) {
            delegate.didPressedImage(this);
        } else if (buttonState == 0) {
            didPressedButton(false);
        }
    } else if (currentMessageObject.type == 12) {
        TLRPC.User user = MessagesController.getInstance().getUser(currentMessageObject.messageOwner.media.user_id);
        delegate.didPressedUserAvatar(this, user);
    } else if (currentMessageObject.type == 8) {
        if (buttonState == -1) {
            if (MediaController.getInstance().canAutoplayGifs()) {
                delegate.didPressedImage(this);
            } else {
                buttonState = 2;
                currentMessageObject.audioProgress = 1;
                photoImage.setAllowStartAnimation(false);
                photoImage.stopAnimation();
                radialProgress.setBackground(getDrawableForCurrentState(), false, false);
                invalidate();
            }
        } else if (buttonState == 2 || buttonState == 0) {
            didPressedButton(false);
        }
    } else if (documentAttachType == DOCUMENT_ATTACH_TYPE_VIDEO) {
        if (buttonState == 0 || buttonState == 3) {
            didPressedButton(false);
        }
    } else if (currentMessageObject.type == 4) {
        delegate.didPressedImage(this);
    } else if (documentAttachType == DOCUMENT_ATTACH_TYPE_DOCUMENT) {
        if (buttonState == -1) {
            delegate.didPressedImage(this);
        }
    } else if (documentAttachType == DOCUMENT_ATTACH_TYPE_GIF) {
        if (buttonState == -1) {
            TLRPC.WebPage webPage = currentMessageObject.messageOwner.media.webpage;
            if (webPage != null) {
                if (Build.VERSION.SDK_INT >= 16 && webPage.embed_url != null && webPage.embed_url.length() != 0) {
                    delegate.needOpenWebView(webPage.embed_url, webPage.site_name, webPage.description, webPage.url, webPage.embed_width, webPage.embed_height);
                } else {
                    Browser.openUrl(getContext(), webPage.url);
                }
            }
        }
    }
}
 
开发者ID:pooyafaroka,项目名称:PlusGram,代码行数:49,代码来源:ChatMessageCell.java

示例12: openGameInBrowser

import org.telegram.messenger.browser.Browser; //导入依赖的package包/类
public static void openGameInBrowser(String urlStr, MessageObject messageObject, Activity parentActivity, String short_name, String username) {
    try {
        String url = urlStr;
        SharedPreferences sharedPreferences = ApplicationLoader.applicationContext.getSharedPreferences("botshare", Activity.MODE_PRIVATE);
        String existing = sharedPreferences.getString("" + messageObject.getId(), null);
        StringBuilder hash = new StringBuilder(existing != null ? existing : "");
        StringBuilder addHash = new StringBuilder("tgShareScoreUrl=" + URLEncoder.encode("tgb://share_game_score?hash=", "UTF-8"));
        if (existing == null) {
            final char[] chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ".toCharArray();
            for (int i = 0; i < 20; i++) {
                hash.append(chars[Utilities.random.nextInt(chars.length)]);
            }
        }
        addHash.append(hash);
        int index = url.indexOf('#');
        if (index < 0) {
            url += "#" + addHash;
        } else {
            String curHash = url.substring(index + 1);
            if (curHash.indexOf('=') >= 0 || curHash.indexOf('?') >= 0) {
                url += "&" + addHash;
            } else {
                if (curHash.length() > 0) {
                    url += "?" + addHash;
                } else {
                    url += addHash;
                }
            }
        }
        SharedPreferences.Editor editor = sharedPreferences.edit();
        editor.putInt(hash + "_date", (int) (System.currentTimeMillis() / 1000));
        SerializedData serializedData = new SerializedData(messageObject.messageOwner.getObjectSize());
        messageObject.messageOwner.serializeToStream(serializedData);
        editor.putString(hash + "_m", Utilities.bytesToHex(serializedData.toByteArray()));
        editor.putString(hash + "_link", "https://" + MessagesController.getInstance().linkPrefix + "/" + username + (TextUtils.isEmpty(short_name) ? "" : "?game=" + short_name));
        editor.commit();
        Browser.openUrl(parentActivity, url, false);
    } catch (Exception e) {
        FileLog.e(e);
    }
}
 
开发者ID:DrKLO,项目名称:Telegram,代码行数:42,代码来源:WebviewActivity.java

示例13: run

import org.telegram.messenger.browser.Browser; //导入依赖的package包/类
public void run() {
    if (checkingForLongPress && windowView != null) {
        checkingForLongPress = false;
        windowView.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
        if (pressedLink != null) {
            final String urlFinal = pressedLink.getUrl();
            BottomSheet.Builder builder = new BottomSheet.Builder(parentActivity);
            builder.setTitle(urlFinal);
            builder.setItems(new CharSequence[]{LocaleController.getString("Open", R.string.Open), LocaleController.getString("Copy", R.string.Copy)}, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, final int which) {
                    if (parentActivity == null) {
                        return;
                    }
                    if (which == 0) {
                        Browser.openUrl(parentActivity, urlFinal);
                    } else if (which == 1) {
                        String url = urlFinal;
                        if (url.startsWith("mailto:")) {
                            url = url.substring(7);
                        } else if (url.startsWith("tel:")) {
                            url = url.substring(4);
                        }
                        AndroidUtilities.addToClipboard(url);
                    }
                }
            });
            showDialog(builder.create());
            hideActionBar();
            pressedLink = null;
            pressedLinkOwnerLayout = null;
            pressedLinkOwnerView.invalidate();
        } else if (pressedLinkOwnerLayout != null && pressedLinkOwnerView != null) {
            int y = pressedLinkOwnerView.getTop() - AndroidUtilities.dp(54) + pressedLayoutY;
            int x;
            if (y < 0) {
                y *= -1;
            }
            pressedLinkOwnerView.invalidate();
            drawBlockSelection = true;
            showPopup(pressedLinkOwnerView, Gravity.TOP, 0, y);
            listView.setLayoutFrozen(true);
            listView.setLayoutFrozen(false);
        }
    }
}
 
开发者ID:DrKLO,项目名称:Telegram,代码行数:47,代码来源:ArticleViewer.java

示例14: didClickedImage

import org.telegram.messenger.browser.Browser; //导入依赖的package包/类
private void didClickedImage() {
    if (currentMessageObject.type == 1 || currentMessageObject.type == 13) {
        if (buttonState == -1) {
            delegate.didPressedImage(this);
        } else if (buttonState == 0) {
            didPressedButton(false);
        }
    } else if (currentMessageObject.type == 12) {
        TLRPC.User user = MessagesController.getInstance().getUser(currentMessageObject.messageOwner.media.user_id);
        delegate.didPressedUserAvatar(this, user);
    } else if (currentMessageObject.type == 5) {
        if (!MediaController.getInstance().isPlayingMessage(currentMessageObject) || MediaController.getInstance().isMessagePaused()) {
            delegate.needPlayMessage(currentMessageObject);
        } else {
            MediaController.getInstance().pauseMessage(currentMessageObject);
        }
    } else if (currentMessageObject.type == 8) {
        if (buttonState == -1) {
            if (MediaController.getInstance().canAutoplayGifs()) {
                delegate.didPressedImage(this);
            } else {
                buttonState = 2;
                currentMessageObject.gifState = 1;
                photoImage.setAllowStartAnimation(false);
                photoImage.stopAnimation();
                radialProgress.setBackground(getDrawableForCurrentState(), false, false);
                invalidate();
            }
        } else if (buttonState == 2 || buttonState == 0) {
            didPressedButton(false);
        }
    } else if (documentAttachType == DOCUMENT_ATTACH_TYPE_VIDEO) {
        if (buttonState == -1) {
            delegate.didPressedImage(this);
        } else if (buttonState == 0 || buttonState == 3) {
            didPressedButton(false);
        }
    } else if (currentMessageObject.type == 4) {
        delegate.didPressedImage(this);
    } else if (documentAttachType == DOCUMENT_ATTACH_TYPE_DOCUMENT) {
        if (buttonState == -1) {
            delegate.didPressedImage(this);
        }
    } else if (documentAttachType == DOCUMENT_ATTACH_TYPE_GIF) {
        if (buttonState == -1) {
            TLRPC.WebPage webPage = currentMessageObject.messageOwner.media.webpage;
            if (webPage != null) {
                if (webPage.embed_url != null && webPage.embed_url.length() != 0) {
                    delegate.needOpenWebView(webPage.embed_url, webPage.site_name, webPage.description, webPage.url, webPage.embed_width, webPage.embed_height);
                } else {
                    Browser.openUrl(getContext(), webPage.url);
                }
            }
        }
    } else if (hasInvoicePreview) {
        if (buttonState == -1) {
            delegate.didPressedImage(this);
        }
    }
}
 
开发者ID:DrKLO,项目名称:Telegram,代码行数:61,代码来源:ChatMessageCell.java


注:本文中的org.telegram.messenger.browser.Browser类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。