九游游戏中心HD v4.6.8.1版本的 MD5 值为:78c397802cc5ffdcc7f5502ede90502e

以下内容为反编译后的 k.java 源代码,内容仅作参考


package cn.ninegame.share.a;

import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.text.TextUtils;
import cn.ninegame.gamemanagerhd.R;
import cn.ninegame.library.util.bc;
import cn.ninegame.library.util.cc;
import cn.ninegame.modules.account.LoginInfo;
import cn.ninegame.share.core.ShareParameter;
import com.sina.weibo.sdk.api.ImageObject;
import com.sina.weibo.sdk.api.TextObject;
import com.sina.weibo.sdk.api.WeiboMultiMessage;
import com.sina.weibo.sdk.api.share.IWeiboShareAPI;
import com.sina.weibo.sdk.api.share.SendMultiMessageToWeiboRequest;
import com.sina.weibo.sdk.api.share.WeiboShareSDK;
import com.sina.weibo.sdk.auth.Oauth2AccessToken;
import com.sina.weibo.sdk.auth.WeiboAuth;
import com.sina.weibo.sdk.auth.sso.SsoHandler;
import com.sina.weibo.sdk.constant.WBConstants;
import com.sina.weibo.sdk.exception.WeiboAuthException;
import com.sina.weibo.sdk.net.RequestListener;
import com.sina.weibo.sdk.utils.Utility;
public final class k extends cn.ninegame.share.core.b {
    public static SsoHandler h;
    private static WeiboAuth k;
    public IWeiboShareAPI i;
    public boolean j;
    private String l;
    private RequestListener m;

    public k(Activity activity, ShareParameter shareParameter) {
        super(activity, shareParameter);
        this.l = "SinaPlatform";
        this.j = false;
        this.m = new n(this);
        if (l()) {
            this.i = WeiboShareSDK.createWeiboAPI(activity, cn.ninegame.share.core.o.a("sina", "2215968974"));
            this.i.registerApp();
        }
    }

    public static void a(int i, int i2, Intent intent) {
        if (h != null) {
            h.authorizeCallBack(i, i2, intent);
        }
    }

    @Override
    public final boolean a(String str) {
        Bundle parseUrl = Utility.parseUrl(str);
        String string = parseUrl.getString(cn.ninegame.share.core.g.ERROR);
        String string2 = parseUrl.getString("error_code");
        String string3 = parseUrl.getString("error_description");
        m mVar = new m(this);
        if (string == null && string2 == null) {
            mVar.onComplete(parseUrl);
            return true;
        }
        mVar.onWeiboException(new WeiboAuthException(string2, string, string3));
        return false;
    }

    @Override
    public final boolean c() {
        return false;
    }

    @Override
    public final void a(ShareParameter shareParameter) {
        String string = shareParameter.getString("title");
        String string2 = shareParameter.getString("content");
        String string3 = shareParameter.getString(cn.ninegame.share.core.g.SHARE_INFO_SHARE_URL);
        String string4 = shareParameter.getString(cn.ninegame.share.core.g.SHARE_INFO_AD_WORD);
        String string5 = shareParameter.getString(cn.ninegame.share.core.g.SHARE_INFO_AD_URL);
        Bitmap a2 = a((Bitmap) shareParameter.get(cn.ninegame.share.core.g.SHARE_INFO_IMG_THUMB), 5242880, 1000, 1000);
        StringBuilder sb = new StringBuilder();
        a(sb, string);
        a(sb, string2);
        a(sb, string3);
        a(sb, string4);
        a(sb, string5);
        if (sb.length() > 140) {
            String substring = string2.substring(0, string2.length() - Math.min(string2.length(), sb.length() - 140));
            sb = new StringBuilder();
            a(sb, string);
            a(sb, substring);
            a(sb, string3);
            a(sb, string4);
            a(sb, string5);
            if (sb.length() > 140) {
                String substring2 = string.substring(0, string.length() - Math.min(string.length(), sb.length() - 140));
                sb = new StringBuilder();
                a(sb, substring2);
                a(sb, substring);
                a(sb, string3);
                a(sb, string4);
                a(sb, string5);
            }
        }
        shareParameter.setSharePic(a2);
        shareParameter.setShareText(sb.toString());
    }

    @Override
    public final boolean a(ShareParameter shareParameter, cn.ninegame.share.core.m<ShareParameter> mVar) {
        if (l()) {
            if (k == null) {
                k = new WeiboAuth(this.f3208a, cn.ninegame.share.core.o.a("sina", "2215968974"), "https://api.weibo.com/oauth2/default.html", "email,direct_messages_read,direct_messages_write,friendships_groups_read,friendships_groups_write,statuses_to_me_read,follow_app_official_microblog,invitation_write");
                SsoHandler ssoHandler = new SsoHandler((Activity) this.f3208a, k);
                h = ssoHandler;
                ssoHandler.authorize(new cn.ninegame.share.c.c(shareParameter, b(mVar)));
                return true;
            } else if (h == null) {
                return true;
            } else {
                h.authorize(new cn.ninegame.share.c.c(shareParameter, b(mVar)));
                return true;
            }
        }
        shareParameter.setOauthPageTitle("新浪微博授权");
        String a2 = cn.ninegame.share.core.o.a("sina", "2215968974");
        ShareParameter shareParameter2 = new ShareParameter();
        shareParameter2.put(WBConstants.AUTH_PARAMS_CLIENT_ID, a2);
        shareParameter2.put(WBConstants.AUTH_PARAMS_REDIRECT_URL, "https://api.weibo.com/oauth2/default.html");
        shareParameter2.put("scope", "email,direct_messages_read,direct_messages_write,friendships_groups_read,friendships_groups_write,statuses_to_me_read,follow_app_official_microblog,invitation_write");
        shareParameter2.put(WBConstants.AUTH_PARAMS_RESPONSE_TYPE, "code");
        shareParameter2.put(WBConstants.AUTH_PARAMS_DISPLAY, LoginInfo.ACCOUNT_TYPE_MOBILE);
        String packageName = this.f3208a.getPackageName();
        String sign = Utility.getSign(this.f3208a, packageName);
        shareParameter2.put("packagename", packageName);
        shareParameter2.put("key_hash", sign);
        shareParameter.setOauthUrl("https://open.weibo.cn/oauth2/authorize?" + shareParameter2.encodeUrl());
        cn.ninegame.share.b bVar = new cn.ninegame.share.b(this.f3208a, shareParameter, this, mVar);
        try {
            bVar.setOnDismissListener(new l(this));
            bVar.show();
            return true;
        } catch (Exception e) {
            cn.ninegame.library.stat.b.b.a(e);
            return true;
        }
    }

    @Override
    public final void b(ShareParameter shareParameter) {
        if (!l()) {
            if (this.j) {
                cc.b((int) R.string.sharing);
                return;
            }
            this.j = true;
            cc.b((int) R.string.sharing_in_background);
            Oauth2AccessToken a2 = cn.ninegame.share.c.b.a(this.f3208a);
            cn.ninegame.share.c.e eVar = new cn.ninegame.share.c.e(a2);
            if (a2 != null && a2.isSessionValid()) {
                try {
                    Bitmap sharePic = this.b.getSharePic();
                    if (sharePic != null && !sharePic.isRecycled()) {
                        eVar.a(this.b.getShareText(), sharePic, this.m);
                    } else {
                        eVar.a(this.b.getShareText(), this.m);
                    }
                    return;
                } catch (Exception e) {
                    cn.ninegame.library.stat.b.b.a(e);
                    return;
                }
            }
            return;
        }
        WeiboMultiMessage weiboMultiMessage = new WeiboMultiMessage();
        TextObject textObject = new TextObject();
        textObject.text = this.b.getShareText();
        weiboMultiMessage.textObject = textObject;
        Bitmap sharePic2 = this.b.getSharePic();
        ImageObject imageObject = new ImageObject();
        if (sharePic2 != null && !sharePic2.isRecycled()) {
            imageObject.setImageObject(this.b.getSharePic());
            weiboMultiMessage.imageObject = imageObject;
        } else {
            String str = (String) this.b.get(cn.ninegame.share.core.g.SHARE_INFO_IMAGE_LOCAL_PATH);
            if (!TextUtils.isEmpty(str)) {
                imageObject.imagePath = str;
                weiboMultiMessage.imageObject = imageObject;
            }
        }
        SendMultiMessageToWeiboRequest sendMultiMessageToWeiboRequest = new SendMultiMessageToWeiboRequest();
        sendMultiMessageToWeiboRequest.transaction = String.valueOf(System.currentTimeMillis());
        sendMultiMessageToWeiboRequest.multiMessage = weiboMultiMessage;
        this.i.sendRequest(sendMultiMessageToWeiboRequest);
    }

    @Override
    public final String f() {
        if (this.b.getString(cn.ninegame.share.core.g.SHARE_INFO_IMG_URL) != null) {
            return this.b.getString(cn.ninegame.share.core.g.SHARE_INFO_IMG_URL);
        }
        if (this.b.getString("iconUrl") != null) {
            return this.b.getString("iconUrl");
        }
        return null;
    }

    public static void a(Intent intent) {
        if (WBConstants.ACTIVITY_REQ_SDK.equals(intent.getAction()) && intent.getExtras() != null) {
            Bundle bundle = new Bundle();
            switch (intent.getExtras().getInt(WBConstants.Response.ERRCODE, -1)) {
                case 0:
                    bundle.putBoolean("bundle_param_is_success", true);
                    bundle.putBoolean("bundle_param_is_cancel", false);
                    break;
                case 1:
                    bundle.putBoolean("bundle_param_is_success", true);
                    bundle.putBoolean("bundle_param_is_cancel", true);
                    break;
                case 2:
                    bundle.putBoolean("bundle_param_is_success", false);
                    bundle.putBoolean("bundle_param_is_cancel", false);
                    break;
                default:
                    bundle.putBoolean("bundle_param_is_success", false);
                    bundle.putBoolean("bundle_param_is_cancel", false);
                    break;
            }
            cn.ninegame.genericframework.basic.g.a().b().a(cn.ninegame.genericframework.basic.r.a("base_biz_share_result", bundle));
        }
    }

    @Override
    public final void k() {
        k = null;
        h = null;
        this.i = null;
    }

    private cn.ninegame.share.core.m<ShareParameter> b(cn.ninegame.share.core.m<ShareParameter> mVar) {
        return new p(this, mVar);
    }

    @Override
    public final boolean a() {
        return cn.ninegame.share.c.b.a(this.f3208a).isSessionValid();
    }

    private boolean l() {
        return bc.a(this.f3208a, "com.sina.weibo");
    }
}