當前位置: 首頁>>代碼示例>>Java>>正文


Java Browser.openUrl方法代碼示例

本文整理匯總了Java中org.telegram.messenger.browser.Browser.openUrl方法的典型用法代碼示例。如果您正苦於以下問題:Java Browser.openUrl方法的具體用法?Java Browser.openUrl怎麽用?Java Browser.openUrl使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.telegram.messenger.browser.Browser的用法示例。


在下文中一共展示了Browser.openUrl方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: 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

示例8: 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

示例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 (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

示例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://" + 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

示例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 == 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.openUrl方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。