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

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


package com.tencent.mobileqq.troop.utils;

import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.text.TextUtils;
import android.widget.EditText;
import com.tencent.av.camera.QavCameraUsage;
import com.tencent.biz.common.util.HttpUtil;
import com.tencent.common.app.BaseApplicationImpl;
import com.tencent.common.config.AppSetting;
import com.tencent.mobileqq.app.AppConstants;
import com.tencent.mobileqq.app.BaseActivity;
import com.tencent.mobileqq.filemanager.util.FileUtil;
import com.tencent.mobileqq.msf.core.NetConnInfoCenter;
import com.tencent.mobileqq.service.message.MessageCache;
import com.tencent.mobileqq.statistics.ReportController;
import com.tencent.mobileqq.text.EmotcationConstants;
import com.tencent.mobileqq.text.QQText;
import com.tencent.mobileqq.text.QQTextBuilder;
import com.tencent.mobileqq.troop.activity.TroopBarPublishUtils;
import com.tencent.mobileqq.troop.data.AudioInfo;
import com.tencent.mobileqq.troop.data.TroopBarPOI;
import com.tencent.mobileqq.troop.utils.HttpWebCgiAsyncTask;
import com.tencent.mobileqq.utils.httputils.HttpMsg;
import com.tencent.mobileqq.widget.QQToast;
import com.tencent.qphone.base.util.QLog;
import com.tencent.tim.R;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.Map;
import mqq.app.AppRuntime;
import mqq.manager.TicketManager;
import org.json.JSONException;
import org.json.JSONObject;
public class TroopBarUtils {
    public static final String A = "";
    protected static final String B = "刚刚";
    protected static final String C = "分钟前";
    protected static final String D = "MM-dd";
    protected static final String E = "HH:mm";
    protected static final String F = "昨天";
    protected static final String G = "前天";
    private static final String H = "&_wv=1031&_bid=128&platform=android&from=native&version=6.5.5";
    public static final int f94039a = 20;
    public static final String f32466a = "TroopBar";
    public static final int f94040b = 50;
    public static final String f32470b = "http://buluo.qq.com/cgi-bin/bar/";
    public static final int f94041c = -1;
    public static final String f32472c = "http://buluo.qq.com/cgi-bin/bar/page";
    protected static final int d = 60000;
    public static final String f32474d = "http://buluo.qq.com/cgi-bin/bar/user/fbar";
    protected static final int e = 86400000;
    public static final String f32475e = "http://buluo.qq.com/cgi-bin/bar/sign";
    protected static final int f = 1440;
    public static final String f32476f = "http://buluo.qq.com/cgi-bin/bar/get_category_post_by_page";
    protected static final int g = 2880;
    public static final String f32477g = "http://buluo.qq.com/cgi-bin/bar/get_best_post_by_page";
    public static final int h = 100000;
    public static final String f32478h = "http://buluo.qq.com/cgi-bin/bar/get_post_by_page";
    public static final int i = 100001;
    public static final String f32479i = "http://buluo.qq.com/cgi-bin/bar/jump?";
    public static final int j = 100003;
    public static final String f32480j = "http://buluo.qq.com/cgi-bin/bar/user/poilist";
    public static final int k = 100004;
    public static final String f32481k = "http://buluo.qq.com/cgi-bin/bar/mybarlist";
    public static final int l = 100012;
    public static final String f32482l = "http://buluo.qq.com/cgi-bin/bar/bar_publish_info";
    public static final int m = -1001;
    public static final String f32483m = "http://upload.buluo.qq.com/cgi-bin/bar/upload/image";
    public static final int n = -1002;
    public static final String f32484n = "http://upload.buluo.qq.com/cgi-bin/bar/upload/meida";
    public static final int o = 0;
    public static final String f32485o = "action";
    public static final int p = 1;
    public static final String f32486p = "info";
    public static final int q = 2;
    public static final String f32487q = "all_bar";
    public static final int r = 3;
    public static final String f32488r = "publish";
    public static final int s = 5;
    public static final String f32489s = "qqweb_index";
    public static final int t = 8;
    public static final String f32490t = "&_wv=1031";
    public static final int u = 9991;
    public static final String f32491u = "target=hot&_wv=1031";
    public static final int v = 9992;
    public static final String f32492v = "extparam";
    public static final int w = 9992;
    public static final String f32493w = "http://buluo.qq.com/cgi-bin/bar/jump?bid=%s";
    public static final String x = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCrkUA+dDEQT52svdheRw04+xrExuTvNj3g7pjcyUkH3+86FiYNhHtyWJc11BywUZ2Ey3RomCyTb/szl5qQEJqR7UC5z4mhLrhgXlbRI0BgmI/LhaMRsfskGM7ziyQ2ZpS0qbHX2xoum6ou/541/VePIwmcnIk6eWUx6GYnA4euZQIDAQAB";
    public static final String y = " ";
    public static final String z = "  ";
    protected static SimpleDateFormat f32467a = new SimpleDateFormat();
    public static Hashtable f32469a = new Hashtable();
    public static final HashMap f32468a = new HashMap();
    public static final HashMap f32471b = new HashMap();
    public static final HashMap f32473c = new HashMap();

    public class PublishDataCacheEntity {
        public int f94042a;
        public AudioInfo f32494a;
        public TroopBarPOI f32495a;
        public String f32496a;
        public ArrayList f32497a;
        public int f94043b;
        public String f32498b;
        public ArrayList f32499b;
        public int f94044c;
        public String f32500c;
        public int d;
        public String f32501d;
    }

    protected static void a(BaseActivity baseActivity, Bundle bundle, String str, int i2, Bundle bundle2, HttpWebCgiAsyncTask.Callback callback, String str2) {
        AppRuntime appRuntime = baseActivity.getAppRuntime();
        String account = appRuntime.getAccount();
        a(baseActivity, account, ((TicketManager) appRuntime.getManager(2)).getSkey(account), bundle, str, i2, bundle2, callback, str2);
    }

    public static void a(Context context, String str, String str2, Bundle bundle, String str3, int i2, Bundle bundle2, HttpWebCgiAsyncTask.Callback callback, String str4) {
        if (bundle != null && !TextUtils.isEmpty(str) && !TextUtils.isEmpty(str2)) {
            bundle.putString("version", AppSetting.g);
            bundle.putString("platform", "android");
            bundle.putString(HttpMsg.s, AppConstants.eJ);
            bundle.putString("Cookie", "uin=" + str + ";skey=" + str2);
            bundle.putString("Referer", "http://buluo.qq.com");
            HashMap hashMap = new HashMap();
            hashMap.put(HttpWebCgiAsyncTask.e, bundle);
            hashMap.put(HttpWebCgiAsyncTask.d, context.getApplicationContext());
            new HttpWebCgiAsyncTask(str3, str4, callback, i2, bundle2).execute(new HashMap[]{hashMap});
        } else if (QLog.isColorLevel()) {
            QLog.w(f32466a, 2, "httpGet skey is null!!!!!!!!!!!!!!!");
        }
    }

    public static void a(BaseActivity baseActivity, Bundle bundle, String str, int i2, Bundle bundle2, HttpWebCgiAsyncTask.Callback callback) {
        a(baseActivity, bundle, str, i2, bundle2, callback, "GET");
    }

    public static void b(BaseActivity baseActivity, Bundle bundle, String str, int i2, Bundle bundle2, HttpWebCgiAsyncTask.Callback callback) {
        a(baseActivity, bundle, str, i2, bundle2, callback, "POST");
    }

    public static final String a(String str) {
        if (TextUtils.isEmpty(str)) {
            return "";
        }
        try {
            long longValue = 1000 * Long.valueOf(str).longValue();
            long serverTime = NetConnInfoCenter.getServerTime();
            if (serverTime <= 0) {
                serverTime = (int) MessageCache.a();
            }
            long j2 = serverTime * 1000;
            Calendar calendar = Calendar.getInstance();
            Calendar calendar2 = Calendar.getInstance();
            calendar.setTimeInMillis(longValue);
            calendar2.setTimeInMillis(j2);
            long j3 = longValue / 86400000;
            long j4 = longValue / 60000;
            long j5 = longValue / 1000;
            long j6 = j2 / 60000;
            long j7 = j2 / 1000;
            long j8 = j2 / 86400000;
            if (calendar.before(calendar2)) {
                long j9 = j8 - j3;
                if (j9 > 2) {
                    f32467a.applyPattern(D);
                    return f32467a.format(calendar.getTime());
                } else if (j9 == 2) {
                    f32467a.applyPattern(E);
                    return "前天" + f32467a.format(calendar.getTime());
                } else if (j9 == 1) {
                    long j10 = j6 - j4;
                    if (j7 - j5 < 60) {
                        return "刚刚";
                    }
                    if (j10 < 60) {
                        return j10 + "分钟前";
                    }
                    f32467a.applyPattern(E);
                    return "昨天" + f32467a.format(calendar.getTime());
                } else {
                    long j11 = j6 - j4;
                    if (j7 - j5 < 60) {
                        return "刚刚";
                    }
                    if (j11 < 60) {
                        return j11 + "分钟前";
                    }
                    f32467a.applyPattern(E);
                    return f32467a.format(calendar.getTime());
                }
            }
            f32467a.applyPattern(D);
            return f32467a.format(calendar.getTime());
        } catch (Exception e2) {
            return "";
        }
    }

    public static byte[] a(Object obj) {
        try {
            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
            ObjectOutputStream objectOutputStream = new ObjectOutputStream(byteArrayOutputStream);
            objectOutputStream.writeObject(obj);
            byte[] byteArray = byteArrayOutputStream.toByteArray();
            objectOutputStream.flush();
            objectOutputStream.close();
            byteArrayOutputStream.close();
            return byteArray;
        } catch (IOException e2) {
            e2.printStackTrace();
            return null;
        }
    }

    public static final void a(String str, String str2, String str3) {
        a("tribe_hp", str, str2, str3, "", "");
    }

    public static final void a(String str, String str2, String str3, String str4, String str5, String str6) {
        a(ReportController.q, str, str2, str3, str4, str5, str6);
    }

    public static final void a(String str, String str2, String str3, String str4, String str5, String str6, String str7) {
        if (TextUtils.isEmpty(str) || TextUtils.isEmpty(str5) || !str.equals(ReportController.q) || !str5.equals(TroopBarPublishUtils.X)) {
            ReportController.b(null, "dc01332", str, "", str2, str3, 0, 0, str4, str5, str6, str7);
        }
    }

    public static final void b(String str, String str2, String str3, String str4, String str5, String str6) {
        ReportController.b(null, "dc01332", ReportController.q, "", str, str2, 0, 0, str3, str4, str5, str6);
    }

    public static final JSONObject a(String str, Context context, String str2, String str3, String str4, Map map) {
        if (FileUtil.m6632b(str2)) {
            HashMap hashMap = new HashMap();
            hashMap.put("Connection", "keep-alive");
            hashMap.put("Referer", "http://www.qq.com");
            HashMap hashMap2 = new HashMap();
            hashMap2.put("file", str2);
            Map hashMap3 = map == null ? new HashMap() : map;
            hashMap3.put("file", str2);
            long currentTimeMillis = System.currentTimeMillis();
            String a2 = HttpUtil.a(str, str3, str4, hashMap3, hashMap2, hashMap);
            if (QLog.isColorLevel()) {
                QLog.d(f32466a, 2, "singleUploadImage t = " + (System.currentTimeMillis() - currentTimeMillis) + ", path = " + str2 + ", size = " + FileUtil.a(str2));
            }
            if (TextUtils.isEmpty(a2)) {
                return null;
            }
            try {
                JSONObject jSONObject = new JSONObject(a2);
                if (jSONObject.optInt(HttpWebCgiAsyncTask.f94008b, -1) == 0 || jSONObject.optInt("ret", -1) == 0) {
                    return jSONObject.getJSONObject("result");
                }
            } catch (JSONException e2) {
                if (QLog.isColorLevel()) {
                    QLog.d(f32466a, 2, e2.getMessage());
                }
            }
        }
        return null;
    }

    public static final String a(EditText editText) {
        QQTextBuilder qQTextBuilder;
        QQText.EmotcationSpan[] emotcationSpanArr;
        if (editText == null) {
            return null;
        }
        if ((editText.getEditableText() instanceof QQTextBuilder) && (qQTextBuilder = (QQTextBuilder) editText.getEditableText()) != null) {
            int length = qQTextBuilder.length();
            char[] cArr = new char[length];
            qQTextBuilder.getChars(0, length, cArr, 0);
            StringBuffer stringBuffer = new StringBuffer();
            stringBuffer.append(cArr);
            int i2 = 0;
            for (QQText.EmotcationSpan emotcationSpan : (QQText.EmotcationSpan[]) qQTextBuilder.getSpans(0, length, QQText.EmotcationSpan.class)) {
                if (emotcationSpan.f30403c == 1) {
                    int spanStart = qQTextBuilder.getSpanStart(emotcationSpan);
                    int spanEnd = qQTextBuilder.getSpanEnd(emotcationSpan);
                    String str = EmotcationConstants.f30354a[emotcationSpan.f30399a & Integer.MAX_VALUE];
                    stringBuffer.replace(spanStart + i2, spanEnd + i2, str);
                    i2 += str.length() - (spanEnd - spanStart);
                } else if (emotcationSpan.f30403c == 2) {
                    int spanStart2 = qQTextBuilder.getSpanStart(emotcationSpan);
                    int spanEnd2 = qQTextBuilder.getSpanEnd(emotcationSpan);
                    String mo8406a = emotcationSpan.mo8406a();
                    stringBuffer.replace(spanStart2 + i2, spanEnd2 + i2, mo8406a);
                    i2 += mo8406a.length() - (spanEnd2 - spanStart2);
                }
            }
            return stringBuffer.toString();
        }
        return editText.getEditableText().toString();
    }

    public static final Uri a(BaseActivity baseActivity, String str, int i2) {
        if (QavCameraUsage.b(BaseApplicationImpl.getContext())) {
            return null;
        }
        File file = new File(str);
        if ((file.exists() ? true : file.mkdirs()) && file.canWrite()) {
            Uri fromFile = Uri.fromFile(new File(AppConstants.bH + System.currentTimeMillis() + ".jpg"));
            Intent intent = new Intent("android.media.action.IMAGE_CAPTURE");
            intent.putExtra("output", fromFile);
            intent.putExtra("android.intent.extra.videoQuality", 100);
            baseActivity.startActivityForResult(intent, i2);
            return fromFile;
        } else if (baseActivity == null || baseActivity.isFinishing()) {
            return null;
        } else {
            QQToast.a(baseActivity, (int) R.string.f61009name_res_0x7f0a0a2e, 1).b(baseActivity.getTitleBarHeight());
            return null;
        }
    }

    public static int a(String str, char c2) {
        if (str != null) {
            int i2 = 0;
            for (int i3 = 0; i3 < str.length(); i3++) {
                if (str.charAt(i3) == c2) {
                    i2++;
                }
            }
            return i2;
        }
        return 0;
    }
}