com.sina.weibo.sdk.utils.NetworkHelper Java Examples

The following examples show how to use com.sina.weibo.sdk.utils.NetworkHelper. 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: WeiboDialog.java    From MiBandDecompiled with Apache License 2.0 6 votes vote down vote up
private void initWebView()
{
    mWebViewContainer = new RelativeLayout(getContext());
    mWebView = new WebView(getContext());
    mWebView.getSettings().setJavaScriptEnabled(true);
    mWebView.getSettings().setSavePassword(false);
    mWebView.setWebViewClient(new WeiboWebViewClient(null));
    mWebView.requestFocus();
    mWebView.setScrollBarStyle(0);
    mWebView.setVisibility(4);
    NetworkHelper.clearCookies(mContext, mAuthUrl);
    mWebView.loadUrl(mAuthUrl);
    android.widget.RelativeLayout.LayoutParams layoutparams = new android.widget.RelativeLayout.LayoutParams(-1, -1);
    android.widget.RelativeLayout.LayoutParams layoutparams1 = new android.widget.RelativeLayout.LayoutParams(-1, -1);
    DisplayMetrics displaymetrics = getContext().getResources().getDisplayMetrics();
    int i = (int)(10F * displaymetrics.density);
    layoutparams1.setMargins(i, i, i, i);
    Drawable drawable = ResourceManager.getNinePatchDrawable(mContext, 1);
    mWebViewContainer.setBackgroundDrawable(drawable);
    mWebViewContainer.addView(mWebView, layoutparams1);
    mWebViewContainer.setGravity(17);
    int j = 1 + ResourceManager.getDrawable(mContext, 2).getIntrinsicWidth() / 2;
    layoutparams.setMargins(j, (int)(25F * displaymetrics.density), j, j);
    mRootContainer.addView(mWebViewContainer, layoutparams);
}
 
Example #2
Source File: WeiboAuth.java    From MiBandDecompiled with Apache License 2.0 5 votes vote down vote up
private void startDialog(WeiboAuthListener weiboauthlistener, int i)
{
    if (weiboauthlistener == null)
    {
        return;
    }
    LinkedHashMap linkedhashmap = new LinkedHashMap();
    linkedhashmap.put("client_id", mAuthInfo.mAppKey);
    linkedhashmap.put("redirect_uri", mAuthInfo.mRedirectUrl);
    linkedhashmap.put("scope", mAuthInfo.mScope);
    linkedhashmap.put("response_type", "code");
    linkedhashmap.put("display", "mobile");
    if (1 == i)
    {
        linkedhashmap.put("packagename", mAuthInfo.mPackageName);
        linkedhashmap.put("key_hash", mAuthInfo.mKeyHash);
    }
    String s = (new StringBuilder("https://open.weibo.cn/oauth2/authorize?")).append(Utility.packUrl(linkedhashmap)).toString();
    if (!NetworkHelper.hasInternetPermission(mContext))
    {
        UIUtils.showAlert(mContext, "Error", "Application requires permission to access the Internet");
        return;
    }
    if (NetworkHelper.isNetworkAvailable(mContext))
    {
        (new WeiboDialog(mContext, s, weiboauthlistener, this)).show();
        return;
    } else
    {
        String s1 = ResourceManager.getString(mContext, 2);
        LogUtil.i("Weibo_web_login", (new StringBuilder("String: ")).append(s1).toString());
        UIUtils.showToast(mContext, s1, 0);
        return;
    }
}
 
Example #3
Source File: WeiboSdkBrowser.java    From letv with Apache License 2.0 4 votes vote down vote up
protected void onDestroy() {
    NetworkHelper.clearCookies(this);
    super.onDestroy();
}
 
Example #4
Source File: BaseHandler.java    From LoginSharePay with Apache License 2.0 4 votes vote down vote up
protected void startWebAuth() {
    AuthInfo authInfo = WbSdk.getAuthInfo();
    WeiboParameters requestParams = new WeiboParameters(authInfo.getAppKey());
    requestParams.put("client_id", authInfo.getAppKey());
    requestParams.put("redirect_uri", authInfo.getRedirectUrl());
    requestParams.put("scope", authInfo.getScope());
    requestParams.put("response_type", "code");
    requestParams.put("version", "0041005000");
    requestParams.put("luicode", "10000360");
    Oauth2AccessToken token = AccessTokenKeeper.readAccessToken(this.mAuthFragment.getContext());
    if (token != null && !TextUtils.isEmpty(token.getToken())) {
        requestParams.put("trans_token", token.getToken());
        requestParams.put("trans_access_token", token.getToken());
    }

    requestParams.put("lfid", "OP_" + authInfo.getAppKey());
    String aid = Utility.getAid(this.mAuthFragment.getContext(), authInfo.getAppKey());
    if (!TextUtils.isEmpty(aid)) {
        requestParams.put("aid", aid);
    }

    requestParams.put("packagename", authInfo.getPackageName());
    requestParams.put("key_hash", authInfo.getKeyHash());
    String url = "https://open.weibo.cn/oauth2/authorize?" + requestParams.encodeUrl();
    if (!NetworkHelper.hasInternetPermission(this.mAuthFragment.getContext())) {
        UIUtils.showAlert(this.mAuthFragment.getContext(), "Error", "Application requires permission to access the Internet");
    } else {
        String mAuthListenerKey = null;
        if (this.authListener != null) {
            WeiboCallbackManager manager = WeiboCallbackManager.getInstance();
            mAuthListenerKey = manager.genCallbackKey();
            manager.setWeiboAuthListener(mAuthListenerKey, this.authListener);
        }

        AuthWebViewRequestParam param = new AuthWebViewRequestParam(authInfo, WebRequestType.AUTH, mAuthListenerKey, "微博登录", url, this.mAuthFragment.getContext());
        Intent intent = new Intent(this.mAuthFragment.getContext(), WeiboSdkWebActivity.class);
        Bundle bundle = new Bundle();
        param.fillBundle(bundle);
        intent.putExtras(bundle);
        this.mAuthFragment.startActivity(intent);
    }

}