close token获取频率

master
wanghao 2 months ago
parent b6ddf680b9
commit 6142ac0114

@ -72,9 +72,9 @@ public class IntentSelectActivity extends BaseActivity {
handler.postDelayed(runnable, 1000); handler.postDelayed(runnable, 1000);
} }
}; };
tokenRunnable = () -> { // tokenRunnable = () -> {
requestToken(); // requestToken();
}; // };
handler.postDelayed(tokenRunnable, 0); handler.postDelayed(tokenRunnable, 0);
keyReceiver = new MyKeyReceiver(); keyReceiver = new MyKeyReceiver();
IntentFilter intentFilter = new IntentFilter(); IntentFilter intentFilter = new IntentFilter();
@ -98,7 +98,10 @@ public class IntentSelectActivity extends BaseActivity {
@Override @Override
public void afterTextChanged(Editable s) { public void afterTextChanged(Editable s) {
if (s.length() == 24) { if (s.length() == 24) {
haohuaMesSelect(s.toString());
requestToken(s.toString());
} }
} }
@ -106,7 +109,7 @@ public class IntentSelectActivity extends BaseActivity {
ip = SharedPreferencesUtils.getstring("ip", "https://rfidpub.haohuatire.com:7443"); ip = SharedPreferencesUtils.getstring("ip", "https://rfidpub.haohuatire.com:7443");
} }
private void requestToken() { private void requestToken(String epc) {
Map<String, String> map = new HashMap<>(); Map<String, String> map = new HashMap<>();
map.put("AppId", "app-20250704032545-nmmhn8jw"); map.put("AppId", "app-20250704032545-nmmhn8jw");
map.put("AppSecret", "dXJZQKubbqhSPCugtA49rsDGACmN5CMD4ItTfP11+DA="); map.put("AppSecret", "dXJZQKubbqhSPCugtA49rsDGACmN5CMD4ItTfP11+DA=");
@ -121,7 +124,9 @@ public class IntentSelectActivity extends BaseActivity {
token = jsonObject.get("Token").getAsString(); token = jsonObject.get("Token").getAsString();
Log.e("TAG", "onSuccess:token=" + token); Log.e("TAG", "onSuccess:token=" + token);
binding.traceSanButton1.setVisibility(View.GONE); binding.traceSanButton1.setVisibility(View.GONE);
handler.postDelayed(tokenRunnable, 60 * 1000 * 90); // handler.postDelayed(tokenRunnable, 60 * 1000 * 90);
haohuaMesSelect(epc);
} else { } else {
tipsDialog.setTip(false, body.getInfo()); tipsDialog.setTip(false, body.getInfo());
tipsDialog.show(); tipsDialog.show();
@ -133,7 +138,7 @@ public class IntentSelectActivity extends BaseActivity {
} }
public void intentRequestToken(View view) { public void intentRequestToken(View view) {
requestToken(); requestToken(binding.dataEpc.getText().toString());
} }
public void dataReadRFID(View view) { public void dataReadRFID(View view) {
@ -165,6 +170,9 @@ public class IntentSelectActivity extends BaseActivity {
} }
private void haohuaMesSelect(String result) { private void haohuaMesSelect(String result) {
OkGo.<MyResult>post(ip + "/UMInterface/RFID/sellTyreTracingBack") OkGo.<MyResult>post(ip + "/UMInterface/RFID/sellTyreTracingBack")
.headers("Token", token) .headers("Token", token)
.params("rfid", result).execute(new MyRecultCall(dialog, this) { .params("rfid", result).execute(new MyRecultCall(dialog, this) {

@ -77,15 +77,18 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginBottom="15dp"> android:layout_marginBottom="15dp">
<Button <Button
android:id="@+id/trace_san_button1" android:id="@+id/trace_san_button1"
style="@style/button_style" style="@style/button_style"
android:layout_width="150dp" android:layout_width="150dp"
android:layout_height="55dp" android:layout_height="55dp"
android:onClick="intentRequestToken"
android:background="@drawable/button_bg2" android:background="@drawable/button_bg2"
android:onClick="intentRequestToken"
android:visibility="gone"
android:text="重新连接" /> android:text="重新连接" />
<Button
<Button
android:id="@+id/trace_san_button" android:id="@+id/trace_san_button"
style="@style/button_style" style="@style/button_style"
android:layout_width="match_parent" android:layout_width="match_parent"

Loading…
Cancel
Save