得物.apk(点击下载) / TencentSearch.java


package com.tencent.lbssearch;

import android.content.Context;
import android.text.TextUtils;
import com.tencent.lbssearch.httpresponse.BaseObject;
import com.tencent.lbssearch.httpresponse.UrlConstant;
import com.tencent.lbssearch.object.RequestParams;
import com.tencent.lbssearch.object.param.Address2GeoParam;
import com.tencent.lbssearch.object.param.DistrictChildrenParam;
import com.tencent.lbssearch.object.param.DistrictSearchParam;
import com.tencent.lbssearch.object.param.Geo2AddressParam;
import com.tencent.lbssearch.object.param.ParamObject;
import com.tencent.lbssearch.object.param.RoutePlanningParam;
import com.tencent.lbssearch.object.param.SearchParam;
import com.tencent.lbssearch.object.param.StreetViewParam;
import com.tencent.lbssearch.object.param.SuggestionParam;
import com.tencent.lbssearch.object.param.TranslateParam;
import com.tencent.lbssearch.object.result.Address2GeoResultObject;
import com.tencent.lbssearch.object.result.DistrictResultObject;
import com.tencent.lbssearch.object.result.Geo2AddressResultObject;
import com.tencent.lbssearch.object.result.SearchResultObject;
import com.tencent.lbssearch.object.result.StreetViewResultObject;
import com.tencent.lbssearch.object.result.SuggestionResultObject;
import com.tencent.lbssearch.object.result.TranslateResultObject;
import com.tencent.map.tools.Util;
import com.tencent.map.tools.net.http.HttpResponseListener;
import com.tencent.mapsdk.internal.gw;

/* compiled from: TMS */
public class TencentSearch implements UrlConstant {
    private final String mApiKey;
    private final Context mContext;
    private boolean mIsDebuggable;
    private final String mSecretKey;

    public TencentSearch(Context context) {
        this(context, null);
    }

    private <T extends BaseObject> void doHttpGet(String str, ParamObject paramObject, Class<T> cls, HttpResponseListener<T> httpResponseListener) {
        if (paramObject != null && paramObject.checkParams()) {
            String str2 = this.mApiKey;
            if (TextUtils.isEmpty(str2)) {
                str2 = Util.getMetaKey(this.mContext, "TencentMapSDK");
                if (TextUtils.isEmpty(str2)) {
                    if (httpResponseListener != null) {
                        httpResponseListener.onFailure(-1, "请申请并填写开发者密钥", null);
                        return;
                    }
                    return;
                }
            }
            RequestParams buildParameters = paramObject.buildParameters();
            if (buildParameters != null) {
                buildParameters.add("key", str2);
                buildParameters.add("output", "json");
            } else {
                buildParameters = new RequestParams();
            }
            buildParameters.add("__suid", gw.d());
            buildParameters.add("__pf", "android");
            buildParameters.add("__chan", "search");
            buildParameters.add("__pid", Util.getRawAppName(this.mContext));
            buildParameters.add("__psv", Util.getAppVersion(this.mContext));
            buildParameters.add("__ver", "1.0.0");
            buildParameters.setDebuggable(this.mIsDebuggable);
            HttpProvider.get(this.mContext, str, buildParameters, cls, this.mSecretKey, httpResponseListener);
        } else if (httpResponseListener != null) {
            httpResponseListener.onFailure(-1, "参数缺少必要字段", null);
        }
    }

    public void address2geo(Address2GeoParam address2GeoParam, HttpResponseListener httpResponseListener) {
        doHttpGet("https://apis.map.qq.com/ws/geocoder/v1", address2GeoParam, Address2GeoResultObject.class, httpResponseListener);
    }

    public void geo2address(Geo2AddressParam geo2AddressParam, HttpResponseListener httpResponseListener) {
        doHttpGet("https://apis.map.qq.com/ws/geocoder/v1", geo2AddressParam, Geo2AddressResultObject.class, httpResponseListener);
    }

    public void getDistrictChildren(DistrictChildrenParam districtChildrenParam, HttpResponseListener httpResponseListener) {
        doHttpGet("https://apis.map.qq.com/ws/district/v1/getchildren", districtChildrenParam, DistrictResultObject.class, httpResponseListener);
    }

    public void getDistrictList(HttpResponseListener httpResponseListener) {
        doHttpGet("https://apis.map.qq.com/ws/district/v1/list", new DistrictChildrenParam(), DistrictResultObject.class, httpResponseListener);
    }

    public void getDistrictSearch(DistrictSearchParam districtSearchParam, HttpResponseListener httpResponseListener) {
        doHttpGet("https://apis.map.qq.com/ws/district/v1/search", districtSearchParam, DistrictResultObject.class, httpResponseListener);
    }

    public void getRoutePlan(RoutePlanningParam routePlanningParam, HttpResponseListener httpResponseListener) {
        doHttpGet(routePlanningParam.getUrl(), routePlanningParam, routePlanningParam.getResultClass(), httpResponseListener);
    }

    public void getpano(StreetViewParam streetViewParam, HttpResponseListener httpResponseListener) {
        doHttpGet("https://apis.map.qq.com/ws/streetview/v1/getpano", streetViewParam, StreetViewResultObject.class, httpResponseListener);
    }

    public void search(SearchParam searchParam, HttpResponseListener httpResponseListener) {
        doHttpGet("https://apis.map.qq.com/ws/place/v1/search", searchParam, SearchResultObject.class, httpResponseListener);
    }

    public void setDebuggable(boolean z) {
        this.mIsDebuggable = z;
    }

    public void suggestion(SuggestionParam suggestionParam, HttpResponseListener httpResponseListener) {
        doHttpGet("https://apis.map.qq.com/ws/place/v1/suggestion", suggestionParam, SuggestionResultObject.class, httpResponseListener);
    }

    public void translate(TranslateParam translateParam, HttpResponseListener httpResponseListener) {
        doHttpGet("https://apis.map.qq.com/ws/coord/v1/translate", translateParam, TranslateResultObject.class, httpResponseListener);
    }

    public TencentSearch(Context context, String str) {
        this(context, null, str);
    }

    public TencentSearch(Context context, String str, String str2) {
        this.mContext = context;
        this.mApiKey = str;
        this.mSecretKey = str2;
        gw.a(context, str, context.getPackageName(), "");
    }
}