package com.jiuqi.njt.son;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewStub;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;
import com.jiuqi.lbsinterface.bean.UserPositionBean;
import com.jiuqi.njt.R;
import com.jiuqi.njt.adapter.WzxxDetailAdapter;
import com.jiuqi.njt.util.DateUtil;
import com.jiuqi.njt.util.TitleBarUtil;
public class LocationDetail extends Activity implements OnClickListener {
private ListView listView;
// private Button deport;// 导出
private WzxxDetailAdapter listViewAdapter;
// private ProgressDialog proDia;
// private String url;
// private static String filename;
// private DownFile df;
// private String filePath = "";
private ArrayList<UserPositionBean> locList = null;
@SuppressWarnings("unchecked")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.layout_template_listview);
ViewStub rlTitleBar = (ViewStub)findViewById(R.id.titleBarStub);
TitleBarUtil.createTitleBar(this, rlTitleBar, "文字详情", new OnClickListener(){
@Override
public void onClick(View v){
LocationDetail.this.finish();
}
},"地图",new OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent();
intent.setClass(LocationDetail.this, WzcxShow.class);
intent.putExtra("locList", locList);
startActivity(intent);
}
});
listView = (ListView) this.findViewById(R.id.listView);
Intent intent = getIntent();
// String startDate = intent.getStringExtra("startDate");
// String endDate = intent.getStringExtra("endDate");
locList = (ArrayList<UserPositionBean>)intent.getSerializableExtra("locList");
initListView();
// deport = (Button) this.findViewById(R.id.deport);
// deport.setOnClickListener(this);
// TextView tv = null;
// StringBuffer sb = new StringBuffer();
// sb.append("");
//
// sb.append("\n");
// tv.setText(Html.fromHtml(sb.toString()));
}
/**
*
* Description: 初始化列表信息 Title: getListItems
*
* @return List<Map<String,Object>>
*/
private void initListView() {
ArrayList<Map<String, Object>> listItems = new ArrayList<Map<String, Object>>();
if(locList!=null){
for (UserPositionBean info : locList) {
Map<String, Object> map = new HashMap<String, Object>();
map.put("textView1", info.getUserName());
map.put("textView2", DateUtil.getTimeStamp(info.getCreateDate(),DateUtil.YYYY_MM_DD_HH_MM_SS ));
map.put("textView3", info.getIsSuccess()==0?"定位成功":"定位失败");
map.put("textView4", info.getProvince());
map.put("textView5", info.getCity());
map.put("textView6", info.getCountry());
map.put("textView7", info.getContent());
map.put("textView8", info.getSim());
listItems.add(map);
}
}
listViewAdapter = new WzxxDetailAdapter(LocationDetail.this, listItems); // 创建适配器
listView.setAdapter(listViewAdapter);
listView.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View view,
int position, long id) {
}
});
}
@Override
public void onClick(View v) {
// if (v == deport) {
// Toast.makeText(Location_Detail.this, "导出成功", Toast.LENGTH_SHORT).show();
// String filePath = "";
// // 判断是导出到SD卡中还是内存中,优先SD卡
//// if ((!Environment.getExternalStorageState().equals(
//// Environment.MEDIA_MOUNTED))) {// 内存
//// filePath = getFilesDir().getAbsolutePath() + File.separator
//// + "rakj_fileTemp" + File.separator;
//// } else {// SD卡
//// filePath = Environment.getExternalStorageDirectory()
//// .getAbsolutePath()
//// + File.separator
//// + "rakj_fileTemp"
//// + File.separator;
//// }
//// Log.i("DOWNFILE", "导出文件路径:" + filePath);
// DownFileThread dft = new DownFileThread(url, filePath, filename);
// dft.start();
// }
}
/**
* 下载文件线程
*
* @author Administrator
*
*/
// class DownFileThread extends Thread {
//
// private String path;
// private String serverPath;
// private String fileName;
//
// public DownFileThread(String serverPath, String path, String fileName) {
// super();
// this.path = path;
// filePath = path;
// System.out.println("path " + path);
// System.out.println("serverPath " + serverPath);
// this.serverPath = serverPath;
// this.fileName = fileName;
// System.out.println("fileName " + fileName);
// }
//
// @Override
// public void run() {
// Looper.prepare();
// Message msg = new Message();
// msg.what = 1;
// myHandler.sendMessage(msg);
//
// // 下载文件
// df = new DownFile();
// Message msg2 = new Message();
// if (df.down(serverPath, path, fileName) == 0) {
// System.out.println("下载成功");
// msg2.what = 2;
// } else {
// msg2.what = 3;
// }
// myHandler.sendMessage(msg2);
// Looper.loop();
// }
//
// }
// Handler myHandler = new Handler() {
// @Override
// public void handleMessage(Message msg) {
// super.handleMessage(msg);
// switch (msg.what) {
// case 1:
// proDia = new ProgressDialog(Location_Detail.this);
// proDia.setTitle("导出文件");
// proDia.setMessage("导出文件中,请稍候……");
// proDia.setProgressStyle(ProgressDialog.STYLE_SPINNER);
// proDia.setCancelable(false);
// proDia.show();
// break;
// case 2:
// Toast.makeText(Location_Detail.this,
// "导出成功,文件保存至" + filePath + filename + "路径下",
// Toast.LENGTH_LONG).show();
// proDia.cancel();
// break;
// case 3:
// Toast.makeText(Location_Detail.this, "导出失败!", Toast.LENGTH_LONG)
// .show();
// proDia.cancel();
// break;
// }
// }
// };
}