排程重做
This commit is contained in:
@@ -160,7 +160,7 @@ dependencies {
|
|||||||
implementation 'top.zibin:Luban:1.1.8'
|
implementation 'top.zibin:Luban:1.1.8'
|
||||||
//带有侧滑功能的recyclerview
|
//带有侧滑功能的recyclerview
|
||||||
implementation 'com.yanzhenjie.recyclerview:x:1.3.2'
|
implementation 'com.yanzhenjie.recyclerview:x:1.3.2'
|
||||||
implementation 'com.github.luqiming666:SwipeRecyclerView:1.4.8'
|
// implementation 'com.github.luqiming666:SwipeRecyclerView:1.4.8'
|
||||||
//Activity与Fragmen实现沉浸式状态栏
|
//Activity与Fragmen实现沉浸式状态栏
|
||||||
implementation 'com.github.tangguna:immersion:1.0.1'
|
implementation 'com.github.tangguna:immersion:1.0.1'
|
||||||
//viewpager2
|
//viewpager2
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ public class AddWaterPlanActivity extends BaseActivity<AddWaterPlanLayoutBinding
|
|||||||
viewBinding.includedTitle.tvTitle.setText(R.string.add_water_plan_title);
|
viewBinding.includedTitle.tvTitle.setText(R.string.add_water_plan_title);
|
||||||
}
|
}
|
||||||
|
|
||||||
mFragmentList.add(new WaterConfigFragment());
|
mFragmentList.add(new WaterConfigFragment_copy());
|
||||||
mFragmentList.add(new BindDeviceFragment());
|
mFragmentList.add(new BindDeviceFragment());
|
||||||
ViewPagerAdapter adapter = new ViewPagerAdapter(mContext, mFragmentList);
|
ViewPagerAdapter adapter = new ViewPagerAdapter(mContext, mFragmentList);
|
||||||
viewBinding.viewpage.setAdapter(adapter);
|
viewBinding.viewpage.setAdapter(adapter);
|
||||||
@@ -84,12 +84,12 @@ public class AddWaterPlanActivity extends BaseActivity<AddWaterPlanLayoutBinding
|
|||||||
initListener();
|
initListener();
|
||||||
|
|
||||||
// 编辑模式下,延迟传递数据给 WaterConfigFragment,等 viewBinding 初始化完成后调用
|
// 编辑模式下,延迟传递数据给 WaterConfigFragment,等 viewBinding 初始化完成后调用
|
||||||
if (mIsEditMode && mEditEntity != null) {
|
// if (mIsEditMode && mEditEntity != null) {
|
||||||
viewBinding.viewpage.post(() -> {
|
// viewBinding.viewpage.post(() -> {
|
||||||
WaterConfigFragment configFragment = (WaterConfigFragment) mFragmentList.get(0);
|
// WaterConfigFragment configFragment = (WaterConfigFragment) mFragmentList.get(0);
|
||||||
configFragment.setEditEntity(mEditEntity);
|
// configFragment.setEditEntity(mEditEntity);
|
||||||
});
|
// });
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initListener() {
|
private void initListener() {
|
||||||
@@ -115,49 +115,52 @@ public class AddWaterPlanActivity extends BaseActivity<AddWaterPlanLayoutBinding
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case R.id.tv_bind:
|
case R.id.tv_bind:
|
||||||
WaterConfigFragment configFragment = (WaterConfigFragment) mFragmentList.get(0);
|
// WaterConfigFragment configFragment = (WaterConfigFragment) mFragmentList.get(0);
|
||||||
if (!configFragment.checkConfigFinish()) {
|
// if (!configFragment.checkConfigFinish()) {
|
||||||
ToastUtil.showShort(mContext, "请完成配置");
|
// ToastUtil.showShort(mContext, "请完成配置");
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
|
|
||||||
// 编辑模式下,检查配置是否有变化
|
// 编辑模式下,检查配置是否有变化
|
||||||
if (mIsEditMode) {
|
// if (mIsEditMode) {
|
||||||
if (configFragment.isConfigChanged()) {
|
// if (configFragment.isConfigChanged()) {
|
||||||
showDialogtext(mContext.getResources().getDrawable(R.mipmap.img_location), false, false, true,
|
// showDialogtext(mContext.getResources().getDrawable(R.mipmap.img_location), false, false, true,
|
||||||
"提示", "配置已修改,是否保存?",
|
// "提示", "配置已修改,是否保存?",
|
||||||
"取消", "保存", new BaseFragment.OnDialogClick() {
|
// "取消", "保存", new BaseFragment.OnDialogClick() {
|
||||||
@Override
|
// @Override
|
||||||
public void onCancelClick() {
|
// public void onCancelClick() {
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public void onConfirmClick() {
|
// public void onConfirmClick() {
|
||||||
configFragment.commitConfig();
|
// configFragment.commitConfig();
|
||||||
}
|
// }
|
||||||
});
|
// });
|
||||||
} else {
|
// } else {
|
||||||
selectTabBind(mEditEntity);
|
// selectTabBind(mEditEntity);
|
||||||
}
|
// }
|
||||||
} else {
|
// } else {
|
||||||
// 新增模式,检查配置是否已保存
|
// // 新增模式,检查配置是否已保存
|
||||||
if (!configFragment.isConfigSave || configFragment.isConfigChanged()) {
|
// if (!configFragment.isConfigSave || configFragment.isConfigChanged()) {
|
||||||
showDialogtext(mContext.getResources().getDrawable(R.mipmap.img_location), false, false, true,
|
// showDialogtext(mContext.getResources().getDrawable(R.mipmap.img_location), false, false, true,
|
||||||
"提示", "关联设备需要保存排程配置,是否继续?",
|
// "提示", "关联设备需要保存排程配置,是否继续?",
|
||||||
"取消", "继续", new BaseFragment.OnDialogClick() {
|
// "取消", "继续", new BaseFragment.OnDialogClick() {
|
||||||
@Override
|
// @Override
|
||||||
public void onCancelClick() {
|
// public void onCancelClick() {
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public void onConfirmClick() {
|
// public void onConfirmClick() {
|
||||||
configFragment.commitConfig();
|
// configFragment.commitConfig();
|
||||||
}
|
// }
|
||||||
});
|
// });
|
||||||
} else {
|
// } else {
|
||||||
selectTabBind(mNewAddEntity);
|
// selectTabBind(mNewAddEntity);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
viewBinding.tvConfig.setSelected(false);
|
||||||
|
viewBinding.tvBind.setSelected(true);
|
||||||
|
viewBinding.viewpage.setCurrentItem(1);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -25,6 +25,11 @@ import com.ckkj.water.plan.mvp.WaterPlanImpl;
|
|||||||
import com.ckkj.water.plan.mvp.WaterPlanPresenter;
|
import com.ckkj.water.plan.mvp.WaterPlanPresenter;
|
||||||
import com.ckkj.water.utils.time.ZYTimeUtils;
|
import com.ckkj.water.utils.time.ZYTimeUtils;
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
|
import com.yanzhenjie.recyclerview.OnItemMenuClickListener;
|
||||||
|
import com.yanzhenjie.recyclerview.SwipeMenu;
|
||||||
|
import com.yanzhenjie.recyclerview.SwipeMenuBridge;
|
||||||
|
import com.yanzhenjie.recyclerview.SwipeMenuCreator;
|
||||||
|
import com.yanzhenjie.recyclerview.SwipeMenuItem;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
@@ -40,6 +45,10 @@ public class WaterConfigFragment_copy extends BaseFragment<WaterConfigFragmentLa
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initData(Bundle state) {
|
public void initData(Bundle state) {
|
||||||
|
// 设置菜单创建器。
|
||||||
|
viewBinding.rvTimes.setSwipeMenuCreator(mSwipeMenuCreator);
|
||||||
|
viewBinding.rvTimes.setOnItemMenuClickListener(mItemMenuClickListener);
|
||||||
|
|
||||||
List<WaterPlanWeekEntity.DetailsBean> list = new ArrayList<>();
|
List<WaterPlanWeekEntity.DetailsBean> list = new ArrayList<>();
|
||||||
for(int i = 0; i < 7; i++){
|
for(int i = 0; i < 7; i++){
|
||||||
WaterPlanWeekEntity.DetailsBean bean = new WaterPlanWeekEntity.DetailsBean();
|
WaterPlanWeekEntity.DetailsBean bean = new WaterPlanWeekEntity.DetailsBean();
|
||||||
@@ -57,13 +66,44 @@ public class WaterConfigFragment_copy extends BaseFragment<WaterConfigFragmentLa
|
|||||||
mWeekAdapter = new WaterPlanWeekAdapter_copy(mContext, R.layout.plan_period_item,list);
|
mWeekAdapter = new WaterPlanWeekAdapter_copy(mContext, R.layout.plan_period_item,list);
|
||||||
viewBinding.rvWeek.setAdapter(mWeekAdapter);
|
viewBinding.rvWeek.setAdapter(mWeekAdapter);
|
||||||
//周期对应的 时间配置
|
//周期对应的 时间配置
|
||||||
|
timeList = weekList.get(0).getTimeData();
|
||||||
mTimeAdapter = new WaterPlanTimeDataAdapter(mContext,R.layout.include_plan_time_item_layout,timeList);
|
mTimeAdapter = new WaterPlanTimeDataAdapter(mContext,R.layout.include_plan_time_item_layout,timeList);
|
||||||
viewBinding.rvTimes.setAdapter(mTimeAdapter);
|
viewBinding.rvTimes.setAdapter(mTimeAdapter);
|
||||||
initListener();
|
initListener();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
// 创建菜单:
|
||||||
|
SwipeMenuCreator mSwipeMenuCreator = new SwipeMenuCreator() {
|
||||||
|
@Override
|
||||||
|
public void onCreateMenu(SwipeMenu leftMenu, SwipeMenu rightMenu, int position) {
|
||||||
|
SwipeMenuItem deleteItem = new SwipeMenuItem(mContext);
|
||||||
|
deleteItem.setBackground(mContext.getResources().getDrawable(R.drawable.shape_item_delete_bg));
|
||||||
|
deleteItem.setText("删除");
|
||||||
|
deleteItem.setTextColor(mContext.getResources().getColor(R.color.white));
|
||||||
|
// 各种文字和图标属性设置。
|
||||||
|
rightMenu.addMenuItem(deleteItem); // 在Item右侧添加一个菜单。
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// 菜单点击监听。
|
||||||
|
OnItemMenuClickListener mItemMenuClickListener = new OnItemMenuClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onItemClick(SwipeMenuBridge menuBridge, int position) {
|
||||||
|
// 任何操作必须先关闭菜单,否则可能出现Item菜单打开状态错乱。
|
||||||
|
menuBridge.closeMenu();
|
||||||
|
// 左侧还是右侧菜单:
|
||||||
|
int direction = menuBridge.getDirection();
|
||||||
|
// 菜单在Item中的Position:
|
||||||
|
int menuPosition = menuBridge.getPosition();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
private void initListener() {
|
private void initListener() {
|
||||||
setClick(viewBinding.tvCommit);
|
setClick(viewBinding.tvCommit);
|
||||||
|
setClick(viewBinding.imgAdd);
|
||||||
// viewBinding.etPlanTime.addTextChangedListener(new TextWatcher() {
|
// viewBinding.etPlanTime.addTextChangedListener(new TextWatcher() {
|
||||||
// @Override
|
// @Override
|
||||||
// public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
// public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||||
@@ -90,6 +130,8 @@ public class WaterConfigFragment_copy extends BaseFragment<WaterConfigFragmentLa
|
|||||||
@Override
|
@Override
|
||||||
public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
|
public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
|
||||||
mWeekAdapter.setSelPos(position);
|
mWeekAdapter.setSelPos(position);
|
||||||
|
List<WaterPlanWeekEntity.TimeDataBean> timeList = weekList.get(position).getTimeData();
|
||||||
|
mTimeAdapter.setNewData(timeList);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -100,6 +142,13 @@ public class WaterConfigFragment_copy extends BaseFragment<WaterConfigFragmentLa
|
|||||||
|
|
||||||
public void onClick(View v){
|
public void onClick(View v){
|
||||||
switch (v.getId()){
|
switch (v.getId()){
|
||||||
|
|
||||||
|
case R.id.img_add:
|
||||||
|
int selPos = mWeekAdapter.getmPos();
|
||||||
|
WaterPlanWeekEntity.TimeDataBean timeData = new WaterPlanWeekEntity.TimeDataBean();
|
||||||
|
weekList.get(selPos).getTimeData().add(timeData);
|
||||||
|
mTimeAdapter.notifyItemInserted(weekList.get(selPos).getTimeData().size() - 1);
|
||||||
|
break;
|
||||||
case R.id.tv_select_time:
|
case R.id.tv_select_time:
|
||||||
boolean times[] = {false, false, false, true, true, false};
|
boolean times[] = {false, false, false, true, true, false};
|
||||||
//时间选择器
|
//时间选择器
|
||||||
|
|||||||
@@ -1,8 +1,13 @@
|
|||||||
package com.ckkj.water.plan.adapter;
|
package com.ckkj.water.plan.adapter;
|
||||||
|
|
||||||
|
import static android.view.View.INVISIBLE;
|
||||||
|
import static android.view.View.VISIBLE;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
import android.view.View;
|
||||||
import android.widget.CheckBox;
|
import android.widget.CheckBox;
|
||||||
|
import android.widget.LinearLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
@@ -35,45 +40,49 @@ public class WaterPlanWeekAdapter_copy extends BaseQuickAdapter<WaterPlanWeekEnt
|
|||||||
|
|
||||||
helper.setText(R.id.tv_week_name,item.getWeekName());
|
helper.setText(R.id.tv_week_name,item.getWeekName());
|
||||||
|
|
||||||
if(!TextUtils.isEmpty(item.getStartTime())){
|
LinearLayout linearItem = helper.getView(R.id.linear_item);
|
||||||
helper.setText(R.id.tv_select_time, item.getStartTime());
|
View viewStatus = helper.getView(R.id.view_status);
|
||||||
|
if(helper.getLayoutPosition() == mPos){
|
||||||
|
linearItem.setBackground(mContext.getResources().getDrawable(R.drawable.shape_water_period_sel_bg));
|
||||||
|
viewStatus.setVisibility(VISIBLE);
|
||||||
|
viewStatus.setBackground(mContext.getResources().getDrawable(R.drawable.shape_green_circle));
|
||||||
}else{
|
}else{
|
||||||
helper.setText(R.id.tv_select_time,"");
|
linearItem.setBackground(null);
|
||||||
tvStartTime.setHint(mContext.getString(R.string.select_water_time));
|
viewStatus.setVisibility(INVISIBLE);
|
||||||
}
|
|
||||||
if(item.getDurationMin() != 0){
|
|
||||||
helper.setText(R.id.tv_plan_duration,item.getDurationMin() + "");
|
|
||||||
}else{
|
|
||||||
helper.setText(R.id.tv_plan_duration,"");
|
|
||||||
tvPlanDuration.setHint(mContext.getString(R.string.input_water_plan_time));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(item.getStatus().equals("1")){
|
|
||||||
checkBox.setChecked(true);
|
|
||||||
}else{
|
|
||||||
checkBox.setChecked(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
helper.addOnClickListener(R.id.linear_week);
|
// if(!TextUtils.isEmpty(item.getStartTime())){
|
||||||
helper.addOnClickListener(R.id.checkbox);
|
// helper.setText(R.id.tv_select_time, item.getStartTime());
|
||||||
helper.addOnClickListener(R.id.tv_select_time);
|
|
||||||
helper.addOnClickListener(R.id.tv_plan_duration);
|
|
||||||
|
|
||||||
// LinearLayout linearItem = helper.getView(R.id.linear_item);
|
|
||||||
// View viewStatus = helper.getView(R.id.view_status);
|
|
||||||
// if(helper.getLayoutPosition() == mPos){
|
|
||||||
// linearItem.setBackground(mContext.getResources().getDrawable(R.drawable.shape_water_period_sel_bg));
|
|
||||||
// viewStatus.setVisibility(VISIBLE);
|
|
||||||
// viewStatus.setBackground(mContext.getResources().getDrawable(R.drawable.shape_green_circle));
|
|
||||||
// }else{
|
// }else{
|
||||||
// linearItem.setBackground(null);
|
// helper.setText(R.id.tv_select_time,"");
|
||||||
|
// tvStartTime.setHint(mContext.getString(R.string.select_water_time));
|
||||||
|
// }
|
||||||
|
// if(item.getDurationMin() != 0){
|
||||||
|
// helper.setText(R.id.tv_plan_duration,item.getDurationMin() + "");
|
||||||
|
// }else{
|
||||||
|
// helper.setText(R.id.tv_plan_duration,"");
|
||||||
|
// tvPlanDuration.setHint(mContext.getString(R.string.input_water_plan_time));
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// if(item.getStatus().equals("1")){
|
||||||
|
// checkBox.setChecked(true);
|
||||||
|
// }else{
|
||||||
|
// checkBox.setChecked(false);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// helper.addOnClickListener(R.id.linear_week);
|
||||||
|
// helper.addOnClickListener(R.id.checkbox);
|
||||||
|
// helper.addOnClickListener(R.id.tv_select_time);
|
||||||
|
// helper.addOnClickListener(R.id.tv_plan_duration);
|
||||||
|
|
||||||
|
|
||||||
// if(!TextUtils.isEmpty(item.getTime()) && !TextUtils.isEmpty(item.getDuration())){
|
// if(!TextUtils.isEmpty(item.getTime()) && !TextUtils.isEmpty(item.getDuration())){
|
||||||
// viewStatus.setVisibility(VISIBLE);
|
// viewStatus.setVisibility(VISIBLE);
|
||||||
// viewStatus.setBackground(mContext.getResources().getDrawable(R.drawable.shape_yellow_circle));
|
// viewStatus.setBackground(mContext.getResources().getDrawable(R.drawable.shape_yellow_circle));
|
||||||
// }else{
|
// }else{
|
||||||
// viewStatus.setVisibility(INVISIBLE);
|
// viewStatus.setVisibility(INVISIBLE);
|
||||||
// viewStatus.setBackground(null);
|
// viewStatus.setBackground(null);
|
||||||
// }
|
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
5
app/src/main/res/drawable/shape_item_delete_bg.xml
Normal file
5
app/src/main/res/drawable/shape_item_delete_bg.xml
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<solid android:color="@color/color_e34d59"/>
|
||||||
|
<corners android:radius="8dp"/>
|
||||||
|
</shape>
|
||||||
@@ -74,19 +74,16 @@
|
|||||||
android:text="@string/plan_time"
|
android:text="@string/plan_time"
|
||||||
android:layout_marginVertical="@dimen/dp_13"/>
|
android:layout_marginVertical="@dimen/dp_13"/>
|
||||||
|
|
||||||
<EditText
|
<TextView
|
||||||
android:id="@+id/et_plan_time"
|
android:id="@+id/tv_plan_duration"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_weight="9"
|
android:layout_weight="9"
|
||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical"
|
||||||
android:textSize="14sp"
|
android:textSize="14sp"
|
||||||
android:textColor="@color/color_222222"
|
android:textColor="@color/color_222222"
|
||||||
android:background="@null"
|
|
||||||
android:layout_marginLeft="@dimen/dp_10"
|
android:layout_marginLeft="@dimen/dp_10"
|
||||||
android:hint="@string/input_water_plan_time"
|
android:hint="@string/input_water_plan_time"/>
|
||||||
android:imeOptions="actionDone"
|
|
||||||
android:inputType="number"/>
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/tv_time_unit"
|
android:id="@+id/tv_time_unit"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
android:gravity="center_horizontal"
|
android:gravity="center_horizontal"
|
||||||
android:background="@drawable/shape_water_period_sel_bg">
|
android:background="@drawable/shape_water_period_sel_bg">
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/tv_week"
|
android:id="@+id/tv_week_name"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:textSize="12sp"
|
android:textSize="12sp"
|
||||||
|
|||||||
@@ -123,6 +123,7 @@
|
|||||||
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"/>
|
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"/>
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
|
android:id="@+id/img_add"
|
||||||
android:layout_width="@dimen/dp_45"
|
android:layout_width="@dimen/dp_45"
|
||||||
android:layout_height="@dimen/dp_45"
|
android:layout_height="@dimen/dp_45"
|
||||||
android:src="@mipmap/icon_add_time"
|
android:src="@mipmap/icon_add_time"
|
||||||
|
|||||||
@@ -29,6 +29,7 @@
|
|||||||
<color name="color_e4fbfa">#E4FBFA</color>
|
<color name="color_e4fbfa">#E4FBFA</color>
|
||||||
<color name="color_d9d9d9">#D9D9D9</color>
|
<color name="color_d9d9d9">#D9D9D9</color>
|
||||||
<color name="color_dcdfe6">#DCDFE6</color>
|
<color name="color_dcdfe6">#DCDFE6</color>
|
||||||
|
<color name="color_e34d59">#E34D59</color>
|
||||||
|
|
||||||
|
|
||||||
<color name="text_hint">#707070</color>
|
<color name="text_hint">#707070</color>
|
||||||
|
|||||||
Reference in New Issue
Block a user