增加 读取user
parent
6142ac0114
commit
a8a3b5da1a
@ -0,0 +1,62 @@
|
|||||||
|
package com.example.writeepc;
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.util.Log;
|
||||||
|
import android.view.View;
|
||||||
|
|
||||||
|
import androidx.databinding.DataBindingUtil;
|
||||||
|
|
||||||
|
import com.example.writeepc.base.BaseActivity;
|
||||||
|
import com.example.writeepc.databinding.ActivityWriteUserBinding;
|
||||||
|
|
||||||
|
public class WriteUserActivity extends BaseActivity {
|
||||||
|
private ActivityWriteUserBinding binding;
|
||||||
|
private InfoData infoData;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
binding = DataBindingUtil.setContentView(this, R.layout.activity_write_user);
|
||||||
|
infoData=new InfoData();
|
||||||
|
binding.setData(infoData);
|
||||||
|
initUHFRManager(5);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void readTidReault(boolean readState, String result, byte[] rdata) {
|
||||||
|
Log.e("TAG", "readTidReault:" + result);
|
||||||
|
infoData.setReadUser(ASCIIUtil.hex2Str(result));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void writeUser(View view) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void readUser(View view) {
|
||||||
|
int lenth = Integer.parseInt(binding.userReadLenth.getSelectedItem().toString());
|
||||||
|
readUser(lenth);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void userClearView(View view) {
|
||||||
|
infoData.setWriteUser(null);
|
||||||
|
infoData.setReadUser(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onDestroy() {
|
||||||
|
super.onDestroy();
|
||||||
|
if (uhfrManager != null) {
|
||||||
|
uhfrManager.close();
|
||||||
|
uhfrManager = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,125 @@
|
|||||||
|
<?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="data"
|
||||||
|
type="com.example.writeepc.InfoData" />
|
||||||
|
</data>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical"
|
||||||
|
tools:context=".WriteUserActivity">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
|
||||||
|
style="@style/info_text"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="55dp"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:background="#6750A4"
|
||||||
|
android:letterSpacing="0.2"
|
||||||
|
android:text="User区读写"
|
||||||
|
android:textColor="@color/white"
|
||||||
|
android:textSize="22sp"
|
||||||
|
android:textStyle="bold" />
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="55dp"
|
||||||
|
android:layout_marginTop="30dp"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
style="@style/info_text"
|
||||||
|
android:layout_width="110dp"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:text="读取长度:" />
|
||||||
|
|
||||||
|
<Spinner
|
||||||
|
android:id="@+id/user_read_lenth"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:textAlignment="center"
|
||||||
|
android:entries="@array/read_lenth"/>
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="55dp"
|
||||||
|
android:layout_marginTop="30dp"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
style="@style/info_text"
|
||||||
|
android:layout_width="110dp"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:text="写入数据:" />
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/epc_view"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="55dp"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:text="@={data.writeUser}" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<Button
|
||||||
|
style="@style/button_style"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="55dp"
|
||||||
|
android:onClick="writeUser"
|
||||||
|
android:layout_marginTop="12dp"
|
||||||
|
android:text="写入数据" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="10dp"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
style="@style/info_text"
|
||||||
|
android:layout_width="110dp"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:text="user:" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
style="@style/san_text"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:padding="5dp"
|
||||||
|
android:minHeight="55dp"
|
||||||
|
android:text="@={data.readUser}" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<Button
|
||||||
|
style="@style/button_style"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="55dp"
|
||||||
|
android:layout_marginTop="12dp"
|
||||||
|
android:onClick="readUser"
|
||||||
|
android:text="扫描验证" />
|
||||||
|
<Button
|
||||||
|
style="@style/button_style"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="55dp"
|
||||||
|
android:layout_marginTop="12dp"
|
||||||
|
android:onClick="userClearView"
|
||||||
|
android:backgroundTint="#FFD600"
|
||||||
|
android:text="清空操作" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
</layout>
|
||||||
Loading…
Reference in New Issue