修改eclipse项目为as项目
This commit is contained in:
2549
app/src/main/java/com/example/chaoran/DjActivity.java
Normal file
2549
app/src/main/java/com/example/chaoran/DjActivity.java
Normal file
File diff suppressed because it is too large
Load Diff
185
app/src/main/java/com/example/chaoran/DjtqActivity.java
Normal file
185
app/src/main/java/com/example/chaoran/DjtqActivity.java
Normal file
@ -0,0 +1,185 @@
|
||||
package com.example.chaoran;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.kobjects.base64.Base64;
|
||||
|
||||
import com.chaoran.component.MyAdapter;
|
||||
import com.chaoran.entiry.DataGrid;
|
||||
import com.chaoran.entiry.Djselefa;
|
||||
import com.example.chaoran.R;
|
||||
import com.util.DialogUtil;
|
||||
import com.util.IoUtil;
|
||||
import com.util.SqlUtil;
|
||||
import com.util.SysUtil;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.View;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.Button;
|
||||
import android.widget.ListView;
|
||||
import android.widget.AdapterView.OnItemClickListener;
|
||||
import android.widget.TextView;
|
||||
|
||||
public class DjtqActivity extends Activity {
|
||||
private ListView listview;
|
||||
private int cur_pos = -1;// 当前显示的一行
|
||||
// private ArrayList items_text = new ArrayList();
|
||||
private Djselefa djselefa;
|
||||
public ProgressDialog pd;
|
||||
public MyAdapter adapter;
|
||||
private ArrayList listdata;
|
||||
private String filedName;// 显示字段的名字
|
||||
private String gzid;
|
||||
private String mxTempTable;
|
||||
private Intent intent;
|
||||
private Handler runHandler = new Handler() {
|
||||
@Override
|
||||
public void handleMessage(Message msg) {
|
||||
super.handleMessage(msg);
|
||||
if (msg.what == -1) {
|
||||
DialogUtil.builder(DjtqActivity.this, "错误信息", "提取方案初始化失败:"
|
||||
+ msg.obj.toString(),0);
|
||||
} else if (msg.what == -4) {
|
||||
DialogUtil.builder(DjtqActivity.this, "错误信息", "提取方案运行失败:"
|
||||
+ msg.obj.toString(),0);
|
||||
} else {
|
||||
if (msg.arg1 == 4) {
|
||||
Object ob = msg.obj;
|
||||
if (ob instanceof ArrayList) {
|
||||
ArrayList list = (ArrayList) ob;
|
||||
if (list.size() > 0) {
|
||||
intent.putExtra("param", (HashMap) list.get(0));
|
||||
setResult(2, intent);
|
||||
}
|
||||
clear();
|
||||
} else {
|
||||
DialogUtil.builder(DjtqActivity.this, "提示信息",
|
||||
ob.toString(),0);
|
||||
}
|
||||
} else {
|
||||
HashMap map = (HashMap) msg.obj;
|
||||
DataGrid dg = (DataGrid) map.get("dg");
|
||||
listdata = dg.getTableData();
|
||||
if(listdata==null||listdata.size()<1){
|
||||
filedName="";
|
||||
}else{
|
||||
filedName=SysUtil.mapFirst(listdata);
|
||||
}
|
||||
if (adapter == null) {
|
||||
adapter = new MyAdapter(DjtqActivity.this, listdata,
|
||||
filedName);
|
||||
listview.setAdapter(adapter);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (pd != null) {
|
||||
pd.dismiss();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.list);
|
||||
listview = (ListView) findViewById(R.id.mxlist);
|
||||
intent = getIntent();
|
||||
HashMap paramMap = (HashMap) intent.getSerializableExtra("paramMap");
|
||||
djselefa = (Djselefa) paramMap.get("djselefa");
|
||||
pd = ProgressDialog.show(DjtqActivity.this, "正在执行提取方案", "正在下载……");
|
||||
try {
|
||||
new RunSearchThread(djselefa.getT_sql(), IoUtil.ob_base64(paramMap
|
||||
.get("t_sqlParam")), runHandler).start();
|
||||
} catch (IOException e) {
|
||||
// e.printStackTrace();
|
||||
DialogUtil.builder(this, "错误信息", "转换成Base64编码失败!",0);
|
||||
}
|
||||
gzid = paramMap.get("GZID").toString();
|
||||
mxTempTable = paramMap.get("mxTempTable").toString();
|
||||
intent.removeExtra("paramMap");
|
||||
TextView tv = (TextView) findViewById(R.id.mxtitle);
|
||||
tv.setText(djselefa.getFangamch());
|
||||
((Button) findViewById(R.id.mxbut)).setText("提取");
|
||||
listview.setChoiceMode(ListView.CHOICE_MODE_SINGLE);// 一定要设置这个属性,否则ListView不会刷新
|
||||
listview.setOnItemClickListener(new OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> arg0, View arg1,
|
||||
int position, long id) {
|
||||
cur_pos = position;// 更新当前行
|
||||
adapter.cur_pos = cur_pos;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void queryMx(View v) {
|
||||
try {
|
||||
if (cur_pos < 0) {
|
||||
DialogUtil.builder(this, "提示信息", "请选择一行!",0);
|
||||
} else {
|
||||
if (mxTempTable == null || mxTempTable.length() < 0) {
|
||||
DialogUtil.builder(this, "提示信息", "明细表不存在!",0);
|
||||
}
|
||||
HashMap item = (HashMap) listdata.get(cur_pos);
|
||||
HashMap hzData = SqlUtil.regSql(djselefa.getHz_sql(), item);
|
||||
HashMap mxData = SqlUtil.regSql(djselefa.getMx_sql(), item);
|
||||
HashMap hm = new HashMap();
|
||||
hm.put("gzid", gzid);
|
||||
hm.put("mxTempTable", mxTempTable);
|
||||
hm.put("hzSql", hzData.get("sql"));
|
||||
hm.put("hzParam", hzData.get("param"));
|
||||
hm.put("mxSql", mxData.get("sql"));
|
||||
hm.put("mxParam", mxData.get("param"));
|
||||
byte[] b = IoUtil.getbyte(hm);
|
||||
DialogUtil.setDialog(pd, "提示信息", "正在运行提取方案");
|
||||
new RunYmupThread(Base64.encode(b), runHandler, "runTqfa",0)
|
||||
.start();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
pd.dismiss();
|
||||
DialogUtil.builder(DjtqActivity.this, "错误信息", "提取修改方案组织数据失败!",0);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean onKeyUp(int keyCode, KeyEvent event) {
|
||||
if (keyCode == KeyEvent.KEYCODE_BACK && event.isTracking()
|
||||
&& !event.isCanceled()) {
|
||||
clear();
|
||||
return true;
|
||||
}
|
||||
return super.onKeyUp(keyCode, event);
|
||||
}
|
||||
|
||||
private void clear() {
|
||||
listview = null;
|
||||
if (pd != null) {
|
||||
pd.dismiss();
|
||||
pd = null;
|
||||
}
|
||||
djselefa = null;
|
||||
adapter = null;
|
||||
if (listdata != null) {
|
||||
listdata.clear();
|
||||
listdata = null;
|
||||
}
|
||||
filedName = null;
|
||||
gzid = null;
|
||||
mxTempTable = null;
|
||||
intent = null;
|
||||
runHandler = null;
|
||||
intent = null;
|
||||
finish();
|
||||
}
|
||||
|
||||
}
|
||||
75
app/src/main/java/com/example/chaoran/ExitThread.java
Normal file
75
app/src/main/java/com/example/chaoran/ExitThread.java
Normal file
@ -0,0 +1,75 @@
|
||||
package com.example.chaoran;
|
||||
|
||||
import org.ksoap2.SoapEnvelope;
|
||||
import org.ksoap2.serialization.SoapObject;
|
||||
import org.ksoap2.serialization.SoapSerializationEnvelope;
|
||||
import org.ksoap2.transport.HttpTransportSE;
|
||||
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.util.Log;
|
||||
|
||||
import com.sys.SysData;
|
||||
|
||||
public class ExitThread extends Thread {
|
||||
public String gzid;
|
||||
public String mxTempTable;
|
||||
public Handler handler;
|
||||
public String method;
|
||||
|
||||
public ExitThread(String gzid, String mxTempTable, Handler handler,
|
||||
String method) {
|
||||
this.gzid = gzid;
|
||||
this.mxTempTable = mxTempTable;
|
||||
this.handler = handler;
|
||||
this.method = method;
|
||||
}
|
||||
|
||||
public void run() {
|
||||
super.run();
|
||||
Log.v("SearchThread", "run执行");
|
||||
try {
|
||||
String url = SysData.url + "/webservice/ServiceInterface?wsdl";
|
||||
// method = "exitDj";
|
||||
SoapObject rpc = new SoapObject("", method);
|
||||
rpc.addProperty("gzid", gzid);
|
||||
rpc.addProperty("mxTempTable", mxTempTable);
|
||||
HttpTransportSE ht = new HttpTransportSE(url);
|
||||
ht.debug = true;
|
||||
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
|
||||
SoapEnvelope.VER11);
|
||||
envelope.bodyOut = rpc;
|
||||
envelope.dotNet = true;
|
||||
envelope.setOutputSoapObject(rpc);
|
||||
ht.call("", envelope);
|
||||
if (handler != null) {
|
||||
if (envelope.getResponse() != null) {// 判断是否返回结果,因为我这个是一个查询操作,是带有返回值的。
|
||||
Message msg = new Message();
|
||||
msg.obj = envelope.getResponse();
|
||||
if (method.equals("exitDj")) {
|
||||
msg.arg1 = 4;
|
||||
} else if (method.equals("queryMx")) {
|
||||
msg.arg1 = 5;
|
||||
}
|
||||
handler.sendMessage(msg);
|
||||
} else {
|
||||
Message msg = new Message();
|
||||
msg.obj = null;
|
||||
handler.sendMessage(msg);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
if (handler != null) {
|
||||
Message msg = new Message();
|
||||
if (method.equals("exitDj")) {
|
||||
msg.what = -4;
|
||||
} else if (method.equals("queryMx")) {
|
||||
msg.what = -5;
|
||||
}
|
||||
msg.obj = e.toString();
|
||||
handler.sendMessage(msg);
|
||||
// e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
698
app/src/main/java/com/example/chaoran/MainActivity.java
Normal file
698
app/src/main/java/com/example/chaoran/MainActivity.java
Normal file
@ -0,0 +1,698 @@
|
||||
package com.example.chaoran;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.ksoap2.SoapEnvelope;
|
||||
import org.ksoap2.serialization.SoapObject;
|
||||
import org.ksoap2.serialization.SoapSerializationEnvelope;
|
||||
import org.ksoap2.transport.HttpTransportSE;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
import com.chaoran.db.DBManager;
|
||||
import com.chaoran.db.SqlHelpUtil;
|
||||
import com.chaoran.entiry.UpdataInfo;
|
||||
import com.chaoran.entiry.UserList;
|
||||
import com.chaoran.lx.activity.DownDataActivity;
|
||||
import com.chaoran.thread.DownApk;
|
||||
import com.example.chaoran.R;
|
||||
import com.honeywell.aidc.AidcManager;
|
||||
import com.honeywell.aidc.AidcManager.CreatedCallback;
|
||||
import com.honeywell.aidc.BarcodeReader;
|
||||
import com.sys.SysData;
|
||||
import com.util.DialogUtil;
|
||||
import com.util.Dom4jUtil;
|
||||
import com.util.InstallUtil;
|
||||
import com.util.IoUtil;
|
||||
import com.util.SysUtil;
|
||||
|
||||
import android.content.pm.ActivityInfo;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager.NameNotFoundException;
|
||||
|
||||
import android.net.wifi.WifiManager;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.ProgressDialog;
|
||||
import android.app.AlertDialog.Builder;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.SharedPreferences.Editor;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.res.Configuration;
|
||||
import android.database.Cursor;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.EditText;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
public class MainActivity extends Activity {
|
||||
SqlHelpUtil db;
|
||||
SQLiteDatabase sDatabase;
|
||||
EditText name;
|
||||
EditText pwd;
|
||||
private CheckBox checkBox;
|
||||
private CheckBox islxScan;
|
||||
public ProgressDialog pd;
|
||||
private int loginTy;// 登录类型,1为在线登录 2为离线数据下载
|
||||
private TextView regts;
|
||||
public String versionStr;
|
||||
|
||||
public static float def_pbl = 0.9f; // 屏幕比列
|
||||
|
||||
//Honeywell 扫描设备控制
|
||||
private static BarcodeReader barcodeReader = null;
|
||||
private AidcManager manager = null;
|
||||
|
||||
private Handler handler = new Handler() {
|
||||
@Override
|
||||
// 当有消息发送出来的时候就执行Handler的这个方法
|
||||
public void handleMessage(Message msg) {
|
||||
if (msg.what == -1) {
|
||||
DialogUtil.builder(MainActivity.this, "错误信息", "连接服务器失败,请检查网络!"
|
||||
+ msg.obj,0);
|
||||
} else if (msg.what == -2) {
|
||||
DialogUtil.builder(MainActivity.this, "错误信息", "用户名或密码错误!",0);
|
||||
} else if (msg.what == -3) {
|
||||
DialogUtil.builder(MainActivity.this, "错误信息", "解析xml失败!",0);
|
||||
} else if (msg.what == -4) {
|
||||
DialogUtil.builder(MainActivity.this, "错误信息", "检查更新失败,请检查网络!",0);
|
||||
} else if (msg.what == -5) {
|
||||
DialogUtil.builder(MainActivity.this, "错误信息", "更新文件失败!",0);
|
||||
} else if (msg.what == 1) {
|
||||
UpdataInfo info = (UpdataInfo) msg.obj;
|
||||
System.out.println(info+"---------------------");
|
||||
System.out.println(versionStr+"---------------------");
|
||||
if (info!=null&&!info.getVersion().equals(versionStr)) {
|
||||
showUpdataDialog(info);
|
||||
}
|
||||
} else if (msg.what == 2) {
|
||||
new InstallUtil().installApk((File) msg.obj, MainActivity.this);
|
||||
} else {
|
||||
if (msg.obj.equals("该功能未授权")) {
|
||||
DialogUtil.builder(MainActivity.this, "提示信息", "该功能未授权!",0);
|
||||
} else {
|
||||
UserList user = (UserList) msg.obj;
|
||||
// System.out.println(so.hasProperty("lgnname"));
|
||||
if (user.getLgnname() == null) {
|
||||
String udesc = user.getUdesc();
|
||||
if (udesc.equals("0")) {
|
||||
DialogUtil.builder(MainActivity.this, "提示信息",
|
||||
"PDA未注册!",0);
|
||||
} else if (udesc.equals("1")) {
|
||||
DialogUtil.builder(MainActivity.this, "提示信息",
|
||||
"PDA还未授权使用!",0);
|
||||
} else if (udesc.equals("2")) {
|
||||
DialogUtil.builder(MainActivity.this, "提示信息",
|
||||
"试用期已过!",0);
|
||||
} else if (udesc.equals("3")) {
|
||||
DialogUtil.builder(MainActivity.this, "提示信息",
|
||||
"超出最大站点数,请联系管理员",0);
|
||||
} else if (udesc.equals("-1")) {
|
||||
DialogUtil.builder(MainActivity.this, "提示信息",
|
||||
"用户名或密码错误!",0);
|
||||
}
|
||||
|
||||
} else {
|
||||
// SysData.username=
|
||||
// so.getProperty("username").toString().trim();
|
||||
SysData.is_lx = false;
|
||||
login_end(user);
|
||||
// SysData.jigid = user.getJigid();
|
||||
// SysData.lgnname = user.getLgnname();
|
||||
// SysData.userid = String.valueOf(user.getUserid());
|
||||
// SysData.scale = MainActivity.this.getResources()
|
||||
// .getDisplayMetrics().density + 1;
|
||||
// SharedPreferences sp = MainActivity.this
|
||||
// .getSharedPreferences("userTxt", MODE_PRIVATE);
|
||||
// Editor editor = sp.edit();
|
||||
// editor.putString("name", name.getText().toString()
|
||||
// .trim());
|
||||
// editor.putString("pwd",
|
||||
// pwd.getText().toString().trim());
|
||||
// editor.commit();
|
||||
// Intent intent = new Intent();
|
||||
// intent.putExtra("displaymode",
|
||||
// user.getDisplaymode());
|
||||
// intent.setClass(getApplicationContext(),
|
||||
// DjActivity.class);
|
||||
// startActivity(intent);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (pd != null) {
|
||||
pd.dismiss();
|
||||
}
|
||||
}
|
||||
};
|
||||
private Handler regHandler = new Handler() {
|
||||
@Override
|
||||
// 当有消息发送出来的时候就执行Handler的这个方法
|
||||
public void handleMessage(Message msg) {
|
||||
if (msg.what != -1) {
|
||||
if(msg.equals("-1")){
|
||||
regts.setText("正式 注册");
|
||||
}else{
|
||||
regts.setText("软件到期时间"+msg.obj);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
public void login_end(UserList user) {
|
||||
SysData.jigid = user.getJigid();
|
||||
SysData.lgnname = user.getLgnname();
|
||||
SysData.userid = String.valueOf(user.getUserid());
|
||||
SysData.scale = MainActivity.this.getResources().getDisplayMetrics().density + 1;
|
||||
//SysData.t_scale = MainActivity.this.getResources().getDisplayMetrics().densityDpi >= 200f ? 200f / MainActivity.this.getResources().getDisplayMetrics().densityDpi : 200f * 0.95f / MainActivity.this.getResources().getDisplayMetrics().densityDpi;
|
||||
SysData.t_scale = MainActivity.this.getResources().getDisplayMetrics().densityDpi >= 300f ? 1 : 300f * def_pbl / MainActivity.this.getResources().getDisplayMetrics().densityDpi;
|
||||
SysData.exectime=Integer.parseInt(user.getUdesc() == null ? "60" : user.getUdesc());
|
||||
System.out.println(SysData.exectime+"---------------------------------------SysData.exectime");
|
||||
SharedPreferences sp = MainActivity.this.getSharedPreferences(
|
||||
"userTxt", MODE_PRIVATE);
|
||||
// Editor editor = sp.edit();
|
||||
// editor.putString("name", name.getText().toString().trim());
|
||||
// editor.putString("pwd", pwd.getText().toString().trim());
|
||||
// editor.commit();
|
||||
if (checkBox.isChecked()) {
|
||||
Editor editor = sp.edit();
|
||||
editor.putString("name", name.getText().toString().trim());
|
||||
editor.putString("pwd", pwd.getText().toString().trim());
|
||||
editor.putBoolean("islxScan",islxScan.isChecked());
|
||||
editor.commit();
|
||||
} else {
|
||||
sp.edit().clear().commit();
|
||||
name.setText("");
|
||||
pwd.setText("");
|
||||
}
|
||||
if (loginTy == 1) {
|
||||
String islxscan="1";
|
||||
if(islxScan.isChecked()){
|
||||
islxscan="0";
|
||||
}
|
||||
Intent intent = new Intent();
|
||||
intent.putExtra("displaymode", user.getDisplaymode());
|
||||
intent.putExtra("islxscan", islxscan);
|
||||
intent.setClass(getApplicationContext(), DjActivity.class);
|
||||
startActivity(intent);
|
||||
} else if (loginTy == 2) {
|
||||
Intent intent = new Intent();
|
||||
intent.setClass(getApplicationContext(), DownDataActivity.class);
|
||||
startActivity(intent);
|
||||
}
|
||||
SysData.no = name.getText().toString().trim();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
System.setProperty("http.keepAlive", "false");
|
||||
setContentView(R.layout.activity_main);
|
||||
SharedPreferences sp = getSharedPreferences("userTxt", MODE_PRIVATE);
|
||||
name = (EditText) findViewById(R.id.name);
|
||||
pwd = (EditText) findViewById(R.id.pwd);
|
||||
regts=(TextView) findViewById(R.id.regts);
|
||||
checkBox = (CheckBox) findViewById(R.id.cb);
|
||||
islxScan=(CheckBox)findViewById(R.id.lxs);
|
||||
if (!sp.contains("name")) {
|
||||
checkBox.setChecked(false);
|
||||
} else {
|
||||
name.setText(sp.getString("name", ""));
|
||||
pwd.setText(sp.getString("pwd", ""));
|
||||
islxScan.setChecked(sp.getBoolean("islxScan", true));
|
||||
}
|
||||
TextView version = (TextView) findViewById(R.id.version);
|
||||
versionStr=getVersionName();
|
||||
version.setText("版本".concat(versionStr));
|
||||
// SysData.clientid = Secure.getString(getContentResolver(),
|
||||
// Secure.ANDROID_ID);
|
||||
SysData.clientid = SysUtil.getLocalMacAddress(MainActivity.this);
|
||||
db = new SqlHelpUtil(getApplicationContext());
|
||||
sDatabase = db.getWritableDatabase();
|
||||
String selectStr = "select col1,col2,col3 from systable where desc='network'";
|
||||
Cursor select_cursor = sDatabase.rawQuery(selectStr, null);
|
||||
if (select_cursor.moveToFirst()) {
|
||||
SysData.url = "http://".concat(select_cursor.getString(0))
|
||||
.concat(":").concat(select_cursor.getString(1)).concat("/")
|
||||
.concat(select_cursor.getString(2));
|
||||
}
|
||||
select_cursor.close();
|
||||
selectStr = "select col1 from systable where desc='pdaState'";
|
||||
select_cursor = sDatabase.rawQuery(selectStr, null);
|
||||
if (select_cursor.moveToFirst()) {
|
||||
SysData.isreg = select_cursor.getString(0);
|
||||
System.out.println(SysData.isreg+"---------------------");
|
||||
}
|
||||
select_cursor.close();
|
||||
if (SysData.url != null) {
|
||||
new Thread(new CheckVersionTask()).start();
|
||||
new Thread(queryZcrq).start();
|
||||
}
|
||||
//
|
||||
BufferedReader br = null;
|
||||
BufferedWriter bw = null;
|
||||
File file = new File(getFilesDir().getAbsolutePath() + "/cr_pda_config");
|
||||
try {
|
||||
if (!file.exists())
|
||||
file.createNewFile();
|
||||
FileInputStream fis = new FileInputStream(file);
|
||||
InputStreamReader isr = new InputStreamReader(fis);
|
||||
br = new BufferedReader(isr);
|
||||
String s = br.readLine();
|
||||
if (s == null || s.trim().length() < 1)
|
||||
throw new Exception("Update config data.");
|
||||
def_pbl = Float.parseFloat(s);
|
||||
if (def_pbl < 0.1 || def_pbl > 10.0)
|
||||
throw new Exception("请填写 0.1~10.0 之间的浮点数!");
|
||||
} catch (Exception e) {
|
||||
def_pbl = 0.9f;
|
||||
try {
|
||||
FileOutputStream fos = new FileOutputStream(file);
|
||||
OutputStreamWriter osw = new OutputStreamWriter(fos);
|
||||
bw = new BufferedWriter(osw);
|
||||
bw.append(Float.toString(def_pbl));
|
||||
} catch (IOException e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
} finally {
|
||||
if (br != null) {
|
||||
try {
|
||||
br.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
if (bw != null) {
|
||||
try {
|
||||
bw.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
//
|
||||
if ("scanpal eda50".equals(android.os.Build.MODEL.toLowerCase())) {
|
||||
AidcManager.create(this, new CreatedCallback() {
|
||||
|
||||
@Override
|
||||
public void onCreated(AidcManager aidcManager) {
|
||||
manager = aidcManager;
|
||||
barcodeReader = manager.createBarcodeReader();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static BarcodeReader getBarcodeObject() {
|
||||
return barcodeReader;
|
||||
}
|
||||
|
||||
Runnable downloadRun = new Runnable() {
|
||||
public void run() {
|
||||
login(name.getText().toString().trim(), pwd.getText().toString()
|
||||
.trim());
|
||||
}
|
||||
};
|
||||
Runnable queryZcrq = new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
String url = SysData.url + "/webservice/ServiceInterface?wsdl";
|
||||
// System.out
|
||||
// .println(url
|
||||
// +
|
||||
// "--------------============================================");
|
||||
String method = "regEndRq";
|
||||
SoapObject rpc = new SoapObject("", method);
|
||||
HttpTransportSE ht = new HttpTransportSE(url, SysData.timeout);
|
||||
ht.debug = true;
|
||||
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
|
||||
SoapEnvelope.VER11);
|
||||
envelope.bodyOut = rpc;
|
||||
envelope.dotNet = true;
|
||||
envelope.setOutputSoapObject(rpc);
|
||||
ht.call("", envelope);
|
||||
Message message = new Message();
|
||||
message.obj = envelope.getResponse().toString();
|
||||
regHandler.sendMessage(message);
|
||||
} catch (Exception e) {
|
||||
Message message = new Message();
|
||||
message.what = -1;
|
||||
message.obj = e.toString();
|
||||
regHandler.sendMessage(message);
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
getMenuInflater().inflate(R.menu.activity_main, menu);
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* 获取当前程序的版本号
|
||||
*/
|
||||
private String getVersionName() {
|
||||
// 获取packagemanager的实例
|
||||
PackageManager packageManager = getPackageManager();
|
||||
// getPackageName()是你当前类的包名,0代表是获取版本信息
|
||||
PackageInfo packInfo = null;
|
||||
try {
|
||||
packInfo = packageManager.getPackageInfo(getPackageName(), 0);
|
||||
} catch (NameNotFoundException e) {
|
||||
DialogUtil.builder(MainActivity.this, "错误信息", "获取版本号失败!",0);
|
||||
}
|
||||
return packInfo.versionName;
|
||||
}
|
||||
|
||||
// 设置按钮监听
|
||||
public void onset(View v) {
|
||||
Intent intent = new Intent();
|
||||
intent.setClass(this, NetWorkSet.class);
|
||||
// intent.setClass(getApplicationContext(), BDMapActivity.class);
|
||||
startActivity(intent);
|
||||
// startActivityForResult(intent,0);
|
||||
}
|
||||
|
||||
public void onopentest(View v) {
|
||||
DialogUtil.builder(this, "测试标题","测试内容!open" + v.getLeft(), 18);
|
||||
// ScanManager sm = (ScanManager) getSystemService("olc_service_scan");
|
||||
//
|
||||
// sm.setScanSwitchLeft(false);
|
||||
// sm.setScanSwitchRight(false);
|
||||
// sm.setScanSwitchMiddle(false);
|
||||
}
|
||||
|
||||
public void onclosetest(View v) {
|
||||
DialogUtil.builder(this, "测试标题","测试内容!close" + v.getLeft(), 18);
|
||||
// ScanManager sm = (ScanManager) getSystemService("olc_service_scan");
|
||||
//
|
||||
// sm.setScanSwitchLeft(true);
|
||||
// sm.setScanSwitchRight(true);
|
||||
// sm.setScanSwitchMiddle(true);
|
||||
}
|
||||
|
||||
// 设置按钮监听
|
||||
public void onRotation(View v) {
|
||||
int i = MainActivity.this.getRequestedOrientation();
|
||||
// name.setText(i+"--"+ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT+"--"+ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
|
||||
if (i == ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT) {
|
||||
MainActivity.this
|
||||
.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
|
||||
}
|
||||
// 纵屏反方向
|
||||
else if (i == ActivityInfo.SCREEN_ORIENTATION_PORTRAIT || i == 3) {
|
||||
MainActivity.this
|
||||
.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isNull() {
|
||||
if (name.getText().toString().trim().equals("")) {
|
||||
DialogUtil.builder(this, "错误信息", "用户名不能为空!",0);
|
||||
name.requestFocus();
|
||||
return false;
|
||||
}
|
||||
if (pwd.getText().toString().trim().equals("")) {
|
||||
DialogUtil.builder(this, "错误信息", "密码不能为空!",0);
|
||||
pwd.requestFocus();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// 设置按钮监听
|
||||
public void onsub(View v) {
|
||||
// if (SysData.url == null) {
|
||||
// DialogUtil.builder(this, "错误信息", "请检查网络!");
|
||||
// return;
|
||||
// }
|
||||
loginTy = 1;
|
||||
start_login();
|
||||
}
|
||||
|
||||
public void start_login() {
|
||||
if (!isNull()) {
|
||||
return;
|
||||
}
|
||||
if (!SysUtil.isNetworkConnected(MainActivity.this)) {
|
||||
DialogUtil.builder(MainActivity.this, "提示", "网络没连接!请检查网络",0);
|
||||
return;
|
||||
}
|
||||
if (name.getText().toString().trim().equals("crtech")
|
||||
&& pwd.getText().toString().trim().equals("crtech")) {
|
||||
Intent pdaIntent = new Intent();
|
||||
pdaIntent.setClass(this, PdaRegActivity.class);
|
||||
startActivity(pdaIntent);
|
||||
return;
|
||||
}
|
||||
if (SysData.url == null || SysData.url.trim().length() < 1) {
|
||||
DialogUtil.builder(this, "错误信息", "请设置URL!",0);
|
||||
return;
|
||||
}
|
||||
if (SysData.clientid.trim().length() < 1) {
|
||||
DialogUtil.builder(this, "错误信息", "mac地址为空,请检查网络!",0);
|
||||
return;
|
||||
}
|
||||
if (pd == null) {
|
||||
pd = ProgressDialog.show(this, "提示", "正在登录……");
|
||||
} else {
|
||||
DialogUtil.setDialog(pd, "提示", "正在登录……");
|
||||
}
|
||||
|
||||
// DialogUtil.setDialog(pd, "提示", "" + MainActivity.this.getResources().getDisplayMetrics().densityDpi);
|
||||
new Thread(downloadRun).start();
|
||||
}
|
||||
|
||||
public void login(String name, String pwd) {
|
||||
// WifiManager wifiManager=(WifiManager)
|
||||
// this.getSystemService(Context.WIFI_SERVICE);
|
||||
// wifiManager.disconnect();
|
||||
// wifiManager.reconnect();
|
||||
try {
|
||||
String url = SysData.url + "/webservice/ServiceInterface?wsdl";
|
||||
// System.out
|
||||
// .println(url
|
||||
// + "--------------============================================");
|
||||
String method = "login";
|
||||
SoapObject rpc = new SoapObject("", method);
|
||||
rpc.addProperty("name", name);
|
||||
rpc.addProperty("pwd", pwd);
|
||||
rpc.addProperty("mac", SysData.clientid);
|
||||
HttpTransportSE ht = new HttpTransportSE(url, SysData.timeout);
|
||||
ht.debug = true;
|
||||
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
|
||||
SoapEnvelope.VER11);
|
||||
envelope.bodyOut = rpc;
|
||||
envelope.dotNet = true;
|
||||
envelope.setOutputSoapObject(rpc);
|
||||
ht.call("", envelope);
|
||||
if (envelope.getResponse() != null) {
|
||||
// SoapObject result = (SoapObject) envelope.bodyIn;
|
||||
// SoapObject soapChilds = (SoapObject) result.getProperty(0);
|
||||
// System.out.println(soapChilds+"---"+soapChilds.getProperty("jigid"));
|
||||
// System.out.println(soapChilds.getProperty("jigid"));
|
||||
byte[] bb = org.kobjects.base64.Base64.decode(envelope
|
||||
.getResponse().toString());
|
||||
Message message = new Message();
|
||||
message.obj = IoUtil.byte_obj(bb);
|
||||
handler.sendMessage(message);
|
||||
} else {
|
||||
Message message = new Message();
|
||||
message.what = -2;
|
||||
handler.sendMessage(message);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Message message = new Message();
|
||||
message.what = -1;
|
||||
message.obj = e.toString();
|
||||
handler.sendMessage(message);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||
if (event.KEYCODE_BACK == keyCode) {
|
||||
if (getRequestedOrientation() == ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT) {
|
||||
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
|
||||
}
|
||||
}
|
||||
return super.onKeyDown(keyCode, event);
|
||||
}
|
||||
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
if (db != null) {
|
||||
db.close();
|
||||
sDatabase.close();
|
||||
}
|
||||
if (barcodeReader != null) {
|
||||
// close BarcodeReader to clean up resources.
|
||||
barcodeReader.close();
|
||||
barcodeReader = null;
|
||||
}
|
||||
|
||||
if (manager != null) {
|
||||
// close AidcManager to disconnect from the scanner service.
|
||||
// once closed, the object can no longer be used.
|
||||
manager.close();
|
||||
}
|
||||
}
|
||||
|
||||
private void showUpdataDialog(final UpdataInfo info) {
|
||||
Builder builer = new Builder(this);
|
||||
builer.setTitle("版本升级");
|
||||
builer.setMessage(info.getDescription());
|
||||
// 当点确定按钮时从服务器上下载 新的apk 然后安装
|
||||
builer.setPositiveButton("确定", new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
downLoadApk(SysData.url.concat(info.getUrl()));
|
||||
}
|
||||
});
|
||||
// 当点取消按钮时进行登录
|
||||
builer.setNegativeButton("取消", new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
dialog.dismiss();
|
||||
}
|
||||
});
|
||||
AlertDialog dialog = builer.create();
|
||||
dialog.show();
|
||||
}
|
||||
|
||||
private void downLoadApk(String url) {
|
||||
ProgressDialog pd = new ProgressDialog(this);
|
||||
pd.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
|
||||
pd.setMessage("正在下载更新");
|
||||
pd.show();
|
||||
new Thread(new DownApk(pd, url, this.getApplicationContext(), handler))
|
||||
.start();
|
||||
}
|
||||
|
||||
public class CheckVersionTask implements Runnable {
|
||||
public void run() {
|
||||
InputStream is = null;
|
||||
HttpURLConnection conn = null;
|
||||
try {
|
||||
String path = SysData.url + "/apk.xml";
|
||||
System.out.println(path+"----------------------");
|
||||
URL url = new URL(path);
|
||||
conn = (HttpURLConnection) url.openConnection();
|
||||
conn.setConnectTimeout(5000);
|
||||
if (conn.getResponseCode() == 200) {
|
||||
is = conn.getInputStream();
|
||||
// UpdataInfo info = getUpdataInfo(is);
|
||||
Message msg = new Message();
|
||||
msg.what = 1;
|
||||
System.out.println(versionStr);
|
||||
msg.obj = Dom4jUtil.parserXml(is,versionStr);
|
||||
handler.sendMessage(msg);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Message msg = new Message();
|
||||
msg.what = -4;
|
||||
handler.sendMessage(msg);
|
||||
} finally {
|
||||
try {
|
||||
if (is != null)
|
||||
is.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
super.onOptionsItemSelected(item);
|
||||
switch (item.getItemId())// 得到被点击的item的itemId
|
||||
{
|
||||
case R.id.lxdatadown:
|
||||
loginTy = 2;
|
||||
start_login();
|
||||
// Intent intent = new Intent();
|
||||
// intent.setClass(getApplicationContext(), DownDataActivity.class);
|
||||
// startActivity(intent);
|
||||
break;
|
||||
case R.id.lxlogin:
|
||||
if (!isNull()) {
|
||||
return true;
|
||||
}
|
||||
DBManager dbManager = new DBManager(this);
|
||||
if (dbManager.existsTable("userlist".toUpperCase()) < 1) {
|
||||
DialogUtil.builder(MainActivity.this, "信息提示", "请下载用户资料表!",0);
|
||||
} else {
|
||||
String sql = "select jigid,lgnname,userid from userlist where username='"
|
||||
+ name.getText().toString().trim()
|
||||
+ "' and pass='"
|
||||
+ pwd.getText().toString().trim() + "'";
|
||||
Cursor cur = dbManager.query(sql);
|
||||
if (cur.getCount() == 0) {
|
||||
DialogUtil.builder(MainActivity.this, "信息提示", "用户账号错误!",0);
|
||||
} else {
|
||||
SysData.is_lx = true;
|
||||
UserList user = new UserList();
|
||||
if (cur.moveToFirst()) {
|
||||
user.setJigid(cur.getString(0));
|
||||
user.setLgnname(cur.getString(1));
|
||||
user.setUserid(cur.getInt(2));
|
||||
user.setDisplaymode("grid");
|
||||
loginTy = 1;
|
||||
login_end(user);
|
||||
}
|
||||
if (dbManager.existsTable("TEMP_BI_DJHZ".toUpperCase()) < 1) {
|
||||
dbManager
|
||||
.exeSql("create table TEMP_BI_DJHZ(FIELDNAME varchar(200),FIELDVALUE VARCHAR(8000))");
|
||||
}
|
||||
}
|
||||
cur.close();
|
||||
cur = null;
|
||||
}
|
||||
dbManager.closeDB();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 该方法解决屏幕旋转程序崩溃,需要对应 AndroidManifest.xml 文件 android:configChanges="orientation|screenSize|keyboardHidden" 配置
|
||||
*/
|
||||
public void onConfigurationChanged(Configuration newConfig) {
|
||||
// TODO Auto-generated method stub
|
||||
super.onConfigurationChanged(newConfig);
|
||||
if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
||||
Toast.makeText(this, "转换横屏", Toast.LENGTH_SHORT).show();
|
||||
} else if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) {
|
||||
Toast.makeText(this, "转换竖屏", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
}
|
||||
122
app/src/main/java/com/example/chaoran/MenuActivity.java
Normal file
122
app/src/main/java/com/example/chaoran/MenuActivity.java
Normal file
@ -0,0 +1,122 @@
|
||||
package com.example.chaoran;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.ksoap2.SoapEnvelope;
|
||||
import org.ksoap2.serialization.SoapObject;
|
||||
import org.ksoap2.serialization.SoapSerializationEnvelope;
|
||||
import org.ksoap2.transport.HttpTransportSE;
|
||||
|
||||
|
||||
import com.chaoran.entiry.DanJuEntity;
|
||||
import com.example.chaoran.R;
|
||||
import com.sys.SysData;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.view.Menu;
|
||||
import android.view.View;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ListView;
|
||||
import android.widget.SimpleAdapter;
|
||||
import android.widget.AdapterView.OnItemClickListener;
|
||||
|
||||
public class MenuActivity extends Activity {
|
||||
private ListView listView;
|
||||
private List mData;
|
||||
SimpleAdapter adapter;
|
||||
Runnable downloadRun = new Runnable() {
|
||||
public void run() {
|
||||
purview();
|
||||
}
|
||||
};
|
||||
private Handler handler = new Handler() {
|
||||
@Override
|
||||
// 当有消息发送出来的时候就执行Handler的这个方法
|
||||
public void handleMessage(Message msg) {
|
||||
adapter.notifyDataSetChanged();
|
||||
}
|
||||
|
||||
};
|
||||
public void purview(){
|
||||
try {
|
||||
String url = SysData.url+"/ChaoRanBI/webservice/ServiceInterface?wsdl";
|
||||
System.out.println(url);
|
||||
String method = "selectAndroidPurview";
|
||||
SoapObject rpc = new SoapObject("", method);
|
||||
rpc.addProperty("userid",SysData.userid);
|
||||
HttpTransportSE ht = new HttpTransportSE(url);
|
||||
ht.debug = true;
|
||||
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
|
||||
SoapEnvelope.VER11);
|
||||
envelope.bodyOut = rpc;
|
||||
envelope.dotNet = true;
|
||||
envelope.setOutputSoapObject(rpc);
|
||||
ht.call("", envelope);
|
||||
if (envelope.getResponse() != null) {// 判断是否返回结果,因为我这个是一个查询操作,是带有返回值的。
|
||||
byte[] bb = org.kobjects.base64.Base64.decode(envelope
|
||||
.getResponse().toString());
|
||||
ByteArrayInputStream bin = new ByteArrayInputStream(bb);
|
||||
ObjectInputStream oin = new ObjectInputStream(bin);
|
||||
List list= (List) oin.readObject();
|
||||
// for(int i=0;i<list.size();i++){
|
||||
// mData.add(list.get(i));
|
||||
// }
|
||||
mData.addAll(list);
|
||||
System.out.println(mData.size()+"----------");
|
||||
Message message = new Message();
|
||||
handler.sendMessage(message);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
new Thread(downloadRun).start();
|
||||
System.out.println("--------------------------------------");
|
||||
// for(int i=0;i<9;i++){
|
||||
// Map m=new HashMap();
|
||||
// m.put("mname","第"+i+"个选项");
|
||||
//
|
||||
// }
|
||||
mData=new ArrayList();
|
||||
adapter = new SimpleAdapter(this,mData,R.layout.activity_menu,
|
||||
new String[]{"mname"},
|
||||
new int[]{R.id.title});
|
||||
listView=new ListView(this);
|
||||
|
||||
listView.setAdapter(adapter);
|
||||
OnItemClickListener lis1 = new OnItemClickListener() {
|
||||
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
|
||||
long arg3) {
|
||||
Map map=(Map)mData.get(arg2);
|
||||
// System.out.println(map.get("gn_no"));
|
||||
Intent intent = new Intent();
|
||||
intent.putExtra("formlx", map.get("gn_no").toString());
|
||||
intent.setClass(getApplicationContext(), DjActivity.class);
|
||||
startActivity(intent);
|
||||
}
|
||||
};
|
||||
listView.setOnItemClickListener(lis1);
|
||||
setContentView(listView);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
getMenuInflater().inflate(R.menu.activity_menu, menu);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
229
app/src/main/java/com/example/chaoran/MipcaActivityCapture.java
Normal file
229
app/src/main/java/com/example/chaoran/MipcaActivityCapture.java
Normal file
@ -0,0 +1,229 @@
|
||||
package com.example.chaoran;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Vector;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.content.res.AssetFileDescriptor;
|
||||
import android.graphics.Bitmap;
|
||||
import android.media.AudioManager;
|
||||
import android.media.MediaPlayer;
|
||||
import android.media.MediaPlayer.OnCompletionListener;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Vibrator;
|
||||
import android.view.SurfaceHolder;
|
||||
import android.view.SurfaceHolder.Callback;
|
||||
import android.view.SurfaceView;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.widget.Button;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.example.chaoran.R;
|
||||
import com.google.zxing.BarcodeFormat;
|
||||
import com.google.zxing.Result;
|
||||
import com.mining.app.zxing.camera.CameraManager;
|
||||
import com.mining.app.zxing.decoding.CaptureActivityHandler;
|
||||
import com.mining.app.zxing.decoding.InactivityTimer;
|
||||
import com.mining.app.zxing.view.ViewfinderView;
|
||||
/**
|
||||
* 摄像头扫描条码
|
||||
*/
|
||||
public class MipcaActivityCapture extends Activity implements Callback {
|
||||
|
||||
private CaptureActivityHandler handler;
|
||||
private ViewfinderView viewfinderView;
|
||||
private boolean hasSurface;
|
||||
private Vector<BarcodeFormat> decodeFormats;
|
||||
private String characterSet;
|
||||
private InactivityTimer inactivityTimer;
|
||||
private MediaPlayer mediaPlayer;
|
||||
private boolean playBeep;
|
||||
private static final float BEEP_VOLUME = 0.10f;
|
||||
private boolean vibrate;
|
||||
private String uiId;
|
||||
|
||||
/** Called when the activity is first created. */
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.camerascansctivity);
|
||||
//ViewUtil.addTopView(getApplicationContext(), this, R.string.scan_card);
|
||||
CameraManager.init(getApplication());
|
||||
viewfinderView = (ViewfinderView) findViewById(R.id.viewfinder_view);
|
||||
Intent intent = getIntent();
|
||||
uiId = intent.getStringExtra("uiId");
|
||||
Button mButtonBack = (Button) findViewById(R.id.button_back);
|
||||
mButtonBack.setOnClickListener(new OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
MipcaActivityCapture.this.finish();
|
||||
|
||||
}
|
||||
});
|
||||
hasSurface = false;
|
||||
inactivityTimer = new InactivityTimer(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
SurfaceView surfaceView = (SurfaceView) findViewById(R.id.preview_view);
|
||||
SurfaceHolder surfaceHolder = surfaceView.getHolder();
|
||||
if (hasSurface) {
|
||||
initCamera(surfaceHolder);
|
||||
} else {
|
||||
surfaceHolder.addCallback(this);
|
||||
surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
|
||||
}
|
||||
decodeFormats = null;
|
||||
characterSet = null;
|
||||
|
||||
playBeep = true;
|
||||
AudioManager audioService = (AudioManager) getSystemService(AUDIO_SERVICE);
|
||||
if (audioService.getRingerMode() != AudioManager.RINGER_MODE_NORMAL) {
|
||||
playBeep = false;
|
||||
}
|
||||
initBeepSound();
|
||||
vibrate = true;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
if (handler != null) {
|
||||
handler.quitSynchronously();
|
||||
handler = null;
|
||||
}
|
||||
CameraManager.get().closeDriver();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
inactivityTimer.shutdown();
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理扫描结果
|
||||
* @param result
|
||||
* @param barcode
|
||||
*/
|
||||
public void handleDecode(Result result, Bitmap barcode) {
|
||||
inactivityTimer.onActivity();
|
||||
playBeepSoundAndVibrate();
|
||||
String resultString = result.getText();
|
||||
if (resultString.equals("")) {
|
||||
Toast.makeText(MipcaActivityCapture.this, "Scan failed!", Toast.LENGTH_SHORT).show();
|
||||
}else {
|
||||
Intent resultIntent = new Intent();
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString("tm", resultString);
|
||||
bundle.putString("uiId",uiId);
|
||||
System.out.println(resultString+"==============-"+uiId+"--------------------------------------------------------");
|
||||
// bundle.putParcelable("bitmap", barcode);
|
||||
resultIntent.putExtras(bundle);
|
||||
this.setResult(4, resultIntent);
|
||||
}
|
||||
MipcaActivityCapture.this.finish();
|
||||
}
|
||||
|
||||
private void initCamera(SurfaceHolder surfaceHolder) {
|
||||
try {
|
||||
CameraManager.get().openDriver(surfaceHolder);
|
||||
} catch (IOException ioe) {
|
||||
return;
|
||||
} catch (RuntimeException e) {
|
||||
return;
|
||||
}
|
||||
if (handler == null) {
|
||||
handler = new CaptureActivityHandler(this, decodeFormats,
|
||||
characterSet);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void surfaceChanged(SurfaceHolder holder, int format, int width,
|
||||
int height) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void surfaceCreated(SurfaceHolder holder) {
|
||||
if (!hasSurface) {
|
||||
hasSurface = true;
|
||||
initCamera(holder);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void surfaceDestroyed(SurfaceHolder holder) {
|
||||
hasSurface = false;
|
||||
|
||||
}
|
||||
|
||||
public ViewfinderView getViewfinderView() {
|
||||
return viewfinderView;
|
||||
}
|
||||
|
||||
public Handler getHandler() {
|
||||
return handler;
|
||||
}
|
||||
|
||||
public void drawViewfinder() {
|
||||
viewfinderView.drawViewfinder();
|
||||
|
||||
}
|
||||
|
||||
private void initBeepSound() {
|
||||
if (playBeep && mediaPlayer == null) {
|
||||
// The volume on STREAM_SYSTEM is not adjustable, and users found it
|
||||
// too loud,
|
||||
// so we now play on the music stream.
|
||||
setVolumeControlStream(AudioManager.STREAM_MUSIC);
|
||||
mediaPlayer = new MediaPlayer();
|
||||
mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
|
||||
mediaPlayer.setOnCompletionListener(beepListener);
|
||||
|
||||
AssetFileDescriptor file = getResources().openRawResourceFd(
|
||||
R.raw.beep);
|
||||
try {
|
||||
mediaPlayer.setDataSource(file.getFileDescriptor(),
|
||||
file.getStartOffset(), file.getLength());
|
||||
file.close();
|
||||
mediaPlayer.setVolume(BEEP_VOLUME, BEEP_VOLUME);
|
||||
mediaPlayer.prepare();
|
||||
} catch (IOException e) {
|
||||
mediaPlayer = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static final long VIBRATE_DURATION = 200L;
|
||||
|
||||
private void playBeepSoundAndVibrate() {
|
||||
if (playBeep && mediaPlayer != null) {
|
||||
mediaPlayer.start();
|
||||
}
|
||||
// if (vibrate) {
|
||||
// Vibrator vibrator = (Vibrator) getSystemService(VIBRATOR_SERVICE);
|
||||
// vibrator.vibrate(VIBRATE_DURATION);
|
||||
// }
|
||||
}
|
||||
|
||||
/**
|
||||
* When the beep has finished playing, rewind to queue up another one.
|
||||
*/
|
||||
private final OnCompletionListener beepListener = new OnCompletionListener() {
|
||||
public void onCompletion(MediaPlayer mediaPlayer) {
|
||||
mediaPlayer.seekTo(0);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
241
app/src/main/java/com/example/chaoran/NetWorkSet.java
Normal file
241
app/src/main/java/com/example/chaoran/NetWorkSet.java
Normal file
@ -0,0 +1,241 @@
|
||||
package com.example.chaoran;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.kobjects.base64.Base64;
|
||||
|
||||
import com.chaoran.db.SqlHelpUtil;
|
||||
import com.example.chaoran.R;
|
||||
import com.sys.SysData;
|
||||
import com.util.DialogUtil;
|
||||
import com.util.IoUtil;
|
||||
import com.util.SysUtil;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.provider.Settings.Secure;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.database.Cursor;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.view.Menu;
|
||||
import android.view.View;
|
||||
import android.widget.EditText;
|
||||
import android.widget.TextView;
|
||||
|
||||
@SuppressLint("NewApi")
|
||||
public class NetWorkSet extends Activity {
|
||||
private EditText ip;
|
||||
private EditText port;
|
||||
private EditText itemName;
|
||||
private EditText bz;
|
||||
private SqlHelpUtil db;
|
||||
private SQLiteDatabase sDatabase;
|
||||
|
||||
private Handler regHandler = new Handler() {
|
||||
@Override
|
||||
public void handleMessage(Message msg) {
|
||||
super.handleMessage(msg);
|
||||
if (msg.obj.equals("0")) {
|
||||
DialogUtil.builder(NetWorkSet.this, "提示信息", "注册成功!", 0);
|
||||
} else if (msg.obj.equals("1")) {
|
||||
DialogUtil.builder(NetWorkSet.this, "提示信息", "该PDA已注册!", 0);
|
||||
} else {
|
||||
DialogUtil.builder(NetWorkSet.this, "提示信息", "注册失败!" + msg.obj.toString(), 0);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
//
|
||||
BufferedReader br = null;
|
||||
BufferedWriter bw = null;
|
||||
File file = new File(getFilesDir().getAbsolutePath() + "/cr_pda_config");
|
||||
try {
|
||||
if (!file.exists()) {
|
||||
file.createNewFile();
|
||||
//DialogUtil.builder(NetWorkSet.this, "错误信息", "文件不存在!", 0);
|
||||
}
|
||||
FileInputStream fis = new FileInputStream(file);
|
||||
InputStreamReader isr = new InputStreamReader(fis);
|
||||
br = new BufferedReader(isr);
|
||||
String s = br.readLine();
|
||||
if (s == null || s.trim().length() < 1)
|
||||
throw new Exception("Update config data.");
|
||||
MainActivity.def_pbl = Float.parseFloat(s);
|
||||
if (MainActivity.def_pbl < 0.1 || MainActivity.def_pbl > 10.0)
|
||||
throw new Exception("请填写 0.1~10.0 之间的浮点数!");
|
||||
} catch (Exception e) {
|
||||
DialogUtil.builder(NetWorkSet.this, "错误信息", e.getMessage(), 0);
|
||||
MainActivity.def_pbl = 0.9f;
|
||||
try {
|
||||
FileOutputStream fos = new FileOutputStream(file);
|
||||
OutputStreamWriter osw = new OutputStreamWriter(fos);
|
||||
bw = new BufferedWriter(osw);
|
||||
bw.append(Float.toString(MainActivity.def_pbl));
|
||||
} catch (IOException e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
} finally {
|
||||
if (br != null) {
|
||||
try {
|
||||
br.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
if (bw != null) {
|
||||
try {
|
||||
bw.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
//
|
||||
setContentView(R.layout.activity_net_work_set);
|
||||
ip = (EditText) findViewById(R.id.ip);
|
||||
port = (EditText) findViewById(R.id.port);
|
||||
itemName = (EditText) findViewById(R.id.itemName);
|
||||
bz = (EditText) findViewById(R.id.bz);
|
||||
TextView mactv = (TextView) findViewById(R.id.mac);
|
||||
mactv.setText("mac:" + SysUtil.getLocalMacAddress(NetWorkSet.this));
|
||||
TextView androidIDtv = (TextView) findViewById(R.id.androidID);
|
||||
androidIDtv.setText("sn:" + SysUtil.getSn());
|
||||
EditText te = (EditText) findViewById(R.id.itemName91);
|
||||
te.setText(Float.toString(MainActivity.def_pbl));
|
||||
// MainActivity.this.getResources().getDisplayMetrics().densityDpi
|
||||
TextView modeltv = (TextView) findViewById(R.id.model);
|
||||
modeltv.setText("型号:" + android.os.Build.MODEL.toLowerCase());
|
||||
//
|
||||
TextView phoneDpi = (TextView) findViewById(R.id.phoneDpi);
|
||||
phoneDpi.setText("密度:" + getResources().getDisplayMetrics().densityDpi);
|
||||
//
|
||||
db = new SqlHelpUtil(getApplicationContext());
|
||||
sDatabase = db.getWritableDatabase();
|
||||
System.out.println(sDatabase.getMaximumSize() + "--------------------------");
|
||||
String selectStr = "select col1,col2,col3 from systable where desc='network'";
|
||||
Cursor select_cursor = sDatabase.rawQuery(selectStr, null);
|
||||
if (select_cursor.moveToFirst()) {
|
||||
ip.setText(select_cursor.getString(0));
|
||||
port.setText(select_cursor.getString(1));
|
||||
itemName.setText(select_cursor.getString(2));
|
||||
}
|
||||
select_cursor.close();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
getMenuInflater().inflate(R.menu.activity_net_work_set, menu);
|
||||
return true;
|
||||
}
|
||||
|
||||
public void onsub(View v) {
|
||||
EditText te = (EditText) findViewById(R.id.itemName91);
|
||||
try {
|
||||
MainActivity.def_pbl = Float.parseFloat(te.getText().toString());
|
||||
} catch (Exception ex) {
|
||||
DialogUtil.builder(NetWorkSet.this, "错误信息", "请填写 0.1~10.0 之间的浮点数!", 0);
|
||||
MainActivity.def_pbl = 0.9f;
|
||||
} finally {
|
||||
if (MainActivity.def_pbl < 0.1 || MainActivity.def_pbl > 10.0) {
|
||||
DialogUtil.builder(NetWorkSet.this, "错误信息", "请填写 0.1~10.0 之间的浮点数!", 0);
|
||||
MainActivity.def_pbl = 0.9f;
|
||||
}
|
||||
}
|
||||
//
|
||||
BufferedWriter bw = null;
|
||||
File file = new File(getFilesDir().getAbsolutePath() + "/cr_pda_config");
|
||||
|
||||
try {
|
||||
FileOutputStream fos = new FileOutputStream(file);
|
||||
OutputStreamWriter osw = new OutputStreamWriter(fos);
|
||||
bw = new BufferedWriter(osw);
|
||||
bw.append(Float.toString(MainActivity.def_pbl));
|
||||
} catch (IOException e1) {
|
||||
e1.printStackTrace();
|
||||
} finally {
|
||||
if (bw != null) {
|
||||
try {
|
||||
bw.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
//
|
||||
// DialogUtil.builder(NetWorkSet.this, "错误信息", "请检查网络!" +
|
||||
// MainActivity.def_pbl,0);
|
||||
if (ip.getText().toString().trim().equals("")) {
|
||||
DialogUtil.builder(NetWorkSet.this, "错误信息", "请填写IP!", 0);
|
||||
ip.requestFocus();
|
||||
return;
|
||||
}
|
||||
if (port.getText().toString().trim().equals("")) {
|
||||
DialogUtil.builder(NetWorkSet.this, "错误信息", "请填写端口!", 0);
|
||||
port.requestFocus();
|
||||
return;
|
||||
}
|
||||
if (itemName.getText().toString().trim().equals("")) {
|
||||
DialogUtil.builder(NetWorkSet.this, "错误信息", "请填写工程名!", 0);
|
||||
itemName.requestFocus();
|
||||
return;
|
||||
}
|
||||
String selectStr = "select col1 from systable where desc='network'";
|
||||
Cursor select_cursor = sDatabase.rawQuery(selectStr, null);
|
||||
String ipValue = ip.getText().toString().trim();
|
||||
String portValue = port.getText().toString().trim();
|
||||
String itemNameValue = itemName.getText().toString().trim();
|
||||
if (select_cursor.moveToFirst()) {
|
||||
sDatabase.execSQL("update systable set col1='" + ipValue + "',col2='" + portValue + "',col3='" + itemNameValue + "' where desc='network'");
|
||||
} else {
|
||||
sDatabase.execSQL("insert into systable (col1,col2,col3,desc) values('" + ipValue + "','" + portValue + "','" + itemNameValue + "','network')");
|
||||
}
|
||||
select_cursor.close();
|
||||
SysData.url = "http://".concat(ipValue).concat(":").concat(portValue).concat("/").concat(itemNameValue);
|
||||
DialogUtil.builder(NetWorkSet.this, "提示", "设置成功!", 0);
|
||||
}
|
||||
|
||||
public void onback(View v) {
|
||||
// Intent intent = this.getIntent();
|
||||
// setResult(0, intent);
|
||||
finish();
|
||||
|
||||
}
|
||||
|
||||
public void pdaRegister(View v) throws Exception {
|
||||
String mac = SysData.clientid;
|
||||
if (mac == null || mac.length() < 1) {
|
||||
DialogUtil.builder(NetWorkSet.this, "提示", "mac地址为空,请检查网络", 0);
|
||||
return;
|
||||
}
|
||||
HashMap map = new HashMap();
|
||||
map.put("mac", mac);
|
||||
map.put("bz", bz.getText().toString().trim());
|
||||
byte[] b = IoUtil.getbyte(map);
|
||||
String paramString = Base64.encode(b);
|
||||
new RunYmupThread(paramString, regHandler, "pdaRegister", 0).start();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
if (db != null) {
|
||||
db.close();
|
||||
sDatabase.close();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
111
app/src/main/java/com/example/chaoran/ParamActivity.java
Normal file
111
app/src/main/java/com/example/chaoran/ParamActivity.java
Normal file
@ -0,0 +1,111 @@
|
||||
package com.example.chaoran;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.chaoran.component.MyAdapter;
|
||||
import com.chaoran.entiry.DataGrid;
|
||||
import com.example.chaoran.R;
|
||||
import com.util.DialogUtil;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Color;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.Menu;
|
||||
import android.view.View;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ListView;
|
||||
import android.widget.SimpleAdapter;
|
||||
import android.widget.TextView;
|
||||
import android.widget.AdapterView.OnItemClickListener;
|
||||
|
||||
public class ParamActivity extends Activity {
|
||||
private ListView listView;
|
||||
private List listdata;
|
||||
private TextView tv;
|
||||
private MyAdapter mxAdapter;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_param);
|
||||
listView = (ListView) findViewById(R.id.list);
|
||||
tv = (TextView) findViewById(R.id.tvtitle);
|
||||
final Intent intent = getIntent();
|
||||
DataGrid dg = (DataGrid) intent.getSerializableExtra("dg");
|
||||
listdata = dg.getTableData();
|
||||
// SimpleAdapter mxAdapter = new SimpleAdapter(this,listdata,
|
||||
// R.layout.activity_menu,
|
||||
// new String[] {dg.getTableHead().get(0).get("columnName").toString()},
|
||||
// new int[] { R.id.title });
|
||||
|
||||
mxAdapter = new MyAdapter(this, (ArrayList) listdata, dg.getTableHead()
|
||||
.get(0).get("columnName").toString());
|
||||
tv.setText(dg.getTableHead().get(0).get("columnChineseName").toString());
|
||||
listView.setAdapter(mxAdapter);
|
||||
// listView.setChoiceMode(ListView.CHOICE_MODE_SINGLE);//
|
||||
// 一定要设置这个属性,否则ListView不会刷新
|
||||
OnItemClickListener lis1 = new OnItemClickListener() {
|
||||
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
|
||||
long arg3) {
|
||||
// mxAdapter.cur_pos=arg2;
|
||||
arg1.setBackgroundColor(Color.GREEN);
|
||||
Serializable map = (Serializable) listdata.get(arg2);
|
||||
// Intent int =getIntent();
|
||||
// intent.putExtra("param",map);
|
||||
intent.putExtra("param", map);
|
||||
intent.putExtra("audioFld",
|
||||
intent.getSerializableExtra("audioFld"));
|
||||
setResult(1, intent);
|
||||
clear();
|
||||
}
|
||||
};
|
||||
listView.setOnItemClickListener(lis1);
|
||||
}
|
||||
|
||||
public void onback(View v) {
|
||||
clear();
|
||||
}
|
||||
|
||||
public boolean onKeyUp(int keyCode, KeyEvent event) {
|
||||
if (keyCode == KeyEvent.KEYCODE_BACK && event.isTracking()
|
||||
&& !event.isCanceled()) {
|
||||
clear();
|
||||
return true;
|
||||
}
|
||||
if (keyCode == KeyEvent.KEYCODE_DPAD_DOWN) {
|
||||
if (mxAdapter.cur_pos < listdata.size()) {
|
||||
mxAdapter.cur_pos++;
|
||||
listView.setSelection(mxAdapter.cur_pos);
|
||||
mxAdapter.notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
if (keyCode == KeyEvent.KEYCODE_DPAD_UP) {
|
||||
if (mxAdapter.cur_pos >0) {
|
||||
mxAdapter.cur_pos--;
|
||||
listView.setSelection(mxAdapter.cur_pos);
|
||||
mxAdapter.notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
return super.onKeyUp(keyCode, event);
|
||||
}
|
||||
|
||||
private void clear() {
|
||||
listView = null;
|
||||
tv = null;
|
||||
if (listdata != null) {
|
||||
listdata.clear();
|
||||
listdata = null;
|
||||
mxAdapter.clear();
|
||||
mxAdapter = null;
|
||||
}
|
||||
finish();
|
||||
}
|
||||
|
||||
}
|
||||
190
app/src/main/java/com/example/chaoran/PdaRegActivity.java
Normal file
190
app/src/main/java/com/example/chaoran/PdaRegActivity.java
Normal file
@ -0,0 +1,190 @@
|
||||
package com.example.chaoran;
|
||||
|
||||
import org.ksoap2.SoapEnvelope;
|
||||
import org.ksoap2.serialization.SoapObject;
|
||||
import org.ksoap2.serialization.SoapSerializationEnvelope;
|
||||
import org.ksoap2.transport.HttpTransportSE;
|
||||
|
||||
import com.chaoran.db.SqlHelpUtil;
|
||||
import com.example.chaoran.R;
|
||||
import com.sys.SysData;
|
||||
import com.util.DialogUtil;
|
||||
import com.util.IoUtil;
|
||||
import com.util.SysUtil;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.app.Activity;
|
||||
import android.database.Cursor;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.view.Menu;
|
||||
import android.view.View;
|
||||
import android.widget.EditText;
|
||||
|
||||
public class PdaRegActivity extends Activity {
|
||||
private EditText ip;
|
||||
private EditText port;
|
||||
private EditText itemName;
|
||||
private SqlHelpUtil db;
|
||||
private SQLiteDatabase sDatabase;
|
||||
private Handler handler = new Handler() {
|
||||
@Override
|
||||
// 当有消息发送出来的时候就执行Handler的这个方法
|
||||
public void handleMessage(Message msg) {
|
||||
if (msg.what == -1) {
|
||||
DialogUtil.builder(PdaRegActivity.this, "错误信息", "连接服务器失败,请检查网络!"
|
||||
+ msg.obj,0);
|
||||
} else if (msg.what == -2) {
|
||||
DialogUtil.builder(PdaRegActivity.this, "错误信息", "返回值为空!",0);
|
||||
} else{
|
||||
String retunVal=msg.obj.toString();
|
||||
if(retunVal.equals("-1")){
|
||||
DialogUtil.builder(PdaRegActivity.this, "提示信息", "序列号还未注册!",0);
|
||||
}else if(!retunVal.equals("Y")){
|
||||
DialogUtil.builder(PdaRegActivity.this, "提示信息", "序列号还未启用!",0);
|
||||
}else{
|
||||
DialogUtil.builder(PdaRegActivity.this, "提示信息", "操作成功!",0);
|
||||
String selectStr = "select col1 from systable where desc='pdaState'";
|
||||
Cursor select_cursor = sDatabase.rawQuery(selectStr, null);
|
||||
if (select_cursor.moveToFirst()) {
|
||||
sDatabase.execSQL("update systable set col1='Y' where desc='pdaState'");
|
||||
} else {
|
||||
sDatabase
|
||||
.execSQL("insert into systable (col1,desc) values('Y','pdaState')");
|
||||
}
|
||||
select_cursor.close();
|
||||
SysData.isreg="Y";
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_pda_reg);
|
||||
ip = (EditText) findViewById(R.id.ip);
|
||||
port = (EditText) findViewById(R.id.port);
|
||||
itemName = (EditText) findViewById(R.id.itemName);
|
||||
db = new SqlHelpUtil(getApplicationContext());
|
||||
sDatabase = db.getWritableDatabase();
|
||||
String selectStr = "select col1,col2,col3 from systable where desc='pdaRegServer'";
|
||||
Cursor select_cursor = sDatabase.rawQuery(selectStr, null);
|
||||
if (select_cursor.moveToFirst()) {
|
||||
ip.setText(select_cursor.getString(0));
|
||||
port.setText(select_cursor.getString(1));
|
||||
itemName.setText(select_cursor.getString(2));
|
||||
}
|
||||
select_cursor.close();
|
||||
}
|
||||
|
||||
public void onsub(View v) {
|
||||
if (ip.getText().toString().trim().equals("")) {
|
||||
DialogUtil.builder(PdaRegActivity.this, "错误信息", "请填写服务器IP!",0);
|
||||
ip.requestFocus();
|
||||
return;
|
||||
}
|
||||
if (port.getText().toString().trim().equals("")) {
|
||||
DialogUtil.builder(PdaRegActivity.this, "错误信息", "请填写服务器端口!",0);
|
||||
port.requestFocus();
|
||||
return;
|
||||
}
|
||||
if (itemName.getText().toString().trim().equals("")) {
|
||||
DialogUtil.builder(PdaRegActivity.this, "错误信息", "请填写工程名!",0);
|
||||
itemName.requestFocus();
|
||||
return;
|
||||
}
|
||||
String selectStr = "select col1 from systable where desc='pdaRegServer'";
|
||||
Cursor select_cursor = sDatabase.rawQuery(selectStr, null);
|
||||
String ipValue = ip.getText().toString().trim();
|
||||
String portValue = port.getText().toString().trim();
|
||||
String itemNameValue = itemName.getText().toString().trim();
|
||||
if (select_cursor.moveToFirst()) {
|
||||
sDatabase.execSQL("update systable set col1='" + ipValue
|
||||
+ "',col2='" + portValue + "',col3='" + itemNameValue
|
||||
+ "' where desc='pdaRegServer'");
|
||||
} else {
|
||||
sDatabase
|
||||
.execSQL("insert into systable (col1,col2,col3,desc) values('"
|
||||
+ ipValue
|
||||
+ "','"
|
||||
+ portValue
|
||||
+ "','"
|
||||
+ itemNameValue + "','pdaRegServer')");
|
||||
}
|
||||
select_cursor.close();
|
||||
SysData.url = "http://".concat(ipValue).concat(":").concat(portValue)
|
||||
.concat("/").concat(itemNameValue);
|
||||
DialogUtil.builder(PdaRegActivity.this, "提示", "保存成功,请点下面的PDA注册按钮进行注册!",0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
getMenuInflater().inflate(R.menu.activity_pda_reg, menu);
|
||||
return true;
|
||||
}
|
||||
|
||||
public void onback(View v) {
|
||||
finish();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
if (db != null) {
|
||||
db.close();
|
||||
sDatabase.close();
|
||||
}
|
||||
}
|
||||
|
||||
public void pdaRegister(View v) throws Exception {
|
||||
String sn = SysUtil.getSn();
|
||||
if (sn == null || sn.length() < 1) {
|
||||
DialogUtil.builder(PdaRegActivity.this, "提示", "序列号为空,请联系供应商",0);
|
||||
return;
|
||||
}
|
||||
new Thread(new PdaRegValidate()).start();
|
||||
}
|
||||
|
||||
public class PdaRegValidate implements Runnable {
|
||||
public void run() {
|
||||
String ipValue = ip.getText().toString().trim();
|
||||
String portValue = port.getText().toString().trim();
|
||||
String itemNameValue = itemName.getText().toString().trim();
|
||||
String url = "http://".concat(ipValue).concat(":")
|
||||
.concat(portValue).concat("/").concat(itemNameValue);
|
||||
url = url + "/webservice/ServiceInterface?wsdl";
|
||||
System.out.println(url);
|
||||
String method = "pdaZcValidate";
|
||||
SoapObject rpc = new SoapObject("", method);
|
||||
System.out.println(SysUtil.getSn());
|
||||
rpc.addProperty("sn", SysUtil.getSn());
|
||||
try {
|
||||
HttpTransportSE ht = new HttpTransportSE(url, SysData.timeout);
|
||||
ht.debug = true;
|
||||
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
|
||||
SoapEnvelope.VER11);
|
||||
envelope.bodyOut = rpc;
|
||||
envelope.dotNet = true;
|
||||
envelope.setOutputSoapObject(rpc);
|
||||
ht.call("", envelope);
|
||||
if (envelope.getResponse() != null) {
|
||||
String s=envelope.getResponse().toString();
|
||||
Message message = new Message();
|
||||
message.obj = s;
|
||||
handler.sendMessage(message);
|
||||
}else{
|
||||
Message message = new Message();
|
||||
message.what = -2;
|
||||
handler.sendMessage(message);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Message message = new Message();
|
||||
message.what = -1;
|
||||
message.obj = e.toString();
|
||||
handler.sendMessage(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
92
app/src/main/java/com/example/chaoran/RunSearchThread.java
Normal file
92
app/src/main/java/com/example/chaoran/RunSearchThread.java
Normal file
@ -0,0 +1,92 @@
|
||||
package com.example.chaoran;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.ksoap2.SoapEnvelope;
|
||||
import org.ksoap2.serialization.SoapObject;
|
||||
import org.ksoap2.serialization.SoapSerializationEnvelope;
|
||||
import org.ksoap2.transport.HttpTransportSE;
|
||||
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.util.Log;
|
||||
|
||||
import com.chaoran.entiry.DataGrid;
|
||||
import com.chaoran.entiry.Sys_DanJuFormsOptions;
|
||||
import com.sys.SysData;
|
||||
import com.util.IoUtil;
|
||||
|
||||
/*运行检索方案线程*/
|
||||
public class RunSearchThread extends Thread {
|
||||
private String sql;
|
||||
private String param;
|
||||
private Handler handler;
|
||||
private String return_one;// 是否单行返回
|
||||
private String audioFld;// 声音播放字段
|
||||
|
||||
public RunSearchThread(String sql, String param, Handler handler,
|
||||
String return_one, String audioFld) {
|
||||
this.sql = sql;
|
||||
this.param = param;
|
||||
this.handler = handler;
|
||||
this.return_one = return_one;
|
||||
this.audioFld = audioFld;
|
||||
}
|
||||
|
||||
public RunSearchThread(String sql, String param, Handler handler) {
|
||||
this.sql = sql;
|
||||
this.param = param;
|
||||
this.handler = handler;
|
||||
}
|
||||
|
||||
public void run() {
|
||||
super.run();
|
||||
Log.v("RunSearchThread", "run执行");
|
||||
try {
|
||||
String url = SysData.url + "/webservice/ServiceInterface?wsdl";
|
||||
String method = "runSearch";
|
||||
SoapObject rpc = new SoapObject("", method);
|
||||
rpc.addProperty("sql", sql);
|
||||
rpc.addProperty("base64Param", param);
|
||||
HttpTransportSE ht = new HttpTransportSE(url,SysData.timeout);
|
||||
ht.debug = true;
|
||||
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
|
||||
SoapEnvelope.VER11);
|
||||
envelope.bodyOut = rpc;
|
||||
envelope.dotNet = true;
|
||||
envelope.setOutputSoapObject(rpc);
|
||||
ht.call("", envelope);
|
||||
byte[] bb = org.kobjects.base64.Base64.decode(envelope
|
||||
.getResponse().toString());
|
||||
Object ob = IoUtil.byte_obj(bb);
|
||||
if (ob instanceof DataGrid) {// 判断是否返回结果,因为我这个是一个查询操作,是带有返回值的。
|
||||
DataGrid dg = (DataGrid) ob;
|
||||
Map map = new HashMap();
|
||||
if (return_one != null) {
|
||||
map.put("return_one", return_one);
|
||||
}
|
||||
if (audioFld != null) {
|
||||
map.put("audioFld", audioFld);
|
||||
}
|
||||
map.put("dg", dg);
|
||||
Message msg = new Message();
|
||||
msg.obj = map;
|
||||
msg.arg1 = 1;
|
||||
handler.sendMessage(msg);
|
||||
} else {
|
||||
Message msg = new Message();
|
||||
msg.obj = ob.toString();
|
||||
msg.what = -1;
|
||||
handler.sendMessage(msg);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Message msg = new Message();
|
||||
msg.what = -1;
|
||||
msg.obj = e.toString();
|
||||
handler.sendMessage(msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
102
app/src/main/java/com/example/chaoran/RunYmupThread.java
Normal file
102
app/src/main/java/com/example/chaoran/RunYmupThread.java
Normal file
@ -0,0 +1,102 @@
|
||||
package com.example.chaoran;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.ksoap2.SoapEnvelope;
|
||||
import org.ksoap2.serialization.SoapObject;
|
||||
import org.ksoap2.serialization.SoapSerializationEnvelope;
|
||||
import org.ksoap2.transport.HttpTransportSE;
|
||||
|
||||
import com.chaoran.entiry.DataGrid;
|
||||
import com.sys.SysData;
|
||||
import com.util.IoUtil;
|
||||
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.util.Log;
|
||||
|
||||
public class RunYmupThread extends Thread {
|
||||
private String param;
|
||||
private Handler handler;
|
||||
private String methodName;
|
||||
private int urlTy;// 0表示访问ServiceInterface,1表示访问offLineInventoryInterface
|
||||
|
||||
public RunYmupThread(String param, Handler handler, String methodName,
|
||||
int urlTy) {
|
||||
this.param = param;
|
||||
this.handler = handler;
|
||||
this.methodName = methodName;
|
||||
this.urlTy = urlTy;
|
||||
}
|
||||
|
||||
public void run() {
|
||||
super.run();
|
||||
Log.v("SearchThread", "run执行");
|
||||
try {
|
||||
String url = null;
|
||||
if (urlTy == 0) {
|
||||
url = SysData.url + "/webservice/ServiceInterface?wsdl";
|
||||
} else if (urlTy == 1) {
|
||||
url = SysData.url
|
||||
+ "/webservice/offLineInventoryInterface?wsdl";
|
||||
}
|
||||
String method = methodName;
|
||||
SoapObject rpc = new SoapObject("", method);
|
||||
if (param != null) {
|
||||
rpc.addProperty("param", param);
|
||||
}
|
||||
HttpTransportSE ht = new HttpTransportSE(url, SysData.timeout);
|
||||
ht.debug = true;
|
||||
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
|
||||
SoapEnvelope.VER11);
|
||||
envelope.bodyOut = rpc;
|
||||
envelope.dotNet = true;
|
||||
envelope.setOutputSoapObject(rpc);
|
||||
ht.call("", envelope);
|
||||
if (envelope.getResponse() != null) {// 判断是否返回结果,因为我这个是一个查询操作,是带有返回值的。
|
||||
// byte[] bb = org.kobjects.base64.Base64.decode(envelope
|
||||
// .getResponse().toString());
|
||||
// Map map= (Map)IoUtil.byte_obj(bb);
|
||||
// Message msg = new Message();
|
||||
// msg.obj = map;
|
||||
// msg.arg1=2;
|
||||
// handler.sendMessage(msg);
|
||||
Message msg = new Message();
|
||||
if (methodName.equals("saveDj")) {
|
||||
msg.arg1 = 3;
|
||||
msg.obj = envelope.getResponse().toString();
|
||||
} else if (methodName.equals("pdaRegister")) {
|
||||
msg.obj = envelope.getResponse().toString();
|
||||
} else {
|
||||
byte[] bb = org.kobjects.base64.Base64.decode(envelope
|
||||
.getResponse().toString());
|
||||
msg.obj = IoUtil.byte_obj(bb);
|
||||
if (methodName.equals("runYmup")) {
|
||||
msg.arg1 = 2;
|
||||
} else if (methodName.equals("runTqfa")) {
|
||||
msg.arg1 = 4;
|
||||
}
|
||||
}
|
||||
handler.sendMessage(msg);
|
||||
} else {
|
||||
Message msg = new Message();
|
||||
msg.obj = null;
|
||||
handler.sendMessage(msg);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Message msg = new Message();
|
||||
if (methodName.equals("runYmup")) {
|
||||
msg.what = -2;
|
||||
} else if (methodName.equals("saveDj")) {
|
||||
msg.what = -3;
|
||||
} else if (methodName.equals("runTqfa")) {
|
||||
msg.what = -4;
|
||||
}else{
|
||||
msg.what = -1;
|
||||
}
|
||||
msg.obj = e.toString();
|
||||
handler.sendMessage(msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
66
app/src/main/java/com/example/chaoran/SearchThread.java
Normal file
66
app/src/main/java/com/example/chaoran/SearchThread.java
Normal file
@ -0,0 +1,66 @@
|
||||
package com.example.chaoran;
|
||||
|
||||
import org.ksoap2.SoapEnvelope;
|
||||
import org.ksoap2.serialization.SoapObject;
|
||||
import org.ksoap2.serialization.SoapSerializationEnvelope;
|
||||
import org.ksoap2.transport.HttpTransportSE;
|
||||
import com.sys.SysData;
|
||||
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.util.Log;
|
||||
|
||||
public class SearchThread extends Thread {
|
||||
private String fangalx;
|
||||
private String functionname;
|
||||
private Handler handler;
|
||||
private int type;// 0 表示检索方案 1表示 页面修改方案,2表示提取方案
|
||||
|
||||
public SearchThread(String fangalx, String functionname, Handler handler,
|
||||
int type) {
|
||||
this.fangalx = fangalx;
|
||||
this.functionname = functionname;
|
||||
this.handler = handler;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public void run() {
|
||||
super.run();
|
||||
Log.v("SearchThread", "run执行");
|
||||
try {
|
||||
String url = SysData.url
|
||||
+ "/webservice/ServiceInterface?wsdl";
|
||||
String method = null;
|
||||
if (type == 0) {
|
||||
method = "queryZdysql";
|
||||
} else if(type==1) {
|
||||
method = "selectYmupSql";
|
||||
}else if(type==2) {
|
||||
method = "selectDjtqFun";
|
||||
}
|
||||
SoapObject rpc = new SoapObject("", method);
|
||||
rpc.addProperty("fangalx", fangalx);
|
||||
rpc.addProperty("functionname", functionname);
|
||||
HttpTransportSE ht = new HttpTransportSE(url,SysData.timeout);
|
||||
ht.debug = true;
|
||||
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
|
||||
SoapEnvelope.VER11);
|
||||
envelope.bodyOut = rpc;
|
||||
envelope.dotNet = true;
|
||||
envelope.setOutputSoapObject(rpc);
|
||||
ht.call("", envelope);
|
||||
if (envelope.getResponse() != null) {// 判断是否返回结果,因为我这个是一个查询操作,是带有返回值的。
|
||||
Message msg = new Message();
|
||||
msg.obj = org.kobjects.base64.Base64.decode(envelope
|
||||
.getResponse().toString());
|
||||
msg.arg1 = type;
|
||||
handler.sendMessage(msg);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Message msg = new Message();
|
||||
msg.what = -1;
|
||||
msg.obj = e.toString();
|
||||
handler.sendMessage(msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
92
app/src/main/java/com/example/chaoran/UpdatePwdActivity.java
Normal file
92
app/src/main/java/com/example/chaoran/UpdatePwdActivity.java
Normal file
@ -0,0 +1,92 @@
|
||||
package com.example.chaoran;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.ksoap2.serialization.SoapObject;
|
||||
|
||||
import com.chaoran.entiry.UpdataInfo;
|
||||
import com.chaoran.thread.UpdatePwdThread;
|
||||
import com.example.chaoran.R;
|
||||
import com.sys.SysData;
|
||||
import com.util.DialogUtil;
|
||||
import com.util.InstallUtil;
|
||||
|
||||
import android.R.color;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.app.Activity;
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Color;
|
||||
import android.view.Menu;
|
||||
import android.view.View;
|
||||
import android.widget.EditText;
|
||||
|
||||
public class UpdatePwdActivity extends Activity {
|
||||
private EditText newPwd;
|
||||
private EditText CfNewPwd;
|
||||
public ProgressDialog pd;
|
||||
private Handler handler = new Handler() {
|
||||
@Override
|
||||
// 当有消息发送出来的时候就执行Handler的这个方法
|
||||
public void handleMessage(Message msg) {
|
||||
if (pd != null) {
|
||||
pd.dismiss();
|
||||
}
|
||||
if (msg.what == -1) {
|
||||
DialogUtil.builder(UpdatePwdActivity.this, "错误信息", msg.obj.toString(),0);
|
||||
}else{
|
||||
if(msg.obj.equals("0")){
|
||||
DialogUtil.builder(UpdatePwdActivity.this, "提示信息","修改密码成功",0);
|
||||
}else{
|
||||
DialogUtil.builder(UpdatePwdActivity.this, "错误信息","修改密码失败".concat( msg.obj.toString()),0);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstaneceState) {
|
||||
super.onCreate(savedInstaneceState);
|
||||
setContentView(R.layout.activity_update_pwd);
|
||||
((EditText)findViewById(R.id.name)).setText(SysData.lgnname);
|
||||
newPwd=(EditText)findViewById(R.id.newpwd);
|
||||
CfNewPwd=(EditText)findViewById(R.id.cfnewpwd);
|
||||
newPwd.requestFocus();
|
||||
}
|
||||
public void onsub(View v) {
|
||||
String newPwdValue=newPwd.getText().toString().trim();
|
||||
if(newPwdValue.equals("")){
|
||||
DialogUtil.builder(this, "错误信息", "请填写新密码!",0);
|
||||
newPwd.requestFocus();
|
||||
return;
|
||||
}
|
||||
String CfNewPwdValue=CfNewPwd.getText().toString().trim();
|
||||
if(CfNewPwdValue.equals("")){
|
||||
DialogUtil.builder(this, "错误信息", "请填写重复密码!",0);
|
||||
CfNewPwd.requestFocus();
|
||||
return;
|
||||
}
|
||||
if(!CfNewPwdValue.equals(newPwdValue)){
|
||||
DialogUtil.builder(this, "错误信息", "新密码和重复密码不一致!",0);
|
||||
newPwd.requestFocus();
|
||||
return;
|
||||
}
|
||||
if (pd == null) {
|
||||
pd = ProgressDialog.show(this, "提示", "正在操作……");
|
||||
} else {
|
||||
DialogUtil.setDialog(pd, "提示", "正在操作……");
|
||||
}
|
||||
new Thread(new UpdatePwdThread(handler,SysData.userid,newPwdValue)).start();
|
||||
}
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
if (pd != null) {
|
||||
pd=null;
|
||||
}
|
||||
handler=null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user