完成 交货
parent
464bcfa2bf
commit
5620639649
@ -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<String> 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.<MyResult>post("http://" + ip + "/api/jion/select")
|
||||
.params("user", SharedPreferencesUtils.getstring("user", ""))
|
||||
.execute(new MyRecultCall(dialog, this) {
|
||||
@Override
|
||||
public void onSuccess(Response<MyResult> response) {
|
||||
super.onSuccess(response);
|
||||
var body = response.body();
|
||||
if (body.getCode() == 0) {
|
||||
|
||||
list = gson.fromJson(body.getJson(), new TypeToken<List<String>>() {
|
||||
}.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() {
|
||||
|
||||
}
|
||||
}
|
@ -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<JionAdapter.MyViewHolder> {
|
||||
private Context context;
|
||||
private List<String> list;
|
||||
private LayoutInflater inflater;
|
||||
|
||||
|
||||
public JionAdapter(Context context) {
|
||||
this.context = context;
|
||||
inflater = LayoutInflater.from(context);
|
||||
}
|
||||
|
||||
public void setList(List<String> 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;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
package com.example.bgsrfidtrack.dialog;
|
||||
|
||||
/**
|
||||
* @author wanghao
|
||||
* @date 2024/7/26 16:22
|
||||
*/
|
||||
public interface DialogClickCall {
|
||||
void dialogClick();
|
||||
}
|
@ -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();
|
||||
}
|
||||
}
|
@ -0,0 +1,91 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<data>
|
||||
|
||||
<variable
|
||||
name="title"
|
||||
type="String" />
|
||||
|
||||
<variable
|
||||
name="state"
|
||||
type="Boolean" />
|
||||
|
||||
<import type="android.view.View" />
|
||||
<variable
|
||||
name="adapter"
|
||||
type="com.example.bgsrfidtrack.adapter.JionAdapter" />
|
||||
</data>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
tools:context=".JionActivity">
|
||||
|
||||
<include
|
||||
layout="@layout/title_bar"
|
||||
app:title="@{title}" />
|
||||
|
||||
<LinearLayout
|
||||
style="@style/layoutbg"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="45dp"
|
||||
android:visibility="@{state?View.GONE:View.VISIBLE}">
|
||||
|
||||
<TextView
|
||||
style="@style/textbg"
|
||||
android:layout_width="100dp"
|
||||
android:layout_height="match_parent"
|
||||
android:text="交货码" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/unbinding_epc"
|
||||
style="@style/santextbg"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
style="@style/layoutbg"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="35dp">
|
||||
|
||||
<TextView
|
||||
style="@style/textbg"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:text="序号" />
|
||||
|
||||
<TextView
|
||||
style="@style/textbg"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="3"
|
||||
android:text="货框" />
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:background="@color/white"
|
||||
android:adapter="@{adapter}"
|
||||
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
|
||||
android:padding="4dp" />
|
||||
|
||||
<Button
|
||||
style="@style/buttonbg"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="50dp"
|
||||
android:onClick="jionDialogShow"
|
||||
android:text='@{state?"交货":"确认"}'/>
|
||||
|
||||
</LinearLayout>
|
||||
</layout>
|
@ -0,0 +1,45 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layout xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<data>
|
||||
|
||||
</data>
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:background="@color/white"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/dialog_dis"
|
||||
android:layout_width="70dp"
|
||||
android:layout_height="70dp"
|
||||
android:src="@mipmap/icon_cha"
|
||||
android:layout_gravity="right"
|
||||
android:padding="22dp" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/dialog_img"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="300dp"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:layout_marginRight="10dp" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="40dp"
|
||||
android:text="对方扫描交货码"
|
||||
android:gravity="center"
|
||||
android:textColor="@color/blue"
|
||||
android:textSize="16sp" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/dialog_submit"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="50dp"
|
||||
android:text="完成"
|
||||
style="@style/buttonbg" />
|
||||
|
||||
</LinearLayout>
|
||||
</layout>
|
@ -0,0 +1,32 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layout xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<data>
|
||||
|
||||
</data>
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="50dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/item_index"
|
||||
style="@style/textbg"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:text="序号" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/item_code"
|
||||
style="@style/textbg"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="3"
|
||||
android:text="货物条码" />
|
||||
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
</layout>
|
Binary file not shown.
After Width: | Height: | Size: 2.2 KiB |
Binary file not shown.
After Width: | Height: | Size: 2.2 KiB |
Binary file not shown.
After Width: | Height: | Size: 2.3 KiB |
Binary file not shown.
After Width: | Height: | Size: 1.7 KiB |
Loading…
Reference in New Issue