package com.jqyd.son; import java.util.ArrayList; import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.text.Editable; import android.text.TextWatcher; import android.util.Log; import android.view.View; import android.view.View.OnClickListener; import android.widget.AdapterView; import android.widget.Button; import android.widget.EditText; import android.widget.ListView; import android.widget.AdapterView.OnItemClickListener; import com.jqyd.adapter.LxrAdapter; import com.jqyd.app.MyApp; import com.jqyd.app.ShareMethod; import com.jqyd.manager.R; import com.jqyd.model.CustomerModule; import com.jqyd.shareInterface.Optdb_interfce; import com.jqyd.shareInterface.Optsharepre_interface; public class KqList extends Activity implements OnClickListener{//地点列表 private ShareMethod shareMethod = null; private ListView ddLv; private EditText find; private Button groupList; private LxrAdapter adapter; private ArrayList<String> data; ArrayList<CustomerModule> custs = null; private MyApp myApp; private String qdMode = "2"; private int point = 0; @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.custlist); shareMethod = new ShareMethod(KqList.this); ddLv=(ListView) findViewById(R.id.list); find = (EditText) this.findViewById(R.id.find); groupList = (Button) this.findViewById(R.id.groupList); groupList.setOnClickListener(this); setSearch(); data=new ArrayList<String>(); qdMode = new Optsharepre_interface(KqList.this).getDataFromPres("QDMODE"); if(!qdMode.equals("3")){ data.add("其他"); } Optdb_interfce db = new Optdb_interfce(KqList.this); custs = db.searchkqAddrs(1,""); for(CustomerModule cust:custs){ data.add(cust.getShort_name()); } db.close_SqlDb(); adapter=new LxrAdapter(data, KqList.this); ddLv.setAdapter(adapter); ddLv.setOnItemClickListener(new OnItemClickListener() {//点击跳转到地点详细信息界面 @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { // TODO Auto-generated method stub Intent intent=new Intent(); Bundle bundle = new Bundle(); if(qdMode.equals("3")){ point = position; }else{ point = position-1; } if(position == 0 && !qdMode.equals("3")){ intent.putExtra("point", 1);//粗 }else{ intent.putExtra("point", 2);//精 CustomerModule cust = custs.get(point); bundle.putString("cid", cust.getCid()); bundle.putString("cname", cust.getCname()); bundle.putString("linkman", cust.getLinkman()); bundle.putString("link_sim", cust.getLink_sim()); bundle.putString("address", cust.getAddress()); bundle.putString("lon", cust.getLon()); bundle.putString("lat", cust.getLat()); bundle.putString("clon", cust.getClon()); bundle.putString("clat", cust.getClat()); bundle.putString("Short_name()", cust.getShort_name()); shareMethod.recordLog(cust.getShort_name()+","+cust.getClon()+","+cust.getClat()); } intent.putExtras(bundle); intent.setClass(KqList.this, Ddxq.class); startActivity(intent); } }); myApp = (MyApp) this.getApplication(); } @Override protected void onStart() { // TODO Auto-generated method stub super.onStart(); myApp.setGroupNums(""); } /** * 模糊搜索 */ private void setSearch(){ find.addTextChangedListener(new TextWatcher() { @Override public void afterTextChanged(Editable arg0) { // TODO Auto-generated method stub data=new ArrayList<String>(); if(!qdMode.equals("3")){ data.add("其他"); } Optdb_interfce db = new Optdb_interfce(KqList.this); custs = db.searchkqAddrs(1,find.getText().toString()); for(CustomerModule cust:custs){ data.add(cust.getShort_name()); } db.close_SqlDb(); adapter=new LxrAdapter(data, KqList.this); ddLv.setAdapter(adapter); ddLv.setOnItemClickListener(new OnItemClickListener() {//点击跳转到地点详细信息界面 @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { // TODO Auto-generated method stub Intent intent=new Intent(); Bundle bundle = new Bundle(); if(qdMode.equals("3")){ point = position; }else{ point = position-1; } if(position == 0 && !qdMode.equals("3")){ intent.putExtra("point", 1);//非正常签到 }else{ intent.putExtra("point", 2);//精 CustomerModule cust = custs.get(point); bundle.putString("cid", cust.getCid()); bundle.putString("cname", cust.getCname()); bundle.putString("linkman", cust.getLinkman()); bundle.putString("link_sim", cust.getLink_sim()); bundle.putString("address", cust.getAddress()); bundle.putString("lon", cust.getLon()); bundle.putString("lat", cust.getLat()); } intent.putExtras(bundle); intent.setClass(KqList.this, Ddxq.class); startActivity(intent); } }); } @Override public void beforeTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) { // TODO Auto-generated method stub } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { // TODO Auto-generated method stub } }); } @Override public void onClick(View v) { // TODO Auto-generated method stub if(v == groupList){ myApp.setModuleName("kq"); startActivity(new Intent().setClass(this, Fzcx.class)); } } @Override protected void onRestart() { // TODO Auto-generated method stub super.onRestart(); Log.e("onRestart", "onRestart"); Optsharepre_interface share_obj = new Optsharepre_interface(KqList.this); share_obj.editPres("istakephoto", "0"); } }