思特奇智慧酒店云平台 v0.0.5版本的 MD5 值为:dedb172bb322639d79d7e0e26262fb5c

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


package com.sitech.core.util.js;

import android.content.Context;
import android.content.Intent;
import android.graphics.BitmapFactory;
import android.util.Base64;
import com.sitech.core.util.Log;
import com.sitech.oncon.api.core.im.data.ThumbnailUtils;
import com.sitech.oncon.app.getphoto.GetMultiplePhotosActivity;
import java.io.File;
import java.io.FileInputStream;
import java.io.Serializable;
import java.util.Iterator;
import java.util.List;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
public class GetMultiplePhotos implements Serializable {
    public static GetMultiplePhotos instance = null;
    public static final long serialVersionUID = 1;
    public Context ctx;
    public GetMultiplePhotosListener mGetPhotoListener;

    public interface GetMultiplePhotosListener {
        void getPhoto(JSONObject jSONObject);
    }

    public GetMultiplePhotos(Context context, GetMultiplePhotosListener getMultiplePhotosListener) {
        this.ctx = context;
        this.mGetPhotoListener = getMultiplePhotosListener;
    }

    public static void clear() {
        instance = null;
    }

    public static String getExtensionName(String str) {
        int lastIndexOf;
        return (str == null || str.length() <= 0 || (lastIndexOf = str.lastIndexOf(46)) <= -1 || lastIndexOf >= str.length() + (-1)) ? str : str.substring(lastIndexOf + 1);
    }

    public static GetMultiplePhotos getInstance(Context context, GetMultiplePhotosListener getMultiplePhotosListener) {
        if (instance == null) {
            instance = new GetMultiplePhotos(context, getMultiplePhotosListener);
        }
        return instance;
    }

    public void getPhotos(String str, String str2) {
        Intent intent = new Intent(this.ctx, GetMultiplePhotosActivity.class);
        intent.putExtra("maxNum", str);
        intent.putExtra("rate", str2);
        this.ctx.startActivity(intent);
    }

    public void returnPhoto(List<String> list) {
        JSONObject jSONObject;
        GetMultiplePhotosListener getMultiplePhotosListener;
        GetMultiplePhotosListener getMultiplePhotosListener2;
        String str;
        String str2;
        JSONObject jSONObject2 = new JSONObject();
        String str3 = "images";
        try {
            try {
                try {
                } catch (Throwable th) {
                    th = th;
                    getMultiplePhotosListener = this.mGetPhotoListener;
                    if (getMultiplePhotosListener != null) {
                        getMultiplePhotosListener.getPhoto(jSONObject);
                    }
                    throw th;
                }
            } catch (Exception e) {
                e = e;
            }
        } catch (Error e2) {
            e = e2;
        }
        if (list != null) {
            try {
            } catch (Error e3) {
                e = e3;
                jSONObject = jSONObject2;
                Error error = e;
                try {
                    jSONObject.put("status", "0");
                } catch (JSONException e4) {
                    e4.printStackTrace();
                }
                Log.a(bk0.V5, error.getMessage(), error);
                getMultiplePhotosListener2 = this.mGetPhotoListener;
                if (getMultiplePhotosListener2 == null) {
                    return;
                }
                getMultiplePhotosListener2.getPhoto(jSONObject);
            } catch (Exception e5) {
                e = e5;
                jSONObject = jSONObject2;
                Exception exc = e;
                try {
                    jSONObject.put("status", "0");
                } catch (JSONException e6) {
                    e6.printStackTrace();
                }
                Log.a(bk0.V5, exc.getMessage(), exc);
                getMultiplePhotosListener2 = this.mGetPhotoListener;
                if (getMultiplePhotosListener2 == null) {
                    return;
                }
                getMultiplePhotosListener2.getPhoto(jSONObject);
            } catch (Throwable th2) {
                th = th2;
                jSONObject = jSONObject2;
                getMultiplePhotosListener = this.mGetPhotoListener;
                if (getMultiplePhotosListener != null) {
                }
                throw th;
            }
            if (list.size() > 0) {
                JSONArray jSONArray = new JSONArray();
                Iterator<String> it = list.iterator();
                while (it.hasNext()) {
                    String next = it.next();
                    JSONObject jSONObject3 = new JSONObject();
                    BitmapFactory.Options options = new BitmapFactory.Options();
                    options.inJustDecodeBounds = true;
                    BitmapFactory.decodeFile(next, options);
                    File file = new File(next);
                    StringBuilder sb = new StringBuilder();
                    Iterator<String> it2 = it;
                    sb.append(ck0.w());
                    JSONObject jSONObject4 = jSONObject2;
                    String str4 = str3;
                    sb.append(System.currentTimeMillis());
                    sb.append(".png");
                    File file2 = new File(sb.toString());
                    ThumbnailUtils.createCompress(this.ctx, file, file2);
                    try {
                        FileInputStream fileInputStream = new FileInputStream(file2);
                        byte[] bArr = new byte[(int) file2.length()];
                        fileInputStream.read(bArr);
                        fileInputStream.close();
                        str = new String(Base64.encode(bArr, 2));
                    } catch (Exception e7) {
                        e7.printStackTrace();
                        str = "";
                    }
                    String substring = options.outMimeType.substring(options.outMimeType.indexOf("/") + 1);
                    StringBuilder sb2 = new StringBuilder();
                    if (bk0.ce) {
                        str2 = "data:image/" + substring + ";base64,";
                    } else {
                        str2 = "";
                    }
                    sb2.append(str2);
                    sb2.append(str);
                    jSONObject3.put("image", sb2.toString());
                    jSONObject3.put("imageType", substring);
                    jSONObject3.put("imageName", next);
                    jSONArray.put(jSONObject3);
                    jSONObject2 = jSONObject4;
                    it = it2;
                    str3 = str4;
                }
                jSONObject = jSONObject2;
                jSONObject.put("status", "1");
                jSONObject.put(str3, jSONArray);
                getMultiplePhotosListener2 = this.mGetPhotoListener;
                if (getMultiplePhotosListener2 == null) {
                    return;
                }
                getMultiplePhotosListener2.getPhoto(jSONObject);
            }
        }
        jSONObject = jSONObject2;
        JSONArray jSONArray2 = new JSONArray();
        JSONObject jSONObject5 = new JSONObject();
        jSONObject5.put("image", "");
        jSONObject5.put("imageType", "");
        jSONObject5.put("imageName", "");
        jSONArray2.put(jSONObject5);
        jSONObject.put("images", jSONArray2);
        jSONObject.put("status", "0");
        getMultiplePhotosListener2 = this.mGetPhotoListener;
        if (getMultiplePhotosListener2 == null) {
        }
        getMultiplePhotosListener2.getPhoto(jSONObject);
    }
}