完成 列表
parent
67ac720833
commit
609b21dc52
@ -0,0 +1,59 @@
|
||||
package com.example.beijingnopowercon.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.beijingnopowercon.BR;
|
||||
import com.example.beijingnopowercon.R;
|
||||
import com.example.beijingnopowercon.data.DeviceInfo;
|
||||
import com.example.beijingnopowercon.data.RecordUse;
|
||||
import com.example.beijingnopowercon.databinding.ItemDeviceBinding;
|
||||
import com.example.beijingnopowercon.databinding.ItemRecordBinding;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class DeviceListAdapter extends RecyclerView.Adapter<DeviceListAdapter.MyViewHoder> {
|
||||
private List<DeviceInfo> list;
|
||||
private Context context;
|
||||
private LayoutInflater inflater;
|
||||
|
||||
public DeviceListAdapter(Context context) {
|
||||
this.context = context;
|
||||
inflater = LayoutInflater.from(context);
|
||||
}
|
||||
|
||||
public void setList(List<DeviceInfo> list) {
|
||||
this.list = list;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public MyViewHoder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
ItemDeviceBinding binding = DataBindingUtil.inflate(inflater, R.layout.item_device, parent, false);
|
||||
return new MyViewHoder(binding);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull MyViewHoder holder, int position) {
|
||||
holder.binding.setVariable(BR.data, list.get(position));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return list == null ? 0 : list.size();
|
||||
}
|
||||
|
||||
public class MyViewHoder extends RecyclerView.ViewHolder {
|
||||
private ItemDeviceBinding binding;
|
||||
|
||||
public MyViewHoder(ItemDeviceBinding binding) {
|
||||
super(binding.getRoot());
|
||||
this.binding = binding;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,57 @@
|
||||
package com.example.beijingnopowercon.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.beijingnopowercon.BR;
|
||||
import com.example.beijingnopowercon.R;
|
||||
import com.example.beijingnopowercon.data.RecordUse;
|
||||
import com.example.beijingnopowercon.databinding.ItemRecordBinding;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class RecordListAdapter extends RecyclerView.Adapter<RecordListAdapter.MyViewHoder> {
|
||||
private List<RecordUse> list;
|
||||
private Context context;
|
||||
private LayoutInflater inflater;
|
||||
|
||||
public RecordListAdapter(Context context) {
|
||||
this.context = context;
|
||||
inflater = LayoutInflater.from(context);
|
||||
}
|
||||
|
||||
public void setList(List<RecordUse> list) {
|
||||
this.list = list;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public MyViewHoder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
ItemRecordBinding binding = DataBindingUtil.inflate(inflater, R.layout.item_record, parent, false);
|
||||
return new MyViewHoder(binding);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull MyViewHoder holder, int position) {
|
||||
holder.binding.setVariable(BR.data, list.get(position));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return list == null ? 0 : list.size();
|
||||
}
|
||||
|
||||
public class MyViewHoder extends RecyclerView.ViewHolder {
|
||||
private ItemRecordBinding binding;
|
||||
|
||||
public MyViewHoder(ItemRecordBinding binding) {
|
||||
super(binding.getRoot());
|
||||
this.binding = binding;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,137 @@
|
||||
package com.example.beijingnopowercon.data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 使用记录对象 device_record_use
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2025-05-19
|
||||
*/
|
||||
public class RecordUse {
|
||||
|
||||
|
||||
private String deviceId;
|
||||
|
||||
/**
|
||||
* 设备编码
|
||||
*/
|
||||
|
||||
private String deviceCode;
|
||||
|
||||
/**
|
||||
* 设备名称
|
||||
*/
|
||||
|
||||
private String deviceName;
|
||||
|
||||
/**
|
||||
* 设备类型
|
||||
*/
|
||||
private String deviceType;
|
||||
|
||||
/**
|
||||
* 开锁时间
|
||||
*/
|
||||
private String openTime;
|
||||
|
||||
/**
|
||||
* 关锁时间
|
||||
*/
|
||||
private String closeTime;
|
||||
|
||||
/**
|
||||
* 使用时间(小时)
|
||||
*/
|
||||
private double useTime;
|
||||
|
||||
/**
|
||||
* 使用状态
|
||||
*/
|
||||
private String useState;
|
||||
private String useStateName;
|
||||
|
||||
public String getUseStateName() {
|
||||
if (useState.equals("1")){
|
||||
return "使用中";
|
||||
}
|
||||
return "已完成";
|
||||
}
|
||||
|
||||
/**
|
||||
* 借用人
|
||||
*/
|
||||
private String useUser;
|
||||
|
||||
public String getDeviceId() {
|
||||
return deviceId;
|
||||
}
|
||||
|
||||
public void setDeviceId(String deviceId) {
|
||||
this.deviceId = deviceId;
|
||||
}
|
||||
|
||||
public String getDeviceCode() {
|
||||
return deviceCode;
|
||||
}
|
||||
|
||||
public void setDeviceCode(String deviceCode) {
|
||||
this.deviceCode = deviceCode;
|
||||
}
|
||||
|
||||
public String getDeviceName() {
|
||||
return deviceName;
|
||||
}
|
||||
|
||||
public void setDeviceName(String deviceName) {
|
||||
this.deviceName = deviceName;
|
||||
}
|
||||
|
||||
public String getDeviceType() {
|
||||
return deviceType;
|
||||
}
|
||||
|
||||
public void setDeviceType(String deviceType) {
|
||||
this.deviceType = deviceType;
|
||||
}
|
||||
|
||||
public String getOpenTime() {
|
||||
return openTime;
|
||||
}
|
||||
|
||||
public void setOpenTime(String openTime) {
|
||||
this.openTime = openTime;
|
||||
}
|
||||
|
||||
public String getCloseTime() {
|
||||
return closeTime;
|
||||
}
|
||||
|
||||
public void setCloseTime(String closeTime) {
|
||||
this.closeTime = closeTime;
|
||||
}
|
||||
|
||||
public double getUseTime() {
|
||||
return useTime;
|
||||
}
|
||||
|
||||
public void setUseTime(double useTime) {
|
||||
this.useTime = useTime;
|
||||
}
|
||||
|
||||
public String getUseState() {
|
||||
return useState;
|
||||
}
|
||||
|
||||
public void setUseState(String useState) {
|
||||
this.useState = useState;
|
||||
}
|
||||
|
||||
public String getUseUser() {
|
||||
return useUser;
|
||||
}
|
||||
|
||||
public void setUseUser(String useUser) {
|
||||
this.useUser = useUser;
|
||||
}
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<corners android:radius="6dp"/>
|
||||
<solid android:color="@color/white"/>
|
||||
</shape>
|
@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<solid android:color="#E3E3E3"/>
|
||||
<corners android:radius="6dp"/>
|
||||
</shape>
|
@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<solid android:color="#D4E157"/>
|
||||
<corners android:radius="6dp"/>
|
||||
</shape>
|
@ -1,22 +1,21 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<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"
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".ui.gallery.GalleryFragment">
|
||||
tools:context=".ui.gallery.GalleryFragment"
|
||||
android:background="#F1F1F1">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text_gallery"
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/record_recycler"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:textAlignment="center"
|
||||
android:textSize="20sp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
android:layout_height="match_parent"
|
||||
android:padding="8dp"
|
||||
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" />
|
||||
</LinearLayout>
|
||||
</layout>
|
@ -0,0 +1,43 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layout xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<data>
|
||||
<variable
|
||||
name="data"
|
||||
type="com.example.beijingnopowercon.data.DeviceInfo" />
|
||||
</data>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="55dp">
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:text="@{data.deviceCode}"
|
||||
style="@style/text_black_16_center" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:text="@{data.deviceName}"
|
||||
style="@style/text_black_16_center" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:text="@{data.locationName}"
|
||||
style="@style/text_black_16_center" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="70dp"
|
||||
android:layout_height="match_parent"
|
||||
|
||||
android:text="@{data.deviceStateName}"
|
||||
style="@style/text_black_16_center" />
|
||||
|
||||
</LinearLayout>
|
||||
</layout>
|
@ -0,0 +1,108 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layout xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<data>
|
||||
|
||||
<variable
|
||||
name="data"
|
||||
type="com.example.beijingnopowercon.data.RecordUse" />
|
||||
</data>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
android:background="@drawable/bg_item"
|
||||
android:orientation="vertical"
|
||||
android:padding="8dp">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="35dp">
|
||||
|
||||
<View
|
||||
android:layout_width="4dp"
|
||||
android:layout_height="25dp"
|
||||
android:layout_gravity="center"
|
||||
android:background="@color/blue" />
|
||||
|
||||
<TextView
|
||||
style="@style/text_black_16"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:paddingStart="5dp"
|
||||
android:text="@{data.deviceName}" />
|
||||
|
||||
<TextView
|
||||
style="@style/text_black_16_center"
|
||||
android:layout_width="100dp"
|
||||
android:layout_height="match_parent"
|
||||
android:background='@{data.useState.equals("0")?@drawable/item_state_0:@drawable/item_state_1}'
|
||||
android:text="@{data.useStateName}" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="35dp"
|
||||
android:layout_marginTop="2dp">
|
||||
|
||||
|
||||
<TextView
|
||||
style="@style/text_black_16_center"
|
||||
android:layout_width="120dp"
|
||||
android:layout_height="match_parent"
|
||||
android:text="开锁时间:" />
|
||||
|
||||
<TextView
|
||||
style="@style/text_black_16"
|
||||
android:layout_width="100dp"
|
||||
android:layout_height="match_parent"
|
||||
android:text="@{data.openTime}" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="35dp"
|
||||
android:layout_marginTop="2dp">
|
||||
|
||||
|
||||
<TextView
|
||||
style="@style/text_black_16_center"
|
||||
android:layout_width="120dp"
|
||||
android:layout_height="match_parent"
|
||||
|
||||
android:text="关锁时间:" />
|
||||
|
||||
<TextView
|
||||
style="@style/text_black_16"
|
||||
android:layout_width="100dp"
|
||||
android:layout_height="match_parent"
|
||||
android:text="@{data.closeTime}" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="35dp"
|
||||
android:layout_marginTop="2dp">
|
||||
|
||||
<TextView
|
||||
style="@style/text_black_16_center"
|
||||
android:layout_width="120dp"
|
||||
android:layout_height="match_parent"
|
||||
android:text="使用时长:" />
|
||||
|
||||
<TextView
|
||||
style="@style/text_black_16"
|
||||
android:layout_width="100dp"
|
||||
android:layout_height="match_parent"
|
||||
android:text='@{String.valueOf(data.useTime)+" 小时"}' />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
</layout>
|
@ -1,17 +1,17 @@
|
||||
package com.example.beijingnopowercon;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Example local unit test, which will execute on the development machine (host).
|
||||
*
|
||||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
|
||||
*/
|
||||
public class ExampleUnitTest {
|
||||
@Test
|
||||
public void addition_isCorrect() {
|
||||
assertEquals(4, 2 + 2);
|
||||
}
|
||||
}
|
||||
// package com.example.beijingnopowercon;
|
||||
//
|
||||
// import org.junit.Test;
|
||||
//
|
||||
// import static org.junit.Assert.*;
|
||||
//
|
||||
// /**
|
||||
// * Example local unit test, which will execute on the development machine (host).
|
||||
// *
|
||||
// * @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
|
||||
// */
|
||||
// public class ExampleUnitTest {
|
||||
// @Test
|
||||
// public void addition_isCorrect() {
|
||||
// assertEquals(4, 2 + 2);
|
||||
// }
|
||||
// }
|
Loading…
Reference in New Issue