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

The following examples show how to use com.tencent.tauth.IUiListener#onComplete() . 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: LocationApi.java    From letv with Apache License 2.0 6 votes vote down vote up
public void searchNearby(Activity activity, Bundle bundle, IUiListener iUiListener) {
    if (c()) {
        this.e = bundle;
        this.f = iUiListener;
        this.b.post(new Runnable(this) {
            final /* synthetic */ LocationApi a;

            {
                this.a = r1;
            }

            public void run() {
                if (this.a.d.a()) {
                    Message.obtain(this.a.c, 103).sendToTarget();
                } else {
                    Message.obtain(this.a.c, 104).sendToTarget();
                }
            }
        });
    } else if (iUiListener != null) {
        iUiListener.onComplete(d());
    }
}
 
Example 2
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 3
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 4
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 5
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 6
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 7
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();
}