Esempio n. 1
0
 @Override
 protected void onPostExecute(PoiPagedResult result) {
   // TODO Auto-generated method stub
   super.onPostExecute(result);
   View parent = null;
   switch (type) {
     case HANDLER_SEARCH_START:
       if (!param.equals(startText.getText().toString())) {
         return;
       }
       mHandler.sendEmptyMessage(HANDLER_SEARCH_START_HIDE_PROGRESSBAR);
       parent = startText;
       break;
     case HANDLER_SEARCH_END:
       if (!param.equals(endText.getText().toString())) {
         return;
       }
       mHandler.sendEmptyMessage(HANDLER_SEARCH_END_HIDE_PROGRESSBAR);
       parent = endText;
       break;
     default:
       break;
   }
   if (result == null) {
     mHandler.sendEmptyMessage(HANDLER_SEARCH_ROUTE_ERROR);
   } else {
     // TODO
     if (result.getPageCount() > 0) {
       if (resulePopupWindow == null) initPopuWindow();
       try {
         List<PoiItem> poiItems = result.getPage(1);
         List<PointBean> datas = new ArrayList<PointBean>();
         for (int i = 0; i < poiItems.size(); i++) {
           if (i == 10) break;
           PoiItem item = poiItems.get(i);
           PointBean bean = new PointBean();
           bean.setName(item.getTitle());
           bean.setAddress(item.getSnippet());
           bean.setPoint(item.getPoint());
           datas.add(bean);
         }
         resultAdapter.setDataAndType(datas, type);
         resultAdapter.notifyDataSetChanged();
         if (!resulePopupWindow.isShowing()) {
           popupWindwShowing(parent);
         }
       } catch (MapAbcException e) {
         // #debug debug
         e.printStackTrace();
       }
     }
   }
 }
Esempio n. 2
0
 @Override
 public void handleMessage(Message msg) {
   RouteActivity activity = mActivity.get();
   if (activity == null) return;
   switch (msg.what) {
     case HANDLER_SEARCH_START_SHOW_PROGRESSBAR:
       activity.startProgress.setVisibility(View.VISIBLE);
       break;
     case HANDLER_SEARCH_START_HIDE_PROGRESSBAR:
       activity.startProgress.setVisibility(View.GONE);
       break;
     case HANDLER_SEARCH_END_SHOW_PROGRESSBAR:
       activity.endProgress.setVisibility(View.VISIBLE);
       break;
     case HANDLER_SEARCH_END_HIDE_PROGRESSBAR:
       activity.endProgress.setVisibility(View.GONE);
       break;
     case HANDLER_SEARCH_START:
       {
         activity.needToSearch = false;
         Bundle bundle = msg.getData();
         PointBean bean = (PointBean) activity.resultAdapter.getItem(bundle.getInt("sel"));
         activity.startText.setText(bean.getName());
         activity.startPoint = bean.getPoint();
         activity.resulePopupWindow.dismiss();
         break;
       }
     case HANDLER_SEARCH_END:
       {
         activity.needToSearch = false;
         Bundle bundle = msg.getData();
         PointBean bean = (PointBean) activity.resultAdapter.getItem(bundle.getInt("sel"));
         activity.endText.setText(bean.getName());
         activity.endPoint = bean.getPoint();
         activity.resulePopupWindow.dismiss();
         break;
       }
     case HANDLER_SEARCH_ROUTE_SHOW_PROGRESSBAR:
       activity.showProgressBar(activity.getString(R.string.searching_route));
       break;
     case HANDLER_SEARCH_ROUTE_HIDE_PROGRESSBAR:
       activity.hideProgressBar();
       break;
     case HANDLER_SEARCH_ROUTE:
       break;
     case HANDLER_SEARCH_ROUTE_ERROR:
       activity.showToast(activity.getString(R.string.query_error));
       break;
     case HANDLER_SEARCH_ROUTE_SUCCESSED:
       {
         Intent intent = new Intent(activity, RouteListActivity.class);
         intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
         intent.putExtra("start", activity.startText.getEditableText().toString());
         intent.putExtra("end", activity.endText.getEditableText().toString());
         intent.putExtra("mode", activity.mode);
         activity.startActivity(intent);
         break;
       }
     default:
       break;
   }
 }