diff --git a/app/src/main/java/com/bonait/bnframework/business/ConfigData.java b/app/src/main/java/com/bonait/bnframework/business/ConfigData.java index 755c079b..f16b0145 100644 --- a/app/src/main/java/com/bonait/bnframework/business/ConfigData.java +++ b/app/src/main/java/com/bonait/bnframework/business/ConfigData.java @@ -626,6 +626,8 @@ public class ConfigData { { good.gyid =allDataResAPI.data.bomInfo.get(0).id; } + + good.userID=cloudGood.goods_TypeID==null?"":cloudGood.goods_TypeID; QueryDB.AddGoods(good); //2.增加配方 // if (allDataResAPI.data.bomTechnologyActionInfo != null && allDataResAPI.data.bomTechnologyActionInfo.size() > 0) { @@ -881,6 +883,8 @@ public class ConfigData { id = java.util.UUID.randomUUID().toString(); QueryDB.UpdateGoodsGY(good.id, id); } + QueryDB.UpdateGoodsTypeId(good.id,xl); + UpdateBomInfo bom = new UpdateBomInfo(); bom.id = id; bom.bomType = fl; diff --git a/app/src/main/java/com/bonait/bnframework/common/db/QueryDB.java b/app/src/main/java/com/bonait/bnframework/common/db/QueryDB.java index 8d3dd974..edcf2cc0 100644 --- a/app/src/main/java/com/bonait/bnframework/common/db/QueryDB.java +++ b/app/src/main/java/com/bonait/bnframework/common/db/QueryDB.java @@ -705,6 +705,20 @@ public class QueryDB { } } + /** + * 修改商品小类信息 + * + * @param id + * @param xlid + */ + public static void UpdateGoodsTypeId(String id, String xlid) { + BPA_GOODS goods = GetGoodsId(id); + if (goods != null) { + goods.userID = xlid; + Update(BPA_GOODS.class, goods); + } + } + /** * 修改烹饪时长 * diff --git a/app/src/main/java/com/bonait/bnframework/common/linktab/LinkMode.java b/app/src/main/java/com/bonait/bnframework/common/linktab/LinkMode.java new file mode 100644 index 00000000..d3e119db --- /dev/null +++ b/app/src/main/java/com/bonait/bnframework/common/linktab/LinkMode.java @@ -0,0 +1,18 @@ +package com.bonait.bnframework.common.linktab; + +import java.util.List; + +public class LinkMode { + public Object type; + + public List content; + + public Boolean isChoose; + + public LinkMode(Object _type,List _content,Boolean _isChoose) + { + type=_type; + content=_content; + isChoose=_isChoose; + } +} diff --git a/app/src/main/java/com/bonait/bnframework/common/linktab/TopItemDecoration.java b/app/src/main/java/com/bonait/bnframework/common/linktab/TopItemDecoration.java new file mode 100644 index 00000000..e56b70bc --- /dev/null +++ b/app/src/main/java/com/bonait/bnframework/common/linktab/TopItemDecoration.java @@ -0,0 +1,107 @@ +package com.bonait.bnframework.common.linktab; + +import static java.lang.Math.min; + +import android.content.Context; +import android.graphics.Canvas; +import android.graphics.Paint; +import android.graphics.Rect; +import android.util.Log; +import android.view.View; + +import androidx.annotation.NonNull; +import androidx.core.content.ContextCompat; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; + +import com.bonait.bnframework.R; + +import java.util.ArrayList; +import java.util.List; + +public class TopItemDecoration extends RecyclerView.ItemDecoration{ + + public Context mContext; + //间隔高度 + private int mHeight = 50; + //矩形画笔 + private Paint mPaint=new Paint(); + //标签画笔 + private Paint textPaint=new Paint(Paint.ANTI_ALIAS_FLAG); + + private Rect mRound =new Rect(); + + public List typeListener=new ArrayList<>(); + public TopItemDecoration(Context _context,List type) + { + mContext=_context; + mPaint.setColor(ContextCompat.getColor(mContext, R.color.transparent)); + textPaint.setColor(ContextCompat.getColor(mContext, R.color.topbj1)); + textPaint.setTextSize(25f); + typeListener=type; + } + + @Override + public void onDraw(@NonNull Canvas c, @NonNull RecyclerView parent, @NonNull RecyclerView.State state) { + super.onDraw(c, parent, state); + int left = parent.getPaddingLeft(); + int right =parent.getWidth() - parent.getPaddingLeft(); + int childCount = parent.getChildCount(); + try + { + for(int i=0;i { + public List Fdata; + public Resources resources; + public LinearLayoutManager Manager; + + public MakeGoodLeftAdapter(@LayoutRes int layoutResId, @Nullable List data, Resources _resources, LinearLayoutManager _manager) { + super(layoutResId, data); + resources = _resources; + Fdata = data; + Manager = _manager; + } + + @Override + protected void convert(BaseViewHolder holder, LinkMode item) { + + GoodsTypeInfo type = (GoodsTypeInfo) item.type; + holder.setText(R.id.tv_type, type.goodsType_Name); + int index_d = Fdata.indexOf(item); + if (item.isChoose) { + holder.setBackgroundColor(R.id.tv_linearlayout, resources.getColor(R.color.tab_11)); + holder.setTextColor(R.id.tv_type, resources.getColor(R.color.topbj1)); + holder.setVisible(R.id.tv_image, true); + } else { + holder.setBackgroundColor(R.id.tv_linearlayout, resources.getColor(R.color.transparent)); + holder.setTextColor(R.id.tv_type, resources.getColor(R.color.tab_text_normal)); + holder.setVisible(R.id.tv_image, false); + } + + //选中行 + holder.getView(R.id.tv_type_layout).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + setChoose(index_d); + Manager.scrollToPositionWithOffset(index_d, 0); + } + }); + } + + /** + * 设置是否选择 + * + * @param position + */ + public void setChoose(Integer position) { + for (LinkMode it : Fdata) { + it.isChoose = false; + } + + if(position { + + public List Fdata; + public Resources resources; + public MyClickListener mListener = null; + public Context context; + + public MakeGoodRightAdapter(@LayoutRes int layoutResId, @Nullable List data, Resources _resources, MyClickListener _mListener,Context c) { + super(layoutResId, data); + resources=_resources; + Fdata=data; + mListener=_mListener; + context=c; + } + + @Override + protected void convert(BaseViewHolder holder, LinkMode item) { + RecyclerView view= holder.getView(R.id.recycler_view); + MyLayoutManager layout = new MyLayoutManager(); + layout.setAutoMeasureEnabled(true); + view.setLayoutManager(layout); + good_adapter adapter = new good_adapter(context, item.content,mListener); + view.setAdapter(adapter); + } +} \ No newline at end of file diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/adapter/good_adapter.java b/app/src/main/java/com/bonait/bnframework/modules/home/adapter/good_adapter.java index 3f921c2b..2532332e 100644 --- a/app/src/main/java/com/bonait/bnframework/modules/home/adapter/good_adapter.java +++ b/app/src/main/java/com/bonait/bnframework/modules/home/adapter/good_adapter.java @@ -40,14 +40,14 @@ public class good_adapter extends RecyclerView.Adapter private Context context; - ArrayList liaos = new ArrayList<>(); + List liaos = new ArrayList<>(); /** * 点击事件 */ public MyClickListener mListener = null; - public good_adapter(Context context, ArrayList data, MyClickListener _mListener) { + public good_adapter(Context context, List data, MyClickListener _mListener) { this.context = context; mLayoutInflater = LayoutInflater.from(context); liaos = data; diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/HomeFragmentPR.java b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/HomeFragmentPR.java index 80f7234f..21273a94 100644 --- a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/HomeFragmentPR.java +++ b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/HomeFragmentPR.java @@ -7,6 +7,7 @@ import androidx.annotation.Nullable; import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.widget.SearchView; import androidx.core.content.ContextCompat; +import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.StaggeredGridLayoutManager; @@ -35,9 +36,14 @@ import com.bonait.bnframework.common.db.QueryDB; import com.bonait.bnframework.common.db.mode.BPA_GOODS; import com.bonait.bnframework.common.helper.I.MyClickListener; import com.bonait.bnframework.common.helper.SoftKeyBoardListener; +import com.bonait.bnframework.common.linktab.LinkMode; +import com.bonait.bnframework.common.linktab.TopItemDecoration; +import com.bonait.bnframework.common.linktab.makegood.MakeGoodLeftAdapter; +import com.bonait.bnframework.common.linktab.makegood.MakeGoodRightAdapter; import com.bonait.bnframework.common.message.MessageLooper; import com.bonait.bnframework.common.message.MessageManager; import com.bonait.bnframework.common.model.mode.CloudGood; +import com.bonait.bnframework.common.model.mode.GoodsTypeInfo; import com.bonait.bnframework.common.utils.AlertDialogUtils; import com.bonait.bnframework.common.utils.ToastUtils; import com.bonait.bnframework.modules.home.adapter.good_adapter; @@ -56,7 +62,9 @@ import com.qmuiteam.qmui.widget.dialog.QMUIDialogAction; import com.qmuiteam.qmui.widget.section.QMUISection; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; +import java.util.stream.Collectors; import butterknife.BindView; import butterknife.ButterKnife; @@ -66,8 +74,20 @@ public class HomeFragmentPR extends BaseFragment { @BindView(R.id.topbar) QMUITopBarLayout mTopBar;//顶部标题 - @BindView(R.id.recycler_view) - RecyclerView recycler_view;//商品 +// @BindView(R.id.recycler_view) +// RecyclerView recycler_view;//商品 + + /** + * 左边分类 + */ + @BindView(R.id.rv_left) + RecyclerView rv_left; + + /** + * 右边商品 + */ + @BindView(R.id.rv_right) + RecyclerView rv_right; @BindView(R.id.quanbucaipu) TextView quanbucaipu;//全部菜谱 @@ -197,44 +217,178 @@ public class HomeFragmentPR extends BaseFragment { }); } + /** * 初始化显示数据 */ private void initData() { - StaggeredGridLayoutManager layout = new StaggeredGridLayoutManager - (3, StaggeredGridLayoutManager.VERTICAL); - recycler_view.setLayoutManager(layout); ArrayList good = new ArrayList<>(); + List cloudGoods = new ArrayList<>(); + String name = search_view.getQuery().toString(); if (name.isEmpty()) { good = QueryDB.GetGoodsALL(); + cloudGoods=ConfigName.getInstance().cloudGoods; } else { good = QueryDB.GetGoodsLike(name); + for (CloudGood kk:ConfigName.getInstance().cloudGoods) + { + if(kk.goods_Name.contains(name)) + { + cloudGoods.add(kk); + } + } } - List Bendi_id = new ArrayList<>(); - ArrayList contents_bdcp = new ArrayList<>(); - ArrayList contents_ydcp = new ArrayList<>(); - for (BPA_GOODS item : good) { - if (item.url == null) { - item.url = "未知"; + List typeIds = new ArrayList<>(); + List type = new ArrayList<>(); + if (ConfigName.getInstance().cloudData != null && ConfigName.getInstance().cloudData.goodsTypeInfo != null) { + for (GoodsTypeInfo mm : ConfigName.getInstance().cloudData.goodsTypeInfo) { + type.add(mm); + typeIds.add(mm.id); } - contents_bdcp.add(new SectionItem(item.name, String.valueOf(item.maketime), item.id, item.url, item.issc == 1, false, true)); - Bendi_id.add(item.id); } + GoodsTypeInfo info = new GoodsTypeInfo(); + info.id = "其他"; + info.goodsType_Name = "其他"; + type.add(info); - for (CloudGood item : ConfigName.getInstance().cloudGoods) { - contents_ydcp.add(new SectionItem(item.goods_Name, "180", item.id, item.goods_ImgUrl, false, true, Bendi_id.contains(item.id) ? true : false)); + List Bendi_id = new ArrayList<>(); + List Bdata = new ArrayList<>(); + List Ydata = new ArrayList<>(); + + int i = 0; + for (GoodsTypeInfo itemtype : type) { + ArrayList contents = new ArrayList<>(); + for (BPA_GOODS item : good) { + if (item.userID != null && !item.userID.isEmpty() && item.userID.equals(itemtype.id)) { + if (item.url == null || item.url.isEmpty()) { + item.url = "未知"; + } + contents.add(new SectionItem(item.name, String.valueOf(item.maketime), item.id, item.url, item.issc == 1, false, true)); + Bendi_id.add(item.id); + } else { + if (itemtype.id.equals("其他") && !typeIds.contains(item.userID == null ? item.userID = "" : item.userID)) { + if (item.url == null || item.url.isEmpty()) { + item.url = "未知"; + } + contents.add(new SectionItem(item.name, String.valueOf(item.maketime), item.id, item.url, item.issc == 1, false, true)); + Bendi_id.add(item.id); + } + } + } + if (contents.size() > 0) { + Bdata.add(new LinkMode(itemtype, Arrays.asList(contents.toArray()), i == 0 ? true : false)); + i++; + } } + i = 0; + for (GoodsTypeInfo itemtype : type) { + ArrayList contents = new ArrayList<>(); + for (CloudGood item : cloudGoods) { + if (item.goods_TypeID.equals(itemtype.id)) { + contents.add(new SectionItem(item.goods_Name, "180", item.id, item.goods_ImgUrl, false, true, Bendi_id.contains(item.id) ? true : false)); + } else { + if (itemtype.id.equals("其他") && !typeIds.contains(item.goods_TypeID)) { + contents.add(new SectionItem(item.goods_Name, "180", item.id, item.goods_ImgUrl, false, true, Bendi_id.contains(item.id) ? true : false)); + Bendi_id.add(item.id); + } + } + } + if (contents.size() > 0) { + Ydata.add(new LinkMode(itemtype, Arrays.asList(contents.toArray()), i == 0 ? true : false)); + i++; + } + } + MakeGoodLeftAdapter leftAdapter = null; + MakeGoodRightAdapter rightAdapter = null; + LinearLayoutManager manager = (LinearLayoutManager) rv_right.getLayoutManager(); if (SelectIndex == 1) { - good_adapter adapter = new good_adapter(context, contents_bdcp, myClickListener); - recycler_view.setAdapter(adapter); + leftAdapter = new MakeGoodLeftAdapter(R.layout.item_left_makegood, Bdata, getResources(), manager); + rightAdapter = new MakeGoodRightAdapter(R.layout.item_right_lc, Bdata, getResources(), myClickListener, context); + rv_left.setAdapter(leftAdapter); + rv_right.setAdapter(rightAdapter); + + //添加分组悬浮效果 + List typeListener = new ArrayList<>(); + for (LinkMode item : Bdata) { + typeListener.add(((GoodsTypeInfo) item.type).goodsType_Name); + } + + if (rv_right.getItemDecorationCount() > 0) { + rv_right.removeItemDecorationAt(0); + } + TopItemDecoration top = new TopItemDecoration(context, typeListener); + rv_right.addItemDecoration(top); + } else { - good_adapter adapter = new good_adapter(context, contents_ydcp, myClickListener); - recycler_view.setAdapter(adapter); + leftAdapter = new MakeGoodLeftAdapter(R.layout.item_left_makegood, Ydata, getResources(), manager); + rightAdapter = new MakeGoodRightAdapter(R.layout.item_right_lc, Ydata, getResources(), myClickListener, context); + rv_left.setAdapter(leftAdapter); + rv_right.setAdapter(rightAdapter); + + //添加分组悬浮效果 + List typeListener = new ArrayList<>(); + for (LinkMode item : Ydata) { + typeListener.add(((GoodsTypeInfo) item.type).goodsType_Name); + } + + if (rv_right.getItemDecorationCount() > 0) { + rv_right.removeItemDecorationAt(0); + } + TopItemDecoration top = new TopItemDecoration(context, typeListener); + rv_right.addItemDecoration(top); } + + //左侧联动 + MakeGoodLeftAdapter finalLeftAdapter = leftAdapter; + rv_right.addOnScrollListener(new RecyclerView.OnScrollListener() { + @Override + public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) { + super.onScrolled(recyclerView, dx, dy); + int firstItemPosition = manager.findLastVisibleItemPosition(); + if (firstItemPosition != -1 && dy != 0) { + rv_left.smoothScrollToPosition(firstItemPosition); + finalLeftAdapter.setChoose(firstItemPosition); + } + } + }); +// StaggeredGridLayoutManager layout = new StaggeredGridLayoutManager +// (3, StaggeredGridLayoutManager.VERTICAL); +// recycler_view.setLayoutManager(layout); +// +// ArrayList good = new ArrayList<>(); +// String name = search_view.getQuery().toString(); +// if (name.isEmpty()) { +// good = QueryDB.GetGoodsALL(); +// } else { +// good = QueryDB.GetGoodsLike(name); +// } +// +// List Bendi_id = new ArrayList<>(); +// ArrayList contents_bdcp = new ArrayList<>(); +// ArrayList contents_ydcp = new ArrayList<>(); +// for (BPA_GOODS item : good) { +// if (item.url == null) { +// item.url = "未知"; +// } +// contents_bdcp.add(new SectionItem(item.name, String.valueOf(item.maketime), item.id, item.url, item.issc == 1, false, true)); +// Bendi_id.add(item.id); +// } +// +// for (CloudGood item : ConfigName.getInstance().cloudGoods) { +// contents_ydcp.add(new SectionItem(item.goods_Name, "180", item.id, item.goods_ImgUrl, false, true, Bendi_id.contains(item.id) ? true : false)); +// } +// +// if (SelectIndex == 1) { +// good_adapter adapter = new good_adapter(context, contents_bdcp, myClickListener); +// recycler_view.setAdapter(adapter); +// } else { +// good_adapter adapter = new good_adapter(context, contents_ydcp, myClickListener); +// recycler_view.setAdapter(adapter); +// } } public MyClickListener myClickListener = new MyClickListener() { diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/newhuoli_control.java b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/newhuoli_control.java index ce3886a8..8f16764f 100644 --- a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/newhuoli_control.java +++ b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/newhuoli_control.java @@ -21,6 +21,8 @@ import butterknife.ButterKnife; import butterknife.OnClick; public class newhuoli_control extends LinearLayout { + @BindView(R.id.close_out) + LinearLayout close_out; @BindView(R.id.colse) ImageView colse; @BindView(R.id.hl1) @@ -157,6 +159,7 @@ public class newhuoli_control extends LinearLayout { { level=value; colse.setVisibility(View.VISIBLE); + close_out.setVisibility(View.VISIBLE); if(value==1) { Status=true; @@ -261,6 +264,7 @@ public class newhuoli_control extends LinearLayout { { Status=false; colse.setVisibility(View.INVISIBLE); + close_out.setVisibility(View.INVISIBLE); colse.setImageResource(R.mipmap.huoli_close); hl1.setImageResource(R.mipmap.hl2); hl2.setImageResource(R.mipmap.hl2); diff --git a/app/src/main/res/layout/activity_cooking.xml b/app/src/main/res/layout/activity_cooking.xml index 74fa84b6..b82c6485 100644 --- a/app/src/main/res/layout/activity_cooking.xml +++ b/app/src/main/res/layout/activity_cooking.xml @@ -112,25 +112,14 @@ - - - - + + + + + + diff --git a/app/src/main/res/layout/activity_cookingsimulated.xml b/app/src/main/res/layout/activity_cookingsimulated.xml index 42df2f44..f870b967 100644 --- a/app/src/main/res/layout/activity_cookingsimulated.xml +++ b/app/src/main/res/layout/activity_cookingsimulated.xml @@ -76,7 +76,7 @@ + android:layout_marginTop="0dp"> - - - - + + + + + + diff --git a/app/src/main/res/layout/fragment_home_pr.xml b/app/src/main/res/layout/fragment_home_pr.xml index 77467b6c..99c213be 100644 --- a/app/src/main/res/layout/fragment_home_pr.xml +++ b/app/src/main/res/layout/fragment_home_pr.xml @@ -13,16 +13,21 @@ + android:layout_marginTop="@dimen/dp_10" + android:layout_marginBottom="@dimen/dp_10" + android:layout_marginLeft="5dp" + android:layout_marginRight="5dp"> + android:layout_height="wrap_content" + android:layout_marginTop="5dp"> + + + @@ -64,21 +70,52 @@ android:layout_height="match_parent" android:layout_marginTop="60dp" android:layout_marginBottom="40dp"> - - + android:layout_height="match_parent" + android:orientation="horizontal"> + + + + + + + + + + + + + + android:visibility="gone" /> diff --git a/app/src/main/res/layout/fragment_home_sbkz.xml b/app/src/main/res/layout/fragment_home_sbkz.xml index 3e09dd4a..21d0fe6a 100644 --- a/app/src/main/res/layout/fragment_home_sbkz.xml +++ b/app/src/main/res/layout/fragment_home_sbkz.xml @@ -55,7 +55,7 @@ android:layout_centerHorizontal="true"> diff --git a/app/src/main/res/layout/item/layout/good_show.xml b/app/src/main/res/layout/item/layout/good_show.xml index c2833b94..e93c0403 100644 --- a/app/src/main/res/layout/item/layout/good_show.xml +++ b/app/src/main/res/layout/item/layout/good_show.xml @@ -2,8 +2,8 @@ + android:layout_width="145dp" + android:layout_height="165dp"> + android:layout_height="100dp"> + + + + - - - + + + - android:layout_width="35dp" - android:layout_height="50dp" - android:layout_centerVertical="true" - android:src="@mipmap/hlwqd" /> - + + + - android:layout_width="35dp" - android:layout_height="50dp" - android:layout_centerVertical="true" - android:src="@mipmap/hlwqd" /> - + + + - android:layout_width="35dp" - android:layout_height="50dp" - android:layout_centerVertical="true" - android:src="@mipmap/hlwqd" /> - - + + + - android:layout_width="35dp" - android:layout_height="50dp" - android:layout_centerVertical="true" - android:src="@mipmap/hlwqd" /> - + + + - android:layout_width="35dp" - android:layout_height="50dp" - android:layout_centerVertical="true" - android:src="@mipmap/hlwqd" /> - + + + - android:layout_width="35dp" - android:layout_height="50dp" - android:layout_centerVertical="true" - android:src="@mipmap/hlwqd" /> + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/item/layout/item_left_makegood.xml b/app/src/main/res/layout/item/layout/item_left_makegood.xml new file mode 100644 index 00000000..da4398db --- /dev/null +++ b/app/src/main/res/layout/item/layout/item_left_makegood.xml @@ -0,0 +1,32 @@ + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/item/layout/item_right_lc.xml b/app/src/main/res/layout/item/layout/item_right_lc.xml new file mode 100644 index 00000000..b191639e --- /dev/null +++ b/app/src/main/res/layout/item/layout/item_right_lc.xml @@ -0,0 +1,16 @@ + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index cf87ff95..8dc24957 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -14,6 +14,9 @@ #3604BFEF #BEAA6A #A5000000 + #99a0aa + #EFE9D2 +