排程部分功能优化,
解绑,删除,绑定
This commit is contained in:
@@ -2,6 +2,7 @@ package com.ckkj.water.plan;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.text.TextUtils;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
|
||||
@@ -15,11 +16,13 @@ import com.ckkj.water.network.BaseBean;
|
||||
//import com.ckkj.water.plan.adapter.PlanDetailTimeAdapter;
|
||||
import com.ckkj.water.plan.adapter.PlanDetailDeviceAdapter;
|
||||
import com.ckkj.water.plan.adapter.PlanDetailTimeAdapter;
|
||||
import com.ckkj.water.plan.adapter.PlanWeekDaysAdapter;
|
||||
import com.ckkj.water.plan.entity.WaterPlanWeekEntity;
|
||||
import com.ckkj.water.plan.mvp.WaterPlanContract;
|
||||
import com.ckkj.water.plan.mvp.WaterPlanImpl;
|
||||
import com.ckkj.water.plan.mvp.WaterPlanPresenter;
|
||||
import com.ckkj.water.utils.show.ToastUtil;
|
||||
import com.ckkj.water.utils.time.ZYTimeUtils;
|
||||
import com.google.gson.Gson;
|
||||
import com.gyf.immersionbar.ImmersionBar;
|
||||
|
||||
@@ -35,7 +38,7 @@ public class PlanDetailActivity extends BaseActivity<WaterPlanDetailLayoutBindin
|
||||
private WaterPlanWeekEntity mPlanEntity;
|
||||
//查询到的排程详情
|
||||
private WaterPlanWeekEntity mDetailEntity;
|
||||
private PlanDetailTimeAdapter mAdapter;
|
||||
private PlanWeekDaysAdapter mAdapter;
|
||||
private PlanDetailDeviceAdapter deviceAdapter;
|
||||
private List<WaterPlanWeekEntity.DetailsBean> mList = new ArrayList<>();
|
||||
|
||||
@@ -62,7 +65,7 @@ public class PlanDetailActivity extends BaseActivity<WaterPlanDetailLayoutBindin
|
||||
.init();
|
||||
viewBinding.includedTitle.tvTitle.setText(R.string.plan_detail_title);
|
||||
initListener();
|
||||
mAdapter = new PlanDetailTimeAdapter(R.layout.plan_detail_time_item,mList);
|
||||
mAdapter = new PlanWeekDaysAdapter(R.layout.single_recycleview_item,mList);
|
||||
viewBinding.rvPlanTime.setAdapter(mAdapter);
|
||||
List<WaterDeviceEntity> deviceList = new ArrayList<>();
|
||||
deviceAdapter = new PlanDetailDeviceAdapter(R.layout.plan_detail_bind_device_item,deviceList);
|
||||
@@ -80,7 +83,7 @@ public class PlanDetailActivity extends BaseActivity<WaterPlanDetailLayoutBindin
|
||||
// if (event.getAction() == MotionEvent.ACTION_DOWN) {
|
||||
// if (viewBinding.switchButton.isChecked()) {
|
||||
// // 当前是开启状态,下一步将是关闭 -> 屏蔽动画(时长设为0)
|
||||
// viewBinding.switchButton.setAnimationDuration(0);
|
||||
// 0
|
||||
// } else {
|
||||
// // 当前是关闭状态,下一步将是开启 -> 开启动画(恢复默认的 250ms 或你想要的时长)
|
||||
// viewBinding.switchButton.setAnimationDuration(250);
|
||||
@@ -173,9 +176,23 @@ public class PlanDetailActivity extends BaseActivity<WaterPlanDetailLayoutBindin
|
||||
List<WaterPlanWeekEntity.DetailsBean> list = new ArrayList<>();
|
||||
for(WaterPlanWeekEntity.DetailsBean bean : entity.getDetails()){
|
||||
if(bean.getStatus().equals("1")){
|
||||
// 检查该日期是否有有效的时间配置
|
||||
boolean hasValidTime = false;
|
||||
if(bean.getTimeData() != null){
|
||||
for(WaterPlanWeekEntity.TimeDataBean timeBean : bean.getTimeData()){
|
||||
if(!TextUtils.isEmpty(timeBean.getStartTime())
|
||||
&& timeBean.getDurationMin() != 0){
|
||||
hasValidTime = true;
|
||||
bean.setWeekName(ZYTimeUtils.getWeekName(bean.getWeekday() - 1));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(hasValidTime){
|
||||
list.add(bean);
|
||||
}
|
||||
}
|
||||
}
|
||||
//日期显示
|
||||
if(mAdapter != null){
|
||||
mAdapter.setNewData(list);
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
package com.ckkj.water.plan.adapter;
|
||||
|
||||
import static android.view.View.INVISIBLE;
|
||||
import static android.view.View.VISIBLE;
|
||||
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter;
|
||||
@@ -10,15 +15,14 @@ import com.ckkj.water.utils.time.ZYTimeUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class PlanDetailTimeAdapter extends BaseQuickAdapter<WaterPlanWeekEntity.DetailsBean, BaseViewHolder> {
|
||||
public class PlanDetailTimeAdapter extends BaseQuickAdapter<WaterPlanWeekEntity.TimeDataBean, BaseViewHolder> {
|
||||
|
||||
public PlanDetailTimeAdapter(int layoutResId, @Nullable List<WaterPlanWeekEntity.DetailsBean> data) {
|
||||
public PlanDetailTimeAdapter(int layoutResId, @Nullable List<WaterPlanWeekEntity.TimeDataBean> data) {
|
||||
super(layoutResId, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void convert(BaseViewHolder helper, WaterPlanWeekEntity.DetailsBean item) {
|
||||
helper.setText(R.id.tv_week, ZYTimeUtils.getWeekName(item.getWeekday() - 1));
|
||||
protected void convert(BaseViewHolder helper, WaterPlanWeekEntity.TimeDataBean item) {
|
||||
helper.setText(R.id.tv_start_time,ZYTimeUtils.formatHHmm(item.getStartTime()));
|
||||
helper.setText(R.id.tv_duration,item.getDurationMin() + "min");
|
||||
}
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
package com.ckkj.water.plan.adapter;
|
||||
|
||||
import android.graphics.Rect;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter;
|
||||
import com.chad.library.adapter.base.BaseViewHolder;
|
||||
import com.ckkj.water.R;
|
||||
import com.ckkj.water.plan.entity.WaterPlanWeekEntity;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class PlanWeekDaysAdapter extends BaseQuickAdapter<WaterPlanWeekEntity.DetailsBean, BaseViewHolder> {
|
||||
|
||||
public PlanWeekDaysAdapter(int layoutResId, @Nullable List<WaterPlanWeekEntity.DetailsBean> data) {
|
||||
super(layoutResId, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void convert(BaseViewHolder helper, WaterPlanWeekEntity.DetailsBean item) {
|
||||
helper.setText(R.id.tv_week_name, item.getWeekName());
|
||||
RecyclerView rvWeekDatas = helper.getView(R.id.rv_plan_detail_times);
|
||||
PlanDetailTimeAdapter adapter = new PlanDetailTimeAdapter(R.layout.plan_detail_time_item, item.getTimeData());
|
||||
rvWeekDatas.setAdapter(adapter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttachedToRecyclerView(RecyclerView recyclerView) {
|
||||
super.onAttachedToRecyclerView(recyclerView);
|
||||
// 添加透明色分割线,高度10px
|
||||
recyclerView.addItemDecoration(new RecyclerView.ItemDecoration() {
|
||||
@Override
|
||||
public void getItemOffsets(Rect outRect, View view,
|
||||
RecyclerView parent, RecyclerView.State state) {
|
||||
int position = parent.getChildAdapterPosition(view);
|
||||
if (position > 0) {
|
||||
outRect.top = (int) (10 * view.getContext().getResources().getDisplayMetrics().density);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDraw(android.graphics.Canvas c, RecyclerView parent, RecyclerView.State state) {
|
||||
// 不绘制任何内容,保持透明
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -72,5 +72,6 @@ public class WaterPlanWeekEntity implements Serializable {
|
||||
public static class TimeDataBean implements Serializable{
|
||||
private String startTime = "";
|
||||
private int durationMin = 0;
|
||||
private String weekName;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_vertical">
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
@@ -45,5 +46,4 @@
|
||||
android:textColor="@color/color_zhu"
|
||||
android:textSize="14sp" />
|
||||
</RelativeLayout>
|
||||
|
||||
</LinearLayout>
|
||||
@@ -10,41 +10,34 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:layout_marginBottom="@dimen/dp_15">
|
||||
android:layout_marginBottom="@dimen/dp_10">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_week"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingHorizontal="@dimen/dp_12"
|
||||
android:gravity="center"
|
||||
android:text="周一"
|
||||
android:textColor="@color/color_666666"
|
||||
android:textSize="14sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_start_time"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:paddingHorizontal="@dimen/dp_12"
|
||||
android:gravity="center"
|
||||
android:gravity="left"
|
||||
android:text="10:30"
|
||||
android:textColor="@color/color_666666"
|
||||
android:textSize="14sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_duration"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:paddingHorizontal="@dimen/dp_12"
|
||||
android:gravity="center"
|
||||
android:gravity="left"
|
||||
android:text="10min"
|
||||
android:textColor="@color/color_666666"
|
||||
android:textSize="14sp" />
|
||||
<View
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="3"/>
|
||||
android:layout_weight="1"/>
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
|
||||
25
app/src/main/res/layout/single_recycleview_item.xml
Normal file
25
app/src/main/res/layout/single_recycleview_item.xml
Normal file
@@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout 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"
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
<TextView
|
||||
android:id="@+id/tv_week_name"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="2"
|
||||
android:textSize="14sp"
|
||||
android:textStyle="bold"
|
||||
android:textColor="@color/color_222222"
|
||||
android:text="周一"/>
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/rv_plan_detail_times"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="8"
|
||||
tools:listitem="@layout/plan_detail_time_item"
|
||||
tools:itemCount="2"
|
||||
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"/>
|
||||
</LinearLayout>
|
||||
@@ -76,8 +76,8 @@
|
||||
android:id="@+id/rv_plan_time"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
tools:listitem="@layout/plan_detail_time_item"
|
||||
tools:itemCount="5"
|
||||
tools:listitem="@layout/single_recycleview_item"
|
||||
tools:itemCount="3"
|
||||
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"/>
|
||||
|
||||
</LinearLayout>
|
||||
@@ -93,7 +93,7 @@
|
||||
<TextView
|
||||
android:layout_width="82dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/water_device_bind"
|
||||
android:text="@string/water_bound_device"
|
||||
android:textColor="@color/color_222222"
|
||||
android:textSize="16sp" />
|
||||
|
||||
@@ -102,7 +102,8 @@
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:orientation="vertical">
|
||||
android:orientation="vertical"
|
||||
android:paddingLeft="@dimen/dp_20">
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/rv_bind_devices"
|
||||
android:layout_width="match_parent"
|
||||
|
||||
Reference in New Issue
Block a user