|
|
@ -6,54 +6,102 @@ import android.annotation.SuppressLint;
|
|
|
|
import android.os.Bundle;
|
|
|
|
import android.os.Bundle;
|
|
|
|
import android.util.Log;
|
|
|
|
import android.util.Log;
|
|
|
|
import android.view.View;
|
|
|
|
import android.view.View;
|
|
|
|
|
|
|
|
import android.widget.Toast;
|
|
|
|
|
|
|
|
|
|
|
|
import com.example.jinyu_rfid.adapter.ResultAdapter;
|
|
|
|
import com.example.jinyu_rfid.adapter.ResultAdapter;
|
|
|
|
import com.example.jinyu_rfid.base.BaseActivity;
|
|
|
|
import com.example.jinyu_rfid.base.BaseActivity;
|
|
|
|
|
|
|
|
import com.example.jinyu_rfid.base.MyRecultCall;
|
|
|
|
|
|
|
|
import com.example.jinyu_rfid.base.MyResult;
|
|
|
|
import com.example.jinyu_rfid.been.ReadTyreNoResult;
|
|
|
|
import com.example.jinyu_rfid.been.ReadTyreNoResult;
|
|
|
|
import com.example.jinyu_rfid.callback.DataReturnCall;
|
|
|
|
import com.example.jinyu_rfid.callback.DataReturnCall;
|
|
|
|
import com.example.jinyu_rfid.databinding.ActivityReadBinding;
|
|
|
|
import com.example.jinyu_rfid.databinding.ActivityReadBinding;
|
|
|
|
import com.example.jinyu_rfid.rfid.C5106Device;
|
|
|
|
import com.example.jinyu_rfid.rfid.C5106Device;
|
|
|
|
import com.example.jinyu_rfid.rfid.RFIDModel;
|
|
|
|
import com.example.jinyu_rfid.rfid.RFIDModel;
|
|
|
|
import com.example.jinyu_rfid.uitls.ASCIIUtil;
|
|
|
|
import com.example.jinyu_rfid.uitls.ASCIIUtil;
|
|
|
|
|
|
|
|
import com.google.gson.reflect.TypeToken;
|
|
|
|
|
|
|
|
import com.lzy.okgo.OkGo;
|
|
|
|
|
|
|
|
import com.lzy.okgo.model.Response;
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import okhttp3.RequestBody;
|
|
|
|
|
|
|
|
|
|
|
|
public class ReadActivity extends BaseActivity implements DataReturnCall {
|
|
|
|
public class ReadActivity extends BaseActivity implements DataReturnCall {
|
|
|
|
private ResultAdapter adapter;
|
|
|
|
private ResultAdapter adapter;
|
|
|
|
private RFIDModel rfidModel;
|
|
|
|
private RFIDModel rfidModel;
|
|
|
|
private String[] stringArray;
|
|
|
|
private String[] stringArray;
|
|
|
|
private List<ReadTyreNoResult> list;
|
|
|
|
private List<ReadTyreNoResult> list;
|
|
|
|
|
|
|
|
private ActivityReadBinding binding;
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
|
|
super.onCreate(savedInstanceState);
|
|
|
|
super.onCreate(savedInstanceState);
|
|
|
|
ActivityReadBinding binding = DataBindingUtil.setContentView(this, R.layout.activity_read);
|
|
|
|
|
|
|
|
|
|
|
|
binding = DataBindingUtil.setContentView(this, R.layout.activity_read);
|
|
|
|
binding.setTitle(getString(R.string.go_read));
|
|
|
|
binding.setTitle(getString(R.string.go_read));
|
|
|
|
adapter = new ResultAdapter(this);
|
|
|
|
adapter = new ResultAdapter(this);
|
|
|
|
|
|
|
|
list = new ArrayList<>(11);
|
|
|
|
|
|
|
|
adapter.setList(list);
|
|
|
|
binding.setAdapter(adapter);
|
|
|
|
binding.setAdapter(adapter);
|
|
|
|
// 名称
|
|
|
|
var workmode = getIntent().getIntExtra("work", 0);
|
|
|
|
|
|
|
|
binding.setType(workmode == 1);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 名称
|
|
|
|
stringArray = getResources().getStringArray(R.array.project_list);
|
|
|
|
stringArray = getResources().getStringArray(R.array.project_list);
|
|
|
|
rfidModel = new C5106Device(this);
|
|
|
|
rfidModel = new C5106Device(this);
|
|
|
|
list = new ArrayList<>(11);
|
|
|
|
|
|
|
|
adapter.setList(list);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void readInfo(View view) {
|
|
|
|
public void readInfo(View view) {
|
|
|
|
rfidModel.sanUser(80);
|
|
|
|
rfidModel.sanUser(80);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void readEPCInfo(View view) {
|
|
|
|
|
|
|
|
rfidModel.sanEpc(6);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@SuppressLint("NotifyDataSetChanged")
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void readEpcCodeInfo(String info, boolean state, String stateInfo) {
|
|
|
|
public void readEpcCodeInfo(String info, boolean state, String stateInfo) {
|
|
|
|
|
|
|
|
if (state) {
|
|
|
|
|
|
|
|
music.start();
|
|
|
|
|
|
|
|
list.clear();
|
|
|
|
|
|
|
|
binding.readText.setText(info);
|
|
|
|
|
|
|
|
Map<String, String> map = new HashMap<>();
|
|
|
|
|
|
|
|
map.put("EpcCode", info);
|
|
|
|
|
|
|
|
map.put("token", "123456");
|
|
|
|
|
|
|
|
OkGo.<MyResult>post(url + "/readEPCCode")
|
|
|
|
|
|
|
|
.upRequestBody(RequestBody.create(JSON, gson.toJson(map))).execute(new MyRecultCall(dialog, this) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void onSuccess(Response<MyResult> response) {
|
|
|
|
|
|
|
|
super.onSuccess(response);
|
|
|
|
|
|
|
|
var body = response.body();
|
|
|
|
|
|
|
|
if (body.getResultFlag().equals("1")) {
|
|
|
|
|
|
|
|
list.addAll(gson.fromJson(body.getJson(),new TypeToken<List<ReadTyreNoResult>>(){}.getType()));
|
|
|
|
|
|
|
|
adapter.notifyDataSetChanged();
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
Toast.makeText(ReadActivity.this, body.getJson(), Toast.LENGTH_SHORT).show();
|
|
|
|
|
|
|
|
adapter.notifyDataSetChanged();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}else {
|
|
|
|
|
|
|
|
binding.readText.setText(null);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@SuppressLint("NotifyDataSetChanged")
|
|
|
|
@SuppressLint("NotifyDataSetChanged")
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void readUserInfo(String user, boolean state, String stateInfo) {
|
|
|
|
public void readUserInfo(String user, boolean state, String stateInfo) {
|
|
|
|
list.clear();
|
|
|
|
list.clear();
|
|
|
|
if (state) {
|
|
|
|
if (state) {
|
|
|
|
|
|
|
|
binding.readText.setText(user);
|
|
|
|
music.start();
|
|
|
|
music.start();
|
|
|
|
String info = ASCIIUtil.hex2Str(user);
|
|
|
|
String info = ASCIIUtil.hex2Str(user);
|
|
|
|
Log.e("TAG", "readUserInfo:" + info);
|
|
|
|
Log.e("TAG", "readUserInfo:" + info);
|
|
|
@ -61,9 +109,15 @@ public class ReadActivity extends BaseActivity implements DataReturnCall {
|
|
|
|
for (int i = 0; i < 12; i++) {
|
|
|
|
for (int i = 0; i < 12; i++) {
|
|
|
|
list.add(new ReadTyreNoResult(i, stringArray[i], infos[i]));
|
|
|
|
list.add(new ReadTyreNoResult(i, stringArray[i], infos[i]));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}else {
|
|
|
|
|
|
|
|
binding.readText.setText(null);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
adapter.notifyDataSetChanged();
|
|
|
|
adapter.notifyDataSetChanged();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
protected void onDestroy() {
|
|
|
|
|
|
|
|
super.onDestroy();
|
|
|
|
|
|
|
|
rfidModel.close();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|