3p棋牌.apk(点击下载) / SocialOperation.java


package com.tencent.open;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Base64;
import androidx.core.view.PointerIconCompat;
import com.alipay.sdk.app.OpenAuthTask;
import com.tencent.connect.auth.QQToken;
import com.tencent.connect.common.BaseApi;
import com.tencent.connect.common.Constants;
import com.tencent.open.a.f;
import com.tencent.open.b.d;
import com.tencent.open.utils.HttpUtils;
import com.tencent.open.utils.h;
import com.tencent.open.utils.k;
import com.tencent.tauth.IUiListener;
import com.tencent.tauth.UiError;
import org.json.JSONObject;

public class SocialOperation extends BaseApi {
    public static final String GAME_FRIEND_ADD_MESSAGE = "add_msg";
    public static final String GAME_FRIEND_LABEL = "friend_label";
    public static final String GAME_FRIEND_OPENID = "fopen_id";
    public static final String GAME_SIGNATURE = "signature";
    public static final String GAME_UNION_ID = "unionid";
    public static final String GAME_UNION_NAME = "union_name";
    public static final String GAME_ZONE_ID = "zoneid";

    public SocialOperation(QQToken qQToken) {
        super(qQToken);
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    private void a(Activity activity) {
        a(activity, "");
    }

    private void a(Activity activity, String str) {
        new TDialog(activity, "", a(str), null, this.c).show();
    }

    public void bindQQGroup(final Activity activity, String str, String str2, final IUiListener iUiListener) {
        f.c("openSDK_LOG.GameAppOperation", "-->bindQQGroup()  -- start");
        if (activity == null) {
            f.e("openSDK_LOG.GameAppOperation", "-->bindQQGroup, activity is empty.");
            if (iUiListener != null) {
                iUiListener.onError(new UiError(1001, "param acitivty is null", "activity param of api can not be null."));
                return;
            }
            return;
        }
        StringBuffer stringBuffer = new StringBuffer("mqqapi://opensdk/bind_group?src_type=app&version=1");
        String appId = this.c.getAppId();
        if (TextUtils.isEmpty(appId)) {
            f.e("openSDK_LOG.GameAppOperation", "-->bindQQGroup, appId is empty.");
            if (iUiListener != null) {
                iUiListener.onError(new UiError(1003, "appid is null", "please login."));
                return;
            }
            return;
        }
        String openId = this.c.getOpenId();
        if (TextUtils.isEmpty(openId)) {
            f.e("openSDK_LOG.GameAppOperation", "-->bindQQGroup, openid is empty.");
            if (iUiListener != null) {
                iUiListener.onError(new UiError(1004, "openid params is null", "please login."));
                return;
            }
            return;
        }
        String a2 = k.a(activity);
        if (TextUtils.isEmpty(a2)) {
            f.e("openSDK_LOG.GameAppOperation", "-->bindQQGroup, appname is empty.");
            if (iUiListener != null) {
                iUiListener.onError(new UiError(1005, "appName params is null", ""));
            }
        } else if (TextUtils.isEmpty(str)) {
            f.e("openSDK_LOG.GameAppOperation", "-->bindQQGroup, organization id is empty.");
            if (iUiListener != null) {
                iUiListener.onError(new UiError(PointerIconCompat.TYPE_CELL, "organizationId params is null", ""));
            }
        } else if (TextUtils.isEmpty(str2)) {
            f.e("openSDK_LOG.GameAppOperation", "-->bindQQGroup, organization name is empty.");
            if (iUiListener != null) {
                iUiListener.onError(new UiError(PointerIconCompat.TYPE_CROSSHAIR, "organizationName params is null", ""));
            }
        } else {
            stringBuffer.append("&app_name=" + Base64.encodeToString(k.i(a2), 2));
            stringBuffer.append("&organization_id=" + Base64.encodeToString(k.i(str), 2));
            stringBuffer.append("&organization_name=" + Base64.encodeToString(k.i(str2), 2));
            stringBuffer.append("&openid=" + Base64.encodeToString(k.i(openId), 2));
            stringBuffer.append("&appid=" + Base64.encodeToString(k.i(appId), 2));
            stringBuffer.append("&sdk_version=" + Base64.encodeToString(k.i(Constants.SDK_VERSION), 2));
            f.a("openSDK_LOG.GameAppOperation", "-->bindQQGroup, url: " + stringBuffer.toString());
            Uri parse = Uri.parse(stringBuffer.toString());
            final Intent intent = new Intent("android.intent.action.VIEW");
            intent.setData(parse);
            if (!a(intent) || h.c(activity, "8.1.0") < 0) {
                f.d("openSDK_LOG.GameAppOperation", "-->bind group, there is no activity, show download page.");
                a(activity);
                return;
            }
            AnonymousClass3 r11 = new IUiListener() {
                /* class com.tencent.open.SocialOperation.AnonymousClass3 */

                @Override // com.tencent.tauth.IUiListener
                public void onCancel() {
                }

                @Override // com.tencent.tauth.IUiListener
                public void onComplete(Object obj) {
                    f.d("openSDK_LOG.GameAppOperation", "-->bind group resp is: " + obj);
                    if (obj == null) {
                        if (iUiListener != null) {
                            iUiListener.onError(new UiError(OpenAuthTask.NOT_INSTALLED, "服务端错误,请稍后重试", "资格检查回包为null。"));
                        }
                    } else if (((JSONObject) obj).optInt("bind") != 1) {
                        try {
                            SocialOperation.this.a(activity, Constants.REQUEST_BIND_GROUP, intent, false);
                        } catch (Exception e) {
                            f.b("openSDK_LOG.GameAppOperation", "-->bind group, start activity exception.", e);
                            SocialOperation.this.a((SocialOperation) activity);
                        }
                    } else {
                        if (iUiListener != null) {
                            iUiListener.onError(new UiError(3002, "该群已绑定!", "绑定过的群不能再次绑定。"));
                        }
                        f.c("openSDK_LOG.GameAppOperation", "-->bindQQGroup() binded return.");
                    }
                }

                @Override // com.tencent.tauth.IUiListener
                public void onError(UiError uiError) {
                    f.a("openSDK_LOG.GameAppOperation", "-->bindQQGroup, error: " + uiError);
                    if (iUiListener != null) {
                        iUiListener.onError(uiError);
                    }
                }
            };
            Bundle a3 = a();
            a3.putString("appid", appId);
            a3.putString("orgid", str);
            HttpUtils.requestAsync(this.c, activity, "https://graph.qq.com/cgi-bin/qunopensdk/check_group", a3, Constants.HTTP_GET, new BaseApi.TempRequestListener(r11));
            f.c("openSDK_LOG.GameAppOperation", "-->bindQQGroup() do.");
        }
    }

    public void joinGroup(final Activity activity, String str, final IUiListener iUiListener) {
        f.c("openSDK_LOG.GameAppOperation", "joinQQGroup()");
        if (activity == null) {
            f.e("openSDK_LOG.GameAppOperation", "-->joinGroup, activity is empty.");
            if (iUiListener != null) {
                iUiListener.onError(new UiError(1001, "param acitivty is null", "activity param of api can not be null."));
            }
        } else if (TextUtils.isEmpty(str)) {
            f.e("openSDK_LOG.GameAppOperation", "-->joinGroup, params is empty.");
            if (iUiListener != null) {
                iUiListener.onError(new UiError(PointerIconCompat.TYPE_CELL, "param organizationId is null", "organizationId param of api can not be null."));
            }
        } else {
            final Intent intent = new Intent();
            String appId = this.c.getAppId();
            if (TextUtils.isEmpty(appId)) {
                f.e("openSDK_LOG.GameAppOperation", "-->joinGroup, appid is empty.");
                if (iUiListener != null) {
                    iUiListener.onError(new UiError(1003, "appid is null", "appid is null, please login."));
                    return;
                }
                return;
            }
            String openId = this.c.getOpenId();
            if (TextUtils.isEmpty(openId)) {
                f.e("openSDK_LOG.GameAppOperation", "-->joinGroup, openid is empty.");
                if (iUiListener != null) {
                    iUiListener.onError(new UiError(1004, "openid is null", "openid is null, please login."));
                    return;
                }
                return;
            }
            StringBuffer stringBuffer = new StringBuffer("mqqapi://opensdk/join_group?src_type=app&version=1");
            stringBuffer.append("&openid=" + Base64.encodeToString(k.i(openId), 2));
            stringBuffer.append("&appid=" + Base64.encodeToString(k.i(appId), 2));
            stringBuffer.append("&organization_id=" + Base64.encodeToString(k.i(str), 2));
            stringBuffer.append("&sdk_version=" + Base64.encodeToString(k.i(Constants.SDK_VERSION), 2));
            intent.setData(Uri.parse(stringBuffer.toString()));
            if (!a(intent) || h.c(activity, "8.1.0") < 0) {
                f.d("openSDK_LOG.GameAppOperation", "-->bind group, there is no activity, show download page.");
                a(activity);
                return;
            }
            AnonymousClass2 r2 = new IUiListener() {
                /* class com.tencent.open.SocialOperation.AnonymousClass2 */

                @Override // com.tencent.tauth.IUiListener
                public void onCancel() {
                }

                @Override // com.tencent.tauth.IUiListener
                public void onComplete(Object obj) {
                    f.d("openSDK_LOG.GameAppOperation", "-->join group resp is: " + obj);
                    if (obj == null) {
                        if (iUiListener != null) {
                            iUiListener.onError(new UiError(OpenAuthTask.NOT_INSTALLED, "服务端错误,请稍后重试", "资格检查回包为null。"));
                        }
                    } else if (((JSONObject) obj).optInt("bind") == 1) {
                        try {
                            SocialOperation.this.a(activity, Constants.REQUEST_JOIN_GROUP, intent, false);
                        } catch (Exception e) {
                            f.b("openSDK_LOG.GameAppOperation", "-->join group, start activity exception.", e);
                            SocialOperation.this.a((SocialOperation) activity);
                        }
                    } else if (iUiListener != null) {
                        iUiListener.onError(new UiError(3003, "该组织未绑群,无法加入", "该组织未绑群,无法加入。"));
                    }
                }

                @Override // com.tencent.tauth.IUiListener
                public void onError(UiError uiError) {
                    f.a("openSDK_LOG.GameAppOperation", "-->joinQQGroup, error: " + uiError);
                    if (iUiListener != null) {
                        iUiListener.onError(uiError);
                    }
                }
            };
            Bundle a2 = a();
            a2.putString("appid", appId);
            a2.putString("orgid", str);
            HttpUtils.requestAsync(this.c, activity, "https://graph.qq.com/cgi-bin/qunopensdk/check_group", a2, Constants.HTTP_GET, new BaseApi.TempRequestListener(r2));
            f.c("openSDK_LOG.GameAppOperation", "-->joinQQGroup() do.");
        }
    }

    public void makeFriend(Activity activity, Bundle bundle) {
        f.c("openSDK_LOG.GameAppOperation", "-->makeFriend()  -- start");
        if (bundle == null) {
            f.e("openSDK_LOG.GameAppOperation", "-->makeFriend params is null");
            d.a().a(this.c.getOpenId(), this.c.getAppId(), Constants.VIA_MAKE_FRIEND, Constants.VIA_REPORT_TYPE_MAKE_FRIEND, "18", "1");
            return;
        }
        String string = bundle.getString(GAME_FRIEND_OPENID);
        if (TextUtils.isEmpty(string)) {
            f.e("openSDK_LOG.GameAppOperation", "-->make friend, fOpenid is empty.");
            d.a().a(this.c.getOpenId(), this.c.getAppId(), Constants.VIA_MAKE_FRIEND, Constants.VIA_REPORT_TYPE_MAKE_FRIEND, "18", "1");
            return;
        }
        String string2 = bundle.getString(GAME_FRIEND_LABEL);
        String string3 = bundle.getString(GAME_FRIEND_ADD_MESSAGE);
        String a2 = k.a(activity);
        String openId = this.c.getOpenId();
        String appId = this.c.getAppId();
        f.a("openSDK_LOG.GameAppOperation", "-->make friend, fOpenid: " + string + " | label: " + string2 + " | message: " + string3 + " | openid: " + openId + " | appid:" + appId);
        StringBuffer stringBuffer = new StringBuffer("mqqapi://opensdk/add_friend?src_type=app&version=1");
        StringBuilder sb = new StringBuilder();
        sb.append("&fopen_id=");
        sb.append(Base64.encodeToString(k.i(string), 2));
        stringBuffer.append(sb.toString());
        if (!TextUtils.isEmpty(openId)) {
            stringBuffer.append("&open_id=" + Base64.encodeToString(k.i(openId), 2));
        }
        if (!TextUtils.isEmpty(appId)) {
            stringBuffer.append("&app_id=" + appId);
        }
        if (!TextUtils.isEmpty(string2)) {
            stringBuffer.append("&friend_label=" + Base64.encodeToString(k.i(string2), 2));
        }
        if (!TextUtils.isEmpty(string3)) {
            stringBuffer.append("&add_msg=" + Base64.encodeToString(k.i(string3), 2));
        }
        if (!TextUtils.isEmpty(a2)) {
            stringBuffer.append("&app_name=" + Base64.encodeToString(k.i(a2), 2));
        }
        f.a("openSDK_LOG.GameAppOperation", "-->make friend, url: " + stringBuffer.toString());
        Intent intent = new Intent("android.intent.action.VIEW");
        intent.setData(Uri.parse(stringBuffer.toString()));
        if (!a(intent) || k.f(activity, "5.1.0")) {
            f.d("openSDK_LOG.GameAppOperation", "-->make friend, there is no activity.");
            a(activity);
            d.a().a(this.c.getOpenId(), this.c.getAppId(), Constants.VIA_MAKE_FRIEND, Constants.VIA_REPORT_TYPE_MAKE_FRIEND, "18", "1");
        } else {
            f.c("openSDK_LOG.GameAppOperation", "-->makeFriend target activity found, qqver greater than 5.1.0");
            try {
                activity.startActivity(intent);
                d.a().a(this.c.getOpenId(), this.c.getAppId(), Constants.VIA_MAKE_FRIEND, Constants.VIA_REPORT_TYPE_MAKE_FRIEND, "18", "0");
            } catch (Exception e) {
                f.b("openSDK_LOG.GameAppOperation", "-->make friend, start activity exception.", e);
                a(activity);
                d.a().a(this.c.getOpenId(), this.c.getAppId(), Constants.VIA_MAKE_FRIEND, Constants.VIA_REPORT_TYPE_MAKE_FRIEND, "18", "1");
            }
        }
        f.c("openSDK_LOG.GameAppOperation", "-->makeFriend()  -- end");
    }

    public void unBindGroup(Context context, String str, final IUiListener iUiListener) {
        f.c("openSDK_LOG.GameAppOperation", "unBindQQGroup()");
        if (context == null) {
            f.e("openSDK_LOG.GameAppOperation", "-->uinBindGroup, activity is empty.");
            if (iUiListener != null) {
                iUiListener.onError(new UiError(1001, "param acitivty is null", "activity param of api can not be null."));
            }
        } else if (TextUtils.isEmpty(str)) {
            f.e("openSDK_LOG.GameAppOperation", "-->unBindGroup, params is empty.");
            if (iUiListener != null) {
                iUiListener.onError(new UiError(PointerIconCompat.TYPE_CELL, "param organizationId is null", "organizationId param of api can not be null."));
            }
        } else {
            String appId = this.c.getAppId();
            if (TextUtils.isEmpty(appId)) {
                f.e("openSDK_LOG.GameAppOperation", "-->unBindGroup, appid is empty.");
                if (iUiListener != null) {
                    iUiListener.onError(new UiError(1003, "param appId is null", "appid is null please login."));
                    return;
                }
                return;
            }
            AnonymousClass1 r1 = new IUiListener() {
                /* class com.tencent.open.SocialOperation.AnonymousClass1 */

                @Override // com.tencent.tauth.IUiListener
                public void onCancel() {
                }

                @Override // com.tencent.tauth.IUiListener
                public void onComplete(Object obj) {
                    f.d("openSDK_LOG.GameAppOperation", "-->unbind group resp is: " + obj);
                    if (obj != null) {
                        JSONObject jSONObject = (JSONObject) obj;
                        if (iUiListener != null) {
                            iUiListener.onComplete(jSONObject);
                        }
                    } else if (iUiListener != null) {
                        iUiListener.onError(new UiError(OpenAuthTask.NOT_INSTALLED, "服务端错误,请稍后重试", "资格检查回包为null。"));
                    }
                }

                @Override // com.tencent.tauth.IUiListener
                public void onError(UiError uiError) {
                    f.a("openSDK_LOG.GameAppOperation", "-->unbindQQGroup, error: " + uiError);
                    if (iUiListener != null) {
                        iUiListener.onError(uiError);
                    }
                }
            };
            Bundle a2 = a();
            a2.putString("appid", appId);
            a2.putString("orgid", str);
            HttpUtils.requestAsync(this.c, context, "https://graph.qq.com/cgi-bin/qunopensdk/unbind", a2, Constants.HTTP_GET, new BaseApi.TempRequestListener(r1));
            f.c("openSDK_LOG.GameAppOperation", "-->unBindQQGroup() do.");
        }
    }
}