TIM v2.3.1版本的 MD5 值为:d6957e3ee7ce901ccc491cefdea0da8c

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


package cooperation.photoplus;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.Environment;
import android.os.Handler;
import android.os.Message;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.TextView;
import android.widget.Toast;
import com.tencent.common.app.BaseApplicationImpl;
import com.tencent.image.URLDrawable;
import com.tencent.mobileqq.app.IphoneTitleBarActivity;
import com.tencent.mobileqq.pluginsdk.PluginBaseInfo;
import com.tencent.mobileqq.pluginsdk.PluginManagerClient;
import com.tencent.mobileqq.pluginsdk.PluginManagerHelper;
import com.tencent.mobileqq.utils.NetworkUtil;
import com.tencent.qphone.base.util.QLog;
import com.tencent.tim.R;
import com.tencent.util.MqqWeakReferenceHandler;
import java.io.File;
import java.math.BigDecimal;
public class PhotoPlusBridgeActivity extends IphoneTitleBarActivity implements Handler.Callback, PluginManagerHelper.OnPluginManagerLoadedListener {
    public static final int f97938a = 100003;
    public static final String f69432a = "photo_path";
    private static final int f97939b = 400;
    public static final String f69433b = "iswaitforsult";
    private static final int f97940c = 1000;
    public static final String f69434c = "type";
    private static final int d = 1001;
    public static final String f69435d = "uin";
    private static final int e = 1002;
    public static final String f69436e = "nick";
    private static final int f = 1003;
    public static final String f69437f = "headDir";
    private static final int g = 1004;
    private static final String f69438g = "Photoplus.apk";
    private static final int h = 90;
    private static final String f69439h = "Photoplus.jpg";
    private static final int i = 99;
    private static String m = "http://dldir1.qq.com/invc/zebra/imgs/photoplus_dowding_img.jpg";
    private static final String n = Environment.getExternalStorageDirectory().getAbsolutePath() + File.separator + "tencent" + File.separator + "zebrasdk" + File.separator;
    private long f69440a;
    private Intent f69441a;
    private ImageView f69442a;
    private ProgressBar f69443a;
    private TextView f69444a;
    private PluginManagerClient f69445a;
    private MqqWeakReferenceHandler f69446a;
    private boolean f69447a;
    private String f69448i;
    private int j;
    private String f69449j;
    private String k;
    private String l;

    @Override
    public boolean doOnCreate(Bundle bundle) {
        super.doOnCreate(bundle);
        getWindow().setBackgroundDrawableResource(R.color.f38443name_res_0x7f0b002a);
        this.f69446a = new MqqWeakReferenceHandler(this);
        PluginManagerHelper.getPluginInterface(this, this);
        this.f69440a = System.currentTimeMillis();
        this.f69441a = getIntent();
        this.f69448i = this.f69441a.getStringExtra(f69432a);
        this.f69447a = this.f69441a.getBooleanExtra(f69433b, false);
        this.j = this.f69441a.getIntExtra("type", 0);
        this.f69449j = this.f69441a.getStringExtra("uin");
        this.k = this.f69441a.getStringExtra("nick");
        this.l = this.f69441a.getStringExtra(f69437f);
        PhotoPlusManager photoPlusManager = (PhotoPlusManager) this.app.getManager(168);
        if (NetworkUtil.a((Context) BaseApplicationImpl.a()) == 1) {
            if (QLog.isColorLevel()) {
                QLog.d("IphoneTitleBarActivity", 2, "[onCreate] update sticker resource");
            }
            try {
                photoPlusManager.a(false);
            } catch (Throwable th) {
                if (QLog.isColorLevel()) {
                    QLog.d("IphoneTitleBarActivity", 2, "[onCreate]", th);
                }
            }
        }
        return true;
    }

    @Override
    public void onPluginManagerLoaded(PluginManagerClient pluginManagerClient) {
        this.f69445a = pluginManagerClient;
        setContentView(R.layout.f56826name_res_0x7f0301e1);
        m10681b();
        if (QLog.isDevelopLevel()) {
            QLog.d("IphoneTitleBarActivity", 4, "[PhotoPlusBridgeActivity] [onPluginManagerLoaded] ");
        }
        if (QLog.isDevelopLevel()) {
            QLog.d("IphoneTitleBarActivity", 4, "[PhotoPlusBridgeActivity] [onCreate] has network!");
        }
        PluginBaseInfo queryPlugin = this.f69445a.queryPlugin("Photoplus.apk");
        if (QLog.isDevelopLevel()) {
            QLog.d("IphoneTitleBarActivity", 4, "[PhotoPlusBridgeActivity] [onPluginManagerLoaded] pluginInfo WATERMARK_CAMERA_ID:" + queryPlugin);
        }
        if (queryPlugin != null) {
            if (queryPlugin.mState == 4) {
                if (QLog.isDevelopLevel()) {
                    QLog.d("IphoneTitleBarActivity", 4, "[PhotoPlusBridgeActivity] [onCreate] 已安装,直接启动!");
                }
                m10680a(-1);
            } else {
                if (QLog.isDevelopLevel()) {
                    QLog.d("IphoneTitleBarActivity", 4, "[PhotoPlusBridgeActivity] [onCreate] 开始下载或者安装!");
                }
                this.f69445a.installPlugin("Photoplus.apk");
            }
        }
        if (QLog.isDevelopLevel()) {
            QLog.d("IphoneTitleBarActivity", 4, "[PhotoPlusBridgeActivity] [onPluginManagerLoaded ACTION_QUERY] ACTION_QUERY ");
        }
        this.f69446a.sendEmptyMessageDelayed(1001, 400L);
        if (!NetworkUtil.h(getApplicationContext())) {
            Toast.makeText(getApplicationContext(), "网络无连接,请检查你的网络连接", 0).show();
        }
    }

    @Override
    public boolean onBackEvent() {
        m10680a(0);
        return super.onBackEvent();
    }

    private void m10681b() {
        if (QLog.isDevelopLevel()) {
            QLog.d("IphoneTitleBarActivity", 4, "[PhotoPlusBridgeActivity] [initUI] start!");
        }
        setTitle("图片编辑");
        this.f69443a = (ProgressBar) findViewById(R.id.f49797name_res_0x7f090aa1);
        this.f69444a = (TextView) findViewById(R.id.f49796name_res_0x7f090aa0);
        this.f69442a = (ImageView) findViewById(R.id.f49798name_res_0x7f090aa2);
        File file = new File(n + f69439h);
        if (file.exists()) {
            if (QLog.isDevelopLevel()) {
                QLog.d("IphoneTitleBarActivity", 4, "[PhotoPlusBridgeActivity] [initUI] intro pic exists!" + file.getAbsolutePath());
            }
            this.f69446a.obtainMessage(1004).sendToTarget();
        } else {
            if (QLog.isDevelopLevel()) {
                QLog.d("IphoneTitleBarActivity", 4, "[PhotoPlusBridgeActivity] [initUI] intro pic not exists!");
            }
            m10682a();
        }
        if (QLog.isDevelopLevel()) {
            QLog.d("IphoneTitleBarActivity", 4, "[PhotoPlusBridgeActivity] [initUI] end!");
        }
    }

    private void m10680a(int i2) {
        if (QLog.isDevelopLevel()) {
            QLog.d("IphoneTitleBarActivity", 4, "[PhotoPlusBridgeActivity] [finishAndResult] begin!");
        }
        setResult(i2, this.f69441a);
        finish();
    }

    @Override
    public void doOnDestroy() {
        super.doOnDestroy();
        this.f69446a.removeMessages(1001);
        if (this.f69445a != null) {
        }
    }

    @Override
    public boolean handleMessage(Message message) {
        switch (message.what) {
            case 1000:
                if (QLog.isDevelopLevel()) {
                    QLog.d("IphoneTitleBarActivity", 4, "[PhotoPlusBridgeActivity] [handleMessage] ACTION_UPDATE_PROGRESS!");
                }
                int i2 = message.arg1;
                this.f69444a.setText("正在加载(" + i2 + "%),大约还需" + a(i2));
                this.f69443a.setProgress(i2);
                return true;
            case 1001:
                if (QLog.isDevelopLevel()) {
                    QLog.d("IphoneTitleBarActivity", 4, "[PhotoPlusBridgeActivity] [handleMessage] ACTION_QUERY!");
                }
                if (!isFinishing()) {
                    a("Photoplus.apk", this.f69445a.queryPlugin("Photoplus.apk"));
                    return true;
                }
                return true;
            case 1002:
                if (QLog.isDevelopLevel()) {
                    QLog.d("IphoneTitleBarActivity", 4, "[PhotoPlusBridgeActivity] [handleMessage] ACTION_INCREMENT!");
                }
                int progress = this.f69443a.getProgress();
                int i3 = progress >= 99 ? progress + 1 : 99;
                this.f69444a.setText("正在加载(" + i3 + "%),大约还需" + a(i3));
                this.f69443a.setProgress(i3);
                return true;
            case 1003:
                if (QLog.isDevelopLevel()) {
                    QLog.d("IphoneTitleBarActivity", 4, "[PhotoPlusBridgeActivity] [handleMessage] ACTION_ERROR!");
                }
                this.f69444a.setText("加载失败");
                Toast.makeText(getApplicationContext(), "网络无连接,请检查你的网络连接", 0).show();
                return true;
            case 1004:
                File file = new File(n + f69439h);
                if (file.exists()) {
                    try {
                        this.f69442a.setImageDrawable(URLDrawable.getDrawable(file, (URLDrawable.URLDrawableOptions) null));
                        this.f69442a.setVisibility(0);
                        if (QLog.isDevelopLevel()) {
                            QLog.d("IphoneTitleBarActivity", 4, "[PhotoPlusBridgeActivity] [handleMessage] show image success!");
                            return true;
                        }
                        return true;
                    } catch (Exception e2) {
                        if (QLog.isColorLevel()) {
                            QLog.e("IphoneTitleBarActivity", 2, "[PhotoPlusBridgeActivity] [handleMessage] show image failed! getDrawable failed", e2);
                            return true;
                        }
                        return true;
                    }
                } else if (QLog.isDevelopLevel()) {
                    QLog.e("IphoneTitleBarActivity", 4, "[PhotoPlusBridgeActivity] [handleMessage] show image failed! file is not exist!");
                    return true;
                } else {
                    return true;
                }
            default:
                return true;
        }
    }

    public void a(String str, PluginBaseInfo pluginBaseInfo) {
        if (pluginBaseInfo == null) {
            if (!this.f69445a.isReady()) {
                this.f69446a.sendEmptyMessageDelayed(1001, 400L);
                return;
            }
            return;
        }
        switch (pluginBaseInfo.mState) {
            case -2:
                if (QLog.isDevelopLevel()) {
                    QLog.d("IphoneTitleBarActivity", 4, "[PhotoPlusBridgeActivity] [handlePluginInfo] PluginInfo.STATE_ERROR!");
                }
                this.f69446a.sendEmptyMessage(1003);
                return;
            case -1:
            default:
                return;
            case 0:
                if (QLog.isDevelopLevel()) {
                    QLog.d("IphoneTitleBarActivity", 4, "[PhotoPlusBridgeActivity] [handlePluginInfo] PluginInfo.STATE_NODOWNLOAD!");
                }
                this.f69445a.installPlugin("Photoplus.apk");
            case 1:
                if (QLog.isDevelopLevel()) {
                    QLog.d("IphoneTitleBarActivity", 4, "[PhotoPlusBridgeActivity] [handlePluginInfo] PluginInfo.STATE_DOWNLOADING!");
                    break;
                }
                break;
            case 2:
                break;
            case 3:
                if (QLog.isDevelopLevel()) {
                    QLog.d("IphoneTitleBarActivity", 4, "[PhotoPlusBridgeActivity] [handlePluginInfo] PluginInfo.STATE_INSTALLING!");
                }
                this.f69446a.sendEmptyMessage(1002);
                this.f69446a.sendEmptyMessageDelayed(1001, 400L);
                return;
            case 4:
                if (QLog.isDevelopLevel()) {
                    QLog.d("IphoneTitleBarActivity", 4, "[PhotoPlusBridgeActivity] [handlePluginInfo] PluginInfo.STATE_INSTALLED!");
                }
                m10680a(-1);
                return;
        }
        if (QLog.isDevelopLevel()) {
            QLog.d("IphoneTitleBarActivity", 4, "[PhotoPlusBridgeActivity] [handlePluginInfo] PluginInfo.STATE_DOWNLOADED!");
        }
        this.f69446a.obtainMessage(1000, (int) (pluginBaseInfo.mDownloadProgress * 90.0f), 0).sendToTarget();
        this.f69446a.sendEmptyMessageDelayed(1001, 400L);
    }

    public void m10682a() {
        new Thread(new xtf(this)).start();
    }

    private String a(int i2) {
        if (i2 == 0) {
            return "20秒";
        }
        float currentTimeMillis = (((float) ((System.currentTimeMillis() - this.f69440a) / 1000)) / i2) * (100 - i2);
        if (currentTimeMillis > 60.0f) {
            return "1分钟";
        }
        try {
            return new BigDecimal(currentTimeMillis).setScale(1, 4) + "秒";
        } catch (Exception e2) {
            return String.format("%.1f秒", Float.valueOf(currentTimeMillis));
        }
    }
}