|
@@ -13,7 +13,6 @@ import android.content.pm.PackageManager;
|
|
import android.location.LocationManager;
|
|
import android.location.LocationManager;
|
|
import android.os.Build;
|
|
import android.os.Build;
|
|
import android.os.Environment;
|
|
import android.os.Environment;
|
|
-import android.os.Handler;
|
|
|
|
import android.provider.MediaStore;
|
|
import android.provider.MediaStore;
|
|
import android.text.TextUtils;
|
|
import android.text.TextUtils;
|
|
import android.util.Log;
|
|
import android.util.Log;
|
|
@@ -35,7 +34,6 @@ import com.clj.fastble.utils.HexUtil;
|
|
import com.google.common.util.concurrent.ListenableFuture;
|
|
import com.google.common.util.concurrent.ListenableFuture;
|
|
import com.google.gson.Gson;
|
|
import com.google.gson.Gson;
|
|
import com.google.gson.reflect.TypeToken;
|
|
import com.google.gson.reflect.TypeToken;
|
|
-import com.naz.sdkdemo.activity.UpTrademarkActivity;
|
|
|
|
import com.naz.sdkdemo.activity.ble.comm.ObserverManager;
|
|
import com.naz.sdkdemo.activity.ble.comm.ObserverManager;
|
|
import com.naz.sdkdemo.base.BaseActivity;
|
|
import com.naz.sdkdemo.base.BaseActivity;
|
|
import com.naz.sdkdemo.bean.PrintModule;
|
|
import com.naz.sdkdemo.bean.PrintModule;
|
|
@@ -44,7 +42,6 @@ import com.naz.sdkdemo.bean.PrintModule3;
|
|
import com.naz.sdkdemo.helper.SerialPortManager;
|
|
import com.naz.sdkdemo.helper.SerialPortManager;
|
|
import com.naz.sdkdemo.http.ApiHelper;
|
|
import com.naz.sdkdemo.http.ApiHelper;
|
|
import com.naz.sdkdemo.utils.MyTools;
|
|
import com.naz.sdkdemo.utils.MyTools;
|
|
-import com.naz.sdkdemo.utils.SerialUtil;
|
|
|
|
import com.naz.sdkdemo.weight.UserCache;
|
|
import com.naz.sdkdemo.weight.UserCache;
|
|
import com.tencent.smtt.export.external.interfaces.WebResourceError;
|
|
import com.tencent.smtt.export.external.interfaces.WebResourceError;
|
|
import com.tencent.smtt.export.external.interfaces.WebResourceRequest;
|
|
import com.tencent.smtt.export.external.interfaces.WebResourceRequest;
|
|
@@ -67,8 +64,6 @@ import java.util.List;
|
|
import java.util.concurrent.ExecutionException;
|
|
import java.util.concurrent.ExecutionException;
|
|
import java.util.concurrent.ExecutorService;
|
|
import java.util.concurrent.ExecutorService;
|
|
import java.util.concurrent.Executors;
|
|
import java.util.concurrent.Executors;
|
|
-import java.util.concurrent.ThreadPoolExecutor;
|
|
|
|
-import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
|
|
import androidx.annotation.NonNull;
|
|
import androidx.annotation.NonNull;
|
|
import androidx.camera.core.CameraSelector;
|
|
import androidx.camera.core.CameraSelector;
|
|
@@ -267,7 +262,7 @@ public class MainActivity extends BaseActivity {
|
|
connectLight.setOnClickListener(new View.OnClickListener() {
|
|
connectLight.setOnClickListener(new View.OnClickListener() {
|
|
@Override
|
|
@Override
|
|
public void onClick(View v) {
|
|
public void onClick(View v) {
|
|
- connectLight();
|
|
|
|
|
|
+ toConnectLight();
|
|
}
|
|
}
|
|
});
|
|
});
|
|
turnOnLight.setOnClickListener(new View.OnClickListener() {
|
|
turnOnLight.setOnClickListener(new View.OnClickListener() {
|
|
@@ -420,6 +415,29 @@ public class MainActivity extends BaseActivity {
|
|
Log.e(TAG, "closePrinter");
|
|
Log.e(TAG, "closePrinter");
|
|
closeUSB();
|
|
closeUSB();
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ @JavascriptInterface
|
|
|
|
+ public void connectLight() {
|
|
|
|
+ Log.e(TAG, "connectLight");
|
|
|
|
+ toConnectLight();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @JavascriptInterface
|
|
|
|
+ public void controlLight(int address, int type) {
|
|
|
|
+ Log.e(TAG, "openLight"+"address="+address+",type="+type);
|
|
|
|
+ if (serialPortManager != null){
|
|
|
|
+ serialPortManager.turnOnLight(address, type);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @JavascriptInterface
|
|
|
|
+ public void disConnectLight() {
|
|
|
|
+ Log.e(TAG, "closeLight");
|
|
|
|
+ if (serialPortManager!=null){
|
|
|
|
+ serialPortManager.close();
|
|
|
|
+ serialPortManager = null;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
private void toCloseCamera() {
|
|
private void toCloseCamera() {
|
|
@@ -1123,7 +1141,7 @@ public class MainActivity extends BaseActivity {
|
|
|
|
|
|
private SerialPortManager serialPortManager;
|
|
private SerialPortManager serialPortManager;
|
|
|
|
|
|
- private void connectLight(){
|
|
|
|
|
|
+ private void toConnectLight(){
|
|
if (serialPortManager == null){
|
|
if (serialPortManager == null){
|
|
serialPortManager = new SerialPortManager();
|
|
serialPortManager = new SerialPortManager();
|
|
serialPortManager.init(MainActivity.this, UserCache.getSerialName(), UserCache.getSerialRate(), new SerialPortManager.SerialCallBack() {
|
|
serialPortManager.init(MainActivity.this, UserCache.getSerialName(), UserCache.getSerialRate(), new SerialPortManager.SerialCallBack() {
|
|
@@ -1135,6 +1153,7 @@ public class MainActivity extends BaseActivity {
|
|
@Override
|
|
@Override
|
|
public void openCallBack(int code) {
|
|
public void openCallBack(int code) {
|
|
Log.e("--------->","------->openCallBack code="+code);
|
|
Log.e("--------->","------->openCallBack code="+code);
|
|
|
|
+ mWebView.loadUrl("javascript:responseLightCode('"+code+"')");
|
|
if (code == 1){
|
|
if (code == 1){
|
|
|
|
|
|
}else {
|
|
}else {
|
|
@@ -1147,6 +1166,8 @@ public class MainActivity extends BaseActivity {
|
|
|
|
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
+ }else {
|
|
|
|
+ serialPortManager.open();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|