package com.jiuqi.njt.ui; import java.lang.reflect.UndeclaredThrowableException; import java.util.ArrayList; import java.util.Arrays; import java.util.Date; import android.annotation.TargetApi; import android.app.Activity; import android.app.AlertDialog; import android.app.Dialog; import android.app.ProgressDialog; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.graphics.drawable.Drawable; import android.location.LocationManager; import android.os.AsyncTask; import android.os.Build; import android.os.Bundle; import android.text.Editable; import android.text.TextWatcher; import android.util.Log; import android.view.View; import android.view.WindowManager; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.CheckBox; import android.widget.CompoundButton; import android.widget.CompoundButton.OnCheckedChangeListener; import android.widget.EditText; import android.widget.ImageView; import com.amap.api.services.core.LatLonPoint; import com.amap.api.services.core.PoiItem; import com.amap.api.services.poisearch.PoiItemDetail; import com.amap.api.services.poisearch.PoiResult; import com.amap.api.services.poisearch.PoiSearch; import com.amap.api.services.poisearch.PoiSearch.OnPoiSearchListener; import com.amap.api.services.poisearch.PoiSearch.SearchBound; import com.jiuqi.mobile.nigo.comeclose.bean.PoiSortType; import com.jiuqi.mobile.nigo.comeclose.bean.app.gps.UserPositionBean; import com.jiuqi.mobile.nigo.comeclose.bean.base.AdminAreaBean; import com.jiuqi.mobile.nigo.comeclose.exception.LoginException; import com.jiuqi.mobile.nigo.comeclose.manager.app.IPositionManager; import com.jiuqi.mobile.nigo.comeclose.manager.app.SelectPoiKey; import com.jiuqi.mobile.nigo.comeclose.ws.client.ClientContext; import com.jiuqi.njt.R; import com.jiuqi.njt.adapter.PoiSearchResultAdapter; import com.jiuqi.njt.data.MyApp; import com.jiuqi.njt.data.OptsharepreInterface; import com.jiuqi.njt.model.CModuleBean; import com.jiuqi.njt.model.ModuleType; import com.jiuqi.njt.util.Constants; import com.jiuqi.njt.util.DateUtil; import com.jiuqi.njt.util.ReturnObject; import com.jiuqi.njt.util.TitleBarUtil; import com.jiuqi.njt.util.UIUtil; import com.jiuqi.njt.widget.DialogWithList; import com.jiuqi.njt.widget.NjtTitleBar; import com.jiuqi.njt.widget.ProgressDialogStyle; import com.jiuqi.njt.widget.XListView; import com.jiuqi.njt.widget.XListView.IXListViewListener; import com.jiuqi.njt.widget.XListView.ListFooteState; /**============================================================ * 版权: 久其软件 版权所有 (c) * 包: * 修改记录: * 日期 作者 内容 * ============================================================= * 2013-6-13 liyue * ============================================================*/ /** * <p> * 位置查询结果界面 * </p> * * <p> * Copyright: 版权所有 (c)<br> * Company: 久其 * </p> * * @author liyue * @version 2013-6-13 */ @TargetApi(Build.VERSION_CODES.FROYO) public class PoiSearchResultActivity extends Activity implements IXListViewListener, OnClickListener { private ProgressDialog progDialog = null;// 搜索时进度条 private PoiResult poiResult; // poi返回的结果 private PoiSearch.Query query;// Poi查询条件类 private PoiSearch poiSearch;// POI搜索 // ****************************************** private OptsharepreInterface sharePre;// 获取定位信息的类 private Context context = this; private String tag = this.getClass().getName(); private Button btnRange; private Button btnPoiType; private Button btnSortType; private Button btnSendSms; private Button btnPrev; private Button btnNext; private CheckBox cbSelectAll; private String ChangeOld = "维修点"; /** * 高德定位 */ private LocationManager locationManager; private static final String[] strsRange = Constants.strPoiRange; private static final double[] rangeValues = Constants.poiRangeValues; // private static final String[] strsPoiType = Constants.strPoiTypes; private static final String[] strsSortType = Constants.strPoiSortType; public static final PoiSortType[] poiSortTypeValues = new PoiSortType[] { PoiSortType.RANGE_ASC, PoiSortType.RANGE_ASC, PoiSortType.RANGE_DESC }; /* * idxRange 搜索范围 idxPoiType 搜索类型 idxSortType 排序方式 */ private int idxRange = 0; private int idxPoiType = 0; private int idxSortType = 0; private ArrayList<UserPositionBean> reslist = new ArrayList<UserPositionBean>(); private UserPositionBean[] resArray = new UserPositionBean[] {}; // 结果项 // private boolean showDialog = true; /** * 翻页,开始索引值和总页数 */ private long startIndex = 0; private int totalCount = 0; // 定位后获取到的经纬度 private double longitude; private double latitude; private XListView listView; private PoiSearchResultAdapter listAdapter; public static Drawable IMG_BG_CHECKED = null; public static Drawable IMG_BG = null; private MyApp application; private View poi_search_method; private int searchRange = 1000;// 默認搜索範圍 private int currentPage = 1;// 當前頁默認值 private CModuleBean moduleBean = null; private Button backLeft; private Button actionRight; private EditText etSearch; private ImageView ivDeleteText; private int tvAction; private String name = ""; // 关键字 private boolean isFirst = true; // 信息查询是不是第一次需要显示进度条 private AdminAreaBean xzqh; // 所在地 private String TAG = this.getClass().getName(); private String Character = "维修点"; private String Range ="默认"; private String SortType = "由近到远"; private String title; private NjtTitleBar njtTitleBar; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); doinit(); } private void doinit() { initParam(); // 框架布局 initWidgets(); initListeners(); initUI(); } private void initParam() { IMG_BG_CHECKED = this.getResources().getDrawable( R.drawable.img_checkbox_checked); IMG_BG = this.getResources().getDrawable(R.drawable.img_checkbox); application = (MyApp) getApplication(); sharePre = new OptsharepreInterface(PoiSearchResultActivity.this); // 接收从上个页面传来的查询类别code和坐标 moduleBean = (CModuleBean) getIntent().getSerializableExtra( Constants.PARAM_MODULEBEAN); if (null != moduleBean) { latitude = application.getLat(); longitude = application.getLon(); switch (moduleBean.getModuleFlag()) { case zbjs: idxPoiType = 3; break; case zbhzs: idxPoiType = 0; break; case zbjyz: idxPoiType = 2; break; case zbwxd: idxPoiType = 0; break; case zbjxs: idxPoiType = 1; break; case zbnjj: idxPoiType = 0; break; case zbjz: idxPoiType = 0; break; // case zbyh: // idxPoiType = 4; // break; default: break; } } else { idxPoiType = getIntent().getIntExtra(Constants.PARAM_ID, 0); latitude = getIntent().getDoubleExtra(Constants.PARAM_LATITUDE, Constants.ZHENGZHOU.getLatitude()); longitude = getIntent().getDoubleExtra(Constants.PARAM_LONGITUDE, Constants.ZHENGZHOU.getLongitude()); } } private void initWidgets() { getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE | WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN); setContentView(R.layout.poi_search_result); if (idxPoiType == 3) { title = "搜索结果"; findViewById(R.id.topop).setVisibility(View.GONE); backLeft = (Button) findViewById(R.id.backleft); actionRight = (Button) findViewById(R.id.actionright); etSearch = (EditText) findViewById(R.id.etSearch); ivDeleteText = (ImageView) findViewById(R.id.ivDeleteText); } else { // View rlTitleBar = findViewById(R.id.titleBarStub); // njtTitleBar = TitleBarUtil.createTitleBar(this, rlTitleBar,title, // new OnClickListener() { // // @Override // public void onClick(View v) { // PoiSearchResultActivity.this.finish(); // } // }); title = Range+"-"+Character+"-"+SortType; } View rlTitleBar = findViewById(R.id.titleBarStub); njtTitleBar = TitleBarUtil.createTitleBar(this, rlTitleBar,title, new OnClickListener() { @Override public void onClick(View v) { PoiSearchResultActivity.this.finish(); } }); btnRange = (Button) findViewById(R.id.btnRange); // 搜索类别的点击按钮 btnPoiType = (Button) findViewById(R.id.btnCharacter); btnSortType = (Button) findViewById(R.id.btnSortType); listView = (XListView) findViewById(R.id.listView); cbSelectAll = (CheckBox) findViewById(R.id.cbSelectAll); btnSendSms = (Button) findViewById(R.id.btnSendSms); btnPrev = (Button) findViewById(R.id.btnPrev); btnNext = (Button) findViewById(R.id.btnNext); poi_search_method = findViewById(R.id.linFillterBar); // if (application.getProvince() != null) { // xzqh = new AdminAreaBean(); // xzqh.setProvinceName(application.getProvince()); // xzqh.setCode(application.getCode()); // Log.e(TAG, xzqh.toString()); // } } private void initListeners() { cbSelectAll.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (buttonView.isChecked()) { cbSelectAll.setText(" 全不选"); if (null != listAdapter) { listAdapter.selectAll(); } } else { cbSelectAll.setText(" 全选"); if (null != listAdapter) { listAdapter.deSelectAll(); } } } }); btnRange.setOnClickListener(this); btnPoiType.setOnClickListener(this); btnSortType.setOnClickListener(this); btnSendSms.setOnClickListener(this); btnPrev.setOnClickListener(this); btnNext.setOnClickListener(this); listView.setPullLoadEnable(true); listView.setXListViewListener(this); // setFootHintText(); // if (idxPoiType == 3) { // backLeft.setOnClickListener(this); // actionRight.setOnClickListener(this); // ivDeleteText.setOnClickListener(this); // erSearchListener(); // } } // private void erSearchListener() { // etSearch.addTextChangedListener(new TextWatcher() { // // @Override // public void onTextChanged(CharSequence s, int start, int before, // int count) { // // } // // @Override // public void beforeTextChanged(CharSequence s, int start, int count, // int after) { // } // // @Override // public void afterTextChanged(Editable s) { // if (s.length() == 0) { // ivDeleteText.setVisibility(View.INVISIBLE); // actionRight.setText("筛选"); // tvAction = 0; // } else { // ivDeleteText.setVisibility(View.VISIBLE); // actionRight.setText("搜索"); // tvAction = 1; // } // } // }); // } // 设置搜索的选项 private void initUI() { setRange(); setPoiType(); setSortType(); doQuery(); /** * 如果是查询周边机手,隐藏筛选条件框 */ if (idxPoiType == 3) { poi_search_method.setVisibility(View.GONE); } } @Override public void onClick(View v) { AlertDialog.Builder builder = new AlertDialog.Builder(this); DialogWithList.Builder dialog = null; switch (v.getId()) { case R.id.btnRange: dialog = new DialogWithList.Builder(this); dialog.setTitle("搜索范围"); dialog.setPositiveButton("取消", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); dialog.setItems(strsRange, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (idxPoiType == 4) { currentPage = 1;// 初始化當前頁的值 searchRangePOI(dialog, which, currentPage - 1);// POI搜索按范围查询 } else { idxRange = which; setRange(); reslist.clear(); startIndex = 0; doQuery(); dialog.dismiss(); } Range = strsRange[which]; title = Range+"-"+Character+"-"+SortType; njtTitleBar.getTvTitle().setText(title); } }); dialog.create().show(); break; // *****搜索类别:查银行, 加油站,维修点 case R.id.btnCharacter: dialog = new DialogWithList.Builder(this); dialog.setTitle("搜索类别"); dialog.setPositiveButton("取消", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // TODO Auto-generated method stub dialog.dismiss(); } }); // * 查询的数据类型名称****** dialog.setItems(UIUtil.getPoiSearchTypes(), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // TODO Auto-generated method stub if (which == 3) { idxPoiType = 4; setPoiType(); // 查询前清空数据 reslist.clear(); // searchRange = 1000;// 搜索范围,默认1000米一内 currentPage = 1;// 初始化當前頁的值 doSearchQuery(searchRange, 0, currentPage - 1); dialog.dismiss(); } else { idxPoiType = which; setPoiType(); // 查询前清空数据 reslist.clear(); startIndex = 0; doQuery(); dialog.dismiss(); } Character = UIUtil.getPoiSearchTypes().get(which); title = Range+"-"+Character+"-"+SortType; njtTitleBar.getTvTitle().setText(title); } }); dialog.create().show(); break; case R.id.btnSortType: dialog = new DialogWithList.Builder(this); dialog.setTitle("排序方式"); dialog.setPositiveButton("取消", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // TODO Auto-generated method stub dialog.dismiss(); } }); dialog.setItems(strsSortType, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // TODO Auto-generated method stub if (idxPoiType == 4) { currentPage = 1;// 初始化當前頁的值 searchOrder(dialog, which, currentPage - 1); } else { idxSortType = which; setSortType(); reslist.clear(); startIndex = 0; doQuery(); dialog.dismiss(); } SortType = strsSortType[which]; title = Range+"-"+Character+"-"+SortType; njtTitleBar.getTvTitle().setText(title); } }); dialog.create().show(); break; case R.id.btnSendSms: builder.setMessage("您要群发短信吗?"); builder.setPositiveButton("是", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { String[] mobiles = listAdapter.getSelectedMobiles(); if (mobiles.length > 0) { UIUtil.sendSmsUi(PoiSearchResultActivity.this, mobiles, ""); } else { UIUtil.showMsg(PoiSearchResultActivity.this, "请先在列表中选择一项"); } } }); builder.setNegativeButton("否", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }); builder.create().show(); break; case R.id.btnPrev: UIUtil.showMsg(this, "已显示全部信息,无更多内容"); break; case R.id.btnNext: UIUtil.showMsg(this, "已显示全部信息,无更多内容"); break; // case R.id.backleft: // this.finish(); // break; // case R.id.actionright: // if (tvAction == 0) { // UIUtil.requestQuery(PoiSearchResultActivity.this, null, // moduleBean.getModuleFlag()); // } else { // isFirst = true; // startIndex = 0; // name = etSearch.getText().toString().trim(); // tvAction = 0; // actionRight.setText("筛选"); // doQuery();//去查詢的 // } // break; // case R.id.ivDeleteText: // etSearch.setText(""); // break; default: break; } } private void setRange() { // btnRange.setText(strsRange[idxRange]); btnRange.setText("搜索范围"); } // 找到的搜索类别 private void setPoiType() { // btnPoiType.setText(strsPoiType[idxPoiType]); btnPoiType.setText("搜索类别"); } private void setSortType() { // btnSortType.setText(strsSortType[idxSortType]); btnSortType.setText("排序方式"); } /** * 根据生成查询条件key * * @return SelectPoiKey */ private SelectPoiKey genSelectPoiKey() { SelectPoiKey key = new SelectPoiKey(); key.setSize(Constants.PAGE_SIZE);// 每页记录数 key.setLatitude(latitude); key.setLongitude(longitude); if (moduleBean.getModuleFlag().equals(ModuleType.zbjs)) { key.setRange_kilometer(10000); } else { key.setRange_kilometer(rangeValues[idxRange]); } key.setRoleCodes(new int[] { UIUtil.getRoleCode(idxPoiType) }); key.setPoiSortType(poiSortTypeValues[idxSortType]);// 排序方式 if (moduleBean.getModuleFlag().equals(ModuleType.zbjs)) { key.setStartIndex(startIndex); } else { if (ChangeOld.equals(UIUtil.getPoiSearchRoleCodes().get(idxPoiType) .getName())) { key.setStartIndex(startIndex); } else { startIndex = 0; ChangeOld = UIUtil.getPoiSearchRoleCodes().get(idxPoiType) .getName(); key.setStartIndex(startIndex); } } // long code = 0;// 代表查全部 // if (null != xzqh) { // StringBuilder sb = new StringBuilder(String.valueOf(xzqh.getCode())); // int data = 12-String.valueOf(xzqh.getCode()).length(); // for(int i=0;i< data;i++){ // sb.append("0"); // } // code = Long.parseLong(sb.toString()); // Log.wtf(TAG, code+""); // } // key.setAreaCode(code); // key.setFastSearch(name); Log.e(tag, idxRange + "rangeValues=" + rangeValues[idxRange] + "--idxRange=" + idxRange + "--" + "--RoleCodes=" + UIUtil.getRoleCode(idxPoiType) + "idxPoiType=" + idxPoiType + "--" + "--poiSortTypeValues=" + poiSortTypeValues[idxSortType] + "--startIndex=" + startIndex); return key; } /** * 当前选择的UserType名称 * * @return String */ private String getUserTypeName() { return UIUtil.getPoiSearchRoleCodes().get(idxPoiType).getName(); } private void doQuery() { new QueryPoiResultTask().execute(genSelectPoiKey()); } private class QueryPoiResultTask extends AsyncTask<SelectPoiKey, Void, ReturnObject> { Dialog pd = null; @Override protected void onPreExecute() { // if (showDialog) { pd = ProgressDialogStyle.createLoadingDialog( PoiSearchResultActivity.this, null); pd.show(); // showDialog = false; // } } @Override protected ReturnObject doInBackground(SelectPoiKey... params) { ReturnObject ro = new ReturnObject(); SelectPoiKey key = params[0]; // 调用莫迪的接口 ClientContext context = null; try { context = application.getClientContext(); // if(!application.getIslog()){ // context = null; // } if (null == context) { context = ClientContext.getClientContext( Constants.SERVER_URL, Constants.ANONYMOUS, Constants.ANONYMOUS); application.setClientContext(context); } IPositionManager ipositionmanager = context .getManager(IPositionManager.class); ro.data = ipositionmanager.getPoisBySelectKey(key); ro.isSuccess = true; } catch (LoginException e) { ro.isSuccess = false; ro.exception = e; e.printStackTrace(); } catch (Exception e) { if (e instanceof UndeclaredThrowableException) { ro.isSuccess = false; ro.exception = e; } e.printStackTrace(); } ReturnObject ro1 = ro; return ro; } @Override protected void onPostExecute(ReturnObject result) { if (null != pd) { pd.dismiss(); } if (startIndex == 0 || reslist.size() == 0) { reslist.clear(); startIndex = 0; } if (result.isSuccess && result.data!=null && ((UserPositionBean[]) result.data).length > 0) { reslist.addAll(Arrays.asList((UserPositionBean[]) result.data)); Log.wtf("几条数据?", reslist.size() + ""); totalCount = reslist.size(); startIndex += reslist.size(); } else { totalCount = 0; } resArray = reslist.toArray(new UserPositionBean[reslist.size()]); inItListView(resArray); } } // 添加的ListView 适配器 private void inItListView(UserPositionBean[] resArray) { setFootHintText(); listAdapter = new PoiSearchResultAdapter(PoiSearchResultActivity.this, resArray); listAdapter.setSelectRoleCode(UIUtil.getPoiSearchRoleCodes().get( idxPoiType)); listView.setAdapter(listAdapter); onLoad(); dissmissProgressDialog(); } @Override public void onRefresh() { if (idxPoiType == 4) { startIndex = 0; currentPage = 1; doSearchQuery(searchRange, 0, currentPage - 1); onLoad(); } else { startIndex = 0; doQuery(); } } // 刷新 @Override public void onLoadMore() { if (startIndex % Constants.PAGE_SIZE == 0) { if (idxPoiType == 4) { currentPage++; doSearchQuery(searchRange, 0, currentPage - 1); onLoad(); } else { doQuery(); } } else { UIUtil.showMsg(PoiSearchResultActivity.this, "没有更多"); onLoad(); } } private void onLoad() { listView.setSelection(((int) (startIndex)) - totalCount); listView.stopRefresh(); listView.stopLoadMore(); listView.setRefreshTime(DateUtil.getTimeStamp(new Date(), DateUtil.MM_DD_HH_MM_SS)); } public void setFootHintText() { if (totalCount == 0) { listView.setListFooteState(ListFooteState.noData); } else if (totalCount % Constants.PAGE_SIZE != 0) { listView.setListFooteState(ListFooteState.noMoreData); } else { listView.setListFooteState(ListFooteState.nomal); } listView.showNoData(); } /** * 查詢附近的銀行 * * @param searchRange * 搜索範圍 * @param orderId * 排序 * @param currentPage * 当前页 */ protected void doSearchQuery(int searchRange, final int orderId, int currentPage) { showProgressDialog();// 显示进度框 String poiString = "银行"; switch (idxPoiType) { case 0: doQuery(); break; case 1: doQuery(); break; case 2: doQuery(); break; case 4: poiString = "银行"; poiSearch(poiString, searchRange, orderId, currentPage); break; default: break; } } /** * 查詢附近的銀行 * * @param poiString * poi检索字段 * @param searchRange * 搜索範圍 * @param orderId * 排序 * @param currentPage * 当前页 */ private void poiSearch(String poiString, int searchRange, final int orderId, int currentPage) { query = new PoiSearch.Query(poiString, "", "");// 第一个参数表示搜索字符串,第二个参数表示poi搜索类型,第三个参数表示poi搜索区域(空字符串代表全国) query.setPageSize(15);// 设置每页最多返回多少条poiitem query.setPageNum(currentPage);// 设置查第一页 poiSearch = new PoiSearch(this, query); System.out.println("-------------------经度:" + latitude + "------纬度:" + longitude + "--------"); LatLonPoint latLonPoint = new LatLonPoint(latitude, longitude); SearchBound searchBound = new SearchBound(latLonPoint, searchRange); poiSearch.setBound(searchBound); poiSearch.setOnPoiSearchListener(new OnPoiSearchListener() { @Override public void onPoiSearched(PoiResult result, int rCode) { // TODO Auto-generated method stub dissmissProgressDialog(); if (rCode == 0) { if (result != null && result.getQuery() != null) { poiResult = result; ArrayList<PoiItem> poiItems = poiResult.getPois(); ArrayList<UserPositionBean> listPOI = new ArrayList<UserPositionBean>(); for (PoiItem item : poiItems) { UserPositionBean bean = new UserPositionBean(); bean.setUserName(item.getTitle());// poi名稱 bean.setProvince(item.getSnippet());// poi地址 bean.setSim(item.getTel());// poi電話 // poi經緯度 bean.setLatitude(item.getLatLonPoint() .getLatitude()); bean.setLongitude(item.getLatLonPoint() .getLongitude()); listPOI.add(bean); } if (orderId == 0 || orderId == 1) { } else {// 由遠及近 java.util.Collections.reverse(listPOI);// list集合倒序 } if (listPOI.size() > 0) { if (ChangeOld.equals(new int[] { UIUtil .getRoleCode(idxPoiType) })) { startIndex += listPOI.size(); } else { startIndex = 0; ChangeOld = UIUtil.getPoiSearchRoleCodes() .get(idxPoiType).getName(); } totalCount = listPOI.size(); listAdapter = new PoiSearchResultAdapter( PoiSearchResultActivity.this, listPOI.toArray(new UserPositionBean[listPOI .size()])); listAdapter.setSelectRoleCode(UIUtil .getPoiSearchRoleCodes().get(idxPoiType)); listView.setAdapter(listAdapter); } else { // 未检索到信息 } } else { totalCount = 0; } } } @Override public void onPoiItemDetailSearched(PoiItemDetail arg0, int arg1) { // TODO Auto-generated method stub } }); poiSearch.searchPOIAsyn(); } private void showProgressDialog() { if (progDialog == null) progDialog = new ProgressDialog(this); progDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER); progDialog.setIndeterminate(false); progDialog.setCancelable(false); progDialog.setMessage("正在搜索:" + "银行"); progDialog.show(); } private void dissmissProgressDialog() { if (progDialog != null) { progDialog.dismiss(); } } // POI搜索按范围查询 public void searchRangePOI(DialogInterface dialog, int which, int currentPage) { // 查询前清空数据 reslist.clear(); switch (which) { case 0: searchRange = 1000;// 搜索范围,默認排序由近及遠 doSearchQuery(searchRange, 0, currentPage); dialog.dismiss(); break; case 1: searchRange = 5000;// 搜索范围 doSearchQuery(searchRange, 0, currentPage); dialog.dismiss(); break; case 2: searchRange = 10000;// 搜索范围 doSearchQuery(searchRange, 0, currentPage); dialog.dismiss(); break; case 3: searchRange = 20000;// 搜索范围 doSearchQuery(searchRange, 0, currentPage); dialog.dismiss(); break; case 4: searchRange = 30000;// 搜索范围 doSearchQuery(searchRange, 0, currentPage); dialog.dismiss(); break; case 5: searchRange = 50000;// 搜索范围 doSearchQuery(searchRange, 0, currentPage); dialog.dismiss(); break; case 6: searchRange = 100000;// 搜索范围 doSearchQuery(searchRange, 0, currentPage); dialog.dismiss(); break; case 7: searchRange = 300000;// 搜索范围 doSearchQuery(searchRange, 0, currentPage); dialog.dismiss(); break; default: break; } } // 排序方法 private void searchOrder(DialogInterface dialog, int which, int currentPage) { switch (which) { case 0:// 默認由近及遠 // 查询前清空数据 reslist.clear(); doSearchQuery(searchRange, 0, currentPage); dialog.dismiss(); break; case 1:// 由近及遠 // 查询前清空数据 reslist.clear(); doSearchQuery(searchRange, 1, currentPage); dialog.dismiss(); break; case 2:// 有遠及進 // 查询前清空数据 reslist.clear(); doSearchQuery(searchRange, 2, currentPage); dialog.dismiss(); break; default: break; } } @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); // 接受Intent传值,如果有值,根据新的查询条件 从新查询. if (requestCode == Constants.REQUEST_XZQH_CODE) { if (resultCode == RESULT_OK) { AdminAreaBean xzqh = (AdminAreaBean) data .getSerializableExtra(Constants.PARAM_XZQH); this.xzqh = xzqh; Log.wtf(TAG, xzqh.getCode()+""); isFirst = true; startIndex = 0; doQuery(); } } } }