完成 handehuoe驱动更新

master
wanghao 6 months ago
parent 6d2031f1a4
commit 3aab607a3f

@ -16,7 +16,7 @@ android {
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
ndk {
// SO
abiFilters 'arm64-v8a' , 'armeabi' , 'armeabi-v7a'
abiFilters 'arm64-v8a' , 'armeabi' , 'armeabi-v7a'
}
}

@ -43,10 +43,23 @@ public class BFActivity extends BaseActivity implements TakePictureDialog.dialog
dataBinding.setVm(wm);
takeDialog = new TakePictureDialog(this);
takeDialog.setCall(this);
setPower(SharedPreferencesUtils.getInt("powerScrap", 17));
bitmaps = new ArrayList<>();
files = new ArrayList<>();
}
@Override
protected void onResume() {
super.onResume();
setPower(SharedPreferencesUtils.getInt("powerScrapIn",17));
uhfLongerManager.setGen2session(true);
uhfLongerManager.asyncStartReading();
}
@Override
protected void onDestroy() {
super.onDestroy();
uhfLongerManager.setGen2session(false);
uhfLongerManager.asyncStopReading();
}
@Override
protected void sanRfid(List<Reader.TAGINFO> epcs) {

@ -194,8 +194,12 @@ public class CheckActivity extends BaseActivity implements AdapterClickCall, InP
public void offCheckRead(View view) {
var b = checkState.get();
if (b) {
uhfLongerManager.setGen2session(false);
uhfLongerManager.asyncStopReading();
handler.removeCallbacks(runnable);
} else {
uhfLongerManager.setGen2session(true);
uhfLongerManager.asyncStartReading();
handler.postDelayed(runnable, 0);
}
checkState.set(!b);
@ -214,7 +218,7 @@ public class CheckActivity extends BaseActivity implements AdapterClickCall, InP
public void run() {
// sendBroadcast(broadcastIntent);
sanEpc();
handler.postDelayed(runnable, 1000);
handler.postDelayed(runnable, 50);
}
};
@ -243,4 +247,14 @@ public class CheckActivity extends BaseActivity implements AdapterClickCall, InP
public void returnListSize(int size) {
binding.confirmPictureNumber2.setText(bitmaps.size() + "");
}
@Override
protected void onDestroy() {
super.onDestroy();
handler.removeCallbacks(runnable);
uhfLongerManager.setGen2session(false);
uhfLongerManager.asyncStopReading();
handler = null;
runnable = null;
}
}

@ -33,7 +33,22 @@ public class FpInActivity extends BaseActivity {
ActivityFpInBinding binding = DataBindingUtil.setContentView(this, R.layout.activity_fp_in);
vm = new FpInVm();
binding.setVm(vm);
}
@Override
protected void onResume() {
super.onResume();
setPower(SharedPreferencesUtils.getInt("powerScrapIn",17));
uhfLongerManager.setGen2session(true);
uhfLongerManager.asyncStartReading();
}
@Override
protected void onDestroy() {
super.onDestroy();
uhfLongerManager.setGen2session(false);
uhfLongerManager.asyncStopReading();
}
@Override

@ -45,7 +45,7 @@ public class FpOutActivity extends BaseActivity {
binding.setAdapter(adapter);
tagList=new ArrayList<>();
initRequest();
setPower(SharedPreferencesUtils.getInt("powerScrapOut",17));
setPower(SharedPreferencesUtils.getInt("powerScrapOut",33));
}
private List<String> tagList;
@ -87,8 +87,12 @@ public class FpOutActivity extends BaseActivity {
public void fp_out_read(View view) {
var b = checkState.get();
if (b) {
uhfLongerManager.setGen2session(false);
uhfLongerManager.asyncStopReading();
handler.removeCallbacks(runnable);
} else {
uhfLongerManager.setGen2session(true);
uhfLongerManager.asyncStartReading();
handler.postDelayed(runnable, 0);
}
checkState.set(!b);
@ -139,7 +143,11 @@ public class FpOutActivity extends BaseActivity {
protected void onDestroy() {
super.onDestroy();
handler.removeCallbacks(runnable);
uhfLongerManager.setGen2session(false);
uhfLongerManager.asyncStopReading();
handler=null;
runnable=null;
}
}

@ -21,6 +21,8 @@ import com.example.beijing_daxing.databinding.ActivityHomePageBinding;
import com.example.beijing_daxing.been.HomeIcon;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.handheld.uhfr.UHFRManager;
import com.uhf.api.cls.Reader;
import java.util.ArrayList;
import java.util.Iterator;
@ -34,11 +36,10 @@ public class HomePageActivity extends AppCompatActivity {
super.onCreate(savedInstanceState);
ActivityHomePageBinding binding = DataBindingUtil.setContentView(this, R.layout.activity_home_page);
initUi(binding);
/* myNetWorkReceiver=new MyNetWorkReceiver();
IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction(WifiManager.NETWORK_STATE_CHANGED_ACTION);
registerReceiver(myNetWorkReceiver, intentFilter);*/
UHFRManager instance = UHFRManager.getInstance();
MyApplication.getApplication().setUhfrManager(instance);
instance.setRegion(Reader.Region_Conf.RG_PRC);
instance.setPower(33,33);
}
@ -62,10 +63,10 @@ public class HomePageActivity extends AppCompatActivity {
@Override
protected void onDestroy() {
super.onDestroy();
var uhfLongerManager = MyApplication.getUhfLongerManager();
var uhfLongerManager = MyApplication.getApplication().getUhfrManager();
uhfLongerManager.asyncStopReading();
uhfLongerManager.close();
MyApplication.uhfLongerManager = null;
MyApplication.getApplication().setUhfrManager(null);
Log.e("TAG", "关闭" );
// unregisterReceiver(myNetWorkReceiver);
}

@ -67,6 +67,7 @@ public class InActivity extends BaseActivity implements AdapterClickCall {
protected void sanRfid(List<Reader.TAGINFO> epcs) {
epcs.stream().forEach(t -> {
var epc = Tools.Bytes2HexString(t.EpcId,t.EpcId.length);
Log.e("TAG", "sanRfid:" + epc);
if (!epc.substring(0,8).equals("53574C44")) return;
if (tagList.contains(epc)) return;
tagList.add(epc);
@ -126,8 +127,6 @@ public class InActivity extends BaseActivity implements AdapterClickCall {
private Runnable runnable = new Runnable() {
@Override
public void run() {
// Log.e("TAG", "发送广播读取RFID");
// sendBroadcast(broadcastIntent);
sanEpc();
handler.postDelayed(runnable, 50);
}
@ -135,8 +134,12 @@ public class InActivity extends BaseActivity implements AdapterClickCall {
public void instore_check(View view) {
var b = checkState.get();
if (b) {
uhfLongerManager.setGen2session(false);
uhfLongerManager.asyncStopReading();
handler.removeCallbacks(runnable);
} else {
uhfLongerManager.setGen2session(true);
uhfLongerManager.asyncStartReading();
handler.postDelayed(runnable, 0);
}
checkState.set(!b);
@ -146,6 +149,8 @@ public class InActivity extends BaseActivity implements AdapterClickCall {
@Override
protected void onDestroy() {
super.onDestroy();
uhfLongerManager.setGen2session(false);
uhfLongerManager.asyncStopReading();
handler.removeCallbacks(runnable);
handler = null;
runnable = null;

@ -4,6 +4,7 @@ import androidx.databinding.DataBindingUtil;
import android.annotation.SuppressLint;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Toast;
import com.example.beijing_daxing.adapter.InAdapter;
@ -51,12 +52,15 @@ public class OutActivity extends BaseActivity implements AdapterClickCall {
protected void onResume() {
super.onResume();
setPower(SharedPreferencesUtils.getInt("powerOut",17));
uhfLongerManager.setGen2session(true);
uhfLongerManager.asyncStartReading();
}
@SuppressLint("NotifyDataSetChanged")
@Override
protected void sanRfid(List<Reader.TAGINFO> epcs) {
epcs.forEach(t -> {
var epc = Tools.Bytes2HexString(t.EpcId,t.EpcId.length);
Log.e("TAG", "sanRfid:" + epc);
if (!epc.startsWith("53574C44")) return;
if (tagList.contains(epc)) return;
tagList.add(epc);
@ -103,4 +107,10 @@ public class OutActivity extends BaseActivity implements AdapterClickCall {
});
}
@Override
protected void onDestroy() {
super.onDestroy();
uhfLongerManager.setGen2session(false);
uhfLongerManager.asyncStopReading();
}
}

@ -110,8 +110,12 @@ public class StoreCheckActivity extends BaseActivity {
public void check_read(View view) {
var b = checkState.get();
if (b) {
uhfLongerManager.setGen2session(false);
uhfLongerManager.asyncStopReading();
handler.removeCallbacks(runnable);
} else {
uhfLongerManager.setGen2session(true);
uhfLongerManager.asyncStartReading();
handler.postDelayed(runnable, 0);
}
checkState.set(!b);
@ -160,6 +164,8 @@ public class StoreCheckActivity extends BaseActivity {
protected void onDestroy() {
super.onDestroy();
handler.removeCallbacks(runnable);
uhfLongerManager.setGen2session(false);
uhfLongerManager.asyncStopReading();
handler = null;
runnable = null;
}

@ -40,8 +40,8 @@ import java.util.List;
import okhttp3.MediaType;
public abstract class BaseActivity extends AppCompatActivity {
public static String url = "http://192.168.137.1:8090/api";
// public static String url = "http://119.45.202.115:8090/api";
// public static String url = "http://192.168.137.1:8090/api";
public static String url = "http://119.45.202.115:8090/api";
public ProgressDialog dialog;
public Gson gson;
public MediaType JSON = MediaType.parse("application/json; charset=utf-8");
@ -67,10 +67,8 @@ public abstract class BaseActivity extends AppCompatActivity {
public void onReceive(Context context, Intent intent) {
var keydown = intent.getBooleanExtra("keydown", false);
Log.e("TAG", "接收到广播:" + keydown);
if (!keydown) {
// readTime = System.currentTimeMillis();
sanEpc();
}
}
@ -78,11 +76,9 @@ public abstract class BaseActivity extends AppCompatActivity {
public void sanEpc() {
List<Reader.TAGINFO> strings = uhfLongerManager.tagInventoryRealTime();
// Log.e("TAG", "驱动" + (uhfLongerManager == null));
if (strings == null || strings.isEmpty()) {
return;
}
mediaPlayer.start();
sanRfid(strings);
}
@ -96,11 +92,7 @@ public abstract class BaseActivity extends AppCompatActivity {
}
private void initSan() {
uhfLongerManager = MyApplication.getUhfLongerManager();
// intentFilter.addAction("android.intent.action.FUN_KEY");
uhfLongerManager.asyncStartReading();
uhfLongerManager = MyApplication.getApplication().getUhfrManager();
myReceiver = new MyReceiver();
IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction("android.rfid.FUN_KEY");
@ -112,7 +104,6 @@ public abstract class BaseActivity extends AppCompatActivity {
try {
Reader.READER_ERR readerErr = uhfLongerManager.setPower(power, power);
Log.e("TAG", "setPower:" + readerErr.name());
int[] power1 = uhfLongerManager.getPower();
Log.e("TAG", "readPower:" + power1[0] + "," + power1[1]);
} catch (Exception e) {

@ -38,8 +38,8 @@ import okhttp3.OkHttpClient;
*/
public class MyApplication extends Application {
MyApplication application;
public static UHFRManager uhfLongerManager;
private static MyApplication application;
private UHFRManager uhfrManager;
@Override
public void onCreate() {
@ -60,18 +60,18 @@ public class MyApplication extends Application {
.init(this);
}
public static UHFRManager getUhfLongerManager() {
if (uhfLongerManager==null){
try {
uhfLongerManager = UHFRManager.getInstance();
uhfLongerManager.setPower(33,33);
} catch (Exception e) {
e.printStackTrace();
}
}
return uhfLongerManager;
public static MyApplication getApplication() {
return application;
}
public UHFRManager getUhfrManager() {
return uhfrManager;
}
public void setUhfrManager(UHFRManager uhfrManager) {
this.uhfrManager = uhfrManager;
}
// OKGO 初始化
private void okGoBase() {
OkHttpClient.Builder builder = new OkHttpClient.Builder();

@ -1,10 +0,0 @@
package com.example.beijing_daxing.rfid;
public interface RFID {
void initRFIDModel();
void setPower(int power);
void sanRFID();
void close();
}

@ -1,60 +0,0 @@
package com.example.beijing_daxing.rfid.impl;
import android.util.Log;
import com.example.beijing_daxing.rfid.RFID;
import com.handheld.uhfr.UHFRManager;
import com.uhf.api.cls.Reader;
import java.util.List;
public class Device6109 implements RFID {
private UHFRManager uhfrManager;
private EpcDataInterface epcDataInterface;
public Device6109(EpcDataInterface epcDataInterface) {
this.epcDataInterface = epcDataInterface;
}
public Device6109() {
}
@Override
public void initRFIDModel() {
if (uhfrManager == null) {
uhfrManager = UHFRManager.getInstance();
}
uhfrManager.asyncStartReading();
}
@Override
public void setPower(int power) {
Reader.READER_ERR readerErr = uhfrManager.setPower(power, power);
Log.e("TAG", "setPower:" + readerErr);
}
@Override
public void sanRFID() {
List<Reader.TAGINFO> data = uhfrManager.tagInventoryRealTime();
if (data == null || data.isEmpty()) {
return;
}
epcDataInterface.epcData(data);
}
@Override
public void close() {
if (uhfrManager == null) {
return;
}
uhfrManager.asyncStopReading();
uhfrManager.close();
uhfrManager = null;
}
public interface EpcDataInterface {
void epcData(List<Reader.TAGINFO> data);
}
}
Loading…
Cancel
Save