Commit 298d6949 by jason

菜品组列表

parent d58cbe4d
package com.gingersoft.supply_chain.mvp.bean;
import lombok.Data;
@Data
public class DishesBean implements Comparable<DishesBean> {
private int id;
private int parentId;
private int restaurantId;
private boolean isParent;
private int seqNo;
private String foodName;
@Override
public int compareTo(DishesBean dishesBean) {
return this.id - dishesBean.id;
}
// private boolean autoMod;
// private int lunchboxPrice;
// private boolean serviceCharge;
// private int invisible;
// private int riceponInvisible;
// private int cost;
// private String startDate;
// private String endDate;
// private int totalSold;
// private int isSold;
// private String createBy;
// private String createTime;
// private String updateBy;
// private String updateTime;
// private int periodId;
// private String posFId;
// private int ablediscount;
// private int takeaway;
// private int limitAmount;
// private int limitType;
// private String foodSummary;
// private String foodName1;
// private String foodName2;
// private int printTo;
// private int printToBill;
// private int conditions;
// private int isRt;
// private int deletes;
// private String periodName1;
// private String startDateStr;
// private String endDateStr;
// private double price;
// private int marketPrice;
// private int blueEdit;
// private int cartEdit;
// private int autoMerge;
// private String foodDesc;
// private String imageUrl;
// private int colorId;
// private int deptId;
// private int approve;
// private int printFont;
// private int advPrice;
// private int pointsAdd;
// private int pointsRatio;
// private int pointsRedeem;
// private int ktPrintMainItem;
// private int ktShowPrice;
// private int toPax;
// private int foodType;
// private int majorMainId;
// private int isTimingFood;
// private int minLongTime;
// private int unitTime;
// private int unitPrice;
// private int freeLongTime;
// private String fId;
// private String plu;
// private String printseting;
// private int isPrintQueueCode;
// private int queueHeadId;
// private String imgUrlSmall;
// private String freePeriodBegin;
// private int agreementType;
}
package com.gingersoft.supply_chain.mvp.bean; package com.gingersoft.supply_chain.mvp.bean;
import com.gingersoft.supply_chain.mvp.ui.adapter.dishes.DishesGroupNode;
import java.util.List; import java.util.List;
import lombok.Data; import lombok.Data;
...@@ -10,11 +12,7 @@ public class DishesResultBean { ...@@ -10,11 +12,7 @@ public class DishesResultBean {
private boolean success; private boolean success;
private long sysTime; private long sysTime;
private String errMsg; private String errMsg;
private DataBean data; private List<DishesGroupNode> data;
@Data
public static class DataBean {
private int count;
private List<DishesBean> list;
}
} }
...@@ -2,22 +2,17 @@ package com.gingersoft.supply_chain.mvp.presenter; ...@@ -2,22 +2,17 @@ package com.gingersoft.supply_chain.mvp.presenter;
import android.app.Application; import android.app.Application;
import com.chad.library.adapter.base.entity.node.BaseNode;
import com.gingersoft.gsa.cloud.common.constans.AppConstant; import com.gingersoft.gsa.cloud.common.constans.AppConstant;
import com.gingersoft.gsa.cloud.common.utils.other.TextUtil; import com.gingersoft.gsa.cloud.common.utils.other.TextUtil;
import com.gingersoft.supply_chain.mvp.bean.DishesBean;
import com.gingersoft.supply_chain.mvp.bean.DishesResultBean; import com.gingersoft.supply_chain.mvp.bean.DishesResultBean;
import com.gingersoft.supply_chain.mvp.contract.DishesContract; import com.gingersoft.supply_chain.mvp.contract.DishesContract;
import com.gingersoft.supply_chain.mvp.ui.adapter.dishes.DishNode;
import com.gingersoft.supply_chain.mvp.ui.adapter.dishes.DishesGroupNode; import com.gingersoft.supply_chain.mvp.ui.adapter.dishes.DishesGroupNode;
import com.jess.arms.di.scope.FragmentScope; import com.jess.arms.di.scope.FragmentScope;
import com.jess.arms.http.imageloader.ImageLoader; import com.jess.arms.http.imageloader.ImageLoader;
import com.jess.arms.integration.AppManager; import com.jess.arms.integration.AppManager;
import com.jess.arms.mvp.BasePresenter; import com.jess.arms.mvp.BasePresenter;
import com.jess.arms.utils.LogUtils;
import com.jess.arms.utils.RxLifecycleUtils; import com.jess.arms.utils.RxLifecycleUtils;
import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -63,7 +58,6 @@ public class DishesPresenter extends BasePresenter<DishesContract.Model, DishesC ...@@ -63,7 +58,6 @@ public class DishesPresenter extends BasePresenter<DishesContract.Model, DishesC
public void getDishesData() { public void getDishesData() {
Map<String, Object> map = new HashMap<>(2); Map<String, Object> map = new HashMap<>(2);
// map.put("","0");
AppConstant.addBrandId(map); AppConstant.addBrandId(map);
AppConstant.addRestaurantId(map); AppConstant.addRestaurantId(map);
mModel.getDishesData(map)//發送請求 mModel.getDishesData(map)//發送請求
...@@ -78,62 +72,8 @@ public class DishesPresenter extends BasePresenter<DishesContract.Model, DishesC ...@@ -78,62 +72,8 @@ public class DishesPresenter extends BasePresenter<DishesContract.Model, DishesC
@Override @Override
public void onNext(DishesResultBean orderCategoryBean) {//數據處理 public void onNext(DishesResultBean orderCategoryBean) {//數據處理
if (orderCategoryBean.isSuccess()) { if (orderCategoryBean.isSuccess()) {
DishesResultBean.DataBean data = orderCategoryBean.getData(); List<DishesGroupNode> data = orderCategoryBean.getData();
if (data != null) { mRootView.loadDishGroupInfo(data);
//將分類食品的list容量設置為一級分類的數量,這樣就不用擔心之後加載不同position的分類數據時,計算位置了
LogUtils.warnInfo(" zjs ="+data.getCount());
List<BaseNode> myData=new ArrayList<>();
List<DishesBean> list= data.getList();
List<DishesBean> plist= new ArrayList<>();
List<DishesBean> clist= new ArrayList<>();
List<DishesGroupNode> pNodes= new ArrayList<>();
List<DishNode> cNodes= new ArrayList<>();
// Collections.sort(list);
long start=System.currentTimeMillis();
LogUtils.warnInfo(" zjs ="+list.size() +" start"+start);
for (int i = 0; i < list.size(); i++) {
DishesBean dishesBean =list.get(i);
if (dishesBean.isParent()) {
clist.add(dishesBean); //子菜单
// DishNode cNode=new DishNode(dishesBean);
// cNodes.add(cNode);
}else {
plist.add(dishesBean);//父菜单
DishesGroupNode groupNode=new DishesGroupNode(dishesBean);
pNodes.add(groupNode);
myData.add(groupNode);
}
LogUtils.warnInfo(" zjs =" + list.get(i).toString());
}
int len=clist.size();
for (int i = 0; i < pNodes.size(); i++) {
DishesGroupNode groupNode= pNodes.get(i);
List<DishNode> subNode= new ArrayList<>();
// List<BaseNode> bNodeList= new ArrayList<>();
for (int j = 0; j < len; j++) {
DishesBean dishesBean =clist.get(i);
if (groupNode.getId() == dishesBean.getParentId()) {
DishNode cNode=new DishNode(dishesBean);
subNode.add(cNode);
groupNode.addChildNode(cNode);
LogUtils.warnInfo(" zjs"," groupNode 组"+groupNode.getFoodName() +" 彩民"+cNode.getFoodName());
}
}
LogUtils.warnInfo(" zjs"," groupNode "+groupNode.getFoodName() +" 数量"+subNode.size());
groupNode.setDishNodes(subNode);
}
mRootView.loadDishGroupInfo(pNodes);
LogUtils.warnInfo(" zjs end="+(System.currentTimeMillis()-start));
}
//第一次加載初始化數量
// initCategoryGoodsSize(data);
// mRootView.initCategoryInfo(data);
} else if (TextUtil.isNotEmptyOrNullOrUndefined(orderCategoryBean.getErrMsg())) { } else if (TextUtil.isNotEmptyOrNullOrUndefined(orderCategoryBean.getErrMsg())) {
mRootView.showMessage(orderCategoryBean.getErrMsg()); mRootView.showMessage(orderCategoryBean.getErrMsg());
} else { } else {
......
...@@ -4,7 +4,6 @@ import androidx.annotation.Nullable; ...@@ -4,7 +4,6 @@ import androidx.annotation.Nullable;
import com.chad.library.adapter.base.entity.node.BaseExpandNode; import com.chad.library.adapter.base.entity.node.BaseExpandNode;
import com.chad.library.adapter.base.entity.node.BaseNode; import com.chad.library.adapter.base.entity.node.BaseNode;
import com.gingersoft.supply_chain.mvp.bean.DishesBean;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
...@@ -19,14 +18,6 @@ public class DishNode extends BaseExpandNode { ...@@ -19,14 +18,6 @@ public class DishNode extends BaseExpandNode {
private List<BaseNode> childNode; private List<BaseNode> childNode;
public DishNode(DishesBean dishesBean) {
this.id = dishesBean.getId();
this.parentId = dishesBean.getParentId();
this.restaurantId = dishesBean.getRestaurantId();
this.isParent = dishesBean.isParent();
this.seqNo = dishesBean.getSeqNo();
this.foodName = dishesBean.getFoodName();
}
public void addChildNode(BaseNode baseNode) { public void addChildNode(BaseNode baseNode) {
if (baseNode == null) { if (baseNode == null) {
return; return;
......
...@@ -23,13 +23,14 @@ public class DishProvider extends BaseNodeProvider { ...@@ -23,13 +23,14 @@ public class DishProvider extends BaseNodeProvider {
@Override @Override
public void convert(@NotNull BaseViewHolder helper, @NotNull BaseNode data) { public void convert(@NotNull BaseViewHolder helper, @NotNull BaseNode data) {
DishNode entity = (DishNode) data; DishNode entity = (DishNode) data;
helper.setText(R.id.tv_dish_title, entity.getTitle()); helper.setText(R.id.tv_dish_title, entity.getFoodName());
if (entity.isExpanded()) { // LogUtil.e("zjs"," entity.isExpanded()="+entity.isExpanded());
helper.setImageResource(R.id.iv_dishes_group_icon, R.mipmap.keyboard_delete_img); // if (entity.isExpanded()) {
} else { // helper.setImageResource(R.id.iv_dishes_group_icon, R.drawable.ic_dishes_up);
helper.setImageResource(R.id.iv_dishes_group_icon, R.mipmap.keyboard_back_img); // } else {
} // helper.setImageResource(R.id.iv_dishes_group_icon, R.drawable.ic_dishes_down);
// }
} }
@Override @Override
......
...@@ -2,7 +2,6 @@ package com.gingersoft.supply_chain.mvp.ui.adapter.dishes; ...@@ -2,7 +2,6 @@ package com.gingersoft.supply_chain.mvp.ui.adapter.dishes;
import com.chad.library.adapter.base.entity.node.BaseExpandNode; import com.chad.library.adapter.base.entity.node.BaseExpandNode;
import com.chad.library.adapter.base.entity.node.BaseNode; import com.chad.library.adapter.base.entity.node.BaseNode;
import com.gingersoft.supply_chain.mvp.bean.DishesBean;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
...@@ -17,18 +16,9 @@ public class DishesGroupNode extends BaseExpandNode{ ...@@ -17,18 +16,9 @@ public class DishesGroupNode extends BaseExpandNode{
private int seqNo; private int seqNo;
private String foodName; private String foodName;
private List<DishNode> dishNodes; private List<DishNode> child;
private List<BaseNode> childNode; private List<BaseNode> childNode;
public DishesGroupNode(DishesBean dishesBean) {
this.id = dishesBean.getId();
this.parentId = dishesBean.getParentId();
this.restaurantId = dishesBean.getRestaurantId();
this.isParent = dishesBean.isParent();
this.seqNo = dishesBean.getSeqNo();
this.foodName = dishesBean.getFoodName();
}
public DishesGroupNode(int id, int parentId, int restaurantId, boolean isParent, int seqNo, String foodName) { public DishesGroupNode(int id, int parentId, int restaurantId, boolean isParent, int seqNo, String foodName) {
this.id = id; this.id = id;
this.parentId = parentId; this.parentId = parentId;
...@@ -40,11 +30,11 @@ public class DishesGroupNode extends BaseExpandNode{ ...@@ -40,11 +30,11 @@ public class DishesGroupNode extends BaseExpandNode{
public List<DishNode> getDishNodes() { public List<DishNode> getDishNodes() {
return dishNodes; return child;
} }
public void setDishNodes(List<DishNode> dishNodes) { public void setDishNodes(List<DishNode> dishNodes) {
this.dishNodes = dishNodes; this.child = dishNodes;
} }
public int getId() { public int getId() {
...@@ -133,6 +123,12 @@ public class DishesGroupNode extends BaseExpandNode{ ...@@ -133,6 +123,12 @@ public class DishesGroupNode extends BaseExpandNode{
@Nullable @Nullable
@Override @Override
public List<BaseNode> getChildNode() { public List<BaseNode> getChildNode() {
if (childNode == null) {
childNode=new ArrayList<>();
}
if ( child != null) {
childNode.addAll(child);
}
return childNode; return childNode;
} }
......
package com.gingersoft.supply_chain.mvp.ui.adapter.dishes; package com.gingersoft.supply_chain.mvp.ui.adapter.dishes;
import android.graphics.Typeface;
import android.view.View; import android.view.View;
import android.view.animation.DecelerateInterpolator; import android.view.animation.DecelerateInterpolator;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.TextView;
import androidx.core.view.ViewCompat; import androidx.core.view.ViewCompat;
import com.chad.library.adapter.base.entity.node.BaseNode; import com.chad.library.adapter.base.entity.node.BaseNode;
import com.chad.library.adapter.base.provider.BaseNodeProvider; import com.chad.library.adapter.base.provider.BaseNodeProvider;
import com.chad.library.adapter.base.viewholder.BaseViewHolder; import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.gingersoft.gsa.cloud.common.utils.CollectionUtils;
import com.gingersoft.supply_chain.R; import com.gingersoft.supply_chain.R;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
...@@ -29,8 +32,8 @@ public class DishesGroupProvider extends BaseNodeProvider { ...@@ -29,8 +32,8 @@ public class DishesGroupProvider extends BaseNodeProvider {
@Override @Override
public void convert(@NotNull BaseViewHolder baseViewHolder, BaseNode baseNode) { public void convert(@NotNull BaseViewHolder baseViewHolder, BaseNode baseNode) {
DishesGroupNode entity = (DishesGroupNode) baseNode; DishesGroupNode entity = (DishesGroupNode) baseNode;
baseViewHolder.setText(R.id.tv_dishes_group_title, entity.getTitle()); baseViewHolder.setText(R.id.tv_dishes_group_title, entity.getFoodName());
baseViewHolder.setImageResource(R.id.iv_dishes_group_icon, R.mipmap.ic_launcher); baseViewHolder.setImageResource(R.id.iv_dishes_group_icon, R.drawable.ic_dishes_down);
setArrowSpin(baseViewHolder, baseNode, false); setArrowSpin(baseViewHolder, baseNode, false);
...@@ -51,26 +54,35 @@ public class DishesGroupProvider extends BaseNodeProvider { ...@@ -51,26 +54,35 @@ public class DishesGroupProvider extends BaseNodeProvider {
DishesGroupNode entity = (DishesGroupNode) data; DishesGroupNode entity = (DishesGroupNode) data;
ImageView imageView = helper.getView(R.id.iv_dishes_group_icon); ImageView imageView = helper.getView(R.id.iv_dishes_group_icon);
TextView title = helper.getView(R.id.tv_dishes_group_title);
if (entity.isExpanded()) { List<DishNode> child= entity.getDishNodes();
if (isAnimate) { if (CollectionUtils.isNotNullOrEmpty(child)) {
ViewCompat.animate(imageView).setDuration(200) imageView.setVisibility(View.VISIBLE);
.setInterpolator(new DecelerateInterpolator()) if (entity.isExpanded()) {
.rotation(0f) title.setTypeface(Typeface.SANS_SERIF, Typeface.BOLD);
.start(); if (isAnimate) {
} else { ViewCompat.animate(imageView).setDuration(200)
imageView.setRotation(0f); .setInterpolator(new DecelerateInterpolator())
} .rotation(180f)
} else { .start();
if (isAnimate) { } else {
ViewCompat.animate(imageView).setDuration(200) imageView.setRotation(180f);
.setInterpolator(new DecelerateInterpolator()) }
.rotation(90f)
.start();
} else { } else {
imageView.setRotation(90f); title.setTypeface(Typeface.SANS_SERIF, Typeface.NORMAL);
if (isAnimate) {
ViewCompat.animate(imageView).setDuration(200)
.setInterpolator(new DecelerateInterpolator())
.rotation(0f)
.start();
} else {
imageView.setRotation(0f);
}
} }
}else {
imageView.setVisibility(View.INVISIBLE);
} }
} }
@Override @Override
......
...@@ -76,8 +76,8 @@ public class DishesFragment extends BaseSupplyChainFragment<DishesPresenter> imp ...@@ -76,8 +76,8 @@ public class DishesFragment extends BaseSupplyChainFragment<DishesPresenter> imp
private void initDishes( List<DishesGroupNode> dishesGroupNodes){ private void initDishes( List<DishesGroupNode> dishesGroupNodes){
DishesTreeAdapter dishesTreeAdapter = new DishesTreeAdapter(); DishesTreeAdapter dishesTreeAdapter = new DishesTreeAdapter();
dishesTreeAdapter.setList(dishesGroupNodes); dishesTreeAdapter.setList(dishesGroupNodes);
rvDishes.setLayoutManager(new CenterLayoutManager(requireContext(), LinearLayoutManager.HORIZONTAL, false)); rvDishesGroup.setLayoutManager(new LinearLayoutManager(requireContext(), LinearLayoutManager.VERTICAL, false));
rvDishes.setAdapter(dishesTreeAdapter); rvDishesGroup.setAdapter(dishesTreeAdapter);
} }
private List<BaseNode> getEntity() { private List<BaseNode> getEntity() {
......
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
<com.scwang.smartrefresh.layout.SmartRefreshLayout <com.scwang.smartrefresh.layout.SmartRefreshLayout
android:id="@+id/refreshLayout" android:id="@+id/refreshLayout"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_weight="4" android:layout_weight="2"
android:layout_height="match_parent"> android:layout_height="match_parent">
<com.scwang.smartrefresh.layout.header.ClassicsHeader <com.scwang.smartrefresh.layout.header.ClassicsHeader
......
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:animateLayoutChanges="true" android:background="@color/dishes_group_bg"
android:background="@color/supply_chain_bg_color" android:orientation="horizontal">
android:orientation="vertical">
<TextView <TextView
android:id="@+id/tv_dishes_group_title" android:id="@+id/tv_dishes_group_title"
android:paddingLeft="@dimen/dp_10"
android:paddingTop="@dimen/dp_6"
android:paddingBottom="@dimen/dp_6"
android:paddingRight="@dimen/dp_10"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:text="菜品明"
android:textColor="@color/white"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content"/> android:layout_height="wrap_content"/>
<ImageView <ImageView
android:id="@+id/iv_dishes_group_icon" android:id="@+id/iv_dishes_group_icon"
android:layout_width="wrap_content" android:layout_height="@dimen/dp_18"
android:visibility="gone" android:layout_width="@dimen/dp_18"
android:layout_height="wrap_content"/> android:layout_marginRight="@dimen/dp_6"
app:layout_constraintTop_toTopOf="@+id/tv_dishes_group_title"
app:layout_constraintBottom_toBottomOf="@+id/tv_dishes_group_title"
app:layout_constraintRight_toRightOf="parent"
android:layout_gravity="center_vertical"
android:src="@drawable/ic_dishes_down"
/>
</LinearLayout> </androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file \ No newline at end of file
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:animateLayoutChanges="true" android:animateLayoutChanges="true"
android:background="@color/supply_chain_bg_color" android:background="@color/supply_chain_bg_color"
...@@ -10,7 +10,9 @@ ...@@ -10,7 +10,9 @@
<TextView <TextView
android:id="@+id/tv_dish_title" android:id="@+id/tv_dish_title"
android:layout_width="match_parent" android:layout_marginLeft="@dimen/dp_16"
android:padding="@dimen/dp_4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/> android:layout_height="wrap_content"/>
</LinearLayout> </LinearLayout>
\ No newline at end of file
...@@ -6,4 +6,5 @@ ...@@ -6,4 +6,5 @@
<color name="order_category_name_unselect_color">@color/color_3c</color> <color name="order_category_name_unselect_color">@color/color_3c</color>
<color name="order_category_name_select_color">@color/theme_color</color> <color name="order_category_name_select_color">@color/theme_color</color>
<color name="click_upload_text_color">#1196DB</color> <color name="click_upload_text_color">#1196DB</color>
<color name="dishes_group_bg">#00B7F8</color>
</resources> </resources>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment