package com.jqyd.son; import java.util.regex.Pattern; import com.jqyd.manager.R; import android.app.Activity; import android.app.AlertDialog; import android.content.DialogInterface; import android.content.Intent; import android.net.Uri; import android.os.Bundle; import android.text.Html; import android.view.View; import android.view.View.OnClickListener; import android.view.View.OnLongClickListener; import android.widget.Button; import android.widget.TextView; public class Info extends Activity implements OnClickListener { private TextView title; private TextView info; private Button back; private String jhDetail = ""; Bundle bundle = null; private String phonestr ="";//电话号码 private String [] phonelist ;//电话号码集合 @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.info); info = (TextView) this.findViewById(R.id.info); title = (TextView) this.findViewById(R.id.title); back = (Button) this.findViewById(R.id.back); back.setOnClickListener(this); title.setOnClickListener(this); //title.getPaint().setFlags(Paint.UNDERLINE_TEXT_FLAG);//下划线 Intent intent = this.getIntent(); String moduleName = intent.getStringExtra("moduleName"); String infos = intent.getStringExtra("info"); String value = ""; if(moduleName.equals("rzcx")){ this.setTitle("日志详情"); bundle = this.getIntent().getExtras(); String rzlx = "常规工作"; if(rzlx.equals("1")){ rzlx = "常规工作"; }else if(rzlx.equals("2")){ rzlx = "市场走访"; }else if(rzlx.equals("3")){ rzlx = "陌生拜访"; }else if(rzlx.equals("4")){ rzlx = "二次回访"; }else if(rzlx.equals("5")){ rzlx = "市场检查"; } value = "<p>业务日期:"+bundle.getString("ywrq")+"</p>" +"<p>工作类型:"+rzlx+"</p>" +"<p>工作时长:"+bundle.getString("gzsc")+"小时"+"</p>" +"<p>工作成果:"+bundle.getString("gzcg")+"</p>" +"<p>工作内容:"+bundle.getString("gznr")+"</p>" +"<p>工作建议:"+bundle.getString("gzyj")+"</p>" +"<p>上报日期:"+bundle.getString("addtime").substring(0, bundle.getString("addtime").length()-5)+"</p>"; }else if(moduleName.equals("clcx")){ this.setTitle("差旅详情"); bundle = this.getIntent().getExtras(); value = "<p>出发地:"+bundle.getString("pro_start")+"-"+bundle.getString("city_start")+"</p>" +"<p>出发日期:"+bundle.getString("cfrq")+"</p>" +"<p>目的地:"+bundle.getString("pro_end")+"-"+bundle.getString("city_end")+"</p>" +"<p>返回日期:"+bundle.getString("fhrq")+"</p>" +"<p>交通方式:"+bundle.getString("jtfs")+"</p>" +"<p>备注说明:"+bundle.getString("bz")+"</p>" +"<p>审批状态:"+bundle.getString("spzt")+"</p>"; }else if(moduleName.equals("jhcx")){ this.setTitle("计划详情"); bundle = this.getIntent().getExtras(); value = "<p>计划类别:"+bundle.getString("jhlb")+"</p>" +"<p>开始日期:"+bundle.getString("ksrq")+"</p>" +"<p>结束日期:"+bundle.getString("jsrq")+"</p>" +"<p>计划数量:"+bundle.getString("jhsl")+"</p>" +"<p>目标客户:"+bundle.getString("mbkh")+"</p>" +"<p>备注:"+bundle.getString("bz")+"</p>" +"<p>状态:"+bundle.getString("status")+"</p>"; }else if(moduleName.equals("qjcx")){ this.setTitle("请假详情"); bundle = this.getIntent().getExtras(); value = "<p>请假类别:"+bundle.getString("qjlb")+"</p>" +"<p>开始日期:"+bundle.getString("ksrq")+"</p>" +"<p>结束日期:"+bundle.getString("jsrq")+"</p>" +"<p>请假天数:"+bundle.getString("day")+"天</p>" +"<p>请假时长:"+bundle.getString("qjsc")+"小时</p>" +"<p>请假事由:"+bundle.getString("bz")+"</p>" +"<p>审核状态:"+bundle.getString("sqzt")+"</p>" +"<p>上报日期:"+bundle.getString("addtime")+"</p>"; }else if(moduleName.equals("rwcx")){ this.setTitle("任务详情"); title.setVisibility(TextView.VISIBLE); bundle = this.getIntent().getExtras(); //任务完成状态(0-未完成 1-待审核 2-已完成) int state = Integer.valueOf(bundle.getString("state")); String stateStr = ""; switch(state){ case 1: stateStr = "未完成"; break; case 2: stateStr = "待审核"; break; case 3: stateStr = "已完成"; break; } String tit = "任务编号:<font color=blue><u>"+bundle.getString("tcode")+"</u></font>"; title.setText(Html.fromHtml(tit)); value = "<br>下达时间:"+bundle.getString("addtime")+"</br>" +"<p>下达者姓名:"+bundle.getString("adduser")+"</p>" +"<p>下达者部门:"+bundle.getString("dept")+"</p>" +"<p>任务类别:"+bundle.getString("tsort")+"</p>" +"<p>任务标题:"+bundle.getString("title")+"</p>" +"<p>任务状态:"+stateStr+"</p>"; jhDetail=bundle.getString("jhdetail"); }else if(moduleName.equals("gztxx")){ this.setTitle("公共信息详情"); String []datas = infos.split("#"); value = "<p>时间:"+datas[0]+"</p>" +"<p>内容:"+datas[1]+"</p>"; }else if(moduleName.equals("ggtz")){ this.setTitle("公告详情"); bundle = this.getIntent().getExtras(); String str = bundle.getString("content"); value = "<p>标题:"+bundle.getString("title")+"</p>"+ "<p>发布时间:"+bundle.getString("addtime")+"</p>"+ "<p>发布人:"+bundle.getString("g_cosim")+"</p>"+ "<p>发布内容:"+tophone(str)+"</p>"; }else if(moduleName.equals("xszs")){ bundle = this.getIntent().getExtras(); if(bundle.getString("p_sort").equals("1")){ this.setTitle("商品详情"); }else if(bundle.getString("p_sort").equals("2")){ this.setTitle("赠品详情"); }if(bundle.getString("p_sort").equals("3")){ this.setTitle("消耗品详情"); } String status = ""; if(bundle.getString("p_status").equals("1")){ status = "在售"; }else{ status = "停售"; } value = "<p>名称:"+bundle.getString("p_name")+"</p>"+ "<p>规格型号:"+bundle.getString("p_type")+"</p>"+ "<p>计价单位:"+bundle.getString("p_unit")+"</p>" +"<p>成本价:"+bundle.getString("p_cbj")+"</p>" +"<p>批发价:"+bundle.getString("p_pbj")+"</p>" +"<p>零售价:"+bundle.getString("p_lsj")+"</p>" +"<p>生产厂家:"+bundle.getString("p_factory")+"</p>" +"<p>生产地:"+bundle.getString("p_addr")+"</p>" +"<p>描述:"+bundle.getString("p_bz")+"</p>" +"<p>状态:"+status+"</p>"; }else if(moduleName.equals("lcgz")){ this.setTitle("流程跟踪详情"); String lcinfo = this.getIntent().getStringExtra("lcinfo"); value = lcinfo; }else if(moduleName.equals("sms")){ this.setTitle("短信详情"); bundle = this.getIntent().getExtras(); value = "<p>发送日期:"+bundle.getString("fsrq")+"</p>"+ "<p>操作员:"+bundle.getString("operSjhm")+"</p>"+ "<p>被叫号码:"+bundle.getString("bjhm")+"</p>"+ "<p>短信内容:"+bundle.getString("content")+"</p>"; }else if(moduleName.equals("wzxq")){ this.setTitle("短信详情"); bundle = this.getIntent().getExtras(); value = "<p>发送日期:"+bundle.getString("fsrq")+"</p>"+ "<p>操作员:"+bundle.getString("operSjhm")+"</p>"+ "<p>被叫号码:"+bundle.getString("bjhm")+"</p>"+ "<p>短信内容:"+bundle.getString("content")+"</p>"; } info.setText(Html.fromHtml(value)); } /** * 检测字符串中电话号码,重组字符串 * * @param queryIntent */ private String tophone(String str){ String mystr =str; String text; Pattern pattern = Pattern.compile("[0-9]*"); for(int i =0 ;i<str.length()-10;i++){ text = str.substring(i, i+11); if(pattern.matcher(text).matches()){ phonestr = phonestr +text+ ","; } } if(!phonestr.equals("")){ phonelist = phonestr.split(","); for (int i = 0; i < phonelist.length; i++) { mystr = mystr.replace(phonelist[i].toString(), "<font color=blue><u>"+phonelist[i]+"</u></font>"); } }else{ phonelist = new String[]{}; } if(phonelist.length>0){ info.setOnLongClickListener(new OnLongClickListener() { @Override public boolean onLongClick(View arg0) { // TODO Auto-generated method stub new AlertDialog.Builder(Info.this) .setTitle("请选择电话号码进行呼叫") .setItems(phonelist, new DialogInterface.OnClickListener() { public void onClick( DialogInterface dialog, int which) { dialTelAndSms(0, phonelist[which]); } }) .setNegativeButton("取消", new DialogInterface.OnClickListener() { public void onClick( DialogInterface dialog, int which) { } }).show(); return false; } }); } return mystr; } @Override public void onClick(View v) { // TODO Auto-generated method stub if(v == back){ finish(); }else{ Intent skipIntent = new Intent(); skipIntent.putExtra("jhDetail", jhDetail); startActivity(skipIntent.setClass(Info.this, Detail.class)); } } /** * 打电话、发短信 * * @param queryIntent */ public void dialTelAndSms(int flag, String tel) { if (flag == 0) { // 直接发起呼叫 Intent intent1 = new Intent(Intent.ACTION_CALL, Uri.parse("tel://" + tel)); startActivity(intent1); } else { // 执行发短信功能,调用系统接口 Uri smsToUri = Uri.parse("smsto:" + tel); Intent intent2 = new Intent(android.content.Intent.ACTION_SENDTO, smsToUri); intent2.putExtra("sms_body", ""); startActivity(intent2); } } }