`
艳过留痕
  • 浏览: 39328 次
社区版块
存档分类

百度地图

阅读更多

 

package com.easecom.zhwg.ctrl.scene.rail;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.app.Dialog;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.content.Intent;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Point;
import android.graphics.Typeface;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Handler;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.LinearLayout.LayoutParams;
import android.widget.PopupWindow;
import android.widget.TextView;
import android.widget.Toast;

import com.baidu.mapapi.BMapManager;
import com.baidu.mapapi.GeoPoint;
import com.baidu.mapapi.ItemizedOverlay;
import com.baidu.mapapi.MKMapViewListener;
import com.baidu.mapapi.MapActivity;
import com.baidu.mapapi.MapController;
import com.baidu.mapapi.MapView;
import com.baidu.mapapi.Overlay;
import com.baidu.mapapi.OverlayItem;
import com.baidu.mapapi.Projection;
import com.easecom.widget.OnWheelChangedListener;
import com.easecom.widget.OnWheelScrollListener;
import com.easecom.widget.WheelView;
import com.easecom.widget.adapters.ArrayWheelAdapter;
import com.easecom.widget.adapters.NumericWheelAdapter;
import com.easecom.zhwg.R;
import com.easecom.zhwg.app.WGApp;
import com.easecom.zhwg.ctrl.scene.rail.GaoTieClass.RainLineDao;
import com.easecom.zhwg.ctrl.scene.rail.GaoTieClass.RainLineService;
import com.easecom.zhwg.ctrl.scene.station.ListViewDialogAdapter;
import com.easecom.zhwg.util.URLUtil;
import com.easecom.zhwg.util.WebUtils;


public class RainStation extends MapActivity {

	// 标题版设置按钮
	private TextView top_text;
	private Button btn_back;
	private Button btn_info;
	public static View mPopView; // 点击mark时弹出的气泡View
	public MapView mMapView;// 地图

	private PopupWindow popupWindow;// 指标框
	private View view;

	public MapController mapController;
	GeoPoint geoPoint;
	List<Overlay> list;
	private List<Map<String, String>> n_list;

	Typeface typeface = null;
	List<RainLineDao> rainLineDaos = null;
	ProgressDialog progressDialog;
	LayoutInflater inflater = null;
	private WGApp app;
	private static int nowMapLeave = 1;
	private Handler handler = new Handler();
	// 存放获取的数据    
	public static List<RainLineDao> mRainLineDao;
	// 存放获取的2G数据
	public static List<RainLineDao> mRainLineDao2G;
	// 存放获取的3G数据
	public static List<RainLineDao> mRainLineDao3G;
	//筛选基站  判断选择哪个
	private int checkIndex=0;

	// 日期控件使用
	private int startYear;
	private int startMonth;
	private int startDay;
	private int endYear;
	private int endMonth;
	private int endDay;
	private String start_time = "";
	private String end_time = "";
	private int width;
	private TextView start_timenew;


	/*
	 * Runnable runnableUi = new Runnable() {
	 * 
	 * @Override public void run() { // 更新界面 progressDialog =
	 * ProgressDialog.show(RainStation.this, null,"正在更新数据,请稍后...", true, true);
	 * try { String path =
	 * URLUtil.RAINLINESERVICE+"?netWorkType=&siteABC=&gwNodeName="; new
	 * QueryRain().execute(path); } catch (Exception e) { }
	 * handler.postDelayed(runnableUi, 1000*60*5); }
	 * 
	 * };
	 */
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.rain_main);
		progressDialog = ProgressDialog.show(RainStation.this, null,
				"正在更新数据,请稍后...", true, true);
		String path = URLUtil.RAINLINESERVICE
				+ "?netWorkType=&siteABC=&gwNodeName=";
		new QueryRain().execute(path);

		QueryRain2G taskTwoG = new QueryRain2G();
		String pathTwoG = URLUtil.RAINLINETWOGSERVICE
				+ "?startTime=&endTime=&gwCellName=&gwNodeName=";
		taskTwoG.execute(pathTwoG);

		QueryRain3G taskThreeG = new QueryRain3G();
		String pathThreeG = URLUtil.RAINLINETHREEGSERVICE
				+ "?startTime=&endTime=&gwCellName=&gwNodeName=";
		taskThreeG.execute(pathThreeG);

		inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		typeface = Typeface.create(Typeface.SANS_SERIF, Typeface.BOLD);
		ViewUI();
		app = (WGApp) this.getApplication();
		if (app.mBMapMan == null) {
			app.mBMapMan = new BMapManager(getApplication());
			app.mBMapMan.init(app.mStrKey, new WGApp.MyGeneralListener());
		}
		app.mBMapMan.start();
		// 如果使用地图SDK,请初始化地图Activity
		super.initMapActivity(app.mBMapMan);
		mMapView = (MapView) findViewById(R.id.bmapView);
		mMapView.regMapViewListener(app.mBMapMan, new MyMapViewListener());
		setDefaultKeyMode(DEFAULT_KEYS_SEARCH_LOCAL);
		init();
		initPopview();
		initLocation();
		// initOverlayItem(new ArrayList<RainLineDao>());
		// handler.post(runnableUi);
	}

	private void ViewUI() {
		top_text = (TextView) findViewById(R.id.top_text);
		top_text.setText("");
		// 返回按钮
		btn_back = (Button) findViewById(R.id.btn_back);
		btn_back.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				RainStation.this.finish();
			}
		});
		btn_info = (Button) findViewById(R.id.btn_info);
		btn_info.setVisibility(View.GONE);
		btn_info.setOnClickListener(new View.OnClickListener() {
			@Override  
			public void onClick(View v) {
				showAtLocation(findViewById(R.id.rain), Gravity.CENTER, 0, 0);
			}
		});

		// 初始化popupwindow
		view = LayoutInflater.from(this).inflate(R.layout.zhibiao, null);
		popupWindow = new PopupWindow(view,
				LinearLayout.LayoutParams.FILL_PARENT,
				LinearLayout.LayoutParams.FILL_PARENT);
		popupWindow.setAnimationStyle(android.R.style.Animation_Toast);
		ColorDrawable dw = new ColorDrawable(0xb0000000);
		popupWindow.setBackgroundDrawable(dw);

	}

	/**
	 * 数据解析
	 * 
	 */
	class QueryRain extends AsyncTask<String, Void, String> {

		@Override
		protected String doInBackground(String... params) {
			Map<String, String> fields = new HashMap<String, String>();
			return WebUtils.httpPost(params[0], fields);
		}

		@Override
		protected void onPostExecute(String result) {
			parJson(result,1);
			if (null == mRainLineDao) {
				progressDialog.dismiss();
				Toast toast = Toast.makeText(RainStation.this, "暂无信息!",
						Toast.LENGTH_SHORT);
				toast.setGravity(Gravity.CENTER, 0, 0);
				toast.show(); 
				return;
			}
		}
	}

	/**
	 * 数据解析2
	 * 
	 */
	class QueryRain2G extends AsyncTask<String, Void, String> {

		@Override
		protected String doInBackground(String... params) {
			Map<String, String> fields = new HashMap<String, String>();
			return WebUtils.httpPost(params[0], fields);
		}

		@Override
		protected void onPostExecute(String result) {
			parJson(result,2);
			if (null == mRainLineDao2G) {
				progressDialog.dismiss();
				Toast toast = Toast.makeText(RainStation.this, "暂无信息!",
						Toast.LENGTH_SHORT);
				toast.setGravity(Gravity.CENTER, 0, 0);
				toast.show(); 
				return;
			}
		}
	}

	/**
	 * 数据解析3
	 * 
	 */
	class QueryRain3G extends AsyncTask<String, Void, String> {
		@Override
		protected String doInBackground(String... params) {
			Map<String, String> fields = new HashMap<String, String>();
			return WebUtils.httpPost(params[0], fields);
		}

		@Override
		protected void onPostExecute(String result) {
			parJson(result,3);
			if (null == mRainLineDao3G) {
				progressDialog.dismiss();
				Toast toast = Toast.makeText(RainStation.this, "暂无信息!",
						Toast.LENGTH_SHORT);
				toast.setGravity(Gravity.CENTER, 0, 0);
				toast.show(); 
				return;
			}
		}
	}

	// 获取listview数据
	public void parJson(String result,int mdate) {
		try {
			System.out.println(":::::::::::::::::::::"+mdate);
			if(mdate==1){
				mRainLineDao = RainLineService.readXML(result);
				initOverlayItem(mRainLineDao);
			}
			else if(mdate==2){
				mRainLineDao2G = RainLineService.readXML2G(result);
			}
			else if(mdate==3){
				mRainLineDao3G = RainLineService.readXML3G(result);
			}
		} catch (Exception e) {
		}
	}

	/**
	 * 根据地图缩放级别显示数据
	 */
	public class MyMapViewListener implements MKMapViewListener {

		@Override
		public void onMapMoveFinish() {
			// TODO Auto-generated method stub
			mMapView.getOverlays().clear();
			nowMapLeave = mMapView.getZoomLevel();	
			if (mRainLineDao != null) {
				initOverlayItem(mRainLineDao);
			}
		}

	}

	private void init() {
		mMapView.setClickable(true);
		mMapView.setEnabled(true);
		mMapView.setTraffic(true);
		mMapView.setBuiltInZoomControls(true);
		mMapView.setDrawOverlayWhenZooming(true);// 设置在缩放动画过程中也显示overlay,默认为不绘制
		mapController = mMapView.getController();
		list = mMapView.getOverlays();
		mMapView.removeViewAt(1); // 去掉logo

	}

	private void initLocation() {
		mMapView.preLoad();
		// geoPoint = LanUtil.getGeoPoint(rpositions);////设置中心点
		geoPoint = new GeoPoint((int) (36.60839 * 1e6), (int) (116.99817 * 1e6));
		mapController.setZoom(10);
		if (null != geoPoint) {
			mapController.setCenter(geoPoint);
		}

	}
	//设置选中的某地名中心点
	private void locationCenter(int weiDu ,int jingDu ,int zoom) {
		mMapView.preLoad();
		//		geoPoint = LanUtil.getGeoPoint(rpositions);//设置中心点
		geoPoint = new GeoPoint( weiDu, jingDu);
		mapController.setZoom(zoom);
		if (null != geoPoint) {
			mapController.setCenter(geoPoint);
		}
	}

	private void initPopview() {
		// 创建点击mark时的弹出泡泡
		mPopView = super.getLayoutInflater().inflate(R.layout.popview, null);// 初始化弹出框
		mMapView.addView(mPopView, new MapView.LayoutParams(
				LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, null,
				MapView.LayoutParams.TOP_LEFT));
		mPopView.setVisibility(View.GONE);
	}

	private void initOverlayItem(List<RainLineDao> mRainLineDao) {
		if (null != mMapView) {
			mMapView.getOverlays().clear();
		}
		nowMapLeave = mMapView.getZoomLevel();
		Drawable marker = getResources().getDrawable(R.drawable.g_null); // 得到需要标在地图上的资源
		marker.setBounds(0, 0, marker.getIntrinsicWidth(),
				marker.getIntrinsicHeight()); // 为maker定义位置和边界
		mMapView.getOverlays().add(
				new OverItemT(marker, this, mRainLineDao, nowMapLeave)); // 添加ItemizedOverlay实例到mMapView
	}

	@Override
	protected void onPause() {
		WGApp app = (WGApp) this.getApplication();
		app.mBMapMan.stop();
		super.onPause();
	}

	@Override
	protected void onResume() {
		WGApp app = (WGApp) this.getApplication();
		app.mBMapMan.start();
		super.onResume();
	}

	@Override
	protected boolean isRouteDisplayed() {
		return false;
	}

	// 创建菜单
	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		super.onCreateOptionsMenu(menu);
		/*menu.add(0, 1, 0, "多维监控");
		menu.add(0, 2, 1, "资源视图");
		menu.add(0, 3, 2, "性能视图");
		menu.add(0, 4, 3, "数据查询");*/
		menu.add(0, 1, 0, "关键指标信息");
		menu.add(0, 2, 1, "筛选基站");
		return true;
	}

	// 菜单点击事件
	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		Intent intent = new Intent();
		switch (item.getItemId()) {
		case 1:
			/*intent.setClass(RainStation.this, MonViewActivity.class);
			startActivity(intent);
			RainStation.this.finish();*/
			intent.setClass(RainStation.this, KeyindexActivity.class);
			startActivity(intent);
			break;
		case 2:
			MyDialogSearchJiZhan();
			/*intent.setClass(RainStation.this, ZiyuanDataActivity.class);
			startActivity(intent);*/
			//new MyDialog(RainStation.this,false).setDisplay();
			//MyDialogSearch();
			break;
		case 3:
			/*intent.setClass(RainStation.this, SceneHistoryplayBack.class);
			startActivity(intent);*/
			break;
		case 4:
			/*intent.setClass(RainStation.this, DataFindLookActivity.class);
			startActivity(intent);*/
			break;

		}
		return true;
	}

	//条件筛选 选择基站名称
	private void MyDialogSearchJiZhan(){
		Dialog dialog = null;
		Builder builder = new AlertDialog.Builder(RainStation.this);
		String[] items = new String[RainStation.mRainLineDao.size()];
		if(RainStation.mRainLineDao.size()>0){	
			for(int i=0;i<mRainLineDao.size();i++ ){
				items[i]=mRainLineDao.get(i).getGwnode_name();
			}
		}
		//		Arrays.sort(items);	//给Array排序
		builder.setTitle("选择指标");
		DialogInterface.OnClickListener mutiListener2 = new OnClickListener() {

			@Override
			public void onClick(DialogInterface dialog, int which) {
				// TODO Auto-generated method stub
				checkIndex=which;
			}
		};

		builder.setSingleChoiceItems(items, -1, mutiListener2);
		DialogInterface.OnClickListener btnListener2 = 
				new DialogInterface.OnClickListener() {
			@Override
			public void onClick(DialogInterface dialogInterface, int which) {
				//获取经纬度
				double weiDu = Double.parseDouble(mRainLineDao.get(checkIndex).getWeidu());
				int weiDu1=(int) (weiDu * 1E6);
				double jingDu = Double.parseDouble(mRainLineDao.get(checkIndex).getJingdu());
				int jingDu1=(int) (jingDu * 1E6);
				//经,纬度,缩放级别
				locationCenter(weiDu1,jingDu1,15);

				//显示弹出框
				Drawable marker = null;
				new OverItemT(marker,RainStation.this,mRainLineDao,15).onTap(checkIndex);
			}
		};
		builder.setPositiveButton("确定", btnListener2);
		builder.setNegativeButton("取消", new OnClickListener() {
			@Override
			public void onClick(DialogInterface dialog, int which) {
				// TODO Auto-generated method stub
				dialog.dismiss();
			}
		});
		dialog = builder.create();
		dialog.show();
	}


	//条件筛选 选择基站名称1
	private void MyDialogSearch(){
		Dialog dialog = null;
		Builder builder = new AlertDialog.Builder(RainStation.this);
		ArrayList<String> arrayList = new ArrayList<String>();
		String[] items = new String[RainStation.mRainLineDao.size()];
		if(RainStation.mRainLineDao.size()>0){	
			for(int i=0;i<mRainLineDao.size();i++ ){
				arrayList.add(mRainLineDao.get(i).getCell_name());
				items[i]=mRainLineDao.get(i).getCell_name();
			}
		}else{

		}


		builder.setTitle("选择小区名称");
		DialogInterface.OnClickListener mutiListener2 = new OnClickListener() {

			@Override
			public void onClick(DialogInterface dialog, int which) {
				// TODO Auto-generated method stub
			}
		};

		builder.setSingleChoiceItems(items, -1, mutiListener2);
		DialogInterface.OnClickListener btnListener2 = 
				new DialogInterface.OnClickListener() {
			@Override
			public void onClick(DialogInterface dialogInterface, int which) {

			}
		};
		builder.setPositiveButton("确定", btnListener2);
		builder.setNegativeButton("取消", new OnClickListener() {
			@Override
			public void onClick(DialogInterface dialog, int which) {
				// TODO Auto-generated method stub
				dialog.dismiss();
			}
		});
		dialog = builder.create();
		dialog.show();
	}

	/*
	 * @Override protected void onDestroy() {
	 * handler.removeCallbacks(runnableUi); super.onDestroy();
	 * 
	 * }
	 */
	// 显示popupwindow
	public void showAtLocation(View parent, int gravity, int x, int y) {
		if (null != popupWindow && popupWindow.isShowing()) {
			popupWindow.dismiss();
		}
		popupWindow.showAtLocation(parent, gravity, x, y);
		// 使其聚集
		popupWindow.setFocusable(true);
		// 设置允许在外点击消失
		// popupWindow.setOutsideTouchable(true);
		// 刷新状态
		popupWindow.update();
	}

	// 隐藏菜单
	public void G2event() {

	}

	public void dismiss() {
		popupWindow.dismiss();
	}


	class MyDialog extends Dialog implements View.OnClickListener {

		private Button button1_date;
		private Button button2_date;
		private EditText start_time;
		private EditText end_time;
		private Button cancelButton;// 取消按钮
		private Button okButton;// 确定按钮
		private ListViewDialogAdapter mAdapter;
		private Context context;
		public MyDialog(Context context,boolean flag) {
			super(context);
			this.context=context;	

		}

		public void setDisplay() {
			setContentView(R.layout.rain_dialog);// 设置对话框的布局
			button1_date = (Button) findViewById(R.id.button1_date);// 开始日期按钮
			button2_date = (Button) findViewById(R.id.button2_date);// 结束日期按钮
			start_time = (EditText) findViewById(R.id.start_time);// 开始时间文本框
			end_time = (EditText) findViewById(R.id.end_time);// 结束时间文本框
			cancelButton = (Button) findViewById(R.id.no_query);// 取消按钮
			okButton = (Button) findViewById(R.id.yes_query);// 确定按钮
			okButton.setOnClickListener(listener);
			button1_date.setOnClickListener(listener);
			button2_date.setOnClickListener(listener);
			cancelButton.setOnClickListener(new View.OnClickListener() {
				@Override
				public void onClick(View v) {
					dismiss();
				}
			});

			setTitle("查询条件");// 设定对话框的标题
			start_time.setText(new StringBuilder().append(startYear)
					.append("-").append(format(startMonth + 1)).append("-")
					.append(format(startDay))
					.append(" ").append("00:00:00"));
			end_time.setText(new StringBuilder().append(endYear)
					.append("-").append(format(endMonth + 1)).append("-")
					.append(format(endDay))
					.append(" ").append("23:59:59"));
			show();// 显示对话框
		}

		private View.OnClickListener listener = new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				Dialog dialog = null;
				Builder builder = new AlertDialog.Builder(RainStation.this);
				switch (v.getId()) {
				case R.id.button1_date:
					initstarttime(start_time,1);
					break;
				case R.id.button2_date:
					initstarttime(end_time,2);
					break;
				case R.id.yes_query:
					dismiss();
					//					progressDialog = ProgressDialog.show(RainStation.this, "请等待...", "正在加载信息,请稍后...",true, true);
					//					String path2 = "";
					//					try {
					//						path2 = URLUtil.KEYINDEX
					//								+ "?startTime="+  URLEncoder.encode(start_time.getText().toString(),"utf-8")
					//								+ "&endTime="+  URLEncoder.encode(end_time.getText().toString(),"utf-8")
					//								+"&granularity=";
					//					} catch (UnsupportedEncodingException e) {
					//						// TODO Auto-generated catch block
					//						e.printStackTrace();
					//					}
					//					System.out.println("我日开始"+start_time.getText().toString());
					//					System.out.println("我日结束"+end_time.getText().toString());
					//					/* 8888888888  此处QueryRain()为假的                 88888888888888888888888888*/
					//					new QueryRain().execute(path2);
					break;

				default:
					break;
				}
			}

		};
		private String format(int x) {
			String s = "" + x;
			if (s.length() == 1)
				s = "0" + s;
			return s;
		}
		@Override
		public void onClick(View v) {
		}

	}

	/**
	 * Updates day wheel. Sets max days according to selected month and year
	 */
	void updateDays(WheelView year, WheelView month, WheelView day) {

		Calendar calendar = Calendar.getInstance();
		calendar.set(Calendar.YEAR,
				calendar.get(Calendar.YEAR) + year.getCurrentItem());
		calendar.set(Calendar.MONTH, month.getCurrentItem());

		int maxDays = calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
		day.setViewAdapter(new DateNumericAdapter(this, 1, maxDays, calendar
				.get(Calendar.DAY_OF_MONTH) - 1));
		int curDay = Math.min(maxDays, day.getCurrentItem() + 1);
		day.setCurrentItem(curDay - 1, true);
	}
	/**
	 * Adapter for numeric wheels. Highlights the current value.
	 */
	private class DateNumericAdapter extends NumericWheelAdapter {
		// Index of current item
		int currentItem;
		// Index of item to be highlighted
		int currentValue;

		/**
		 * Constructor
		 */
		public DateNumericAdapter(Context context, int minValue, int maxValue,
				int current) {
			super(context, minValue, maxValue);
			this.currentValue = current;
			setTextSize(16);
		}

		public DateNumericAdapter(Context context, int minValue, int maxValue,
				int current, String format) {
			super(context, minValue, maxValue, format);
			this.currentValue = current;
			setTextSize(16);
		}

		@Override
		protected void configureTextView(TextView view) {
			super.configureTextView(view);
			if (currentItem == currentValue) {
				view.setTextColor(0xFF0000F0);
			}
			view.setTypeface(Typeface.SANS_SERIF);
		}

		@Override
		public View getItem(int index, View cachedView, ViewGroup parent) {
			currentItem = index;
			return super.getItem(index, cachedView, parent);
		}
	}
	/**
	 * Adapter for string based wheel. Highlights the current value.
	 */
	private class DateArrayAdapter extends ArrayWheelAdapter<String> {
		// Index of current item
		int currentItem;
		// Index of item to be highlighted
		int currentValue;

		/**
		 * Constructor
		 */
		public DateArrayAdapter(Context context, String[] items, int current) {
			super(context, items);
			this.currentValue = current;
			setTextSize(16);
		}

		@Override
		protected void configureTextView(TextView view) {
			super.configureTextView(view);
			if (currentItem == currentValue) {
				view.setTextColor(0xFF0000F0);
			}
			view.setTypeface(Typeface.SANS_SERIF);
		}

		@Override
		public View getItem(int index, View cachedView, ViewGroup parent) {
			currentItem = index;
			return super.getItem(index, cachedView, parent);
		}
	}
	/**
	 * 时间控件
	 * */
	private void initstarttime(final TextView sTextView,final int flag) {
		LayoutInflater inflater=LayoutInflater.from(this);
		final View dialog=inflater.inflate(R.layout.date_layout_dialog, null);
		final Calendar calendar = Calendar.getInstance();
		final WheelView day = (WheelView) dialog.findViewById(R.id.day);
		final WheelView month = (WheelView) dialog.findViewById(R.id.month);
		final WheelView year = (WheelView) dialog.findViewById(R.id.year);
		final WheelView hours = (WheelView) dialog.findViewById(R.id.hour);
		final WheelView mins = (WheelView) dialog.findViewById(R.id.mins);
		final WheelView seconds = (WheelView) dialog.findViewById(R.id.seconds);
		AlertDialog.Builder builder=new AlertDialog.Builder(RainStation.this);
		builder.setTitle("选择时间");
		builder.setView(dialog); //关键
		builder.setPositiveButton("确定", new DialogInterface.OnClickListener() {
			@Override
			public void onClick(DialogInterface dialog, int which) {
				sTextView.setText(calendar.get(Calendar.YEAR) + year.getCurrentItem()+"-"
						+((month.getCurrentItem()+1<10)?("0"+(month.getCurrentItem()+1)):month.getCurrentItem()+1)+"-"
						+(day.getCurrentItem() + 1)
						+" "+hours.getCurrentItem()+":"
						+((mins.getCurrentItem() < 10) ? ("0" + mins.getCurrentItem()) : mins.getCurrentItem())+":"
						+((seconds.getCurrentItem() < 10) ? ("0" + seconds.getCurrentItem()) : seconds.getCurrentItem()));
				if(flag==1){
					start_time=calendar.get(Calendar.YEAR) + year.getCurrentItem()+"-"
							+((month.getCurrentItem()+1<10)?("0"+(month.getCurrentItem()+1)):month.getCurrentItem()+1)+"-"
							+(day.getCurrentItem() + 1)
							+" "+hours.getCurrentItem()+":"
							+((mins.getCurrentItem() < 10) ? ("0" + mins.getCurrentItem()) : mins.getCurrentItem())+":"
							+((seconds.getCurrentItem() < 10) ? ("0" + seconds.getCurrentItem()) : seconds.getCurrentItem());
				}else if (flag==2) {
					end_time=calendar.get(Calendar.YEAR) + year.getCurrentItem()+"-"
							+((month.getCurrentItem()+1<10)?("0"+(month.getCurrentItem()+1)):month.getCurrentItem()+1)+"-"
							+(day.getCurrentItem() + 1)
							+" "+hours.getCurrentItem()+":"
							+((mins.getCurrentItem() < 10) ? ("0" + mins.getCurrentItem()) : mins.getCurrentItem())+":"
							+((seconds.getCurrentItem() < 10) ? ("0" + seconds.getCurrentItem()) : seconds.getCurrentItem());
				}

			}
		});
		builder.setNegativeButton("取消",new DialogInterface.OnClickListener() {
			@Override
			public void onClick(DialogInterface dialog, int which) {
				dialog.dismiss();
			}
		});

		OnWheelChangedListener listener = new OnWheelChangedListener() {
			public void onChanged(WheelView wheel, int oldValue, int newValue) {
				updateDays(year, month, day);
			}
		};
		OnWheelScrollListener scrollListener = new OnWheelScrollListener() {
			public void onScrollingStarted(WheelView wheel) {}
			public void onScrollingFinished(WheelView wheel) {}
		};
		// year
		int curYear = calendar.get(Calendar.YEAR);
		year.setViewAdapter(new DateNumericAdapter(this, curYear, curYear + 10,0));
		year.setCurrentItem(curYear);
		year.addChangingListener(listener);
		year.addScrollingListener(scrollListener);
		// month
		int curMonth = calendar.get(Calendar.MONTH);
		String months[] = new String[] { "1月", "2月", "3月", "4月", "5月", "6月","7月", "8月", "9月", "10月", "11月", "12月" };
		month.setViewAdapter(new DateArrayAdapter(this, months, curMonth));
		month.setCurrentItem(curMonth);
		month.addChangingListener(listener);
		month.addScrollingListener(scrollListener);
		// day
		updateDays(year, month, day);
		day.setCurrentItem(calendar.get(Calendar.DAY_OF_MONTH) - 1);
		day.addScrollingListener(scrollListener);
		// hour
		int curHours = calendar.get(Calendar.HOUR_OF_DAY);
		hours.setViewAdapter(new DateNumericAdapter(this, 0, 23, curHours));
		hours.setCurrentItem(curHours);
		hours.addScrollingListener(scrollListener);
		// minus
		int curMinutes = calendar.get(Calendar.MINUTE);
		mins.setViewAdapter(new DateNumericAdapter(this, 0, 59, curMinutes,"%02d"));
		mins.setCyclic(true);
		mins.setCurrentItem(curMinutes);
		mins.addScrollingListener(scrollListener);
		//second
		int curSeconds=calendar.get(Calendar.SECOND);
		seconds.setViewAdapter(new DateNumericAdapter(this, 0, 59, curSeconds,"%02d"));
		seconds.setCurrentItem(curSeconds);
		seconds.setCyclic(true);
		seconds.addScrollingListener(scrollListener);

		builder.create().show();
	}
}

// 坐表
class OverItemT extends ItemizedOverlay<OverlayItem> {
	private List<OverlayItem> mGeoList = new ArrayList<OverlayItem>();
	private Drawable marker;
	private RainStation mContext;
	private List<RainLineDao> listmp = null;
	// 存放获取的数据
	public static List<RainLineDao> mRainLineDao;

	public OverItemT(Drawable marker, Context context,
			List<RainLineDao> mRainLineDao, int nowMapLeave) {
		super(boundCenterBottom(marker));
		int t = 1;
		this.marker = marker;
		this.mContext = (RainStation) context;
		double mLat1 = 36.376601;// 39.9022; // point1纬度
		double mLon1 = 116.90301;// 116.3822;// point1经度

		List<String> data = new ArrayList<String>();
		for (RainLineDao mposition : mRainLineDao) {
			data.add(mposition.getJingdu() + "," + mposition.getWeidu() + ","
					+ mposition.getGsmwcdma() + "," + mposition.getGsmwcdma());
		}

		if (nowMapLeave > 10 && nowMapLeave < 13) {
			t = 1;
		} else if (nowMapLeave == 10) {
			t = 20;
		} else if (nowMapLeave == 9) {
			t = 33;
		} else if (nowMapLeave == 8) {
			t = 40;
		} else if (nowMapLeave == 7) {
			t = 60;
		} else if (nowMapLeave == 6) {
			t = 80;
		} else if (nowMapLeave <= 5) {
			t = data.size();
		}
		for (int i = 0; i < data.size(); i = i + t) {
			if (nowMapLeave < 5) {
				break;
			}
			/*
			 * RainLineDao mposition = mRainLineDao.get(i); // for (RainLineDao
			 * mposition : mRainLineDao) { mLat1 =
			 * Double.parseDouble(mposition.getJingdu()); mLon1 =
			 * Double.parseDouble(mposition.getWeidu());
			 * //mContext.mapController.setCenter(new GeoPoint((int) (mLon1 *
			 * 1E6), // (int) (mLat1 * 1E6))); // 画出坐标 if (mLon1 != 0 && mLat1
			 * != 0) { mGeoList.add(new OverlayItem(new GeoPoint((int) (mLon1 *
			 * 1E6), (int) (mLat1 * 1E6)), mposition.getGsmwcdma(),
			 * mposition.getGsmwcdma())); }
			 */

			String str = data.get(i).replaceAll(" ", "");
			String[] pstr = str.split(",");
			mLat1 = Double.parseDouble(pstr[1]);
			mLon1 = Double.parseDouble(pstr[0]);
			mGeoList.add(new OverlayItem(new GeoPoint((int) (mLat1 * 1E6),
					(int) (mLon1 * 1E6)), pstr[2], pstr[3]));
			mContext.progressDialog.dismiss();

		}
		// 用给定的经纬度构造GeoPoint,单位是微度 (度 * 1E6)
		/*
		 * for (Rposition mposition : listmp) { //画出坐标 if (mposition.getWeidu()
		 * != 0 && mposition.getJingdu() != 0) { mGeoList.add(new OverlayItem(
		 * new GeoPoint((int) (mposition.getWeidu() * 1E6), (int)
		 * (mposition.getJingdu() * 1E6)), mposition .getAlarm_node(),
		 * mposition.getGsmwcdma() + mposition.getInfo1())); } }
		 */
		populate(); // createItem(int)方法构造item。一旦有了数据,在调用其它方法前,首先调用这个方法
	}

	@Override
	public void draw(Canvas canvas, MapView mapView, boolean shadow) {
		// Projection接口用于屏幕像素坐标和经纬度坐标之间的变换
		Projection projection = mapView.getProjection();

		for (int index = size() - 1; index >= 0; index--) { // 遍历mGeoList
			OverlayItem overLayItem = getItem(index); // 得到给定索引的item
			String title = overLayItem.getTitle();
			// 把经纬度变换到相对于MapView左上角的屏幕像素坐标
			Point point = projection.toPixels(overLayItem.getPoint(), null);
			// 在坐标点画红色的圆
			Paint paintCircle = new Paint();
			paintCircle.setColor(Color.RED);
			canvas.drawCircle(point.x, point.y, 5, paintCircle); // 画圆

			if (overLayItem.getSnippet().equals("GSMVIP")) {
				Drawable marker = mContext.getResources().getDrawable(
						R.drawable.g_vip);
				overLayItem.setMarker(boundCenterBottom(marker));
			} else if (overLayItem.getSnippet().equals("GSM")) {
				Drawable marker = mContext.getResources().getDrawable(
						R.drawable.g_a);
				overLayItem.setMarker(boundCenterBottom(marker));
			} else if (overLayItem.getSnippet().equals("GSMB")) {
				Drawable marker = mContext.getResources().getDrawable(
						R.drawable.g_b);
				overLayItem.setMarker(boundCenterBottom(marker));
			} else if (overLayItem.getSnippet().equals("GSMC")) {
				Drawable marker = mContext.getResources().getDrawable(
						R.drawable.g_c);
				overLayItem.setMarker(boundCenterBottom(marker));
			} else if (overLayItem.getSnippet().equals("WCDMAVIP")) {
				Drawable marker = mContext.getResources().getDrawable(
						R.drawable.w_vip);
				overLayItem.setMarker(boundCenterBottom(marker));
			} else if (overLayItem.getSnippet().equals("WCDMAA")) {
				Drawable marker = mContext.getResources().getDrawable(
						R.drawable.w_a);
				overLayItem.setMarker(boundCenterBottom(marker));
			} else if (overLayItem.getSnippet().equals("WCDMAB")) {
				Drawable marker = mContext.getResources().getDrawable(
						R.drawable.w_b);
				overLayItem.setMarker(boundCenterBottom(marker));
			} else if (overLayItem.getSnippet().equals("WCDMAC")) {
				Drawable marker = mContext.getResources().getDrawable(
						R.drawable.w_c);
				overLayItem.setMarker(boundCenterBottom(marker));
			}

			// 可在此处添加您的绘制代码
			Paint paintText = new Paint();
			paintText.setColor(R.color.dimgray);
			// paintText.setColor(Color.BLACK);
			// paintText.setSubpixelText(true);
			paintText.setTypeface(mContext.typeface);
			paintText.setTextSize(16);
			canvas.drawText(title, point.x - 30, point.y + 20, paintText); // 绘制文本

		}

		super.draw(canvas, mapView, shadow);
		// 调整一个drawable边界,使得(0,0)是这个drawable底部最后一行中心的一个像素
		boundCenterBottom(marker);

	}

	@Override
	protected OverlayItem createItem(int i) {
		return mGeoList.get(i);
	}

	@Override
	public int size() {
		return mGeoList.size();
	}

	@Override
	// 处理当点击事件
	protected boolean onTap(int i) {
		setFocus(mGeoList.get(i));
		GeoPoint pt = mGeoList.get(i).getPoint();
		MapView.LayoutParams geoLP = new MapView.LayoutParams(
				LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, pt,
				MapView.LayoutParams.BOTTOM_CENTER);
		mContext.mMapView.updateViewLayout(mContext.mPopView, geoLP);
		mContext.mPopView.setVisibility(View.VISIBLE);
		/*-------------------------------------------------------*/
		//GWNODE_NAME 基站名称
		String Gsmwcdma= RainStation.mRainLineDao.get(i).getGsmwcdma();//网络类别
		String Site_abc= RainStation.mRainLineDao.get(i).getSite_abc();//基站级别
		String Gwnode_name= RainStation.mRainLineDao.get(i).getGwnode_name();//基站名称
		String Cells= RainStation.mRainLineDao.get(i).getCells();//小区  NJ187-党家支局O-41064,NJ187-党家支局O-41066
		if(Cells.indexOf(",")>=0){
			int end=Cells.indexOf(",");
			Cells=Cells.substring(0, end);
			//			System.out.println("Cells:"+Cells);
		}

		//判断网络类型调用相应2G/3G接口
		int j=-1,k=-1;
		if(Gsmwcdma.equals("GSM")){		
			for( j=0;j<RainStation.mRainLineDao2G.size();j++){
				if(Cells.equals(RainStation.mRainLineDao2G.get(j).getCell_name())){
					break;
				}
			}
		}else if(Gsmwcdma.equals("WCDMA")){
			for( k=0;k<RainStation.mRainLineDao3G.size();k++){
				if(Cells.equals(RainStation.mRainLineDao3G.get(k).getCell_name3G())){
					break;
				}
			}
		}

		LinearLayout guideLinearLayout = (LinearLayout) mContext.mPopView
				.findViewById(R.id.con_s);
		guideLinearLayout.removeAllViews();
		LinearLayout guide_typesitem = (LinearLayout) mContext.inflater
				.inflate(R.layout.thepopview, null);
		/*((Button) guide_typesitem.findViewById(R.id.g2_xiaoqu))
				.setOnClickListener(new View.OnClickListener() {

					@Override
					public void onClick(View v) {
						// TODO Auto-generated method stub
						// Toast.makeText(mContext, "okok",
						// Toast.LENGTH_SHORT).show();
						NewpopWindowsuntil aa = new NewpopWindowsuntil(mContext);
						aa.showPopwindows(
								mContext.findViewById(R.id.g2_xiaoqu),
								Gravity.CENTER, 0, 0);
					}
				});*/
		((TextView)
				guide_typesitem.findViewById(R.id.jizhan_names)).setText(RainStation.mRainLineDao.get(i).getGwnode_name());//基站名称
		((TextView)
				guide_typesitem.findViewById(R.id.jizhan_titles)).setText(RainStation.mRainLineDao.get(i).getCells());//小区

		((TextView)
				guide_typesitem.findViewById(R.id.jizhan_msc)).setText(RainStation.mRainLineDao.get(i).getRelated_msc());//所属MSC
		// Dn
		((TextView)
				guide_typesitem.findViewById(R.id.jizhan_cdmas)).setText(RainStation.mRainLineDao.get(i).getGsmwcdma());//网络类别
		// 类别
		((TextView)
				guide_typesitem.findViewById(R.id.jizhan_citys)).setText(RainStation.mRainLineDao.get(i).getArea_name());//地市
		// 城市
		((TextView)
				guide_typesitem.findViewById(R.id.jizhan_bscs)).setText(RainStation.mRainLineDao.get(i).getRelated_bsc());//所属BSC/RNC
		// 标示
		((TextView)
				guide_typesitem.findViewById(R.id.jizhan_levels)).setText(RainStation.mRainLineDao.get(i).getSite_abc());//基站级别
		// 生产厂商
		((TextView)
				guide_typesitem.findViewById(R.id.jizhan_jingdus)).setText(RainStation.mRainLineDao.get(i).getJingdu());//经度
		// 经度
		((TextView)
				guide_typesitem.findViewById(R.id.jizhan_weidus)).setText(RainStation.mRainLineDao.get(i).getWeidu());//纬度
		//添加全部信息到视图
		guideLinearLayout.addView(guide_typesitem);


		//2G信息
		if(j>=0){
			LinearLayout guide_typesitem2G = (LinearLayout) mContext.inflater
					.inflate(R.layout.thepopview2g, null);

			// 所属MSS:
			((TextView)
					guide_typesitem2G.findViewById(R.id.jizhan2g_mss)).setText(RainStation.mRainLineDao2G.get(j).getRelated_mss() );//纬度
			// 业务信道总话务量ERL:
			((TextView)
					guide_typesitem2G.findViewById(R.id.jizhan2g_erl)).setText(RainStation.mRainLineDao2G.get(j).getTch_traffic() );//纬度
			//业务信道每信道话务量ERL:
			((TextView)
					guide_typesitem2G.findViewById(R.id.jizhan2g_pererl)).setText(RainStation.mRainLineDao2G.get(j).getTch_pertraffic() );//纬度
			// TCH掉话率:
			((TextView)
					guide_typesitem2G.findViewById(R.id.jizhan2g_tch)).setText(RainStation.mRainLineDao2G.get(j).getTch_droprate() );//纬度
			// 2G无线利用率:
			((TextView)
					guide_typesitem2G.findViewById(R.id.jizhan2g_wireless_userate)).setText(RainStation.mRainLineDao2G.get(j).getWireless_userate() );//纬度
			// 登记用户数:
			((TextView)
					guide_typesitem2G.findViewById(R.id.jizhan2g_nbr_user)).setText(RainStation.mRainLineDao2G.get(j).getNbr_user() );//纬度
			// 上行流量:
			((TextView)
					guide_typesitem2G.findViewById(R.id.jizhan2g_psuioct)).setText(RainStation.mRainLineDao2G.get(j).getPsuioct() );//纬度
			// 下行流量:
			((TextView)
					guide_typesitem2G.findViewById(R.id.jizhan2g_psdioct)).setText(RainStation.mRainLineDao2G.get(j).getPsdioct() );//纬度
			//添加2G信息到视图
			guideLinearLayout.addView(guide_typesitem2G);
		}



		//3G信息
		if(k>=0){
			LinearLayout guide_typesitem3G = (LinearLayout) mContext.inflater
					.inflate(R.layout.thepopview3g, null);

			// 所属MSS:
			((TextView)
					guide_typesitem3G.findViewById(R.id.jizhan3g_MSS)).setText(RainStation.mRainLineDao3G.get(k).getRelated_mss3G() );//纬度
			// 分组域上行流量(KB):
			((TextView)
					guide_typesitem3G.findViewById(R.id.jizhan3g_psuioct)).setText(RainStation.mRainLineDao3G.get(k).getPsuioct3G() );//纬度
			// 分组域下行流量(KB):
			((TextView)
					guide_typesitem3G.findViewById(R.id.jizhan3g_psdioct)).setText(RainStation.mRainLineDao3G.get(k).getPsdioct3G() );//纬度

			// HSDPA RAB建立成功率:
			((TextView)
					guide_typesitem3G.findViewById(R.id.jizhan3g_hsdpa_rab)).setText(RainStation.mRainLineDao3G.get(k).getHsdpa_rabrate() );//纬度

			// HSUPA RAB建立成功率:
			((TextView)
					guide_typesitem3G.findViewById(R.id.jizhan3g_hsupa_rab)).setText(RainStation.mRainLineDao3G.get(k).getHsupa_rabrate() );//纬度

			// HSDPA平均在线用户数:
			((TextView)
					guide_typesitem3G.findViewById(R.id.jizhan3g_hsdpa)).setText(RainStation.mRainLineDao3G.get(k).getHsdpa_meannbruser() );//纬度

			// HSUPA平均在线用户数:
			((TextView)
					guide_typesitem3G.findViewById(R.id.jizhan3g_hsupa)).setText(RainStation.mRainLineDao3G.get(k).getHsupa_meannbruser() );//纬度

			// IUCS口话务量/电路域话务量(ERL):
			((TextView)
					guide_typesitem3G.findViewById(R.id.jizhan3g_cstraffic)).setText(RainStation.mRainLineDao3G.get(k).getCstraffic() );//纬度
			// 登记用户数:
			((TextView)
					guide_typesitem3G.findViewById(R.id.jizhan3g_nbr_user)).setText(RainStation.mRainLineDao3G.get(k).getNbr_user3G() );//纬度

			guideLinearLayout.addView(guide_typesitem3G);
		}





		/*for (int index = size() - 1; index >= 0; index--) {
			OverlayItem overLayItem = getItem(index);
			if (overLayItem.getPoint().getLatitudeE6() == pt.getLatitudeE6()
					&& overLayItem.getPoint().getLongitudeE6() == pt
							.getLongitudeE6()
					&& !overLayItem.getTitle().equals(
							mGeoList.get(i).getTitle())) {
				LinearLayout guide_typesitems = (LinearLayout) mContext.inflater
						.inflate(R.layout.popviews, null);
				guideLinearLayout.addView(guide_typesitems);
			}
		}*/

		return true;
	}

	@Override
	public boolean onTap(GeoPoint arg0, MapView arg1) {
		// 消去弹出的气泡
		mContext.mPopView.setVisibility(View.GONE);
		return super.onTap(arg0, arg1);
	}

}
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics