瀏覽代碼

资产编号日志

wushaodong 3 年之前
父節點
當前提交
365ce09a40

+ 4 - 1
android/app/src/main/java/com/zzliaoyuan/power_sensor/activity/MainActivity.java

@@ -7,6 +7,7 @@ import android.content.Intent;
 import android.content.pm.ActivityInfo;
 import android.media.AudioManager;
 import android.media.SoundPool;
+import android.net.Uri;
 import android.os.Build;
 import android.os.Bundle;
 import android.os.Environment;
@@ -113,6 +114,7 @@ public class MainActivity extends ReactActivity {
             initSound();
             initUHF();
             UHFReadTagFragment.getInstance().setContext(this);
+            UHFReadTagFragment.getInstance().setUserModel();
         } else {
             final AlertDialog.Builder normalDialog = new AlertDialog.Builder(this);
 //            normalDialog.setTitle("电金晴");
@@ -207,7 +209,8 @@ public class MainActivity extends ReactActivity {
 
     @Override
     protected void onDestroy() {
-
+        Uri data = Uri.parse("file:///storage/emulated/0/assetsLog/assets.txt");
+        this.sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, data));
         if (mReader != null) {
             mReader.free();
         }

+ 5 - 2
android/app/src/main/java/com/zzliaoyuan/power_sensor/fragment/UHFReadTagFragment.java

@@ -1,6 +1,7 @@
 package com.zzliaoyuan.power_sensor.fragment;
 
-import android.os.Bundle;
+import android.Manifest;
+import android.media.MediaScannerConnection;
 import android.os.Environment;
 import android.util.Log;
 
@@ -51,7 +52,7 @@ public class UHFReadTagFragment {
 
 
     // wsdd userd
-    public void onCheckedChanged(int checkedId) {
+    public void setUserModel() {
         // 设置循环盘点同时读取 EPC、TID、USER 模式
         mContext.mReader.setEPCAndTIDUserMode(0, 24);
         readAssets();
@@ -171,6 +172,7 @@ public class UHFReadTagFragment {
     }
 
     public void readAssets() {
+        assetsList = new ArrayList<String>();
         try {
             // 存放的文件路径
             File assetsFile = new File(
@@ -229,6 +231,7 @@ public class UHFReadTagFragment {
                 if (!file.exists()) {
                     file.createNewFile();
                 }
+//                MediaScannerConnection.scanFile(mContext, new String[] { file.getAbsolutePath() }, null, null);
                 assetsList.add(asset);
                 RandomAccessFile raf = new RandomAccessFile(file, "rwd");
                 raf.seek(file.length());

+ 1 - 1
android/app/src/main/java/com/zzliaoyuan/power_sensor/readUHF/ReadUHFModule.java

@@ -26,7 +26,7 @@ public class ReadUHFModule extends ReactContextBaseJavaModule {
     public void changeFlag(Integer type) {
         if(type == null)
             type = 1;
-        UHFReadTagFragment.getInstance().onCheckedChanged(type);
+        UHFReadTagFragment.getInstance().setUserModel();
     }
 
     @ReactMethod

+ 1 - 1
jscore/pages/Desktop/Home.js

@@ -37,7 +37,7 @@ class DesktopHome extends Component {
     };
 
     componentDidMount() {
-        ReadUHF.changeFlag(0)
+        // ReadUHF.changeFlag(0)
         DeviceEventEmitter.addListener('MsgFromAndroid', this._addCode);
         DeviceEventEmitter.addListener('onKeyDown', this.onKeyDown);
     }