曹妃甸核酸检测平台.apk(点击下载) / ShareWebViewRequestParam.java


package com.sina.weibo.sdk.web.param;

import android.content.Context;
import android.net.Uri;
import android.os.Bundle;
import android.text.TextUtils;
import com.igexin.download.Downloads;
import com.netease.yunxin.base.utils.StringUtils;
import com.sina.weibo.sdk.api.BaseMediaObject;
import com.sina.weibo.sdk.api.ImageObject;
import com.sina.weibo.sdk.api.TextObject;
import com.sina.weibo.sdk.api.WebpageObject;
import com.sina.weibo.sdk.api.WeiboMultiMessage;
import com.sina.weibo.sdk.auth.AuthInfo;
import com.sina.weibo.sdk.auth.Oauth2AccessToken;
import com.sina.weibo.sdk.exception.WeiboException;
import com.sina.weibo.sdk.net.AsyncWeiboRunner;
import com.sina.weibo.sdk.net.RequestListener;
import com.sina.weibo.sdk.net.WeiboParameters;
import com.sina.weibo.sdk.utils.Base64;
import com.sina.weibo.sdk.utils.Utility;
import com.sina.weibo.sdk.utils.WbSdkVersion;
import com.sina.weibo.sdk.web.WebPicUploadResult;
import com.sina.weibo.sdk.web.WebRequestType;
import com.sina.weibo.sdk.web.param.BaseWebViewRequestParam;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;

public class ShareWebViewRequestParam extends BaseWebViewRequestParam {
    private static final String SHARE_URL = "http://service.weibo.com/share/mobilesdk.php";
    private static final String UPLOAD_PIC_URL = "http://service.weibo.com/share/mobilesdk_uppic.php";
    private String hashKey;
    private byte[] mBase64ImgData;
    private String mShareContent;
    private WeiboMultiMessage multiMessage;
    private String packageName;
    private String picId;
    private String token;

    public ShareWebViewRequestParam() {
    }

    public ShareWebViewRequestParam(Context context) {
        this.context = context;
    }

    public ShareWebViewRequestParam(AuthInfo authInfo, WebRequestType webRequestType, String str, int i, String str2, String str3, Context context) {
        super(authInfo, webRequestType, str, i, str2, str3, context);
    }

    public ShareWebViewRequestParam(AuthInfo authInfo, WebRequestType webRequestType, String str, String str2, String str3, Context context) {
        this(authInfo, webRequestType, str, 0, str2, str3, context);
    }

    private void getBaseUrl() {
        StringBuilder sb = new StringBuilder();
        TextObject textObject = this.multiMessage.textObject;
        if (textObject instanceof TextObject) {
            sb.append(textObject.text + StringUtils.SPACE);
        }
        BaseMediaObject baseMediaObject = this.multiMessage.mediaObject;
        if (baseMediaObject != null && (baseMediaObject instanceof WebpageObject) && !TextUtils.isEmpty(baseMediaObject.actionUrl)) {
            sb.append(this.multiMessage.mediaObject.actionUrl);
        }
        ImageObject imageObject = this.multiMessage.imageObject;
        if (imageObject instanceof ImageObject) {
            handleMblogPic(imageObject.imagePath, imageObject.imageData);
        }
        this.mShareContent = sb.toString();
    }

    /* JADX WARNING: Removed duplicated region for block: B:22:0x0041 A[SYNTHETIC, Splitter:B:22:0x0041] */
    /* JADX WARNING: Removed duplicated region for block: B:30:0x0048  */
    /* JADX WARNING: Removed duplicated region for block: B:33:0x004d  */
    /* JADX WARNING: Removed duplicated region for block: B:39:? A[ADDED_TO_REGION, RETURN, SYNTHETIC] */
    private void handleMblogPic(String str, byte[] bArr) {
        FileInputStream fileInputStream;
        Throwable th;
        try {
            if (!TextUtils.isEmpty(str)) {
                File file = new File(str);
                if (file.exists() && file.canRead() && file.length() > 0) {
                    byte[] bArr2 = new byte[((int) file.length())];
                    try {
                        fileInputStream = new FileInputStream(file);
                        try {
                            fileInputStream.read(bArr2);
                            this.mBase64ImgData = Base64.encodebyte(bArr2);
                            try {
                                fileInputStream.close();
                                return;
                            } catch (Exception unused) {
                                return;
                            }
                        } catch (IOException unused2) {
                            if (fileInputStream != null) {
                            }
                            if (bArr == null) {
                            }
                        } catch (Throwable th2) {
                            th = th2;
                            if (fileInputStream != null) {
                            }
                            throw th;
                        }
                    } catch (IOException unused3) {
                        fileInputStream = null;
                        if (fileInputStream != null) {
                            fileInputStream.close();
                        }
                        if (bArr == null) {
                            return;
                        }
                    } catch (Throwable th3) {
                        th = th3;
                        fileInputStream = null;
                        if (fileInputStream != null) {
                            try {
                                fileInputStream.close();
                            } catch (Exception unused4) {
                            }
                        }
                        throw th;
                    }
                }
            }
        } catch (SecurityException unused5) {
        }
        if (bArr == null && bArr.length > 0) {
            this.mBase64ImgData = Base64.encodebyte(bArr);
        }
    }

    /* access modifiers changed from: protected */
    @Override // com.sina.weibo.sdk.web.param.BaseWebViewRequestParam
    public void childFillBundle(Bundle bundle) {
        WeiboMultiMessage weiboMultiMessage = this.multiMessage;
        if (weiboMultiMessage != null) {
            weiboMultiMessage.toBundle(bundle);
        }
        bundle.putString("token", this.token);
        bundle.putString("packageName", this.packageName);
        bundle.putString("hashKey", this.hashKey);
    }

    @Override // com.sina.weibo.sdk.web.param.BaseWebViewRequestParam
    public void doExtraTask(final BaseWebViewRequestParam.ExtraTaskCallback extraTaskCallback) {
        super.doExtraTask(extraTaskCallback);
        WeiboParameters weiboParameters = new WeiboParameters(getBaseData().getAuthInfo().getAppKey());
        weiboParameters.put("img", new String(this.mBase64ImgData));
        new AsyncWeiboRunner(this.context).requestAsync(UPLOAD_PIC_URL, weiboParameters, "POST", new RequestListener() {
            /* class com.sina.weibo.sdk.web.param.ShareWebViewRequestParam.AnonymousClass1 */

            @Override // com.sina.weibo.sdk.net.RequestListener
            public void onComplete(String str) {
                WebPicUploadResult parse = WebPicUploadResult.parse(str);
                if (parse == null || parse.getCode() != 1 || TextUtils.isEmpty(parse.getPicId())) {
                    BaseWebViewRequestParam.ExtraTaskCallback extraTaskCallback = extraTaskCallback;
                    if (extraTaskCallback != null) {
                        extraTaskCallback.onException("upload pic fail");
                        return;
                    }
                    return;
                }
                ShareWebViewRequestParam.this.picId = parse.getPicId();
                BaseWebViewRequestParam.ExtraTaskCallback extraTaskCallback2 = extraTaskCallback;
                if (extraTaskCallback2 != null) {
                    extraTaskCallback2.onComplete(ShareWebViewRequestParam.this.picId);
                }
            }

            @Override // com.sina.weibo.sdk.net.RequestListener
            public void onWeiboException(WeiboException weiboException) {
                BaseWebViewRequestParam.ExtraTaskCallback extraTaskCallback = extraTaskCallback;
                if (extraTaskCallback != null) {
                    extraTaskCallback.onException("upload pic fail");
                }
            }
        });
    }

    @Override // com.sina.weibo.sdk.web.param.BaseWebViewRequestParam
    public String getRequestUrl() {
        String appKey = getBaseData().getAuthInfo().getAppKey();
        Uri.Builder buildUpon = Uri.parse(SHARE_URL).buildUpon();
        buildUpon.appendQueryParameter(Downloads.COLUMN_TITLE, this.mShareContent);
        buildUpon.appendQueryParameter("version", WbSdkVersion.WEIBO_SDK_VERSION_CODE);
        if (!TextUtils.isEmpty(appKey)) {
            buildUpon.appendQueryParameter("source", appKey);
        }
        if (!TextUtils.isEmpty(this.token)) {
            buildUpon.appendQueryParameter(Oauth2AccessToken.KEY_ACCESS_TOKEN, this.token);
        }
        Context context = this.context;
        if (context != null) {
            String aid = Utility.getAid(context, appKey);
            if (!TextUtils.isEmpty(aid)) {
                buildUpon.appendQueryParameter("aid", aid);
            }
        }
        if (!TextUtils.isEmpty(this.packageName)) {
            buildUpon.appendQueryParameter("packagename", this.packageName);
        }
        if (!TextUtils.isEmpty(this.hashKey)) {
            buildUpon.appendQueryParameter("key_hash", this.hashKey);
        }
        if (!TextUtils.isEmpty(this.picId)) {
            buildUpon.appendQueryParameter("picinfo", this.picId);
        }
        buildUpon.appendQueryParameter("luicode", "10000360");
        buildUpon.appendQueryParameter("lfid", "OP_" + appKey);
        return buildUpon.build().toString();
    }

    @Override // com.sina.weibo.sdk.web.param.BaseWebViewRequestParam
    public boolean hasExtraTask() {
        byte[] bArr = this.mBase64ImgData;
        if (bArr == null || bArr.length <= 0) {
            return super.hasExtraTask();
        }
        return true;
    }

    public void setHashKey(String str) {
        this.hashKey = str;
    }

    public void setMultiMessage(WeiboMultiMessage weiboMultiMessage) {
        this.multiMessage = weiboMultiMessage;
    }

    public void setPackageName(String str) {
        this.packageName = str;
    }

    public void setToken(String str) {
        this.token = str;
    }

    /* access modifiers changed from: protected */
    @Override // com.sina.weibo.sdk.web.param.BaseWebViewRequestParam
    public void transformChildBundle(Bundle bundle) {
        this.multiMessage = new WeiboMultiMessage();
        this.multiMessage.toObject(bundle);
        this.token = bundle.getString("token");
        this.packageName = bundle.getString("packageName");
        this.hashKey = bundle.getString("hashKey");
        getBaseUrl();
    }

    @Override // com.sina.weibo.sdk.web.param.BaseWebViewRequestParam
    public void updateRequestUrl(String str) {
        this.picId = str;
    }
}