diff --git a/app/build.gradle b/app/build.gradle
index a49a3f4..77da02a 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -46,4 +46,8 @@ dependencies {
implementation 'com.lzy.net:okgo:3.0.4'
// https://mvnrepository.com/artifact/com.google.code.gson/gson
implementation 'com.google.code.gson:gson:2.10.1'
+ implementation 'com.google.zxing:core:3.3.3'
+ // https://mvnrepository.com/artifact/com.google.zxing/javase
+// implementation 'com.google.zxing:javase:3.5.3'
+
}
\ No newline at end of file
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 9dbe96b..39749b0 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -22,12 +22,15 @@
android:theme="@style/Theme.BGSRFIDTrack"
android:usesCleartextTraffic="true"
tools:targetApi="31">
+
+ android:exported="true" />
@@ -48,7 +51,6 @@
android:exported="true">
-
diff --git a/app/src/main/java/com/example/bgsrfidtrack/HomePageActivity.java b/app/src/main/java/com/example/bgsrfidtrack/HomePageActivity.java
index 33f2955..7a9dcb8 100644
--- a/app/src/main/java/com/example/bgsrfidtrack/HomePageActivity.java
+++ b/app/src/main/java/com/example/bgsrfidtrack/HomePageActivity.java
@@ -20,7 +20,7 @@ public class HomePageActivity extends BaseActivity {
Intent intent = new Intent(this, BindingActivity.class);
Intent intent2 = new Intent(this, UnBindingActivity.class);
Intent intent3 = new Intent(this, BindingDBActivity.class);
- Intent intent4 = new Intent(this, UnBindingActivity.class);
+ Intent jionIntent = new Intent(this, JionActivity.class);
binding.homeIn.setOnClickListener(v -> {
startActivity(intent);
});
@@ -30,8 +30,13 @@ public class HomePageActivity extends BaseActivity {
binding.binding.setOnClickListener(v -> {
startActivity(intent3);
});
- binding.homeJiaojie.setOnClickListener(v -> {
- startActivity(intent4);
+ binding.homeJiao.setOnClickListener(v -> {
+ jionIntent.putExtra("type", true);
+ startActivity(jionIntent);
+ });
+ binding.homeJie.setOnClickListener(v -> {
+ jionIntent.putExtra("type", false);
+ startActivity(jionIntent);
});
}
diff --git a/app/src/main/java/com/example/bgsrfidtrack/JionActivity.java b/app/src/main/java/com/example/bgsrfidtrack/JionActivity.java
new file mode 100644
index 0000000..e17ae54
--- /dev/null
+++ b/app/src/main/java/com/example/bgsrfidtrack/JionActivity.java
@@ -0,0 +1,117 @@
+package com.example.bgsrfidtrack;
+
+import androidx.appcompat.app.AppCompatActivity;
+import androidx.databinding.DataBindingUtil;
+
+import android.graphics.Color;
+import android.os.Bundle;
+import android.util.Log;
+import android.view.View;
+import android.widget.Toast;
+import android.graphics.Bitmap;
+
+import com.example.bgsrfidtrack.dialog.DialogClickCall;
+import com.google.zxing.BarcodeFormat;
+import com.google.zxing.EncodeHintType;
+import com.google.zxing.MultiFormatWriter;
+import com.google.zxing.WriterException;
+import com.google.zxing.common.BitMatrix;
+import com.google.zxing.qrcode.QRCodeWriter;
+import com.example.bgsrfidtrack.adapter.JionAdapter;
+import com.example.bgsrfidtrack.base.BaseActivity;
+import com.example.bgsrfidtrack.base.MyRecultCall;
+import com.example.bgsrfidtrack.base.MyResult;
+import com.example.bgsrfidtrack.base.SharedPreferencesUtils;
+import com.example.bgsrfidtrack.databinding.ActivityJionBinding;
+import com.example.bgsrfidtrack.dialog.ImgDialog;
+import com.google.gson.reflect.TypeToken;
+import com.lzy.okgo.OkGo;
+import com.lzy.okgo.model.Response;
+
+import java.util.Hashtable;
+import java.util.List;
+
+public class JionActivity extends BaseActivity implements DialogClickCall {
+ private String ip;
+ private JionAdapter adapter;
+ private ImgDialog imgDialog;
+ private List list;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ ActivityJionBinding binding = DataBindingUtil.setContentView(this, R.layout.activity_jion);
+ var type = getIntent().getBooleanExtra("type", true);
+ binding.setState(type);
+ ip = SharedPreferencesUtils.getstring("ip", "");
+ adapter = new JionAdapter(this);
+ imgDialog = new ImgDialog(this, this);
+ binding.setAdapter(adapter);
+ if (type) {
+ binding.setTitle("交货");
+ initJionRequest();
+ } else {
+ binding.setTitle("接货");
+ }
+ }
+
+ // 查询交货列表
+ private void initJionRequest() {
+ OkGo.post("http://" + ip + "/api/jion/select")
+ .params("user", SharedPreferencesUtils.getstring("user", ""))
+ .execute(new MyRecultCall(dialog, this) {
+ @Override
+ public void onSuccess(Response response) {
+ super.onSuccess(response);
+ var body = response.body();
+ if (body.getCode() == 0) {
+
+ list = gson.fromJson(body.getJson(), new TypeToken>() {
+ }.getType());
+ adapter.setList(list);
+ adapter.notifyDataSetChanged();
+ }
+ Toast.makeText(context, body.getMsg(), Toast.LENGTH_SHORT).show();
+ }
+ });
+ }
+
+ public void jionDialogShow(View view) {
+ String s = list.toString().replace("[","").replace("]","");
+ Log.e("TAG", "jionDialogShow:" + s);
+
+ try {
+ imgDialog.dialogShow(Create2DCode(s, 600, 600));
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+
+ }
+
+
+ public Bitmap Create2DCode(String str, int w, int h) throws Exception {
+
+ BitMatrix matrix = new MultiFormatWriter().encode(str, BarcodeFormat.QR_CODE, w, h);
+ int width = matrix.getWidth();
+ int height = matrix.getHeight();
+ // 二维矩阵转为一维像素数组
+ int[] pixels = new int[width * height];
+ for (int j = 0; j < height; j++) {
+ for (int i = 0; i < width; i++) {
+ if (matrix.get(i, j)) {
+ pixels[j * width + i] = Color.BLACK;
+ }
+ }
+ }
+ Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
+ // 通过像素数组生成bitmap,具体参考api
+ bitmap.setPixels(pixels, 0, width, 0, 0, width, height);
+ return bitmap;
+
+ }
+
+ @Override
+ public void dialogClick() {
+
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/example/bgsrfidtrack/RflyActivity.java b/app/src/main/java/com/example/bgsrfidtrack/RflyActivity.java
index 2e119ec..a64360d 100644
--- a/app/src/main/java/com/example/bgsrfidtrack/RflyActivity.java
+++ b/app/src/main/java/com/example/bgsrfidtrack/RflyActivity.java
@@ -212,6 +212,7 @@ public class RflyActivity extends BaseActivity implements Rfly.ConnectCallback,
.params("locationCode", list2.get(0))
.params("hkCode", list1.get(0))
.execute(new MyRecultCall(dialog, this) {
+ @SuppressLint("NotifyDataSetChanged")
@Override
public void onSuccess(Response response) {
super.onSuccess(response);
diff --git a/app/src/main/java/com/example/bgsrfidtrack/UnBindingActivity.java b/app/src/main/java/com/example/bgsrfidtrack/UnBindingActivity.java
index a3a25b1..59ac314 100644
--- a/app/src/main/java/com/example/bgsrfidtrack/UnBindingActivity.java
+++ b/app/src/main/java/com/example/bgsrfidtrack/UnBindingActivity.java
@@ -80,7 +80,7 @@ public class UnBindingActivity extends BaseActivity implements MyKeyInfoCall, Ad
var body = response.body();
if (body.getCode() == 0) {
- list = gson.fromJson(body.getData().toString(), new TypeToken>() {
+ list = gson.fromJson(body.getJson(), new TypeToken>() {
}.getType());
adapter.setList(list);
adapter.notifyDataSetChanged();
diff --git a/app/src/main/java/com/example/bgsrfidtrack/adapter/JionAdapter.java b/app/src/main/java/com/example/bgsrfidtrack/adapter/JionAdapter.java
new file mode 100644
index 0000000..3ec5591
--- /dev/null
+++ b/app/src/main/java/com/example/bgsrfidtrack/adapter/JionAdapter.java
@@ -0,0 +1,67 @@
+package com.example.bgsrfidtrack.adapter;
+
+import android.content.Context;
+import android.view.LayoutInflater;
+import android.view.ViewGroup;
+
+import androidx.annotation.NonNull;
+import androidx.databinding.DataBindingUtil;
+import androidx.recyclerview.widget.RecyclerView;
+
+import com.example.bgsrfidtrack.R;
+import com.example.bgsrfidtrack.databinding.ItemGoodsInfoBinding;
+import com.example.bgsrfidtrack.databinding.ItemJionBinding;
+
+import java.util.List;
+
+/**
+ * @author wanghao
+ * @date 2024/7/10 15:30
+ */
+public class JionAdapter extends RecyclerView.Adapter {
+ private Context context;
+ private List list;
+ private LayoutInflater inflater;
+
+
+ public JionAdapter(Context context) {
+ this.context = context;
+ inflater = LayoutInflater.from(context);
+ }
+
+ public void setList(List list) {
+ this.list = list;
+ }
+
+ @NonNull
+ @Override
+ public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
+ ItemJionBinding binding = DataBindingUtil.inflate(inflater, R.layout.item_jion, parent, false);
+ return new MyViewHolder(binding);
+ }
+
+ @Override
+ public void onBindViewHolder(@NonNull MyViewHolder holder, int position) {
+ var binding = holder.binding;
+ binding.itemCode.setText(list.get(position));
+ binding.itemIndex.setText(position+1+"");
+
+
+ }
+
+ @Override
+ public int getItemCount() {
+ return list==null ? 0 : list.size();
+ }
+
+ static class MyViewHolder extends RecyclerView.ViewHolder {
+ private ItemJionBinding binding;
+
+ public MyViewHolder(ItemJionBinding binding) {
+ super(binding.getRoot());
+ this.binding = binding;
+ }
+
+
+ }
+}
diff --git a/app/src/main/java/com/example/bgsrfidtrack/base/MyRecultCall.java b/app/src/main/java/com/example/bgsrfidtrack/base/MyRecultCall.java
index 27f8880..0c88620 100644
--- a/app/src/main/java/com/example/bgsrfidtrack/base/MyRecultCall.java
+++ b/app/src/main/java/com/example/bgsrfidtrack/base/MyRecultCall.java
@@ -31,7 +31,7 @@ public class MyRecultCall extends AbsCallback {
if (body == null) return null;
Gson gson = new Gson();
MyResult resust = gson.fromJson(body.string(), MyResult.class);
- resust.setData(gson.toJson(resust.getData()));
+ resust.setJson(gson.toJson(resust.getData()));
return resust;
}
diff --git a/app/src/main/java/com/example/bgsrfidtrack/base/MyResult.java b/app/src/main/java/com/example/bgsrfidtrack/base/MyResult.java
index cd0e933..8718b92 100644
--- a/app/src/main/java/com/example/bgsrfidtrack/base/MyResult.java
+++ b/app/src/main/java/com/example/bgsrfidtrack/base/MyResult.java
@@ -7,10 +7,19 @@ package com.example.bgsrfidtrack.base;
public class MyResult {
private int code;
private String msg;
+ private String json;
private Object data;
private Object rows;
private int total;
+ public String getJson() {
+ return json;
+ }
+
+ public void setJson(String json) {
+ this.json = json;
+ }
+
public int getTotal() {
return total;
}
diff --git a/app/src/main/java/com/example/bgsrfidtrack/dialog/DialogClickCall.java b/app/src/main/java/com/example/bgsrfidtrack/dialog/DialogClickCall.java
new file mode 100644
index 0000000..2ec5d01
--- /dev/null
+++ b/app/src/main/java/com/example/bgsrfidtrack/dialog/DialogClickCall.java
@@ -0,0 +1,9 @@
+package com.example.bgsrfidtrack.dialog;
+
+/**
+ * @author wanghao
+ * @date 2024/7/26 16:22
+ */
+public interface DialogClickCall {
+ void dialogClick();
+}
diff --git a/app/src/main/java/com/example/bgsrfidtrack/dialog/ImgDialog.java b/app/src/main/java/com/example/bgsrfidtrack/dialog/ImgDialog.java
new file mode 100644
index 0000000..4a71a98
--- /dev/null
+++ b/app/src/main/java/com/example/bgsrfidtrack/dialog/ImgDialog.java
@@ -0,0 +1,39 @@
+package com.example.bgsrfidtrack.dialog;
+
+import android.app.Dialog;
+import android.content.Context;
+import android.graphics.Bitmap;
+import android.view.LayoutInflater;
+
+import androidx.annotation.NonNull;
+import androidx.databinding.DataBindingUtil;
+
+import com.example.bgsrfidtrack.R;
+import com.example.bgsrfidtrack.databinding.DialogImgBinding;
+import com.example.bgsrfidtrack.databinding.ItemJionBinding;
+
+/**
+ * @author wanghao
+ * @date 2024/7/26 13:23
+ */
+public class ImgDialog extends Dialog {
+
+ private DialogImgBinding binding;
+ private DialogClickCall call;
+
+ public ImgDialog(@NonNull Context context,DialogClickCall call) {
+ super(context, R.style.dialogStyle);
+ LayoutInflater inflater=LayoutInflater.from(context);
+ this.call=call;
+ binding = DataBindingUtil.inflate(inflater,R.layout.dialog_img,null,false);
+ setContentView(binding.getRoot());
+ binding.dialogDis.setOnClickListener(v -> dismiss());
+ binding.dialogSubmit.setOnClickListener(v -> call.dialogClick());
+ }
+
+
+ public void dialogShow(Bitmap bitmap) {
+ binding.dialogImg.setImageBitmap(bitmap);
+ super.show();
+ }
+}
diff --git a/app/src/main/res/layout/activity_home_page.xml b/app/src/main/res/layout/activity_home_page.xml
index a13076c..b9da900 100644
--- a/app/src/main/res/layout/activity_home_page.xml
+++ b/app/src/main/res/layout/activity_home_page.xml
@@ -72,15 +72,47 @@
android:textSize="20sp" />
+
+
+
+
+
+
+
diff --git a/app/src/main/res/layout/activity_jion.xml b/app/src/main/res/layout/activity_jion.xml
new file mode 100644
index 0000000..2cf76a3
--- /dev/null
+++ b/app/src/main/res/layout/activity_jion.xml
@@ -0,0 +1,91 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/dialog_img.xml b/app/src/main/res/layout/dialog_img.xml
new file mode 100644
index 0000000..ad426df
--- /dev/null
+++ b/app/src/main/res/layout/dialog_img.xml
@@ -0,0 +1,45 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/item_jion.xml b/app/src/main/res/layout/item_jion.xml
new file mode 100644
index 0000000..1e18957
--- /dev/null
+++ b/app/src/main/res/layout/item_jion.xml
@@ -0,0 +1,32 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/mipmap-xhdpi/home_cha.png b/app/src/main/res/mipmap-xhdpi/home_cha.png
new file mode 100644
index 0000000..c4c5c1e
Binary files /dev/null and b/app/src/main/res/mipmap-xhdpi/home_cha.png differ
diff --git a/app/src/main/res/mipmap-xhdpi/home_jiao.png b/app/src/main/res/mipmap-xhdpi/home_jiao.png
new file mode 100644
index 0000000..7125262
Binary files /dev/null and b/app/src/main/res/mipmap-xhdpi/home_jiao.png differ
diff --git a/app/src/main/res/mipmap-xhdpi/home_jie.png b/app/src/main/res/mipmap-xhdpi/home_jie.png
new file mode 100644
index 0000000..037864f
Binary files /dev/null and b/app/src/main/res/mipmap-xhdpi/home_jie.png differ
diff --git a/app/src/main/res/mipmap-xhdpi/icon_cha.png b/app/src/main/res/mipmap-xhdpi/icon_cha.png
new file mode 100644
index 0000000..b65a1da
Binary files /dev/null and b/app/src/main/res/mipmap-xhdpi/icon_cha.png differ
diff --git a/app/src/main/res/values/themes.xml b/app/src/main/res/values/themes.xml
index 9e5c850..e01ba24 100644
--- a/app/src/main/res/values/themes.xml
+++ b/app/src/main/res/values/themes.xml
@@ -44,4 +44,18 @@
+
+
\ No newline at end of file