|
|
@@ -8,6 +8,7 @@ import android.content.Intent;
|
|
|
import android.content.pm.PackageManager;
|
|
|
import android.graphics.BitmapFactory;
|
|
|
import android.graphics.drawable.BitmapDrawable;
|
|
|
+import android.os.Environment;
|
|
|
import android.os.Handler;
|
|
|
import android.os.Message;
|
|
|
import android.support.annotation.NonNull;
|
|
|
@@ -39,6 +40,7 @@ import android.widget.PopupWindow;
|
|
|
import android.widget.RelativeLayout;
|
|
|
import android.widget.SimpleAdapter;
|
|
|
import android.widget.TextView;
|
|
|
+import android.widget.Toast;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
@@ -52,10 +54,10 @@ import com.scwang.smartrefresh.layout.api.RefreshLayout;
|
|
|
import com.uas.esop.R;
|
|
|
import com.uas.esop.adapter.PdfOrImageAdapter;
|
|
|
import com.uas.esop.application.PdaApplication;
|
|
|
+import com.uas.esop.bean.CloseEventBusBean;
|
|
|
import com.uas.esop.bean.IpAndPortBean;
|
|
|
import com.uas.esop.bean.Master;
|
|
|
import com.uas.esop.bean.ResourcefileBean;
|
|
|
-import com.uas.esop.bean.TCPEventBusBean;
|
|
|
import com.uas.esop.fragment.BaseFragment;
|
|
|
import com.uas.esop.fragment.WorkOrderSearchFragment;
|
|
|
import com.uas.esop.global.GloableParams;
|
|
|
@@ -85,13 +87,18 @@ import org.greenrobot.eventbus.EventBus;
|
|
|
import org.greenrobot.eventbus.Subscribe;
|
|
|
|
|
|
import java.io.BufferedReader;
|
|
|
+import java.io.File;
|
|
|
+import java.io.FileInputStream;
|
|
|
+import java.io.FileOutputStream;
|
|
|
import java.io.InputStream;
|
|
|
import java.io.InputStreamReader;
|
|
|
+import java.io.PrintStream;
|
|
|
import java.net.ServerSocket;
|
|
|
import java.net.Socket;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
+import java.util.Scanner;
|
|
|
import java.util.regex.Matcher;
|
|
|
import java.util.regex.Pattern;
|
|
|
|
|
|
@@ -156,6 +163,12 @@ public class IndexActivity extends BaseActivity implements AdapterView.OnItemCli
|
|
|
private TextView tv_ps_stepcode;
|
|
|
private TextView tv_pr_spec;
|
|
|
private TextView tv_pr_detail;
|
|
|
+ private String ss_brdipsone;
|
|
|
+ private String ss_brdportsone;
|
|
|
+ private TextView btn_sengMessage;
|
|
|
+ private File file = null;
|
|
|
+ private String filePath;
|
|
|
+ private String fileName;
|
|
|
|
|
|
@Override
|
|
|
protected void onDestroy() {
|
|
|
@@ -202,7 +215,7 @@ public class IndexActivity extends BaseActivity implements AdapterView.OnItemCli
|
|
|
tv_pr_spec = findViewById(R.id.tv_pr_spec);
|
|
|
tv_pr_detail = findViewById(R.id.tv_pr_detail);
|
|
|
|
|
|
- TextView btn_sengMessage = findViewById(R.id.btn_sengMessage);
|
|
|
+ btn_sengMessage = findViewById(R.id.btn_sengMessage);
|
|
|
tcp_text = findViewById(R.id.tcp_text);
|
|
|
findViewById(R.id.index_edit).setOnClickListener(this);
|
|
|
mRefreshLayout = findViewById(R.id.SmartRefreshLayout_id);
|
|
|
@@ -252,6 +265,7 @@ public class IndexActivity extends BaseActivity implements AdapterView.OnItemCli
|
|
|
btn_get.setOnClickListener(new View.OnClickListener() {
|
|
|
@Override
|
|
|
public void onClick(View v) {
|
|
|
+// ioData();
|
|
|
if (StringUtil.isEmpty(filename)) {
|
|
|
CommonUtil.toastNoRepeat(IndexActivity.this, "请先获取数据");
|
|
|
return;
|
|
|
@@ -475,12 +489,14 @@ public class IndexActivity extends BaseActivity implements AdapterView.OnItemCli
|
|
|
|
|
|
}
|
|
|
});
|
|
|
- String ss_brdips = SharedPreUtil.getString(IndexActivity.this, "ss_brdip", null);
|
|
|
- String ss_brdports = SharedPreUtil.getString(IndexActivity.this, "ss_brdport", null);
|
|
|
+ ss_brdipsone = SharedPreUtil.getString(IndexActivity.this, "ss_brdip", null);
|
|
|
+ ss_brdportsone = SharedPreUtil.getString(IndexActivity.this, "ss_brdport", null);
|
|
|
sound_monitor_vibration_sv2.setOnClickListener(new View.OnClickListener() {
|
|
|
@Override
|
|
|
public void onClick(View v) {
|
|
|
- if (StringUtil.isEmpty(ss_brdips)||StringUtil.isEmpty(ss_brdports)){
|
|
|
+ ss_brdipsone = SharedPreUtil.getString(IndexActivity.this, "ss_brdip", null);
|
|
|
+ ss_brdportsone = SharedPreUtil.getString(IndexActivity.this, "ss_brdport", null);
|
|
|
+ if (StringUtil.isEmpty(ss_brdipsone)||StringUtil.isEmpty(ss_brdportsone)){
|
|
|
error_ok_image=false;
|
|
|
sound_monitor_vibration_sv2.setSelected(false);
|
|
|
CommonUtil.toastNoRepeat(IndexActivity.this,"站点或端口为空");
|
|
|
@@ -499,8 +515,18 @@ public class IndexActivity extends BaseActivity implements AdapterView.OnItemCli
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
@Override
|
|
|
protected void initEvents() {
|
|
|
menuGridView.setOnItemClickListener(this);
|
|
|
@@ -544,6 +570,64 @@ public class IndexActivity extends BaseActivity implements AdapterView.OnItemCli
|
|
|
|
|
|
|
|
|
}
|
|
|
+ private static final String FILENAME = "mydata.txt" ;// 设置文件名称
|
|
|
+ private static final String DIR = "ljpdata" ;
|
|
|
+ public void ioData(){
|
|
|
+ if(Environment.getExternalStorageState().equals(
|
|
|
+ Environment.MEDIA_MOUNTED)){ // 如果sdcard存在
|
|
|
+ File file = new File(Environment
|
|
|
+ .getExternalStorageDirectory().toString()
|
|
|
+ + File.separator
|
|
|
+ + DIR + File.separator + FILENAME) ; // 定义File类对象
|
|
|
+ if (! file.getParentFile().exists()) { // 父文件夹不存在
|
|
|
+ file.getParentFile().mkdirs() ; // 创建文件夹
|
|
|
+ }
|
|
|
+ PrintStream out = null ; // 打印流对象用于输出
|
|
|
+ try {
|
|
|
+ out = new PrintStream(new FileOutputStream(file, true)); // 追加文件
|
|
|
+ out.println("山东大学软件学院(SDU,www.sdu.edu.cn),讲师:学生");
|
|
|
+ ioduqudata();
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ } finally {
|
|
|
+ if (out != null) {
|
|
|
+ out.close() ; // 关闭打印流
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else { // SDCard不存在,使用Toast提示用户
|
|
|
+ Toast.makeText(this, "保存失败,SD卡不存在!",Toast.LENGTH_LONG).show();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 设置保存文件夹
|
|
|
+ private TextView msg = null ;
|
|
|
+ public void ioduqudata(){
|
|
|
+ if(Environment.getExternalStorageState().equals(
|
|
|
+ Environment.MEDIA_MOUNTED)){ // 如果sdcard存在
|
|
|
+ File file = new File(Environment
|
|
|
+ .getExternalStorageDirectory().toString()
|
|
|
+ + File.separator
|
|
|
+ + DIR + File.separator + FILENAME) ; // 定义File类对象
|
|
|
+ if (! file.getParentFile().exists()) { // 父文件夹不存在
|
|
|
+ file.getParentFile().mkdirs() ; // 创建文件夹
|
|
|
+ }
|
|
|
+ Scanner scan = null ; // 扫描输入
|
|
|
+ try {
|
|
|
+ scan = new Scanner(new FileInputStream(file)) ; // 实例化Scanner
|
|
|
+ while(scan.hasNext()){ // 循环读取
|
|
|
+ this.msg.append(scan.next() +""); // 设置文本
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ } finally {
|
|
|
+ if (scan != null) {
|
|
|
+ scan.close() ; // 关闭打印流
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else { // SDCard不存在,使用Toast提示用户
|
|
|
+ Toast.makeText(this, "读取失败,SD卡不存在!",Toast.LENGTH_LONG).show();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
@Override
|
|
|
public void onClick(View v) {
|
|
|
@@ -695,6 +779,9 @@ public class IndexActivity extends BaseActivity implements AdapterView.OnItemCli
|
|
|
SharedPreUtil.saveString(IndexActivity.this,"ss_code", ss_codetext);
|
|
|
SharedPreUtil.saveString(IndexActivity.this,"ss_brdip", ss_brdip);
|
|
|
SharedPreUtil.saveString(IndexActivity.this,"ss_brdport", ss_brdport);
|
|
|
+ String ss_brdports = SharedPreUtil.getString(IndexActivity.this, "ss_brdport", null);
|
|
|
+ String ss_brdip = SharedPreUtil.getString(IndexActivity.this, "ss_brdip", null);
|
|
|
+ Log.e("ss_brdports===",ss_brdports+ss_brdip);
|
|
|
mEmNameTv.setText("("+ss_brdip+" "+ss_brdport+")");
|
|
|
sound_monitor_vibration_sv.setClickable(true);
|
|
|
mEmCodeTv.setText(ss_nametext);
|
|
|
@@ -1065,12 +1152,12 @@ public class IndexActivity extends BaseActivity implements AdapterView.OnItemCli
|
|
|
}
|
|
|
|
|
|
@Subscribe
|
|
|
- public void onMessageEvent(TCPEventBusBean evensst) {
|
|
|
- Log.e("连接失败","连接失败");
|
|
|
-
|
|
|
+ public void onMessageEvent(CloseEventBusBean evensst) {
|
|
|
+ error_ok_image=false;
|
|
|
+ sound_monitor_vibration_sv2.setSelected(false);
|
|
|
+ destoryhistoryData();
|
|
|
+ handler.removeCallbacks(runnable);
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
//全部删除
|
|
|
public void getalldeltes(String workOrder){
|
|
|
progressDialog.show();
|
|
|
@@ -1754,13 +1841,12 @@ public class IndexActivity extends BaseActivity implements AdapterView.OnItemCli
|
|
|
String ss_brdips = SharedPreUtil.getString(IndexActivity.this, "ss_brdip", null);
|
|
|
String ss_brdports = SharedPreUtil.getString(IndexActivity.this, "ss_brdport", null);
|
|
|
error_ok_image=true;
|
|
|
- Log.e("是否关闭","没有关闭");
|
|
|
QpushClient.getInstance(new Handler(new Handler.Callback() {
|
|
|
@Override
|
|
|
public boolean handleMessage(Message msg) {
|
|
|
String stringtext = msg.obj.toString();
|
|
|
setdataDisplay(stringtext);
|
|
|
- Log.e("服务器数据", msg.obj.toString());
|
|
|
+ Log.e("服务器数据", msg.obj.toString()+"");
|
|
|
return false;
|
|
|
}
|
|
|
})).init(ss_brdips,Integer.valueOf(ss_brdports));//Integer.valueOf(ss_brdports)
|
|
|
@@ -1856,9 +1942,9 @@ public class IndexActivity extends BaseActivity implements AdapterView.OnItemCli
|
|
|
String[] separated = s.split("=");
|
|
|
if (stringtext.contains(".PNG") || stringtext.contains(".JPG") || stringtext.contains(".webp") || stringtext.contains(".jpeg")
|
|
|
|| stringtext.contains(".png") || stringtext.contains(".jpg") || stringtext.contains(".WEBP") || stringtext.contains(".JPEG")){
|
|
|
- tcpReceiveBean.setFilename(separated[1] + ".png");
|
|
|
- }else if (stringtext.contains(".pdf") || stringtext.contains(".PDF")){
|
|
|
- tcpReceiveBean.setFilename(separated[1] + ".pdf");
|
|
|
+ tcpReceiveBean.setFilename(separated[1] + "");
|
|
|
+ }else if (stringtext.contains(".pdf") || stringtext.contains("")){
|
|
|
+ tcpReceiveBean.setFilename(separated[1] + "");
|
|
|
|
|
|
}else {
|
|
|
CommonUtil.toastNoRepeat(IndexActivity.this,"无法解析数据");
|