|
|
|
@ -45,16 +45,23 @@ import cn.pda.serialport.Tools;
|
|
|
|
import okhttp3.MediaType;
|
|
|
|
import okhttp3.MediaType;
|
|
|
|
|
|
|
|
|
|
|
|
public class BaseActivity extends AppCompatActivity {
|
|
|
|
public class BaseActivity extends AppCompatActivity {
|
|
|
|
|
|
|
|
public static final int CAMERA_PHOTO = 1;
|
|
|
|
public SimpleDateFormat dateFormat;
|
|
|
|
public SimpleDateFormat dateFormat;
|
|
|
|
public ProgressDialog dialog;
|
|
|
|
public ProgressDialog dialog;
|
|
|
|
public Context context;
|
|
|
|
public Context context;
|
|
|
|
public Gson gson;
|
|
|
|
public Gson gson;
|
|
|
|
public String url;
|
|
|
|
public String url;
|
|
|
|
public MediaType JSON = MediaType.parse("application/json; charset=utf-8");
|
|
|
|
public MediaType JSON = MediaType.parse("application/json; charset=utf-8");
|
|
|
|
|
|
|
|
public byte[] accessBytes = Tools.HexString2Bytes("00000000");
|
|
|
|
|
|
|
|
@SuppressLint("SimpleDateFormat")
|
|
|
|
|
|
|
|
public SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd_HHmmss");
|
|
|
|
|
|
|
|
public UhfReader uhfReader;
|
|
|
|
|
|
|
|
public MediaPlayer music;
|
|
|
|
|
|
|
|
public MyKeyReceiver keyReceiver;
|
|
|
|
// 拍照
|
|
|
|
// 拍照
|
|
|
|
private Uri img_uri;
|
|
|
|
private Uri img_uri;
|
|
|
|
private File outputImage;
|
|
|
|
private File outputImage;
|
|
|
|
public byte[] accessBytes = Tools.HexString2Bytes("00000000");
|
|
|
|
|
|
|
|
@SuppressLint("SimpleDateFormat")
|
|
|
|
@SuppressLint("SimpleDateFormat")
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
|
|
|
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
|
|
|
@ -79,10 +86,13 @@ public class BaseActivity extends AppCompatActivity {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public int getDeptId(String name) {
|
|
|
|
public int getDeptId(String name) {
|
|
|
|
if (name.equals("光明修理厂"))
|
|
|
|
if (name.equals("光明修理厂")) {
|
|
|
|
return 200;
|
|
|
|
return 200;
|
|
|
|
|
|
|
|
} else if (name.equals("石岩修理厂")) {
|
|
|
|
return 201;
|
|
|
|
return 201;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 209;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public String getTypeCode(String typeName) {
|
|
|
|
public String getTypeCode(String typeName) {
|
|
|
|
if (typeName.equals("二级保养")) {
|
|
|
|
if (typeName.equals("二级保养")) {
|
|
|
|
@ -102,9 +112,7 @@ public class BaseActivity extends AppCompatActivity {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
public static final int CAMERA_PHOTO = 1;
|
|
|
|
|
|
|
|
@SuppressLint("SimpleDateFormat")
|
|
|
|
|
|
|
|
public SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd_HHmmss");
|
|
|
|
|
|
|
|
public void teke_photo() throws IOException {
|
|
|
|
public void teke_photo() throws IOException {
|
|
|
|
outputImage = new File(getExternalCacheDir(), "output_imgage" + format.format(new Date()) + ".jpg");
|
|
|
|
outputImage = new File(getExternalCacheDir(), "output_imgage" + format.format(new Date()) + ".jpg");
|
|
|
|
outputImage.createNewFile();
|
|
|
|
outputImage.createNewFile();
|
|
|
|
@ -149,7 +157,7 @@ public class BaseActivity extends AppCompatActivity {
|
|
|
|
fos.write(compressedImageData);
|
|
|
|
fos.write(compressedImageData);
|
|
|
|
fos.flush();
|
|
|
|
fos.flush();
|
|
|
|
fos.close();*/
|
|
|
|
fos.close();*/
|
|
|
|
if (requestCode == CAMERA_PHOTO ){
|
|
|
|
if (requestCode == CAMERA_PHOTO) {
|
|
|
|
tekePhotoResult(img_uri.toString(), outputImage);
|
|
|
|
tekePhotoResult(img_uri.toString(), outputImage);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -170,11 +178,12 @@ public class BaseActivity extends AppCompatActivity {
|
|
|
|
public boolean dispatchTouchEvent(MotionEvent ev) {
|
|
|
|
public boolean dispatchTouchEvent(MotionEvent ev) {
|
|
|
|
if (ev.getAction() == MotionEvent.ACTION_DOWN) {
|
|
|
|
if (ev.getAction() == MotionEvent.ACTION_DOWN) {
|
|
|
|
View v = getCurrentFocus();
|
|
|
|
View v = getCurrentFocus();
|
|
|
|
boolean isKeyboardShown = v != null && (v instanceof EditText) && isKeyboardShowing(getCurrentFocus(), this);
|
|
|
|
boolean isKeyboardShown =
|
|
|
|
|
|
|
|
v != null && (v instanceof EditText) && isKeyboardShowing(getCurrentFocus(), this);
|
|
|
|
if (isKeyboardShown) {
|
|
|
|
if (isKeyboardShown) {
|
|
|
|
Rect outRect = new Rect();
|
|
|
|
Rect outRect = new Rect();
|
|
|
|
v.getGlobalVisibleRect(outRect);
|
|
|
|
v.getGlobalVisibleRect(outRect);
|
|
|
|
if (!outRect.contains((int)ev.getRawX(), (int)ev.getRawY())) {
|
|
|
|
if (!outRect.contains((int) ev.getRawX(), (int) ev.getRawY())) {
|
|
|
|
hideSoftKeyboard(this);
|
|
|
|
hideSoftKeyboard(this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -183,7 +192,8 @@ public class BaseActivity extends AppCompatActivity {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void hideSoftKeyboard(Activity activity) {
|
|
|
|
private void hideSoftKeyboard(Activity activity) {
|
|
|
|
InputMethodManager inputMethodManager = (InputMethodManager) activity.getSystemService(Activity.INPUT_METHOD_SERVICE);
|
|
|
|
InputMethodManager inputMethodManager =
|
|
|
|
|
|
|
|
(InputMethodManager) activity.getSystemService(Activity.INPUT_METHOD_SERVICE);
|
|
|
|
inputMethodManager.hideSoftInputFromWindow(activity.getCurrentFocus().getWindowToken(), 0);
|
|
|
|
inputMethodManager.hideSoftInputFromWindow(activity.getCurrentFocus().getWindowToken(), 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -191,9 +201,7 @@ public class BaseActivity extends AppCompatActivity {
|
|
|
|
InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
|
|
|
|
InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
|
|
|
|
return imm.isAcceptingText();
|
|
|
|
return imm.isAcceptingText();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
public UhfReader uhfReader;
|
|
|
|
|
|
|
|
public MediaPlayer music;
|
|
|
|
|
|
|
|
public MyKeyReceiver keyReceiver;
|
|
|
|
|
|
|
|
public void initRFID() {
|
|
|
|
public void initRFID() {
|
|
|
|
uhfReader = MyApplication.getManager();
|
|
|
|
uhfReader = MyApplication.getManager();
|
|
|
|
music = MediaPlayer.create(this, R.raw.msg);
|
|
|
|
music = MediaPlayer.create(this, R.raw.msg);
|
|
|
|
@ -203,6 +211,7 @@ public class BaseActivity extends AppCompatActivity {
|
|
|
|
initRFID();
|
|
|
|
initRFID();
|
|
|
|
initKeyRecriver(this::readEPC);
|
|
|
|
initKeyRecriver(this::readEPC);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@SuppressLint("UnspecifiedRegisterReceiverFlag")
|
|
|
|
@SuppressLint("UnspecifiedRegisterReceiverFlag")
|
|
|
|
public void initKeyRecriver(MyKeyInfoCall call) {
|
|
|
|
public void initKeyRecriver(MyKeyInfoCall call) {
|
|
|
|
keyReceiver = new MyKeyReceiver(call);
|
|
|
|
keyReceiver = new MyKeyReceiver(call);
|
|
|
|
|