增加 webapi
parent
d90dee93cd
commit
5722c0f6fc
@ -0,0 +1,56 @@
|
||||
package com.example.writeepc;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.KeyEvent;
|
||||
import android.widget.RadioButton;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.example.writeepc.base.BaseActivity;
|
||||
import com.example.writeepc.base.MyApplication;
|
||||
import com.handheld.uhfr.UHFRManager;
|
||||
|
||||
public class HomeActivity extends BaseActivity {
|
||||
private UHFRManager uhfrManager;
|
||||
private long exitTime = 0L;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_home);
|
||||
uhfrManager = UHFRManager.getInstance();
|
||||
MyApplication.getApplication().setUhfrManager(uhfrManager);
|
||||
RadioButton button1 = this.findViewById(R.id.home_1);
|
||||
RadioButton button2 = this.findViewById(R.id.home_2);
|
||||
button1.setOnClickListener(v -> {
|
||||
startActivity(new Intent(this, ShuangqianActivity.class));
|
||||
});
|
||||
button2.setOnClickListener(v -> {
|
||||
startActivity(new Intent(this, ShuangqianActivity2.class));
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||
if (keyCode == 4) {
|
||||
if ((System.currentTimeMillis() - exitTime) > 2000) {
|
||||
Toast.makeText(getApplicationContext(), "再按一次退出程序", Toast.LENGTH_SHORT).show();
|
||||
exitTime = System.currentTimeMillis();
|
||||
return true;
|
||||
} else {
|
||||
finish();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
if (uhfrManager != null) {
|
||||
uhfrManager.close();
|
||||
uhfrManager = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,32 @@
|
||||
package com.example.writeepc;
|
||||
|
||||
import android.os.Bundle;
|
||||
import androidx.appcompat.app.ActionBar;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.preference.PreferenceFragmentCompat;
|
||||
|
||||
public class SettingsActivity extends AppCompatActivity {
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.settings_activity);
|
||||
if (savedInstanceState == null) {
|
||||
getSupportFragmentManager()
|
||||
.beginTransaction()
|
||||
.replace(R.id.settings, new SettingsFragment())
|
||||
.commit();
|
||||
}
|
||||
ActionBar actionBar = getSupportActionBar();
|
||||
if (actionBar != null) {
|
||||
actionBar.setDisplayHomeAsUpEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
public static class SettingsFragment extends PreferenceFragmentCompat {
|
||||
@Override
|
||||
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
|
||||
setPreferencesFromResource(R.xml.root_preferences, rootKey);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,68 @@
|
||||
package com.example.writeepc.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.writeepc.BR;
|
||||
import com.example.writeepc.R;
|
||||
import com.example.writeepc.been.MESInfo;
|
||||
import com.example.writeepc.databinding.ItemMesInfoBinding;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class MyMesInfoAdapter extends RecyclerView.Adapter<MyMesInfoAdapter.MyMesInfoAdapterViewHolder> {
|
||||
|
||||
private Context context;
|
||||
private LayoutInflater inflater;
|
||||
private List<MESInfo> list;
|
||||
|
||||
public MyMesInfoAdapter(Context context) {
|
||||
this.context = context;
|
||||
inflater = LayoutInflater.from(context);
|
||||
}
|
||||
|
||||
public void setList(List<MESInfo> list) {
|
||||
this.list = list;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public MyMesInfoAdapterViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
ItemMesInfoBinding binding = DataBindingUtil.inflate(inflater, R.layout.item_mes_info, parent, false);
|
||||
return new MyMesInfoAdapterViewHolder(binding);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull MyMesInfoAdapterViewHolder holder, int position) {
|
||||
ItemMesInfoBinding binding = holder.getBinding();
|
||||
MESInfo mesInfo = list.get(position);
|
||||
binding.setVariable(BR.data,mesInfo);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return list == null ? 0 : list.size();
|
||||
}
|
||||
|
||||
class MyMesInfoAdapterViewHolder extends RecyclerView.ViewHolder {
|
||||
private ItemMesInfoBinding binding;
|
||||
|
||||
public ItemMesInfoBinding getBinding() {
|
||||
return binding;
|
||||
}
|
||||
|
||||
public MyMesInfoAdapterViewHolder(ItemMesInfoBinding binding) {
|
||||
super(binding.getRoot());
|
||||
this.binding = binding;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,68 @@
|
||||
package com.example.writeepc.base.okgo;
|
||||
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.lzy.okgo.callback.AbsCallback;
|
||||
import com.lzy.okgo.model.Response;
|
||||
import com.lzy.okgo.request.base.Request;
|
||||
|
||||
import okhttp3.ResponseBody;
|
||||
|
||||
/**
|
||||
* @author wanghao
|
||||
* @date 2023/11/20 14:27
|
||||
*/
|
||||
public abstract class MyRecultCall extends AbsCallback<MyResult> {
|
||||
private ProgressDialog dialog;
|
||||
private Context context;
|
||||
|
||||
public MyRecultCall(ProgressDialog dialog, Context context) {
|
||||
this.dialog = dialog;
|
||||
this.context = context;
|
||||
}
|
||||
@Override
|
||||
public void onSuccess(Response<MyResult> response) {
|
||||
dialog.dismiss();
|
||||
// Log.e("网络请求情况", "onSuccess:");
|
||||
}
|
||||
@Override
|
||||
public MyResult convertResponse(okhttp3.Response response) throws Throwable {
|
||||
ResponseBody body = response.body();
|
||||
if (body == null) return null;
|
||||
Gson gson = new Gson();
|
||||
MyResult resust = gson.fromJson(body.string(), MyResult.class);
|
||||
resust.setDataJson(gson.toJson(resust.getData()));
|
||||
return resust;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void onError(Response<MyResult> response) {
|
||||
super.onError(response);
|
||||
dialog.dismiss();
|
||||
Log.e("网络请求情况", "onError:" );
|
||||
Toast.makeText(context, "接口请求连接失败", Toast.LENGTH_LONG).show();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart(Request<MyResult, ? extends Request> request) {
|
||||
super.onStart(request);
|
||||
dialog.show();
|
||||
// Log.e("网络请求情况", "onStart:" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFinish() {
|
||||
super.onFinish();
|
||||
dialog.dismiss();
|
||||
Log.e("网络请求情况", "onFinish:" );
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,72 @@
|
||||
package com.example.writeepc.base.okgo;
|
||||
|
||||
/**
|
||||
* @author wanghao
|
||||
* @date 2023/12/21 15:31
|
||||
*/
|
||||
public class MyResult {
|
||||
private int code;
|
||||
private String msg;
|
||||
private String info;
|
||||
private Object data;
|
||||
private String dataJson;
|
||||
private Object rows;
|
||||
private int total;
|
||||
|
||||
|
||||
public String getInfo() {
|
||||
return info;
|
||||
}
|
||||
|
||||
public void setInfo(String info) {
|
||||
this.info = info;
|
||||
}
|
||||
|
||||
public String getDataJson() {
|
||||
return dataJson;
|
||||
}
|
||||
|
||||
public void setDataJson(String dataJson) {
|
||||
this.dataJson = dataJson;
|
||||
}
|
||||
|
||||
public int getTotal() {
|
||||
return total;
|
||||
}
|
||||
|
||||
public void setTotal(int total) {
|
||||
this.total = total;
|
||||
}
|
||||
|
||||
public Object getRows() {
|
||||
return rows;
|
||||
}
|
||||
|
||||
public void setRows(Object rows) {
|
||||
this.rows = rows;
|
||||
}
|
||||
|
||||
public int getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(int code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getMsg() {
|
||||
return msg;
|
||||
}
|
||||
|
||||
public void setMsg(String msg) {
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
public Object getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setData(Object data) {
|
||||
this.data = data;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,22 @@
|
||||
package com.example.writeepc.been;
|
||||
|
||||
public class MESInfo {
|
||||
private String title;
|
||||
private String info;
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public String getInfo() {
|
||||
return info;
|
||||
}
|
||||
|
||||
public void setInfo(String info) {
|
||||
this.info = info;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,87 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
tools:context=".HomeActivity">
|
||||
|
||||
<TextView
|
||||
|
||||
style="@style/info_text"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="55dp"
|
||||
android:background="#6750A4"
|
||||
android:letterSpacing="0.2"
|
||||
android:text="主页"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="22sp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<RadioGroup
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="20dp"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<RadioButton
|
||||
android:id="@+id/home_1"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:button="@null"
|
||||
android:drawableTop="@mipmap/ic_binding"
|
||||
android:drawablePadding="10dp"
|
||||
android:gravity="center"
|
||||
android:text="MES绑定"
|
||||
android:textSize="20sp" />
|
||||
|
||||
<RadioButton
|
||||
android:id="@+id/home_2"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:button="@null"
|
||||
android:drawableTop="@mipmap/ic_home"
|
||||
android:drawablePadding="10dp"
|
||||
android:gravity="center"
|
||||
android:text="信息追溯"
|
||||
android:textSize="20sp" />
|
||||
|
||||
</RadioGroup>
|
||||
|
||||
<RadioGroup
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="20dp"
|
||||
android:visibility="gone"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<RadioButton
|
||||
android:id="@+id/home_3"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:button="@null"
|
||||
android:drawableTop="@mipmap/ic_info"
|
||||
android:drawablePadding="10dp"
|
||||
android:gravity="center"
|
||||
android:text="轮胎信息查询"
|
||||
android:textSize="20sp" />
|
||||
|
||||
<RadioButton
|
||||
android:id="@+id/home_4"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:button="@null"
|
||||
android:drawableTop="@mipmap/home_setting"
|
||||
android:drawablePadding="10dp"
|
||||
android:gravity="center"
|
||||
android:text="设置"
|
||||
android:textSize="20sp" />
|
||||
|
||||
</RadioGroup>
|
||||
|
||||
</LinearLayout>
|
||||
@ -0,0 +1,85 @@
|
||||
<?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="adapter"
|
||||
type="com.example.writeepc.adapter.MyMesInfoAdapter" />
|
||||
</data>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
tools:context=".ShuangqianActivity2">
|
||||
|
||||
<TextView
|
||||
|
||||
style="@style/info_text"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="55dp"
|
||||
android:background="#6750A4"
|
||||
android:letterSpacing="0.2"
|
||||
android:text="MES追溯"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="22sp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="55dp"
|
||||
android:layout_marginTop="20dp"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
style="@style/info_text"
|
||||
android:layout_width="110dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="center"
|
||||
android:text="扫描RFID:" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/data_epc"
|
||||
style="@style/san_text"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="center" />
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/data_info"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:gravity="left|center"
|
||||
android:padding="20dp"
|
||||
android:textSize="18sp"
|
||||
android:visibility="gone" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="110dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="8dp"
|
||||
android:text="查询信息"
|
||||
android:textColor="@color/blue" />
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:adapter="@{adapter}"
|
||||
android:padding="10dp"
|
||||
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" />
|
||||
|
||||
<Button
|
||||
style="@style/button_style"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="65dp"
|
||||
android:layout_marginBottom="15dp"
|
||||
android:onClick="dataReadRFID"
|
||||
android:text="扫描RFID" />
|
||||
</LinearLayout>
|
||||
</layout>
|
||||
@ -0,0 +1,41 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layout xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<data>
|
||||
<variable
|
||||
name="data"
|
||||
type="com.example.writeepc.been.MESInfo" />
|
||||
</data>
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="52dp">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="50dp">
|
||||
|
||||
<TextView
|
||||
style="@style/item_text"
|
||||
android:layout_width="110dp"
|
||||
android:layout_height="match_parent"
|
||||
android:text='@{data.title+" :"}' />
|
||||
|
||||
<TextView
|
||||
style="@style/item_text"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:text="@{data.info}" />
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_marginTop="1dp"
|
||||
android:layout_height="1dp"
|
||||
android:background="#e1e1e1" />
|
||||
|
||||
</LinearLayout>
|
||||
</layout>
|
||||
@ -0,0 +1,9 @@
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
<FrameLayout
|
||||
android:id="@+id/settings"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"/>
|
||||
</LinearLayout>
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 5.1 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 4.0 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 5.4 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 2.7 KiB |
@ -1,3 +1,19 @@
|
||||
<resources>
|
||||
<string name="app_name">WriteEpc</string>
|
||||
<string name="title_activity_settings">SettingsActivity</string>
|
||||
|
||||
<!-- Preference Titles -->
|
||||
<string name="messages_header">Messages</string>
|
||||
<string name="sync_header">Sync</string>
|
||||
|
||||
<!-- Messages Preferences -->
|
||||
<string name="signature_title">Your signature</string>
|
||||
<string name="reply_title">Default reply action</string>
|
||||
|
||||
<!-- Sync Preferences -->
|
||||
<string name="sync_title">Sync email periodically</string>
|
||||
<string name="attachment_title">Download incoming attachments</string>
|
||||
<string name="attachment_summary_on">Automatically download attachments for incoming emails
|
||||
</string>
|
||||
<string name="attachment_summary_off">Only download attachments when manually requested</string>
|
||||
</resources>
|
||||
@ -0,0 +1,38 @@
|
||||
<PreferenceScreen
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<PreferenceCategory
|
||||
app:title="@string/messages_header">
|
||||
|
||||
<EditTextPreference
|
||||
app:key="signature"
|
||||
app:title="@string/signature_title"
|
||||
app:useSimpleSummaryProvider="true"/>
|
||||
|
||||
<ListPreference
|
||||
app:key="reply"
|
||||
app:title="@string/reply_title"
|
||||
app:entries="@array/reply_entries"
|
||||
app:entryValues="@array/reply_values"
|
||||
app:defaultValue="reply"
|
||||
app:useSimpleSummaryProvider="true"/>
|
||||
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory
|
||||
app:title="@string/sync_header">
|
||||
|
||||
<SwitchPreferenceCompat
|
||||
app:key="sync"
|
||||
app:title="@string/sync_title"/>
|
||||
|
||||
<SwitchPreferenceCompat
|
||||
app:key="attachment"
|
||||
app:title="@string/attachment_title"
|
||||
app:summaryOn="@string/attachment_summary_on"
|
||||
app:summaryOff="@string/attachment_summary_off"
|
||||
app:dependency="sync"/>
|
||||
|
||||
</PreferenceCategory>
|
||||
|
||||
</PreferenceScreen>
|
||||
Loading…
Reference in New Issue