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

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


package com.tencent.mobileqq.maproam.widget;

import android.app.Dialog;
import android.content.Context;
import android.graphics.drawable.ColorDrawable;
import android.os.Handler;
import android.os.Looper;
import android.text.InputFilter;
import android.text.TextUtils;
import android.view.View;
import android.view.WindowManager;
import android.view.inputmethod.InputMethodManager;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.ListAdapter;
import android.widget.TextView;
import com.tencent.mobileqq.activity.NearPeopleFilterActivity;
import com.tencent.mobileqq.app.ThreadManager;
import com.tencent.mobileqq.app.utils.SmsContent;
import com.tencent.mobileqq.maproam.data.LocationDetail;
import com.tencent.mobileqq.utils.JumpAction;
import com.tencent.mobileqq.utils.ReverseGeocode;
import com.tencent.qphone.base.util.QLog;
import com.tencent.tim.R;
import com.tencent.widget.AdapterView;
import com.tencent.widget.XListView;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.List;
import org.apache.http.HttpVersion;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.conn.params.ConnManagerParams;
import org.apache.http.conn.params.ConnPerRouteBean;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.params.BasicHttpParams;
import org.apache.http.params.HttpConnectionParams;
import org.apache.http.params.HttpProtocolParams;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
public class RoamSearchDialog extends Dialog implements View.OnClickListener, AdapterView.OnItemClickListener {
    public static final int f90256a = 10;
    public static final String f25042a = RoamSearchDialog.class.getSimpleName();
    public static final int f90257b = 20000;
    public static final int f90258c = 10000;
    public static final int d = 8192;
    public static final int e = 10;
    public static final int f = 20000;
    public static final int g = 10000;
    public static final int h = 0;
    public static final int i = 1;
    public static final int j = 5;
    public long f25043a;
    public Context f25044a;
    public Button f25045a;
    public EditText f25046a;
    public ImageButton f25047a;
    public TextView f25048a;
    public OnRoamResultObserver f25049a;
    public OnSearchResultItemClick f25050a;
    public XListView f25051a;
    public List f25052a;
    public sjo f25053a;
    public String f25054b;
    public int k;

    public interface OnRoamResultObserver {
        void a(int i, String str);

        void a(int i, List list);
    }

    public interface OnSearchResultItemClick {
        void a(AdapterView adapterView, View view, int i, LocationDetail locationDetail);
    }

    public RoamSearchDialog(Context context) {
        super(context);
        this.f25052a = new ArrayList();
        this.f25054b = "北京";
        this.k = 1;
        this.f25044a = context;
        requestWindowFeature(1);
        getWindow().setSoftInputMode(36);
        getWindow().setBackgroundDrawable(new ColorDrawable());
        setContentView(R.layout.f56780name_res_0x7f0301b3);
        WindowManager.LayoutParams attributes = getWindow().getAttributes();
        attributes.x = 0;
        attributes.y = 0;
        attributes.width = -1;
        attributes.windowAnimations = 16973824;
        attributes.gravity = 51;
        b();
        c();
        d();
        e();
    }

    private void b() {
        this.f25051a = (XListView) findViewById(R.id.f48853search_result_list);
        this.f25051a.setOnItemClickListener(this);
        this.f25053a = new sjo(this);
        this.f25051a.setAdapter((ListAdapter) this.f25053a);
        this.f25051a.setOnTouchListener(new sjg(this));
        this.f25051a.setOnScrollListener(new sjh(this));
        this.f25048a = (TextView) findViewById(R.id.f48854name_res_0x7f0906f2);
        this.f25048a.setCompoundDrawables(null, null, null, null);
        this.f25048a.setText(R.string.f63745name_res_0x7f0a14e0);
    }

    private void c() {
        this.f25046a = (EditText) findViewById(R.id.f48670et_search_keyword);
        this.f25046a.setFilters(new InputFilter[]{new InputFilter.LengthFilter(15)});
        this.f25046a.setHint(R.string.f65639name_res_0x7f0a1c4b);
        this.f25046a.addTextChangedListener(new sji(this));
        this.f25046a.setImeOptions(3);
        sjm sjmVar = new sjm(this, null);
        this.f25046a.setOnEditorActionListener(sjmVar);
        this.f25046a.setOnKeyListener(sjmVar);
        this.f25046a.setSelection(0);
        this.f25046a.requestFocus();
    }

    private void d() {
        this.f25047a = (ImageButton) findViewById(R.id.f51612ib_clear_text);
        this.f25047a.setOnClickListener(this);
    }

    private void e() {
        this.f25045a = (Button) findViewById(R.id.f48669btn_cancel_search);
        this.f25045a.setVisibility(0);
        this.f25045a.setOnClickListener(this);
    }

    @Override
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.f48669btn_cancel_search:
                dismiss();
                return;
            case R.id.f51612ib_clear_text:
                if (this.f25046a != null) {
                    this.f25046a.setText("");
                    return;
                }
                return;
            default:
                return;
        }
    }

    public void a(String str, String str2, int i2, int i3) {
        if (QLog.isColorLevel()) {
            QLog.i(f25042a, 2, "search poi, currentKeyword = " + str + ", region = " + str2);
        }
        if (i3 == 1) {
            this.f25052a.clear();
            if (this.f25053a != null) {
                this.f25053a.notifyDataSetChanged();
            }
        }
        ThreadManager.a(new sjj(this, str, str2, i2, i3), 5, null, false);
    }

    public void b(String str, String str2, int i2, int i3) {
        String str3;
        IOException e2;
        int i4;
        BufferedReader bufferedReader;
        if (TextUtils.isEmpty(str2)) {
            str2 = "北京";
        }
        String str4 = "http://apis.map.qq.com/ws/place/v1/search/?keyword=" + URLEncoder.encode(str) + "&boundary=region(" + URLEncoder.encode(str2) + ")&key=JHXBZ-SCQRG-VKWQP-IRKOM-C6Z5S-XWBE3&page_size=" + i2 + "&page_index=" + i3;
        BasicHttpParams basicHttpParams = new BasicHttpParams();
        ConnManagerParams.setTimeout(basicHttpParams, (long) NearPeopleFilterActivity.f85193a);
        ConnManagerParams.setMaxConnectionsPerRoute(basicHttpParams, new ConnPerRouteBean(10));
        ConnManagerParams.setMaxTotalConnections(basicHttpParams, 10);
        HttpConnectionParams.setConnectionTimeout(basicHttpParams, 10000);
        HttpConnectionParams.setSoTimeout(basicHttpParams, 20000);
        HttpConnectionParams.setTcpNoDelay(basicHttpParams, true);
        HttpConnectionParams.setSocketBufferSize(basicHttpParams, 8192);
        HttpProtocolParams.setVersion(basicHttpParams, HttpVersion.HTTP_1_1);
        HttpProtocolParams.setUserAgent(basicHttpParams, "android-qzone");
        DefaultHttpClient defaultHttpClient = new DefaultHttpClient(basicHttpParams);
        ReverseGeocode.a(this.f25044a, (HttpClient) defaultHttpClient);
        try {
            bufferedReader = new BufferedReader(new InputStreamReader(defaultHttpClient.execute(new HttpGet(str4)).getEntity().getContent()));
            str3 = "";
        } catch (IOException e3) {
            str3 = "";
            e2 = e3;
        }
        while (true) {
            try {
                try {
                    String readLine = bufferedReader.readLine();
                    if (readLine != null) {
                        str3 = str3 + readLine;
                    }
                } catch (IOException e4) {
                    e2 = e4;
                    e2.printStackTrace();
                    break;
                    JSONObject jSONObject = new JSONObject(str3);
                    i4 = jSONObject.getInt("status");
                    String string = jSONObject.getString("message");
                    Handler handler = new Handler(Looper.getMainLooper());
                    if (i4 == 0) {
                    }
                }
                break;
            } catch (JSONException e5) {
                return;
            }
        }
        JSONObject jSONObject2 = new JSONObject(str3);
        i4 = jSONObject2.getInt("status");
        String string2 = jSONObject2.getString("message");
        Handler handler2 = new Handler(Looper.getMainLooper());
        if (i4 == 0) {
            if (QLog.isColorLevel()) {
                QLog.i(f25042a, 2, "getResultFromLocation falil, status = " + i4 + ", message = " + string2);
            }
            handler2.post(new sjk(this, i4, string2));
            return;
        }
        int i5 = jSONObject2.getInt("count");
        JSONArray jSONArray = jSONObject2.getJSONArray("data");
        ArrayList arrayList = new ArrayList();
        int length = jSONArray.length();
        for (int i6 = 0; i6 < length; i6++) {
            JSONObject optJSONObject = jSONArray.optJSONObject(i6);
            LocationDetail locationDetail = new LocationDetail();
            if (optJSONObject.has("id")) {
                locationDetail.f25028a = optJSONObject.getString("id");
            }
            if (optJSONObject.has("title")) {
                locationDetail.f25029b = optJSONObject.getString("title");
            }
            if (optJSONObject.has(SmsContent.f87933c)) {
                locationDetail.f90252c = optJSONObject.getString(SmsContent.f87933c);
            }
            if (optJSONObject.has("category")) {
                locationDetail.d = optJSONObject.getString("category");
            }
            if (optJSONObject.has("location")) {
                JSONObject jSONObject3 = optJSONObject.getJSONObject("location");
                if (jSONObject3.has(JumpAction.cy)) {
                    locationDetail.f90250a = jSONObject3.getDouble(JumpAction.cy);
                }
                if (jSONObject3.has("lng")) {
                    locationDetail.f90251b = jSONObject3.getDouble("lng");
                }
            }
            arrayList.add(locationDetail);
        }
        handler2.post(new sjl(this, arrayList, i5));
    }

    public void a(String str) {
        this.f25054b = str;
    }

    public void a(OnRoamResultObserver onRoamResultObserver) {
        this.f25049a = onRoamResultObserver;
    }

    public void a(OnSearchResultItemClick onSearchResultItemClick) {
        this.f25050a = onSearchResultItemClick;
    }

    public void a() {
        long currentTimeMillis = System.currentTimeMillis();
        if (currentTimeMillis - this.f25043a > 2000) {
            this.f25043a = currentTimeMillis;
            this.k = 1;
            a(this.f25046a.getText().toString(), this.f25054b, 5, this.k);
        }
    }

    @Override
    public void a(AdapterView adapterView, View view, int i2, long j2) {
        ListAdapter a2 = this.f25051a.a();
        if (this.f25053a != null && a2 != null && a2 == this.f25053a && this.f25053a.getItemViewType(i2) != 1) {
            LocationDetail locationDetail = (LocationDetail) this.f25053a.getItem(i2);
            if (this.f25050a != null && locationDetail != null) {
                this.f25050a.a(adapterView, view, i2, locationDetail);
                if (QLog.isColorLevel()) {
                    QLog.i(f25042a, 2, "current click location, lat = " + locationDetail.f90250a + ", lon = " + locationDetail.f90251b);
                }
            }
        }
    }

    @Override
    public void dismiss() {
        ((InputMethodManager) this.f25044a.getSystemService("input_method")).hideSoftInputFromWindow(this.f25046a.getWindowToken(), 0);
        this.f25052a.clear();
        if (this.f25053a != null) {
            this.f25053a.notifyDataSetChanged();
        }
        this.f25046a.setText("");
        this.f25051a.setVisibility(8);
        this.f25048a.setVisibility(8);
        try {
            super.dismiss();
        } catch (Exception e2) {
        }
    }
}