Java Code Examples for com.tencent.tauth.IUiListener#onError()

The following examples show how to use com.tencent.tauth.IUiListener#onError() . 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: AssistActivity.java    From letv with Apache License 2.0 5 votes vote down vote up
private void openBrowser(Bundle bundle) {
    String string = bundle.getString("viaShareType");
    String string2 = bundle.getString("callbackAction");
    String string3 = bundle.getString("url");
    String string4 = bundle.getString("openId");
    String string5 = bundle.getString("appId");
    String str = "";
    String str2 = "";
    if (SystemUtils.QQ_SHARE_CALLBACK_ACTION.equals(string2)) {
        str = Constants.VIA_SHARE_TO_QQ;
        str2 = "10";
    } else if (SystemUtils.QZONE_SHARE_CALLBACK_ACTION.equals(string2)) {
        str = Constants.VIA_SHARE_TO_QZONE;
        str2 = "11";
    }
    if (Util.openBrowser(this, string3)) {
        d.a().a(string4, string5, str, str2, "3", "0", string, "0", "2", "0");
    } else {
        IUiListener iUiListener = (IUiListener) TemporaryStorage.get(string2);
        if (iUiListener != null) {
            iUiListener.onError(new UiError(-6, Constants.MSG_OPEN_BROWSER_ERROR, null));
        }
        d.a().a(string4, string5, str, str2, "3", "1", string, "0", "2", "0");
        finish();
    }
    getIntent().removeExtra("shareH5");
}
 
Example 2
Source File: WPA.java    From letv with Apache License 2.0 5 votes vote down vote up
public void getWPAUserOnlineState(String str, IUiListener iUiListener) {
    if (str == null) {
        try {
            d.a().a(this.mToken.getOpenId(), this.mToken.getAppId(), Constants.VIA_WAP_STATE, "15", "18", "1");
            throw new Exception("uin null");
        } catch (Exception e) {
            if (iUiListener != null) {
                iUiListener.onError(new UiError(-5, Constants.MSG_PARAM_ERROR, null));
            }
            d.a().a(this.mToken.getOpenId(), this.mToken.getAppId(), Constants.VIA_WAP_STATE, "15", "18", "1");
        }
    } else if (str.length() < 5) {
        d.a().a(this.mToken.getOpenId(), this.mToken.getAppId(), Constants.VIA_WAP_STATE, "15", "18", "1");
        throw new Exception("uin length < 5");
    } else {
        int i = 0;
        while (i < str.length()) {
            if (Character.isDigit(str.charAt(i))) {
                i++;
            } else {
                d.a().a(this.mToken.getOpenId(), this.mToken.getAppId(), Constants.VIA_WAP_STATE, "15", "18", "1");
                throw new Exception("uin not digit");
            }
        }
        Bundle bundle = null;
        HttpUtils.requestAsync(this.mToken, Global.getContext(), "http://webpresence.qq.com/getonline?Type=1&" + str + NetworkUtils.DELIMITER_COLON, bundle, "GET", new TempRequestListener(iUiListener));
        d.a().a(this.mToken.getOpenId(), this.mToken.getAppId(), Constants.VIA_WAP_STATE, "15", "18", "0");
    }
}
 
Example 3
Source File: RecordManager.java    From letv with Apache License 2.0 5 votes vote down vote up
public void deleteRecord(String str, final IUiListener iUiListener) {
    Bundle composeCGIParams = composeCGIParams();
    IRequestListener tempRequestListener = new TempRequestListener(new IUiListener(this) {
        final /* synthetic */ RecordManager b;

        public void onError(UiError uiError) {
            iUiListener.onError(uiError);
        }

        public void onComplete(Object obj) {
            JSONObject jSONObject = (JSONObject) obj;
            try {
                if (jSONObject.getInt("ret") == 0) {
                    iUiListener.onComplete("");
                } else {
                    iUiListener.onError(new UiError(-4, jSONObject.toString(), null));
                }
            } catch (JSONException e) {
                iUiListener.onError(new UiError(-4, e.getMessage(), null));
            }
        }

        public void onCancel() {
            iUiListener.onCancel();
        }
    });
    composeCGIParams.putString("key", Util.toHexString(str));
    HttpUtils.requestAsync(this.mToken, Global.getContext(), "https://graph.qq.com/weiyun/delete_record", composeCGIParams, "GET", tempRequestListener);
}
 
Example 4
Source File: RecordManager.java    From letv with Apache License 2.0 5 votes vote down vote up
public void getRecord(String str, final IUiListener iUiListener) {
    Bundle composeCGIParams = composeCGIParams();
    IRequestListener tempRequestListener = new TempRequestListener(new IUiListener(this) {
        final /* synthetic */ RecordManager b;

        public void onError(UiError uiError) {
            iUiListener.onError(uiError);
        }

        public void onComplete(Object obj) {
            JSONObject jSONObject = (JSONObject) obj;
            try {
                if (jSONObject.getInt("ret") == 0) {
                    iUiListener.onComplete(Util.hexToString(jSONObject.getJSONObject(ShareRequestParam.RESP_UPLOAD_PIC_PARAM_DATA).getString(Constants.VALUE_ID)));
                    return;
                }
                iUiListener.onError(new UiError(-4, jSONObject.toString(), null));
            } catch (JSONException e) {
                iUiListener.onError(new UiError(-4, e.getMessage(), null));
            }
        }

        public void onCancel() {
            iUiListener.onCancel();
        }
    });
    composeCGIParams.putString("key", Util.toHexString(str));
    HttpUtils.requestAsync(this.mToken, Global.getContext(), "https://graph.qq.com/weiyun/get_record", composeCGIParams, "GET", tempRequestListener);
}
 
Example 5
Source File: RecordManager.java    From letv with Apache License 2.0 5 votes vote down vote up
public void checkRecord(String str, final IUiListener iUiListener) {
    Bundle composeCGIParams = composeCGIParams();
    IRequestListener tempRequestListener = new TempRequestListener(new IUiListener(this) {
        final /* synthetic */ RecordManager b;

        public void onError(UiError uiError) {
            iUiListener.onError(uiError);
        }

        public void onComplete(Object obj) {
            try {
                if (((JSONObject) obj).getInt("ret") == 0) {
                    iUiListener.onComplete(Boolean.TRUE);
                } else {
                    iUiListener.onComplete(Boolean.FALSE);
                }
            } catch (JSONException e) {
                iUiListener.onError(new UiError(-4, e.getMessage(), null));
            }
        }

        public void onCancel() {
            iUiListener.onCancel();
        }
    });
    composeCGIParams.putString("key", Util.toHexString(str));
    HttpUtils.requestAsync(this.mToken, Global.getContext(), "https://graph.qq.com/weiyun/check_record", composeCGIParams, "GET", tempRequestListener);
}
 
Example 6
Source File: QQShare.java    From letv with Apache License 2.0 4 votes vote down vote up
public void shareToQQ(Activity activity, Bundle bundle, IUiListener iUiListener) {
    f.c(a, "shareToQQ() -- start.");
    String string = bundle.getString("imageUrl");
    String string2 = bundle.getString("title");
    String string3 = bundle.getString("summary");
    String string4 = bundle.getString("targetUrl");
    String string5 = bundle.getString("imageLocalUrl");
    int i = bundle.getInt("req_type", 1);
    f.c(a, "shareToQQ -- type: " + i);
    switch (i) {
        case 1:
            this.mViaShareQQType = "1";
            break;
        case 2:
            this.mViaShareQQType = "3";
            break;
        case 5:
            this.mViaShareQQType = "2";
            break;
        case 6:
            this.mViaShareQQType = "4";
            break;
    }
    if (i == 6) {
        if (SystemUtils.compareQQVersion(activity, SystemUtils.QQ_VERSION_NAME_5_0_0) < 0) {
            iUiListener.onError(new UiError(-15, Constants.MSG_PARAM_APPSHARE_TOO_LOW, null));
            f.e(a, "shareToQQ, app share is not support below qq5.0.");
            d.a().a(1, "SHARE_CHECK_SDK", Constants.DEFAULT_UIN, this.mToken.getAppId(), String.valueOf(0), Long.valueOf(SystemClock.elapsedRealtime()), 0, 1, "shareToQQ, app share is not support below qq5.0.");
            return;
        }
        string4 = String.format(ServerSetting.APP_DETAIL_PAGE, new Object[]{this.mToken.getAppId(), "mqq"});
        bundle.putString("targetUrl", string4);
    }
    if (Util.hasSDCard() || SystemUtils.compareQQVersion(activity, SystemUtils.QQ_VERSION_NAME_4_5_0) >= 0) {
        if (i == 5) {
            if (SystemUtils.compareQQVersion(activity, SystemUtils.QQ_VERSION_NAME_4_3_0) < 0) {
                iUiListener.onError(new UiError(-6, Constants.MSG_PARAM_QQ_VERSION_ERROR, null));
                f.e(a, "shareToQQ, version below 4.3 is not support.");
                d.a().a(1, "SHARE_CHECK_SDK", Constants.DEFAULT_UIN, this.mToken.getAppId(), String.valueOf(0), Long.valueOf(SystemClock.elapsedRealtime()), 0, 1, "shareToQQ, version below 4.3 is not support.");
                return;
            } else if (!Util.fileExists(string5)) {
                iUiListener.onError(new UiError(-6, Constants.MSG_PARAM_IMAGE_URL_FORMAT_ERROR, null));
                f.e(a, "shareToQQ -- error: 非法的图片地址!");
                d.a().a(1, "SHARE_CHECK_SDK", Constants.DEFAULT_UIN, this.mToken.getAppId(), String.valueOf(0), Long.valueOf(SystemClock.elapsedRealtime()), 0, 1, Constants.MSG_PARAM_IMAGE_URL_FORMAT_ERROR);
                return;
            }
        }
        if (i != 5) {
            if (TextUtils.isEmpty(string4) || !(string4.startsWith("http://") || string4.startsWith("https://"))) {
                iUiListener.onError(new UiError(-6, Constants.MSG_PARAM_ERROR, null));
                f.e(a, "shareToQQ, targetUrl is empty or illegal..");
                d.a().a(1, "SHARE_CHECK_SDK", Constants.DEFAULT_UIN, this.mToken.getAppId(), String.valueOf(0), Long.valueOf(SystemClock.elapsedRealtime()), 0, 1, "shareToQQ, targetUrl is empty or illegal..");
                return;
            } else if (TextUtils.isEmpty(string2)) {
                iUiListener.onError(new UiError(-6, Constants.MSG_PARAM_TITLE_NULL_ERROR, null));
                f.e(a, "shareToQQ, title is empty.");
                d.a().a(1, "SHARE_CHECK_SDK", Constants.DEFAULT_UIN, this.mToken.getAppId(), String.valueOf(0), Long.valueOf(SystemClock.elapsedRealtime()), 0, 1, "shareToQQ, title is empty.");
                return;
            }
        }
        if (TextUtils.isEmpty(string) || string.startsWith("http://") || string.startsWith("https://") || new File(string).exists()) {
            if (!TextUtils.isEmpty(string2) && string2.length() > 45) {
                bundle.putString("title", Util.subString(string2, 45, null, null));
            }
            if (!TextUtils.isEmpty(string3) && string3.length() > 60) {
                bundle.putString("summary", Util.subString(string3, 60, null, null));
            }
            if (Util.isMobileQQSupportShare(activity)) {
                a(activity, bundle, iUiListener);
            } else {
                c(activity, bundle, iUiListener);
            }
            f.c(a, "shareToQQ() -- end.");
            return;
        }
        iUiListener.onError(new UiError(-6, Constants.MSG_PARAM_IMAGE_URL_FORMAT_ERROR, null));
        f.e(a, " shareToQQ, image url is emprty or illegal.");
        d.a().a(1, "SHARE_CHECK_SDK", Constants.DEFAULT_UIN, this.mToken.getAppId(), String.valueOf(0), Long.valueOf(SystemClock.elapsedRealtime()), 0, 1, "shareToQQ, image url is emprty or illegal.");
        return;
    }
    iUiListener.onError(new UiError(-6, Constants.MSG_SHARE_NOSD_ERROR, null));
    f.e(a, "shareToQQ sdcard is null--end");
    d.a().a(1, "SHARE_CHECK_SDK", Constants.DEFAULT_UIN, this.mToken.getAppId(), String.valueOf(0), Long.valueOf(SystemClock.elapsedRealtime()), 0, 1, "shareToQQ sdcard is null");
}
 
Example 7
Source File: BaseApi.java    From letv with Apache License 2.0 4 votes vote down vote up
public static void handleDataToListener(Intent intent, IUiListener iUiListener) {
    if (intent == null) {
        iUiListener.onCancel();
        return;
    }
    String stringExtra = intent.getStringExtra(Constants.KEY_ACTION);
    String stringExtra2;
    if (SystemUtils.ACTION_LOGIN.equals(stringExtra)) {
        int intExtra = intent.getIntExtra(Constants.KEY_ERROR_CODE, 0);
        if (intExtra == 0) {
            stringExtra2 = intent.getStringExtra(Constants.KEY_RESPONSE);
            if (stringExtra2 != null) {
                try {
                    iUiListener.onComplete(Util.parseJson(stringExtra2));
                    return;
                } catch (Throwable e) {
                    iUiListener.onError(new UiError(-4, Constants.MSG_JSON_ERROR, stringExtra2));
                    f.b(f.d, "OpenUi, onActivityResult, json error", e);
                    return;
                }
            }
            f.b(f.d, "OpenUi, onActivityResult, onComplete");
            iUiListener.onComplete(new JSONObject());
            return;
        }
        f.e(f.d, "OpenUi, onActivityResult, onError = " + intExtra + "");
        iUiListener.onError(new UiError(intExtra, intent.getStringExtra(Constants.KEY_ERROR_MSG), intent.getStringExtra(Constants.KEY_ERROR_DETAIL)));
    } else if (SystemUtils.ACTION_SHARE.equals(stringExtra)) {
        stringExtra = intent.getStringExtra("result");
        stringExtra2 = intent.getStringExtra("response");
        if ("cancel".equals(stringExtra)) {
            iUiListener.onCancel();
        } else if (NativeProtocol.BRIDGE_ARG_ERROR_BUNDLE.equals(stringExtra)) {
            iUiListener.onError(new UiError(-6, "unknown error", stringExtra2 + ""));
        } else if ("complete".equals(stringExtra)) {
            try {
                if (stringExtra2 == null) {
                    stringExtra = "{\"ret\": 0}";
                } else {
                    stringExtra = stringExtra2;
                }
                iUiListener.onComplete(new JSONObject(stringExtra));
            } catch (JSONException e2) {
                e2.printStackTrace();
                iUiListener.onError(new UiError(-4, "json error", stringExtra2 + ""));
            }
        }
    }
}
 
Example 8
Source File: QQShare.java    From MiBandDecompiled with Apache License 2.0 4 votes vote down vote up
private void a(Activity activity, Bundle bundle, IUiListener iuilistener)
{
    com.tencent.a.a.c.a("openSDK_LOG", "shareToMobileQQ() --start");
    String s = bundle.getString("imageUrl");
    String s1 = bundle.getString("title");
    String s2 = bundle.getString("summary");
    if (!TextUtils.isEmpty(s))
    {
        if (Util.isValidUrl(s))
        {
            if (TextUtils.isEmpty(s1) && TextUtils.isEmpty(s2) && !Util.hasSDCard())
            {
                if (iuilistener != null)
                {
                    iuilistener.onError(new UiError(-6, "\u5206\u4EAB\u56FE\u7247\u5931\u8D25\uFF0C\u68C0\u6D4B\u4E0D\u5230SD\u5361!", null));
                    Log.v("shareToQQ", "\u5206\u4EAB\u56FE\u7247\u5931\u8D25\uFF0C\u68C0\u6D4B\u4E0D\u5230SD\u5361!");
                }
                return;
            }
            if (SystemUtils.compareQQVersion(activity, "4.3.0") >= 0)
            {
                b(activity, bundle, iuilistener);
            } else
            {
                (new AsynLoadImg(activity)).save(s, new com.tencent.connect.share.c(this, bundle, s1, s2, iuilistener, activity));
            }
        } else
        {
            bundle.putString("imageUrl", null);
            if (SystemUtils.compareQQVersion(activity, "4.3.0") < 0)
            {
                b(activity, bundle, iuilistener);
            } else
            {
                com.tencent.connect.share.a.a(activity, s, new b(this, bundle, s1, s2, iuilistener, activity));
            }
        }
    } else
    {
        b(activity, bundle, iuilistener);
    }
    com.tencent.a.a.c.a("openSDK_LOG", "shareToMobileQQ() --start");
}
 
Example 9
Source File: QQShare.java    From MiBandDecompiled with Apache License 2.0 4 votes vote down vote up
public void shareToQQ(Activity activity, Bundle bundle, IUiListener iuilistener)
{
    String s = bundle.getString("imageUrl");
    String s1 = bundle.getString("title");
    String s2 = bundle.getString("summary");
    String s3 = bundle.getString("targetUrl");
    String s4 = bundle.getString("imageLocalUrl");
    int i = bundle.getInt("req_type", 1);
    if (!Util.hasSDCard())
    {
        iuilistener.onError(new UiError(-6, "\u5206\u4EAB\u56FE\u7247\u5931\u8D25\uFF0C\u68C0\u6D4B\u4E0D\u5230SD\u5361!", null));
        com.tencent.a.a.c.a("openSDK_LOG", "shareToQQ() sdcard is null--end");
        return;
    }
    if (i == 5)
    {
        if (SystemUtils.compareQQVersion(activity, "4.3.0") < 0)
        {
            iuilistener.onError(new UiError(-6, "\u4F4E\u7248\u672C\u624BQ\u4E0D\u652F\u6301\u8BE5\u9879\u529F\u80FD!", null));
            com.tencent.a.a.c.a("openSDK_LOG", "shareToQQ() both null--end");
            return;
        }
        if (!Util.fileExists(s4))
        {
            iuilistener.onError(new UiError(-6, "\u975E\u6CD5\u7684\u56FE\u7247\u5730\u5740!", null));
            com.tencent.a.a.c.a("openSDK_LOG", "shareToQQ()--end\u975E\u6CD5\u7684\u56FE\u7247\u5730\u5740!");
            return;
        }
    }
    if (i != 5)
    {
        if (TextUtils.isEmpty(s3) || !s3.startsWith("http://") && !s3.startsWith("https://"))
        {
            iuilistener.onError(new UiError(-6, "\u4F20\u5165\u53C2\u6570\u6709\u8BEF!", null));
            com.tencent.a.a.c.a("openSDK_LOG", "shareToQQ() targetUrl error--end");
            return;
        }
        if (TextUtils.isEmpty(s1))
        {
            iuilistener.onError(new UiError(-6, "title\u4E0D\u80FD\u4E3A\u7A7A!", null));
            com.tencent.a.a.c.a("openSDK_LOG", "shareToQQ() title null--end");
            return;
        }
    }
    if (!TextUtils.isEmpty(s) && !s.startsWith("http://") && !s.startsWith("https://") && !(new File(s)).exists())
    {
        iuilistener.onError(new UiError(-6, "\u975E\u6CD5\u7684\u56FE\u7247\u5730\u5740!", null));
        com.tencent.a.a.c.a("openSDK_LOG", "shareToQQ() image url error--end");
        return;
    }
    if (!TextUtils.isEmpty(s1) && s1.length() > 45)
    {
        bundle.putString("title", Util.subString(s1, 45, null, null));
    }
    if (!TextUtils.isEmpty(s2) && s2.length() > 60)
    {
        bundle.putString("summary", Util.subString(s2, 60, null, null));
    }
    if (Util.isMobileQQSupportShare(activity))
    {
        a(activity, bundle, iuilistener);
    } else
    {
        c(activity, bundle, iuilistener);
    }
    com.tencent.a.a.c.a("openSDK_LOG", "shareToQQ() --end");
}
 
Example 10
Source File: AuthAgent.java    From MiBandDecompiled with Apache License 2.0 4 votes vote down vote up
public void onActivityResult(int l, int i1, Intent intent)
{
    Iterator iterator = mTaskList.iterator();
    IUiListener iuilistener;
    do
    {
        boolean flag = iterator.hasNext();
        iuilistener = null;
        if (!flag)
        {
            break;
        }
        com.tencent.connect.common.BaseApi.ApiTask apitask = (com.tencent.connect.common.BaseApi.ApiTask)iterator.next();
        if (apitask.mRequestCode != l)
        {
            continue;
        }
        iuilistener = apitask.mListener;
        mTaskList.remove(apitask);
        break;
    } while (true);
    if (iuilistener == null)
    {
        return;
    }
    if (i1 == -1)
    {
        int j1 = intent.getIntExtra("key_error_code", 0);
        if (j1 == 0)
        {
            String s = intent.getStringExtra("key_response");
            if (s != null)
            {
                try
                {
                    JSONObject jsonobject = Util.parseJson(s);
                    if (iuilistener == a)
                    {
                        String s1 = jsonobject.getString("access_token");
                        String s2 = jsonobject.getString("expires_in");
                        String s3 = jsonobject.getString("openid");
                        if (!TextUtils.isEmpty(s1) && !TextUtils.isEmpty(s2) && !TextUtils.isEmpty(s3))
                        {
                            mToken.setAccessToken(s1, s2);
                            mToken.setOpenId(s3);
                        }
                    }
                    iuilistener.onComplete(jsonobject);
                }
                catch (JSONException jsonexception)
                {
                    iuilistener.onError(new UiError(-4, "\u670D\u52A1\u5668\u8FD4\u56DE\u6570\u636E\u683C\u5F0F\u6709\u8BEF!", s));
                    com.tencent.a.a.c.a("openSDK_LOG", "OpenUi, onActivityResult, json error", jsonexception);
                }
            } else
            {
                com.tencent.a.a.c.b("openSDK_LOG", "OpenUi, onActivityResult, onComplete");
                iuilistener.onComplete(new JSONObject());
            }
        } else
        {
            com.tencent.a.a.c.d("openSDK_LOG", (new StringBuilder()).append("OpenUi, onActivityResult, onError = ").append(j1).append("").toString());
            iuilistener.onError(new UiError(j1, intent.getStringExtra("key_error_msg"), intent.getStringExtra("key_error_detail")));
        }
    } else
    {
        com.tencent.a.a.c.b("openSDK_LOG", "OpenUi, onActivityResult, Constants.ACTIVITY_CANCEL");
        iuilistener.onCancel();
    }
    com.tencent.a.a.c.a().b();
}
 
Example 11
Source File: BaseApi.java    From MiBandDecompiled with Apache License 2.0 4 votes vote down vote up
public void onActivityResult(int i, int j, Intent intent)
{
    Iterator iterator = mTaskList.iterator();
    IUiListener iuilistener;
    do
    {
        boolean flag = iterator.hasNext();
        iuilistener = null;
        if (!flag)
        {
            break;
        }
        ApiTask apitask = (ApiTask)iterator.next();
        if (apitask.mRequestCode != i)
        {
            continue;
        }
        iuilistener = apitask.mListener;
        mTaskList.remove(apitask);
        break;
    } while (true);
    if (iuilistener == null)
    {
        return;
    }
    if (j == -1)
    {
        int k = intent.getIntExtra("key_error_code", 0);
        if (k == 0)
        {
            String s = intent.getStringExtra("key_response");
            if (s != null)
            {
                try
                {
                    iuilistener.onComplete(Util.parseJson(s));
                }
                catch (JSONException jsonexception)
                {
                    iuilistener.onError(new UiError(-4, "\u670D\u52A1\u5668\u8FD4\u56DE\u6570\u636E\u683C\u5F0F\u6709\u8BEF!", s));
                    c.a("openSDK_LOG", "OpenUi, onActivityResult, json error", jsonexception);
                }
            } else
            {
                c.b("openSDK_LOG", "OpenUi, onActivityResult, onComplete");
                iuilistener.onComplete(new JSONObject());
            }
        } else
        {
            c.d("openSDK_LOG", (new StringBuilder()).append("OpenUi, onActivityResult, onError = ").append(k).append("").toString());
            iuilistener.onError(new UiError(k, intent.getStringExtra("key_error_msg"), intent.getStringExtra("key_error_detail")));
        }
    } else
    {
        c.b("openSDK_LOG", "OpenUi, onActivityResult, Constants.ACTIVITY_CANCEL");
        iuilistener.onCancel();
    }
    c.a().b();
}