Example usage for com.squareup.okhttp HttpUrl.Builder toString

List of usage examples for com.squareup.okhttp HttpUrl.Builder toString

Introduction

In this page you can find the example usage for com.squareup.okhttp HttpUrl.Builder toString.

Prototype

@Override
    public String toString() 

Source Link

Usage

From source file:com.github.mobile.accounts.LoginActivity.java

License:Apache License

private void openLoginInBrowser(ApiClient client) {
    String initialScope = "user,public_repo,repo,delete_repo,notifications,gist";
    HttpUrl.Builder url = new HttpUrl.Builder().scheme("https").host(OAUTH_HOST).addPathSegment("login")
            .addPathSegment("oauth").addPathSegment("authorize")
            .addQueryParameter("client_id", client.getApiClient()).addQueryParameter("scope", initialScope);

    Intent intent = new Intent(this, LoginWebViewActivity.class);
    intent.putExtra(INTENT_EXTRA_URL, url.toString());
    startActivityForResult(intent, WEBVIEW_REQUEST_CODE);
}

From source file:com.github.pockethub.accounts.LoginActivity.java

License:Apache License

private void openLoginInBrowser(GithubDeveloperCredentialsProvider client) {
    String initialScope = "user,public_repo,repo,delete_repo,notifications,gist";
    HttpUrl.Builder url = new HttpUrl.Builder().scheme("https").host(OAUTH_HOST).addPathSegment("login")
            .addPathSegment("oauth").addPathSegment("authorize")
            .addQueryParameter("client_id", client.getApiClient()).addQueryParameter("scope", initialScope);

    Intent intent = new Intent(this, LoginWebViewActivity.class);
    intent.putExtra(INTENT_EXTRA_URL, url.toString());
    startActivityForResult(intent, WEBVIEW_REQUEST_CODE);
}

From source file:com.github.pockethub.android.accounts.LoginActivity.java

License:Apache License

private void openLoginInBrowser() {
    String initialScope = "user,public_repo,repo,delete_repo,notifications,gist";
    HttpUrl.Builder url = new HttpUrl.Builder().scheme("https").host(OAUTH_HOST).addPathSegment("login")
            .addPathSegment("oauth").addPathSegment("authorize")
            .addQueryParameter("client_id", getString(R.string.github_client))
            .addQueryParameter("scope", initialScope);

    Intent intent = new Intent(this, LoginWebViewActivity.class);
    intent.putExtra(INTENT_EXTRA_URL, url.toString());
    startActivityForResult(intent, WEBVIEW_REQUEST_CODE);
}

From source file:de.schildbach.wallet.ui.WalletActivity.java

License:Open Source License

private void checkAlerts() {
    final PackageInfo packageInfo = getWalletApplication().packageInfo();
    final int versionNameSplit = packageInfo.versionName.indexOf('-');
    final HttpUrl.Builder url = HttpUrl
            .parse(Constants.VERSION_URL
                    + (versionNameSplit >= 0 ? packageInfo.versionName.substring(versionNameSplit) : ""))
            .newBuilder();/*w  w  w. j  a  v  a  2  s  . c o  m*/
    url.addEncodedQueryParameter("package", packageInfo.packageName);
    url.addQueryParameter("current", Integer.toString(packageInfo.versionCode));

    new HttpGetThread(url.build(), application.httpUserAgent()) {
        @Override
        protected void handleLine(final String line, final long serverTime) {
            final int serverVersionCode = Integer.parseInt(line.split("\\s+")[0]);

            log.info("according to \"" + url + "\", strongly recommended minimum app version is "
                    + serverVersionCode);

            if (serverTime > 0) {
                final long diffMinutes = Math
                        .abs((System.currentTimeMillis() - serverTime) / DateUtils.MINUTE_IN_MILLIS);

                if (diffMinutes >= 60) {
                    log.info(
                            "according to \"" + url + "\", system clock is off by " + diffMinutes + " minutes");

                    runOnUiThread(new Runnable() {
                        @Override
                        public void run() {
                            if (!isFinishing())
                                return;
                            final Bundle args = new Bundle();
                            args.putLong("diff_minutes", diffMinutes);
                            showDialog(DIALOG_TIMESKEW_ALERT, args);
                        }
                    });

                    return;
                }
            }

            if (serverVersionCode > packageInfo.versionCode) {
                runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        if (isFinishing())
                            return;
                        showDialog(DIALOG_VERSION_ALERT);
                    }
                });

                return;
            }
        }

        @Override
        protected void handleException(final Exception x) {
            if (x instanceof UnknownHostException || x instanceof SocketException
                    || x instanceof SocketTimeoutException) {
                // swallow
                log.debug("problem reading", x);
            } else {
                CrashReporter.saveBackgroundTrace(new RuntimeException(url.toString(), x), packageInfo);
            }
        }
    }.start();

    if (CrashReporter.hasSavedCrashTrace()) {
        final StringBuilder stackTrace = new StringBuilder();

        try {
            CrashReporter.appendSavedCrashTrace(stackTrace);
        } catch (final IOException x) {
            log.info("problem appending crash info", x);
        }

        final ReportIssueDialogBuilder dialog = new ReportIssueDialogBuilder(this,
                R.string.report_issue_dialog_title_crash, R.string.report_issue_dialog_message_crash) {
            @Override
            protected CharSequence subject() {
                return Constants.REPORT_SUBJECT_CRASH + " " + packageInfo.versionName;
            }

            @Override
            protected CharSequence collectApplicationInfo() throws IOException {
                final StringBuilder applicationInfo = new StringBuilder();
                CrashReporter.appendApplicationInfo(applicationInfo, application);
                return applicationInfo;
            }

            @Override
            protected CharSequence collectStackTrace() throws IOException {
                if (stackTrace.length() > 0)
                    return stackTrace;
                else
                    return null;
            }

            @Override
            protected CharSequence collectDeviceInfo() throws IOException {
                final StringBuilder deviceInfo = new StringBuilder();
                CrashReporter.appendDeviceInfo(deviceInfo, WalletActivity.this);
                return deviceInfo;
            }

            @Override
            protected CharSequence collectWalletDump() {
                return wallet.toString(false, true, true, null);
            }
        };

        dialog.show();
    }
}