Selaa lähdekoodia

一拖四重构

一拖四炒菜机
pry 7 kuukautta sitten
vanhempi
commit
7bf20b16e7
39 muutettua tiedostoa jossa 5230 lisäystä ja 9 poistoa
  1. +1
    -1
      .idea/gradle.xml
  2. +19
    -0
      app/src/main/java/com/bonait/bnframework/common/constant/ConfigName.java
  3. +1
    -1
      app/src/main/java/com/bonait/bnframework/common/tabbar/MainNavigateTabBar.java
  4. +74
    -0
      app/src/main/java/com/bonait/bnframework/common/view/CircleImageView.java
  5. +7
    -7
      app/src/main/java/com/bonait/bnframework/modules/home/activity/BottomNavigationMainActivity.java
  6. +69
    -0
      app/src/main/java/com/bonait/bnframework/modules/home/adapter/gongxubuzhou_adapter.java
  7. +313
    -0
      app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/CpActivity.java
  8. +577
    -0
      app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/DiyActivity.java
  9. +733
    -0
      app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/DiyMemoryActivity.java
  10. +623
    -0
      app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/DiyUpdate1Activity.java
  11. +698
    -0
      app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/DiyUpdateActivity.java
  12. +199
    -0
      app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/QDListSectionAdapter.java
  13. +62
    -0
      app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/QDSectionHeaderView.java
  14. +64
    -0
      app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/SectionHeader.java
  15. +118
    -0
      app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/SectionItem.java
  16. +170
    -0
      app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/fragment_gx.java
  17. +266
    -0
      app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/huoli_control.java
  18. +12
    -0
      app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/item_gx.java
  19. +13
    -0
      app/src/main/res/drawable/input_bj1.xml
  20. +27
    -0
      app/src/main/res/layout/activity_cp.xml
  21. +318
    -0
      app/src/main/res/layout/activity_diy.xml
  22. +332
    -0
      app/src/main/res/layout/activity_diy_update.xml
  23. +343
    -0
      app/src/main/res/layout/activity_diy_update1.xml
  24. +115
    -0
      app/src/main/res/layout/item/layout/item_huolikongzhi.xml
  25. +75
    -0
      app/src/main/res/layout/item/layout/note_rv_tree_second.xml
  26. BIN
     
  27. BIN
     
  28. BIN
     
  29. BIN
     
  30. BIN
     
  31. BIN
     
  32. BIN
     
  33. BIN
     
  34. BIN
     
  35. BIN
     
  36. BIN
     
  37. BIN
     
  38. BIN
     
  39. +1
    -0
      app/src/main/res/values/colors.xml

+ 1
- 1
.idea/gradle.xml Näytä tiedosto

@@ -5,7 +5,7 @@
<option name="linkedExternalProjectsSettings">
<GradleProjectSettings>
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="gradleJvm" value="#GRADLE_LOCAL_JAVA_HOME" />
<option name="gradleJvm" value="corretto-11" />
<option name="modules">
<set>
<option value="$PROJECT_DIR$" />


+ 19
- 0
app/src/main/java/com/bonait/bnframework/common/constant/ConfigName.java Näytä tiedosto

@@ -238,6 +238,25 @@ public class ConfigName {

}};

/**
* 挡位 功率
*/
public ConcurrentHashMap<String, Integer> HeatingGear = new ConcurrentHashMap<String, Integer>() {{
put("停止", 0);
put("一档", 1);
put("二档", 2);
put("三档", 3);
put("四档", 4);
put("五档", 5);
put("六档", 6);
put("七档", 7);
put("八档", 8);
}};

/**
* 最大火力级别
*/
public String HuoLi="八档";
//endreion

//region 奶茶机


+ 1
- 1
app/src/main/java/com/bonait/bnframework/common/tabbar/MainNavigateTabBar.java Näytä tiedosto

@@ -41,7 +41,7 @@ public class MainNavigateTabBar extends LinearLayout implements View.OnClickList
private ColorStateList mSelectedTextColor;
private ColorStateList mNormalTextColor;
private float mTabTextSize;
private int mDefaultSelectedTab = 0;
private int mDefaultSelectedTab = 1;
private int mCurrentSelectedTab;

public MainNavigateTabBar(Context context) {


+ 74
- 0
app/src/main/java/com/bonait/bnframework/common/view/CircleImageView.java Näytä tiedosto

@@ -0,0 +1,74 @@
package com.bonait.bnframework.common.view;

import android.annotation.SuppressLint;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapShader;
import android.graphics.Canvas;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.Shader;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;

import androidx.annotation.Nullable;

public class CircleImageView extends androidx.appcompat.widget.AppCompatImageView {

//画笔
private Paint mPaint;
//圆形图片的半径
private int mRadius;
//图片的宿放比例
private float mScale;

public CircleImageView(Context context) {
super(context);
}

public CircleImageView(Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
}

public CircleImageView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}

@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
//由于是圆形,宽高应保持一致
int size = Math.min(getMeasuredWidth(), getMeasuredHeight());
mRadius = size / 2;
setMeasuredDimension(size, size);
}

@SuppressLint("DrawAllocation")
@Override
protected void onDraw(Canvas canvas) {

mPaint = new Paint();

Drawable drawable = getDrawable();

if (null != drawable) {
Bitmap bitmap = ((BitmapDrawable) drawable).getBitmap();

//初始化BitmapShader,传入bitmap对象
BitmapShader bitmapShader = new BitmapShader(bitmap, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP);
//计算缩放比例
mScale = (mRadius * 2.0f) / Math.min(bitmap.getHeight(), bitmap.getWidth());

Matrix matrix = new Matrix();
matrix.setScale(mScale, mScale);
bitmapShader.setLocalMatrix(matrix);
mPaint.setShader(bitmapShader);
//画圆形,指定好坐标,半径,画笔
canvas.drawCircle(mRadius, mRadius, mRadius, mPaint);
} else {
super.onDraw(canvas);
}
}

}

+ 7
- 7
app/src/main/java/com/bonait/bnframework/modules/home/activity/BottomNavigationMainActivity.java Näytä tiedosto

@@ -55,7 +55,7 @@ public class BottomNavigationMainActivity extends BaseActivity {
ButterKnife.bind(this);
MediaPlayerHelper.getInstance().SetConText(getBaseContext());
mNavigateTabBar.onRestoreInstanceState(savedInstanceState);
// mNavigateTabBar.addTab(null, new MainNavigateTabBar.TabParam(R.mipmap.gongneng, R.mipmap.gongneng_selected, "功能"));
mNavigateTabBar.addTab(null, new MainNavigateTabBar.TabParam(R.mipmap.gongneng, R.mipmap.gongneng_selected, "功能"));
// mNavigateTabBar.addTab(null, new MainNavigateTabBar.TabParam(R.mipmap.dingdan, R.mipmap.dingdan_selected, "日志"));
mNavigateTabBar.addTab(null, new MainNavigateTabBar.TabParam(0, 0, ""));
mNavigateTabBar.addTab(null, new MainNavigateTabBar.TabParam(R.mipmap.shezhi, R.mipmap.shezhi_selected, "设置"));
@@ -88,7 +88,7 @@ public class BottomNavigationMainActivity extends BaseActivity {
*/
private void initFragment() {
fragmentList = new ArrayList<>();
// fragmentList.add(new GongnengFragment());
fragmentList.add(new GongnengFragment());
// fragmentList.add(new DingDanfragment());

if(ConfigName.getInstance().versionSelectionEnum.equals("一拖四")){
@@ -107,9 +107,9 @@ public class BottomNavigationMainActivity extends BaseActivity {
//手指滑动
viewPager.addOnPageChangeListener(pageChangeListener);
// 设置viewPager缓存多少个fragment
viewPager.setOffscreenPageLimit(2);
viewPager.setOffscreenPageLimit(3);
// 再来一单
viewPager.setCurrentItem(0);
viewPager.setCurrentItem(1);
}

/**
@@ -168,9 +168,9 @@ public class BottomNavigationMainActivity extends BaseActivity {
// }
int _postion = 0;
switch (holder.tag) {
// case "功能":
// _postion = 0;
// break;
case "功能":
_postion = 0;
break;
// case "订单":
// _postion = 1;
// break;


+ 69
- 0
app/src/main/java/com/bonait/bnframework/modules/home/adapter/gongxubuzhou_adapter.java Näytä tiedosto

@@ -0,0 +1,69 @@
package com.bonait.bnframework.modules.home.adapter;

import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.bonait.bnframework.R;
import com.bonait.bnframework.common.db.mode.BPA_GOODSRECIPE;
import com.bonait.bnframework.common.helper.I.MyClickListener;

import java.util.List;


public class gongxubuzhou_adapter extends ArrayAdapter<BPA_GOODSRECIPE> {
/**
* 内部点击事件
*/
private MyClickListener mListener;
private List<BPA_GOODSRECIPE> datas;

private int selectedPosition = -1;// 选中的位置
int resource1;
public gongxubuzhou_adapter(@NonNull Context context, int resource, @NonNull List<BPA_GOODSRECIPE> objects, MyClickListener listener) {
super(context, resource, objects);
mListener = listener;
datas=objects;
this.resource1=resource;
}

public int getSelectedPosition()
{
return selectedPosition;
}

public void setSelectedPosition(int position) {
selectedPosition = position;
}
//每个子项被滚动到屏幕内的时候会被调用
@NonNull
@Override
public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
BPA_GOODSRECIPE lc = (BPA_GOODSRECIPE) getItem(position);//得到当前项选中item实例
//为每一个子项加载设定的布局
View view = LayoutInflater.from(getContext()).inflate(resource1, parent, false);
//分别获取 image view 和 textview 的实例

TextView text = view.findViewById(R.id.text);
text.setText((position+1)+"、"+lc.processms);

if (selectedPosition == position) {
text.setSelected(true);
text.setTextColor(Color.WHITE);
text.setBackground(getContext().getResources().getDrawable(R.color.green_primary_dark));
} else {
text.setSelected(false);
text.setTextColor(Color.BLACK);
text.setBackground(getContext().getResources().getDrawable(R.color.white));

}
return view;
}
}

+ 313
- 0
app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/CpActivity.java Näytä tiedosto

@@ -0,0 +1,313 @@
package com.bonait.bnframework.modules.home.fragment.from;

import static com.bonait.bnframework.MainApplication.getContext;

import android.annotation.SuppressLint;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.View;

import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.bonait.bnframework.R;
import com.bonait.bnframework.business.ConfigData;
import com.bonait.bnframework.common.base.BaseActivity;
import com.bonait.bnframework.common.constant.ConfigName;
import com.bonait.bnframework.common.constant.MessageName;
import com.bonait.bnframework.common.db.QueryDB;
import com.bonait.bnframework.common.db.mode.BPA_GOODS;
import com.bonait.bnframework.common.db.mode.BPA_GOODSRECIPE;
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.utils.AlertDialogUtils;
import com.bonait.bnframework.common.utils.ToastUtils;
import com.bonait.bnframework.modules.home.fragment.mode.QDListSectionAdapter;
import com.bonait.bnframework.modules.home.fragment.mode.SectionHeader;
import com.bonait.bnframework.modules.home.fragment.mode.SectionItem;
import com.qmuiteam.qmui.widget.QMUITopBarLayout;
import com.qmuiteam.qmui.widget.dialog.QMUIDialog;
import com.qmuiteam.qmui.widget.dialog.QMUIDialogAction;
import com.qmuiteam.qmui.widget.section.QMUISection;
import com.qmuiteam.qmui.widget.section.QMUIStickySectionAdapter;
import com.qmuiteam.qmui.widget.section.QMUIStickySectionLayout;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

public class CpActivity extends BaseActivity {

@BindView(R.id.topbar)
QMUITopBarLayout mTopBar;

@BindView(R.id.qmuisection_layout)
QMUIStickySectionLayout mSectionLayout;
private RecyclerView.LayoutManager mLayoutManager;
protected static QMUIStickySectionAdapter<SectionHeader, SectionItem, QMUIStickySectionAdapter.ViewHolder> mAdapter;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_cp);
//属性绑定
ButterKnife.bind(this);
context=this;
initTopBar();
initAdapter();
initAdapterLogicalOperation();
NBClick();
}

// QDListSectionAdapter
private void initAdapter() {
mLayoutManager = createLayoutManager();
mSectionLayout.setLayoutManager(mLayoutManager);
mAdapter = createAdapter();
//mSectionLayout.setAnimation(AnimationUtils.loadAnimation(getContext(), R.anim.aword_fade_enter));
}

private void initAdapterLogicalOperation() {
mAdapter.setCallback(new QMUIStickySectionAdapter.Callback<SectionHeader, SectionItem>() {
@Override
public void loadMore(final QMUISection<SectionHeader, SectionItem> section, final boolean loadMoreBefore) {

}

//点击事件
@Override
public void onItemClick(QMUIStickySectionAdapter.ViewHolder holder, int position) {
if (holder.getItemViewType() != 1) {
int pos = holder.isForStickyHeader ? position : holder.getAdapterPosition();
mAdapter.toggleFold(pos, false);
}
}

//长按事件
@Override
public boolean onItemLongClick(QMUIStickySectionAdapter.ViewHolder holder, int position) {
int FirstPos = mAdapter.getSectionIndex(position);
int SecondPos = mAdapter.getItemIndex(position);
//ItemPopupWindow.show(getContext(), holder.itemView, holder.getItemViewType(), FirstPos, SecondPos);
ToastUtils.info("一级条目" + FirstPos + "二级" + SecondPos);
return true;
}
});
mSectionLayout.setAdapter(mAdapter, true);
ConfigData.getInstance().GetGevGood(this, mHandler);
mAdapter.setData(getList());
}
Context context;
@SuppressLint("HandlerLeak")
private Handler mHandler = new Handler() {
@Override
public void handleMessage(Message msg) {
if (msg.obj.toString() == "MSG_REFRESH") {
mAdapter.setData(getList());
}
}
};

public void NBClick() {
/**
* 删除菜品
*/
MessageManager.getInstance().registerMessageReceiver(this, MessageName.DeleteGood, new MessageLooper.OnMessageListener() {
@Override
public void onMessage(Object msg) {
if (msg != null) {
SectionItem item = (SectionItem) msg;
QueryDB.DeleteGoodsid(item.getAccount());
QueryDB.DeleteGoodsSrecipeList(item.getAccount());
mAdapter.setDataWithoutDiff(getList(), true);
}
}
});

/**
* 刷新菜品
*/
MessageManager.getInstance().registerMessageReceiver(this, MessageName.ScGood, new MessageLooper.OnMessageListener() {
@Override
public void onMessage(Object msg) {
if (msg != null) {
mAdapter.setData(new ArrayList<QMUISection<SectionHeader, SectionItem>>());
mAdapter.setData(getList());
}
}
});

/**
* 点击菜品
*/
MessageManager.getInstance().registerMessageReceiver(this, MessageName.ClickGood, new MessageLooper.OnMessageListener() {
@Override
public void onMessage(Object msg) {
if (msg != null) {
SectionItem item = (SectionItem) msg;
String goodid = item.getAccount();//商品id
Intent intent = new Intent(getContext(), DiyUpdateActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.putExtra("id", goodid);
startActivity(intent);
}
}
});
}

protected QMUIStickySectionAdapter<SectionHeader, SectionItem, QMUIStickySectionAdapter.ViewHolder> createAdapter() {
return new QDListSectionAdapter();
}

protected RecyclerView.LayoutManager createLayoutManager() {
// return new LinearLayoutManager(getContext()) {
// @Override
// public RecyclerView.LayoutParams generateDefaultLayoutParams() {
// return new RecyclerView.LayoutParams(
// ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
// }
// };

final GridLayoutManager layoutManager;
if(ConfigName.getInstance().IsPortraitScreen)//竖屏
{
layoutManager = new GridLayoutManager(getContext(), 3);
}else
{
layoutManager = new GridLayoutManager(getContext(), 5);
}
layoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
@Override
public int getSpanSize(int i) {
return mAdapter.getItemIndex(i) < 0 ? layoutManager.getSpanCount() : 1;
}
});

return layoutManager;
}

/**
* 获取数据
*
* @return
*/
private static ArrayList<QMUISection<SectionHeader, SectionItem>> getList() {
ArrayList<QMUISection<SectionHeader, SectionItem>> list = new ArrayList<>();
ArrayList<BPA_GOODS> good = QueryDB.GetGoodsALL();
List<String> Bendi_id = new ArrayList<>();

SectionHeader header_bdcp = new SectionHeader("本地菜谱", "", "");
ArrayList<SectionItem> contents_bdcp = new ArrayList<>();

SectionHeader header_sccp = new SectionHeader("收藏菜谱", "", "");
ArrayList<SectionItem> contents_sccp = new ArrayList<>();

SectionHeader header_ydcp = new SectionHeader("云端菜谱", "", "");
ArrayList<SectionItem> 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));
if (item.issc == 1) {
contents_sccp.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));
}
list.add(new QMUISection<>(header_bdcp, contents_bdcp, false));
list.add(new QMUISection<>(header_sccp, contents_sccp, true));
list.add(new QMUISection<>(header_ydcp, contents_ydcp, true));
return list;
}

private void initTopBar() {
mTopBar.setTitle("菜谱管理");
/**
* 返回按钮
*/
mTopBar.addLeftImageButton(R.mipmap.fanhui, R.id.topbar).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
finish();
}
});

/**
* 下载云端菜谱
*/
mTopBar.addRightImageButton(R.mipmap.clouddownload, R.id.cLeftImageViewId).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String title = "同步云端菜谱操作提示!";
String message = "请问客官确定要同步菜谱吗?此操作将完全复刻云端菜谱,本地菜谱将清除!请确认本地菜谱已上传云端!!!!";
AlertDialogUtils.showDialog(context, title, message, new QMUIDialogAction.ActionListener() {
@Override
public void onClick(QMUIDialog dialog, int index) {

if(ConfigName.getInstance().cloudGoods!=null && ConfigName.getInstance().cloudGoods.size()>0)
{
ArrayList<BPA_GOODS> goods= QueryDB.GetGoodsALL();
ArrayList<BPA_GOODSRECIPE> rec= QueryDB.GetGoodsSrecipeALL();
for (BPA_GOODS good:goods)
{
QueryDB.DeleteGoods(good);
}
for (BPA_GOODSRECIPE pf:rec)
{
QueryDB.DeleteGoodsSrecipe(pf);
}

for (CloudGood item : ConfigName.getInstance().cloudGoods) {
ConfigData.getInstance().GetGoodProcess(context,item.id,false);
}
}
dialog.dismiss();
}
});
}
});

/**
* 新建商品
*/
mTopBar.addRightTextButton("新建商品", R.id.topbar).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
skipToActivity(DiyActivity.class);
}
});


}

/**
* 跳转界面
*/
private void skipToActivity(Class da) {
// 跳转到登录页面
Intent intent = new Intent(context, da);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
}

@Override
public void onDestroy() {
super.onDestroy();
}

@Override
protected boolean canDragBack() {
return false;
}
}

+ 577
- 0
app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/DiyActivity.java Näytä tiedosto

@@ -0,0 +1,577 @@
package com.bonait.bnframework.modules.home.fragment.from;

import static com.bonait.bnframework.MainApplication.getContext;

import android.content.Intent;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.View;
import android.view.WindowManager;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.Spinner;

import com.bonait.bnframework.R;
import com.bonait.bnframework.common.base.BaseActivity;
import com.bonait.bnframework.common.constant.DataBus;
import com.bonait.bnframework.common.constant.MessageName;
import com.bonait.bnframework.common.db.QueryDB;
import com.bonait.bnframework.common.db.mode.BPA_GOODS;
import com.bonait.bnframework.common.db.mode.BPA_GOODSRECIPE;
import com.bonait.bnframework.common.db.mode.BPA_MATERIAL;
import com.bonait.bnframework.common.db.mode.BPA_PROCESS;
import com.bonait.bnframework.common.db.mode.BPA_PROCESSModel;
import com.bonait.bnframework.common.image.MyBitmapUtils;
import com.bonait.bnframework.common.message.MessageLooper;
import com.bonait.bnframework.common.message.MessageManager;
import com.bonait.bnframework.common.utils.AlertDialogUtils;
import com.bonait.bnframework.common.utils.ToastUtils;
import com.bonait.bnframework.modules.home.adapter.gongxubuzhou_adapter;
import com.bonait.bnframework.modules.home.fragment.mode.fragment_gx;
import com.bonait.bnframework.modules.home.fragment.mode.item_gx;
import com.qmuiteam.qmui.widget.QMUITopBarLayout;
import com.qmuiteam.qmui.widget.dialog.QMUIDialog;
import com.qmuiteam.qmui.widget.dialog.QMUIDialogAction;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class DiyActivity extends BaseActivity {
@BindView(R.id.topbar)
QMUITopBarLayout mTopBar;
@BindView(R.id.edittext)
EditText edittext;//菜谱名称
@BindView(R.id.cpfm)
ImageView cpfm;//菜谱封面
@BindView(R.id.zzsc)
EditText zzsc;//制作时长
@BindView(R.id.check)
CheckBox check;//默认收藏
// @BindView(R.id.Banner_Main)
// Banner Banner_Main;//轮播图
// //用于存放获取的图片
List<Drawable> Banner_list = new ArrayList<>();

@BindView(R.id.hrgx)
Spinner hrgx;//工序
Map<String, String> hrgx_map = new LinkedHashMap<>();
Map<String, Integer> hrgx_map_index = new LinkedHashMap<>();

@BindView(R.id.gxchid)
LinearLayout gxchid;//工序子集

@BindView(R.id.datatab_gxbz)
ListView datatab_gxbz;//工序步骤
public gongxubuzhou_adapter gxbz_adapter = null;
public String imageUrl = "";
/**
* 工序步骤
*/
public ArrayList<BPA_GOODSRECIPE> bpa_goodsrecipes = new ArrayList<>();
/**
* 是否人工单击
*/
public boolean isUserClicked = false;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_diy);//属性绑定
ButterKnife.bind(this);
initTopBar();
initData();
}

private void initData() {
//1.初始化轮播图
//Drawable_Get(Banner_list);
//2.初始化工序
ArrayList<BPA_PROCESS> data = QueryDB.GetProcessALL();
int i = 0;
String id = "";
for (BPA_PROCESS item : data) {
hrgx_map.put(item.name, item.id);
hrgx_map_index.put(item.name, i);
if (i == 0) {
id = item.id;
}
i++;
}
ArrayAdapter<String> adapter_kk = new ArrayAdapter<>(getContext(), R.layout.spinner_text_item, new ArrayList<>(hrgx_map.keySet()));
adapter_kk.setDropDownViewResource(R.layout.spinner_dropdown_item);
hrgx.setAdapter(adapter_kk);

hrgx.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
isUserClicked = true;
view.performClick();
return false;
}
});
hrgx.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
if (isUserClicked)//不是用户点击返回
{
String id = hrgx_map.get(hrgx.getSelectedItem().toString());
SelectItemFrom(id);
isUserClicked = false;
}
}

@Override
public void onNothingSelected(AdapterView<?> adapterView) {
}
});
SelectItemFrom(id);
//3.工序步骤
gxbz_adapter = new gongxubuzhou_adapter(getContext(), R.layout.gx_item, (List<BPA_GOODSRECIPE>) bpa_goodsrecipes, null);
datatab_gxbz.setAdapter(gxbz_adapter);

datatab_gxbz.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long l) {
// TODO Auto-generated method stub
gxbz_adapter.setSelectedPosition(position);
gxbz_adapter.notifyDataSetInvalidated();

SetSelectGX(bpa_goodsrecipes.get(position));//单击工序行,显示变量
}
});

//图标选择
MessageManager.getInstance().registerMessageReceiver(this, MessageName.ClickImage, new MessageLooper.OnMessageListener() {
@Override
public void onMessage(Object msg) {
if (msg != null) {
imageUrl = (String) msg;
new MyBitmapUtils().disPlay(cpfm, imageUrl);
}
}
});

//DIY 刷新
MessageManager.getInstance().registerMessageReceiver(this, MessageName.DIY, new MessageLooper.OnMessageListener() {
@Override
public void onMessage(Object msg) {
if (msg != null) {
bpa_goodsrecipes.clear();
for(BPA_GOODSRECIPE item:DataBus.getInstance().bpa_goodsrecipes)
{
bpa_goodsrecipes.add(item);
}
zzsc.setText(DataBus.getInstance().TimeOut+"");
gxbz_adapter.notifyDataSetChanged();
}
}
});

getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
}

/**
* 根据选中步骤显示变量
*
* @param goodsrecipe
*/
public void SetSelectGX(BPA_GOODSRECIPE goodsrecipe) {
try {
//1.根据工序名称显示工序集合
hrgx.setSelection(hrgx_map_index.get(goodsrecipe.processname));
String id = hrgx_map.get(hrgx.getSelectedItem().toString());
SelectItemFrom(id);

//2.根据工序变量集合-获取变量名称和值
final HashMap<String, String> formulation = new HashMap<>();
//region 获取变量名称和值
String text = goodsrecipe.processvalue;
List<String> data = new ArrayList<>();
if (text.contains("|")) {
String[] res = text.split("[|]");
for (int i = 0; i < res.length; i++) {
data.add(res[i]);
}
} else {
data.add(text);
}
for (String item : data) {
if (!item.isEmpty() && item.contains(",")) {
String[] wl = item.split("[,]");
if (wl != null && wl.length == 2) {
String name = wl[0];
String val = wl[1];
formulation.put(name, val);
}
}
}
//endregion

//3.查询子集-填充变量
for (Map.Entry<String, String> entry : formulation.entrySet()) {
String key = entry.getKey();
String value = entry.getValue();
String STR = formulation.get(key);
}

for (int i = 0; i < gxchid.getChildCount(); i++) {
fragment_gx gongxu = (fragment_gx) gxchid.getChildAt(i);
String res = formulation.get(gongxu.model.name);
if (res != null) {
gongxu.SetValues(res);
}
}
} catch (Exception ex) {
}
}

/**
* 根据选中工序id显示集合
*
* @param id
*/
public void SelectItemFrom(String id) {
try {
gxchid.removeAllViews();
ArrayList<BPA_PROCESSModel> mode = QueryDB.GetProcessModelProcessID(id);
if (mode.size() > 0)//工序
{
for (BPA_PROCESSModel item : mode) {
item_gx gx = new item_gx();
gx.datatype = item.datatype;
gx.name = item.name;
gx.data = item.data;
gx.IsWL = false;
fragment_gx gongxu = new fragment_gx(this, null, gx);
gxchid.addView(gongxu);
}
} else //物料
{
ArrayList<BPA_MATERIAL> materials = QueryDB.GetMaterialALL();
for (BPA_MATERIAL item2 : materials) {
item_gx gx = new item_gx();
gx.datatype = 0;//液体料都是数字
gx.name = item2.name;
gx.IsWL = true;
fragment_gx gongxu = new fragment_gx(this, null, gx);
gxchid.addView(gongxu);
}
}
} catch (Exception ex) {
}
}

/**
* 获取选中行的变量
*
* @return
*/
public BPA_GOODSRECIPE GetSelectItemFromValue() {
BPA_GOODSRECIPE pf = new BPA_GOODSRECIPE();
try {
String name = hrgx.getSelectedItem().toString();
boolean IsVerify = true;
String description = "";
// 延迟,100|延迟,100|延迟,100|延迟,100|
String data = "";
String desc = "";
if (name.contains("液体料")) {
pf.materialType = 0;
for (int i = 0; i < gxchid.getChildCount(); i++) {
fragment_gx gongxu = (fragment_gx) gxchid.getChildAt(i);
String values = gongxu.GetValues();
if (!values.isEmpty()) {
data += gongxu.model.name + "," + values + "|";
desc += values + ",";
}
}

if (data.isEmpty()) {
IsVerify = false;
description += "物料-不能为空,请勾选一个物料\n";
}
} else {
pf.materialType = 1;
for (int i = 0; i < gxchid.getChildCount(); i++) {
fragment_gx gongxu = (fragment_gx) gxchid.getChildAt(i);
String values = gongxu.GetValues();
if (values.isEmpty()) {
IsVerify = false;
description += gongxu.model.name + "-不能为空\n";
} else {
data += gongxu.model.name + "," + values + "|";
desc += values + ",";
}
}
}
if (IsVerify) {
pf.processname = name;
pf.processms = name + "(" + desc.substring(0, desc.length() - 1) + ")";
pf.processvalue = data.substring(0, data.length() - 1);
return pf;
} else {
ToastUtils.info("数据验证失败,原因:" + description);
return null;
}
} catch (Exception ex) {
return null;
}
}

private void initTopBar() {
mTopBar.setTitle("DIY模式");
mTopBar.addLeftImageButton(R.mipmap.fanhui, R.id.topbar).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
finish();
}
});
}

/**
* 获取图片存放到list中
*
* @param arrayList
*/
private void Drawable_Get(List arrayList) {
//把他们存放到一个list集合中
arrayList.add(getResources().getDrawable(R.mipmap.image1));
arrayList.add(getResources().getDrawable(R.mipmap.image2));
arrayList.add(getResources().getDrawable(R.mipmap.image3));
arrayList.add(getResources().getDrawable(R.mipmap.image4));
//调用轮播图设置方法
Banner_Set(Banner_list);
}

/**
* 将图片存放到轮播图中
*
* @param arrayList
*/
private void Banner_Set(List arrayList) {
//这是设置轮播图的关键位置,setImages(list) 设置轮播图的图片资源
//setImageLoader(一个实体类)用于加载图片到手机页面上显示
//Banner_Main.setImages(Banner_list).setImageLoader(new MyImage()).start();
}

/**
* 点击事件
*
* @param view
*/
@OnClick({R.id.add_hrgx, R.id.update_gx, R.id.delete_gx, R.id.shangyi, R.id.xiayi, R.id.caozuomoshi, R.id.shengchengcaipu, R.id.cpfm})
public void onViewClicked(View view) {
switch (view.getId()) {
case R.id.cpfm://菜谱封面
// 跳转到登录页面
Intent intent = new Intent(getContext(), ImageChooseActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
break;
case R.id.add_hrgx://添加工序
BPA_GOODSRECIPE goodsrecipe = GetSelectItemFromValue();
if (goodsrecipe != null) {
if(goodsrecipe.processname.equals("加热"))
{
boolean isfa=false;
for (BPA_GOODSRECIPE item:bpa_goodsrecipes)
{
if(item.processname.equals("搅拌"))
{
isfa=true;
}
}
if(isfa==false)
{
ToastUtils.warning("加热工序之前,必须先添加搅拌工序!");
return;
}
}

bpa_goodsrecipes.add(GetSelectItemFromValue());
gxbz_adapter.notifyDataSetChanged();
}
break;
case R.id.update_gx://修改工序
int index_update = gxbz_adapter.getSelectedPosition();
if (index_update >= 0 && index_update < bpa_goodsrecipes.size()) {
BPA_GOODSRECIPE obj_update = (BPA_GOODSRECIPE) bpa_goodsrecipes.get(index_update);
String selectname = hrgx.getSelectedItem().toString();
if (!obj_update.processname.equals(selectname)) {
ToastUtils.info("请先选择工序!");
return;
}
bpa_goodsrecipes.set(index_update, GetSelectItemFromValue());
gxbz_adapter.notifyDataSetChanged();
ToastUtils.info("修改步骤" + (index_update + 1) + ":" + obj_update.processname + "成功!");
} else {
ToastUtils.info("请先选择工序!");
}
break;
case R.id.delete_gx://删除工序
int index_delete = gxbz_adapter.getSelectedPosition();
if (index_delete >= 0 && index_delete < bpa_goodsrecipes.size()) {
BPA_GOODSRECIPE obj_delete = (BPA_GOODSRECIPE) bpa_goodsrecipes.get(index_delete);
bpa_goodsrecipes.remove(obj_delete);
gxbz_adapter.notifyDataSetChanged();

//移动光标
if (index_delete - 1 >= 0) {
SetSelectPos(index_delete - 1);
}
ToastUtils.info("删除工序" + obj_delete.processname + "成功!");
} else {
ToastUtils.info("请先选择工序!");
}
break;
case R.id.shangyi://上移
int index_up = gxbz_adapter.getSelectedPosition();
;
if (index_up > 0) {
BPA_GOODSRECIPE obj_up = (BPA_GOODSRECIPE) bpa_goodsrecipes.get(index_up);
bpa_goodsrecipes.remove(obj_up);
bpa_goodsrecipes.add(index_up - 1, obj_up);
gxbz_adapter.notifyDataSetChanged();

//移动光标
SetSelectPos(index_up - 1);
} else {
ToastUtils.info("已经最顶部!");
}
break;
case R.id.xiayi://下移
int index_down = gxbz_adapter.getSelectedPosition();
if (index_down < bpa_goodsrecipes.size() - 1 && index_down >= 0) {
BPA_GOODSRECIPE obj_down = (BPA_GOODSRECIPE) bpa_goodsrecipes.get(index_down);
bpa_goodsrecipes.remove(obj_down);
bpa_goodsrecipes.add(index_down + 1, obj_down);
gxbz_adapter.notifyDataSetChanged();

//移动光标
SetSelectPos(index_down + 1);
} else {
ToastUtils.info("已经最底部!");
}
break;
case R.id.caozuomoshi://操作模式,打开自动记忆模式
Intent intent1 = new Intent(getContext(), DiyMemoryActivity.class);
intent1.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent1);
break;
case R.id.shengchengcaipu://生成菜谱
String name = edittext.getText().toString();


if (name.isEmpty()) {
ToastUtils.info("菜谱名称不能为空!");
return;
} else {
boolean isSucess = QueryDB.GetGoodsIs(name);
if (isSucess) {
ToastUtils.info("菜谱名称已存在!");
return;
}

if(!IsHotJ())
{
ToastUtils.warning("加热工序之前,必须先添加搅拌工序!");
return;
}

//按钮点击
String title = "生成菜谱操作提示!";
String message = "请问客官确定要生成[" + name + "]菜谱吗?";
AlertDialogUtils.showDialog(view.getContext(), title, message, new QMUIDialogAction.ActionListener() {
@Override
public void onClick(QMUIDialog dialog, int index) {
int sc = 60 * 3;
if (!zzsc.getText().toString().isEmpty() && !zzsc.getText().toString().equals("0")) {
sc = Integer.parseInt(zzsc.getText().toString());
}

ArrayList<BPA_GOODS> goods = QueryDB.GetGoodsALL();
BPA_GOODS good = new BPA_GOODS();
good.name = name;
good.status = 1;
good.sort = goods.size() + 1;
good.maketime = sc;
good.issc = check.isChecked() ? 1 : 0;
good.url = imageUrl;
QueryDB.AddGoods(good);
for (int k = 0; k < bpa_goodsrecipes.size(); k++) {
BPA_GOODSRECIPE item = bpa_goodsrecipes.get(k);
item.goodsID = good.id;
item.sort = k + 1;
QueryDB.AddGoodsSrecipe(item);
}
ToastUtils.info("菜谱生成成功!");
MessageManager.getInstance().sendMessage(MessageName.ScGood,"Good");
dialog.dismiss();
}
});

}
break;
}
}

/**
* 判断数据是否合法
*/
public boolean IsHotJ()
{
int index=1;
int k=0;int j=0;
for(BPA_GOODSRECIPE item:bpa_goodsrecipes)
{
if(item.processname.contains("搅拌") && k==0)
{
k=index;
}

if(item.processname.contains("加热") && j==0)
{
j=index;
}
index++;
}

if(j<k)
{
return false;
}else
{
return true;
}
}

public void SetSelectPos(int index) {
//移动光标
gxbz_adapter.setSelectedPosition(index);
gxbz_adapter.notifyDataSetInvalidated();
}

@Override
public void onDestroy() {
super.onDestroy();
}

@Override
protected boolean canDragBack() {
return false;
}

}

+ 733
- 0
app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/DiyMemoryActivity.java Näytä tiedosto

@@ -0,0 +1,733 @@
package com.bonait.bnframework.modules.home.fragment.from;

import android.content.Context;
import android.graphics.Color;
import android.os.Bundle;
import android.os.SystemClock;
import android.view.View;
import android.widget.Chronometer;
import android.widget.ImageView;
import android.widget.LinearLayout;

import androidx.annotation.NonNull;

import com.bonait.bnframework.R;
import com.bonait.bnframework.business.ExecuteTheRecipe;
import com.bonait.bnframework.common.base.BaseActivity;
import com.bonait.bnframework.common.constant.ConfigName;
import com.bonait.bnframework.common.constant.DataBus;
import com.bonait.bnframework.common.constant.MessageName;
import com.bonait.bnframework.common.db.QueryDB;
import com.bonait.bnframework.common.db.mode.BPA_GOODSRECIPE;
import com.bonait.bnframework.common.db.mode.BPA_MATERIAL;
import com.bonait.bnframework.common.helper.I.IWriteCallBack;
import com.bonait.bnframework.common.helper.I.MyClickListener;
import com.bonait.bnframework.common.message.MessageManager;
import com.bonait.bnframework.common.utils.AlertDialogUtils;
import com.bonait.bnframework.common.utils.ToastUtils;
import com.bonait.bnframework.modules.home.fragment.mode.fragment_gx;
import com.bonait.bnframework.modules.home.fragment.mode.huoli_control;
import com.bonait.bnframework.modules.home.fragment.mode.item_gx;
import com.litao.slider.NiftySlider;
import com.qmuiteam.qmui.widget.QMUITopBarLayout;
import com.qmuiteam.qmui.widget.dialog.QMUIDialog;
import com.qmuiteam.qmui.widget.dialog.QMUIDialogAction;

import java.util.ArrayList;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class DiyMemoryActivity extends BaseActivity {

@BindView(R.id.topbar)
QMUITopBarLayout mTopBar;

@BindView(R.id.gxchid)
LinearLayout gxchid;//工序子集

@BindView(R.id.start_bj)
LinearLayout start_bj;//背景

@BindView(R.id.startbutton)
ImageView startbutton;//启动停止

public boolean isRun = false;

@BindView(R.id.runtime)
Chronometer runtime;//运行时间

@BindView(R.id.huoli)
huoli_control huoli;//火力 控件

@BindView(R.id.nifty_slider2)
NiftySlider nifty_slider2;//搅拌挡位

// @BindView(R.id.nifty_slider3)
// NiftySlider nifty_slider3;//移动挡位


@BindView(R.id.zhuliaotouliao)
LinearLayout zhuliaotouliao;//
private Context context;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_diy_memory);
ButterKnife.bind(this);
initTopBar();
initData();
}

/**
* 初始化数据
*/
private void initData() {
try {

if (ConfigName.getInstance().versionSelectionEnum.equals("大炒版本") || ConfigName.getInstance().versionSelectionEnum.contains("一拖")) {
zhuliaotouliao.setVisibility(View.GONE);
} else {
zhuliaotouliao.setVisibility(View.VISIBLE);
}

DataBus.getInstance().bpa_goodsrecipes.clear();
gxchid.removeAllViews();
ArrayList<BPA_MATERIAL> materials = QueryDB.GetMaterialALL();
for (BPA_MATERIAL item2 : materials) {
item_gx gx = new item_gx();
gx.datatype = 0;//液体料都是数字
gx.name = item2.name;
gx.IsWL = true;
fragment_gx gongxu = new fragment_gx(this, null, gx);
gxchid.addView(gongxu);
}
} catch (Exception ex) {
}
}

private void initTopBar() {
mTopBar.setTitle("手动操作模式");
mTopBar.addLeftImageButton(R.mipmap.fanhui, R.id.topbar).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (isRun) {
ToastUtils.warning("请先结束烹饪!!!");
} else {
finish();
}
}
});
//为Chronomter绑定事件监听器,超过一小时自动日内告知
runtime.setOnChronometerTickListener(new Chronometer.OnChronometerTickListener() {
@Override
public void onChronometerTick(Chronometer chronometer) {
//如果计时到现在超过了一小时秒
if (SystemClock.elapsedRealtime() - runtime.getBase() > 3600 * 1000) {
runtime.stop();
}
}
});

nifty_slider2.setOnValueChangeListener(new NiftySlider.OnValueChangeListener() {
@Override
public void onValueChange(@NonNull NiftySlider niftySlider, float v, boolean b) {
nifty_slider2.setThumbText((int) v + "");
}
});

// nifty_slider3.setOnValueChangeListener(new NiftySlider.OnValueChangeListener() {
// @Override
// public void onValueChange(@NonNull NiftySlider niftySlider, float v, boolean b) {
// nifty_slider3.setThumbText((int) v + "");
// }
// });
nifty_slider2.setValue(0, true);
// nifty_slider3.setValue(0, true);

huoli.mListener = new MyClickListener() {
@Override
public void clickListener(View v, Object data) {
if (isRunClick()) {
long elapsedMillis = SystemClock.elapsedRealtime() - runtime.getBase();
int time = (int) (elapsedMillis / 1000);//当前点击多少秒
int time_c = time - ClikTime;

if (time_c > 0)//如果大于0,那么加一个延迟
{
DataBus.getInstance().bpa_goodsrecipes.add(Get延迟(time_c));
}

String sdstr = Get挡位((int) data);
BPA_GOODSRECIPE data1 = Get加热(sdstr);
DataBus.getInstance().bpa_goodsrecipes.add(data1);
ClikTime = time;
ExecuteTheRecipe.Write_PLC_HuoLI((int) data);
}

}

@Override
public void clickListenerNew(View v, int k, Object data) {

}
};
}


public int TimeOut = 0;//当前运行总时长
public int ClikTime = 0;//上一次点击时间

@OnClick({R.id.startbutton, R.id.querendangwei,
R.id.chuliao, R.id.touliao1, R.id.touliao0,
R.id.touliao2, R.id.touliao3,
R.id.touliao4
, R.id.ydw, R.id.dcw, R.id.clw
, R.id.qxw, R.id.ccw1, R.id.ccw2, R.id.ccw3
, R.id.zidongchucan
, R.id.touliao_sd})
public void onViewClicked(View view) {
long elapsedMillis = SystemClock.elapsedRealtime() - runtime.getBase();
int time = (int) (elapsedMillis / 1000);//当前点击多少秒
int time_c = time - ClikTime;

switch (view.getId()) {
case R.id.touliao_sd://手动投料
ShouDongMainDish();
break;
case R.id.startbutton://启动 停止
if (isRun) {
String title = "停止操作提示!";
String message = "请问客官确定要停止制作吗,小菠萝会生气的,啊啊啊啊啊啊啊...我的饭饭?";
AlertDialogUtils.showDialog(view.getContext(), title, message, new QMUIDialogAction.ActionListener() {
@Override
public void onClick(QMUIDialog dialog, int index) {
StopTime();
dialog.dismiss();
}
});
} else {

String title = "开始操作提示!";
String message = "请问客官确定要开始制作吗,小菠萝好开心呀,马上就有好吃的耶?";
AlertDialogUtils.showDialog(view.getContext(), title, message, new QMUIDialogAction.ActionListener() {
@Override
public void onClick(QMUIDialog dialog, int index) {
StartTime();
dialog.dismiss();
}
});
}
break;
case R.id.querendangwei://确认搅拌挡位
if (isRunClick()) {
if (time_c > 0)//如果大于0,那么加一个延迟
{
DataBus.getInstance().bpa_goodsrecipes.add(Get延迟(time_c));
}

int sd = (int) nifty_slider2.getValue();
String sdstr = Get速度(sd);
BPA_GOODSRECIPE data = Get搅拌(sdstr);
DataBus.getInstance().bpa_goodsrecipes.add(data);
ExecuteTheRecipe.WritePLC("搅拌速度", sd, new IWriteCallBack() {
@Override
public void onSuccess() {
if (sd == 0) {
ExecuteTheRecipe.WritePLC("搅拌", false, null);
} else {
ExecuteTheRecipe.WritePLC("搅拌", true, null);
}
}

@Override
public void onFailure(String ErrorMsg) {
}
});
ClikTime = time;
}
break;
case R.id.chuliao://出料
if (isRunClick()) {
BPA_GOODSRECIPE data = GetSelectItemFromValue();
if (data != null) {
DataBus.getInstance().bpa_goodsrecipes.add(data);
MakeRecipe(data);
ClikTime = time;
}
}
break;
case R.id.touliao0://主料1
if (isRunClick()) {
ExecuteTheRecipe.BottomClick("平移-去1号位");
}
break;
case R.id.touliao1://主料1
ClickZL(time, time_c, 1);
break;
case R.id.touliao2://主料2
ClickZL(time, time_c, 2);
break;
case R.id.touliao3://主料3
ClickZL(time, time_c, 3);
break;
case R.id.touliao4://主料4
ClickZL(time, time_c, 4);
break;
case R.id.ydw://原点位
ClickWZ(time, time_c, "原点位");
break;
case R.id.dcw://到菜位
ClickWZ(time, time_c, "倒菜位");
break;
case R.id.clw://出料位置
ClickWZ(time, time_c, "抽料位");
break;
case R.id.qxw://清洗位置
ClickWZ(time, time_c, "清洗位");
break;
case R.id.ccw1://炒菜位1
ClickWZ(time, time_c, "炒菜位1");
break;
case R.id.ccw2://炒菜位2
ClickWZ(time, time_c, "炒菜位2");
break;
case R.id.ccw3://炒菜位3
ClickWZ(time, time_c, "炒菜位3");
break;
case R.id.zidongchucan://自动出餐
if (isRunClick()) {
BPA_GOODSRECIPE data1 = Get出菜(time_c);
DataBus.getInstance().bpa_goodsrecipes.add(data1);
// BPA_GOODSRECIPE data2 = Get清洗(0);
// DataBus.getInstance().bpa_goodsrecipes.add(data2);
MakeRecipe(data1);
ClikTime = time;
}
break;
}
}

//region 常用函数

/**
* 是否运行
*
* @return
*/
public boolean isRunClick() {
if (!isRun) {
ToastUtils.warning("请先开始计时器!!!");
return false;
}

if (isMake) {
ToastUtils.warning("请等待上一步骤结束!!!");
return false;
}


// if (!isRun) {
// ToastUtils.info("请先开始计时器!!!");
// return false;
// }

return true;
}

public void ClickZL(int time, int time_c, int num) {
// Object sb = ExecuteTheRecipe.ReadPLC("平移轴在1号位");
// if (sb != null) {
// if ((boolean) (sb)) {
//
// } else {
// ToastUtils.warning("平移轴未复位!!!");
// }
// } else {
// ToastUtils.warning("PLC未连接!!!");
// }

if (isRunClick()) {
if (time_c > 0)//如果大于0,那么加一个延迟
{
DataBus.getInstance().bpa_goodsrecipes.add(Get延迟(time_c));
}

//控制去炒菜位
BPA_GOODSRECIPE data1 = Get位置("高速", "炒菜位1");
DataBus.getInstance().bpa_goodsrecipes.add(data1);

BPA_GOODSRECIPE data = Get主料(num);
DataBus.getInstance().bpa_goodsrecipes.add(data);
MakeRecipe(data);//执行主料
ClikTime = time;
}

}

public void ClickWZ(int time, int time_c, String name) {
if (isRunClick()) {
if (time_c > 0)//如果大于0,那么加一个延迟
{
DataBus.getInstance().bpa_goodsrecipes.add(Get延迟(time_c));
}

// int sd = (int) nifty_slider3.getValue();
// String sdstr= Get速度(sd);
BPA_GOODSRECIPE data = Get位置("高速", name);
DataBus.getInstance().bpa_goodsrecipes.add(data);
MakeRecipe(data);
ClikTime = time;
}
}

public boolean isMake = false;

public void MakeRecipe(BPA_GOODSRECIPE recipe) {
isMake = true;
new Thread(new Runnable() {
@Override
public void run() {
if (recipe.materialType == 0)//正常物料
{
BPA_GOODSRECIPE data1 = Get位置("高速", "抽料位");
ExecuteTheRecipe.ExecuteOperationSteps(data1.processname, data1.processvalue);

ExecuteTheRecipe.ExecuteMaterialIssuance(recipe.processvalue);
} else if (recipe.materialType == 1)//工序模型
{
if (recipe.processname.equals("主料")) {
BPA_GOODSRECIPE data1 = Get位置("高速", "炒菜位1");
ExecuteTheRecipe.ExecuteOperationSteps(data1.processname, data1.processvalue);
ExecuteTheRecipe.ExecuteOperationSteps(recipe.processname, recipe.processvalue);
} else {
if (recipe.processname.equals("出菜")) {
ExecuteTheRecipe.ExecuteOperationSteps(recipe.processname, recipe.processvalue);
BPA_GOODSRECIPE data2 = Get清洗(0);
ExecuteTheRecipe.ExecuteOperationSteps(data2.processname, data2.processvalue);
} else {
ExecuteTheRecipe.ExecuteOperationSteps(recipe.processname, recipe.processvalue);
}
}
}
isMake = false;
}
}).start();
}

/**
* 手动投主菜品
*
* @param
*/
public void ShouDongMainDish() {
int time = (int) ((SystemClock.elapsedRealtime() - runtime.getBase()) / 1000);//当前点击多少秒
int time_c = time - ClikTime;

if (time_c > 0)//如果大于0,那么加一个延迟
{
DataBus.getInstance().bpa_goodsrecipes.add(Get延迟(time_c));
}
DataBus.getInstance().bpa_goodsrecipes.add(Get手动主料());
ExecuteTheRecipe.WritePLC("暂停开关", true, null);
String title = "手动投料-温馨提示!";
String message = "客官请投入主料,投入后点击[确定]继续流程!";
new QMUIDialog.MessageDialogBuilder(context)
.setCancelable(false)
.setCanceledOnTouchOutside(false)
.setTitle(title)
.setMessage(message)
.addAction("确定", new QMUIDialogAction.ActionListener() {
@Override
public void onClick(QMUIDialog dialog, int index) {
ExecuteTheRecipe.WritePLC("暂停开关", false, null);
ClikTime = (int) ((SystemClock.elapsedRealtime() - runtime.getBase()) / 1000);
dialog.dismiss();
}
})
.create(AlertDialogUtils.mCurrentDialogStyle).show();

}

/**
* 获取选中行的变量
*
* @return
*/
public BPA_GOODSRECIPE GetSelectItemFromValue() {
BPA_GOODSRECIPE pf = new BPA_GOODSRECIPE();
try {
boolean IsVerify = true;
String description = "";
// 延迟,100|延迟,100|延迟,100|延迟,100|
String data = "";
String desc = "";

pf.materialType = 0;
for (int i = 0; i < gxchid.getChildCount(); i++) {
fragment_gx gongxu = (fragment_gx) gxchid.getChildAt(i);
String values = gongxu.GetValues();
if (!values.isEmpty()) {
data += gongxu.model.name + "," + values + "|";
desc += values + ",";
}
}

if (data.isEmpty()) {
IsVerify = false;
description += "物料-不能为空,请勾选一个物料\n";
}


if (IsVerify) {
pf.processname = "液体料";
pf.processms = "液体料" + "(" + desc.substring(0, desc.length() - 1) + ")";
pf.processvalue = data.substring(0, data.length() - 1);
return pf;
} else {
ToastUtils.error("数据验证失败,原因:" + description);
return null;
}
} catch (Exception ex) {
return null;
}
}

/**
* 获取延迟
*
* @param time
* @return
*/
public BPA_GOODSRECIPE Get延迟(int time) {
BPA_GOODSRECIPE pf = new BPA_GOODSRECIPE();
pf.materialType = 1;
pf.processname = "延迟";
pf.processms = "延迟(" + time + ")";
pf.processvalue = "延迟(秒)," + time;
return pf;
}

/**
* 获取清洗
*
* @return
*/
public BPA_GOODSRECIPE Get清洗(int k) {
BPA_GOODSRECIPE pf = new BPA_GOODSRECIPE();
pf.materialType = 1;
pf.processname = "清洗";
pf.processms = "清洗(" + k + ")";
pf.processvalue = "等待(秒)," + k;
return pf;
}

/**
* 获取主料
*
* @param wz
* @return
*/
public BPA_GOODSRECIPE Get主料(int wz) {
BPA_GOODSRECIPE pf = new BPA_GOODSRECIPE();
pf.materialType = 1;
pf.processname = "主料";
pf.processms = "主料(未知," + wz + "号位,0,直接投出,0)";
pf.processvalue = "主料名称,未知|主料位置," + wz + "号位|主料重量,0|投料动作,直接投出|烹饪(秒),0";
return pf;
}

/**
* 获取手动主料
*
* @param
* @return
*/
public BPA_GOODSRECIPE Get手动主料() {
String ms = "未知";
BPA_GOODSRECIPE pf = new BPA_GOODSRECIPE();
pf.materialType = 1;
pf.processname = "主料";
pf.processms = "主料(" + ms + ",1号位,0,手动投料,0)";
pf.processvalue = "主料名称," + ms + "|主料位置,1号位|主料重量,0|投料动作,手动投料|烹饪(秒),0";
return pf;
}

/**
* 获取位置
*
* @param sd
* @return
*/
public BPA_GOODSRECIPE Get位置(String sd, String name) {
BPA_GOODSRECIPE pf = new BPA_GOODSRECIPE();
pf.materialType = 1;
pf.processname = "位置";
pf.processms = "位置(" + sd + "," + name + ",0)";
pf.processvalue = "转动速度," + sd + "|位置动作," + name + "|延迟(秒),0";
return pf;
}

/**
* 获取搅拌
*
* @param sd
* @return
*/
public BPA_GOODSRECIPE Get搅拌(String sd) {
BPA_GOODSRECIPE pf = new BPA_GOODSRECIPE();
pf.materialType = 1;
pf.processname = "搅拌";
pf.processms = "搅拌(" + sd + ",0)";
pf.processvalue = "搅拌速度," + sd + "|延迟(秒),0";
return pf;
}

/**
* 获取加热
*
* @param sd
* @return
*/
public BPA_GOODSRECIPE Get加热(String sd) {
BPA_GOODSRECIPE pf = new BPA_GOODSRECIPE();
pf.materialType = 1;
pf.processname = "加热";
pf.processms = "加热(" + sd + ",0)";
pf.processvalue = "加热功率," + sd + "|延迟(秒),0";
return pf;
}

/**
* 获取出菜
*
* @return
*/
public BPA_GOODSRECIPE Get出菜(int k) {
BPA_GOODSRECIPE pf = new BPA_GOODSRECIPE();
pf.materialType = 1;
pf.processname = "出菜";
pf.processms = "出菜(" + k + ")";
pf.processvalue = "等待(秒)," + k;
return pf;
}

/**
* 获取速度
*
* @return
*/
public String Get速度(int speed) {
if (speed >= 0 && speed < 5) {
return "停止";
} else if (speed >= 5 && speed < 15) {
return "最低";
} else if (speed >= 15 && speed < 25) {
return "低速";
} else if (speed >= 25 && speed < 35) {
return "中速";
} else if (speed >= 35 && speed < 45) {
return "高速";
} else if (speed >= 45 && speed < 55) {
return "最高";
} else {
return "极高";
}
}

/**
* 获取挡位
*
* @return
*/
public String Get挡位(int speed) {
if (speed == 0) {
return "停止";
} else if (speed == 1) {
return "一档";
} else if (speed == 2) {
return "二档";
} else if (speed == 3) {
return "三档";
} else if (speed == 4) {
return "四档";
} else if (speed == 5) {
return "五档";
} else if (speed == 6) {
return "六档";
} else if (speed == 7) {
return "七档";
} else {
return "八档";
}
}

/**
* 启动定时器
*/
public void StartTime() {
runOnUiThread(new Runnable() {
@Override
public void run() {
//设置开始计时时间
runtime.setBase(SystemClock.elapsedRealtime());
//启动计时器
runtime.start();
isRun = true;
startbutton.setImageResource(R.mipmap.stop_js);
//5700FF22
//25FF9800
start_bj.setBackgroundColor(Color.parseColor("#5700FF22"));

DataBus.getInstance().bpa_goodsrecipes.clear();//清空所有工序
TimeOut = 0;
ClikTime = 0;
}
});

}

/**
* 停止定时器
*/
public void StopTime() {
runOnUiThread(new Runnable() {
@Override
public void run() {
//启动计时器
runtime.stop();
isRun = false;
startbutton.setImageResource(R.mipmap.start_js);

start_bj.setBackgroundColor(Color.parseColor("#25FF9800"));

long elapsedMillis = SystemClock.elapsedRealtime() - runtime.getBase();
TimeOut = (int) (elapsedMillis / 1000);//当前点击多少秒
DataBus.getInstance().TimeOut = TimeOut;
if (DataBus.getInstance().bpa_goodsrecipes.size() >= 0) {
MessageManager.getInstance().sendMessage(MessageName.DIY, "DIY");
}

ExecuteTheRecipe.WritePLC("搅拌", false, null);
ExecuteTheRecipe.WritePLC("加热", false, null);
ConfigName.getInstance().IsOpenHuoLi = false;
ExecuteTheRecipe.BottomClick("平移-去1号位");
}
});

}
//endregion


@Override
public void onDestroy() {
super.onDestroy();
}

@Override
protected boolean canDragBack() {
return false;
}
}

+ 623
- 0
app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/DiyUpdate1Activity.java Näytä tiedosto

@@ -0,0 +1,623 @@
package com.bonait.bnframework.modules.home.fragment.from;

import static com.bonait.bnframework.MainApplication.getContext;

import android.content.Intent;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.View;
import android.view.WindowManager;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.Spinner;

import androidx.core.content.ContextCompat;

import com.bonait.bnframework.R;
import com.bonait.bnframework.common.base.BaseActivity;
import com.bonait.bnframework.common.constant.DataBus;
import com.bonait.bnframework.common.constant.MessageName;
import com.bonait.bnframework.common.db.QueryDB;
import com.bonait.bnframework.common.db.mode.BPA_GOODS;
import com.bonait.bnframework.common.db.mode.BPA_GOODSRECIPE;
import com.bonait.bnframework.common.db.mode.BPA_MATERIAL;
import com.bonait.bnframework.common.db.mode.BPA_PROCESS;
import com.bonait.bnframework.common.db.mode.BPA_PROCESSModel;
import com.bonait.bnframework.common.image.MyBitmapUtils;
import com.bonait.bnframework.common.message.MessageLooper;
import com.bonait.bnframework.common.message.MessageManager;
import com.bonait.bnframework.common.utils.AlertDialogUtils;
import com.bonait.bnframework.common.utils.ToastUtils;
import com.bonait.bnframework.common.view.CircleImageView;
import com.bonait.bnframework.modules.home.adapter.gongxubuzhou_adapter;
import com.bonait.bnframework.modules.home.fragment.mode.fragment_gx;
import com.bonait.bnframework.modules.home.fragment.mode.item_gx;
import com.qmuiteam.qmui.widget.QMUITopBarLayout;
import com.qmuiteam.qmui.widget.dialog.QMUIDialog;
import com.qmuiteam.qmui.widget.dialog.QMUIDialogAction;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class DiyUpdate1Activity extends BaseActivity {
@BindView(R.id.topbar)
QMUITopBarLayout mTopBar;
@BindView(R.id.edittext)
EditText edittext;//菜谱名称
@BindView(R.id.cpfm)
CircleImageView cpfm;//菜谱封面
@BindView(R.id.zzsc)
EditText zzsc;//制作时长
@BindView(R.id.check)
CheckBox check;//默认收藏
@BindView(R.id.hrgx)
Spinner hrgx;//工序
Map<String, String> hrgx_map = new LinkedHashMap<>();
Map<String, Integer> hrgx_map_index = new LinkedHashMap<>();
@BindView(R.id.gxchid)
LinearLayout gxchid;//工序子集
@BindView(R.id.datatab_gxbz)
ListView datatab_gxbz;//工序步骤
public gongxubuzhou_adapter gxbz_adapter = null;
/**
* 工序步骤
*/
public ArrayList<BPA_GOODSRECIPE> bpa_goodsrecipes = new ArrayList<>();

/**
* 是否人工单击
*/
public boolean isUserClicked = false;
/**
* 当前商品
*/
public BPA_GOODS good = null;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_diy_update1);
ButterKnife.bind(this);
initTopBar();
initData();
SetGood();
}

private void initData() {
//1.初始化轮播图
//Drawable_Get(Banner_list);
//2.初始化工序
ArrayList<BPA_PROCESS> data = QueryDB.GetProcessALL();
int i = 0;
String id = "";
for (BPA_PROCESS item : data) {
hrgx_map.put(item.name, item.id);
hrgx_map_index.put(item.name, i);
if (i == 0) {
id = item.id;
}
i++;
}
ArrayAdapter<String> adapter_kk = new ArrayAdapter<>(getContext(), R.layout.spinner_text_item, new ArrayList<>(hrgx_map.keySet()));
adapter_kk.setDropDownViewResource(R.layout.spinner_dropdown_item);
hrgx.setAdapter(adapter_kk);

hrgx.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
isUserClicked = true;
view.performClick();
return false;
}
});
hrgx.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
if (isUserClicked)//不是用户点击返回
{
String id = hrgx_map.get(hrgx.getSelectedItem().toString());
SelectItemFrom(id);
isUserClicked = false;
}
}

@Override
public void onNothingSelected(AdapterView<?> adapterView) {
}
});
SelectItemFrom(id);
//3.工序步骤
gxbz_adapter = new gongxubuzhou_adapter(getContext(), R.layout.gx_item1, (List<BPA_GOODSRECIPE>) bpa_goodsrecipes, null);
datatab_gxbz.setAdapter(gxbz_adapter);
datatab_gxbz.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long l) {
// TODO Auto-generated method stub
gxbz_adapter.setSelectedPosition(position);
gxbz_adapter.notifyDataSetInvalidated();

SetSelectGX(bpa_goodsrecipes.get(position));//单击工序行,显示变量
}
});
//图标选择
MessageManager.getInstance().registerMessageReceiver(this, MessageName.ClickImage, new MessageLooper.OnMessageListener() {
@Override
public void onMessage(Object msg) {
if (msg != null) {
good.url = (String) msg;
new MyBitmapUtils().disPlay(cpfm, good.url);
}
}
});

//图标选择
MessageManager.getInstance().registerMessageReceiver(this, MessageName.DIY, new MessageLooper.OnMessageListener() {
@Override
public void onMessage(Object msg) {
if (msg != null) {
bpa_goodsrecipes.clear();
for (BPA_GOODSRECIPE item : DataBus.getInstance().bpa_goodsrecipes) {
bpa_goodsrecipes.add(item);
}
zzsc.setText(DataBus.getInstance().TimeOut + "");
gxbz_adapter.notifyDataSetChanged();
}
}
});
}

/**
* 根据选中步骤显示变量
*
* @param goodsrecipe
*/
public void SetSelectGX(BPA_GOODSRECIPE goodsrecipe) {
try {
//1.根据工序名称显示工序集合
hrgx.setSelection(hrgx_map_index.get(goodsrecipe.processname));
String id = hrgx_map.get(hrgx.getSelectedItem().toString());
SelectItemFrom(id);

//2.根据工序变量集合-获取变量名称和值
final HashMap<String, String> formulation = new HashMap<>();
//region 获取变量名称和值
String text = goodsrecipe.processvalue;
List<String> data = new ArrayList<>();
if (text.contains("|")) {
String[] res = text.split("[|]");
for (int i = 0; i < res.length; i++) {
data.add(res[i]);
}
} else {
data.add(text);
}
for (String item : data) {
if (!item.isEmpty() && item.contains(",")) {
String[] wl = item.split("[,]");
if (wl != null && wl.length == 2) {
String name = wl[0];
String val = wl[1];
formulation.put(name, val);
}
}
}
//endregion

//3.查询子集-填充变量
for (Map.Entry<String, String> entry : formulation.entrySet()) {
String key = entry.getKey();
String value = entry.getValue();
String STR = formulation.get(key);
}

for (int i = 0; i < gxchid.getChildCount(); i++) {
fragment_gx gongxu = (fragment_gx) gxchid.getChildAt(i);
String res = formulation.get(gongxu.model.name);
if (res != null) {
gongxu.SetValues(res);
}
}
} catch (Exception ex) {
}
}

/**
* 设置当前商品
*
* @param
*/
public void SetGood() {
try {
Intent intent = getIntent();
String id = intent.getStringExtra("id");
if (!id.isEmpty()) {
good = QueryDB.GetGoodsId(id);
if (good != null) {
bpa_goodsrecipes.clear();
ArrayList<BPA_GOODSRECIPE> goodsrecipes = QueryDB.GetGoodsSrecipeID(good.id);
for (BPA_GOODSRECIPE item : goodsrecipes) {
bpa_goodsrecipes.add(item);
}
edittext.setText(good.name);
check.setChecked(good.issc == 1);
zzsc.setText(good.maketime + "");
gxbz_adapter.notifyDataSetChanged();//刷新商品配方
new MyBitmapUtils().disPlay(cpfm, good.url);
}
}
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
} catch (Exception ex) {

}
}

/**
* 根据选中工序id显示集合
*
* @param id
*/
public void SelectItemFrom(String id) {
try {
gxchid.removeAllViews();
ArrayList<BPA_PROCESSModel> mode = QueryDB.GetProcessModelProcessID(id);
if (mode.size() > 0)//工序
{
for (BPA_PROCESSModel item : mode) {
item_gx gx = new item_gx();
gx.datatype = item.datatype;
gx.name = item.name;
gx.data = item.data;
gx.IsWL = false;
fragment_gx gongxu = new fragment_gx(this, null, gx);
gxchid.addView(gongxu);
}
} else //物料
{
ArrayList<BPA_MATERIAL> materials = QueryDB.GetMaterialALL();
for (BPA_MATERIAL item2 : materials) {
item_gx gx = new item_gx();
gx.datatype = 0;//液体料都是数字
gx.name = item2.name;
gx.IsWL = true;
fragment_gx gongxu = new fragment_gx(this, null, gx);
gxchid.addView(gongxu);
}
}
} catch (Exception ex) {
}
}

/**
* 获取选中行的变量
*
* @return
*/
public BPA_GOODSRECIPE GetSelectItemFromValue() {
BPA_GOODSRECIPE pf = new BPA_GOODSRECIPE();
try {
String name = hrgx.getSelectedItem().toString();
boolean IsVerify = true;
String description = "";
// 延迟,100|延迟,100|延迟,100|延迟,100|
String data = "";
String desc = "";
if (name.contains("液体料")) {
pf.materialType = 0;
for (int i = 0; i < gxchid.getChildCount(); i++) {
fragment_gx gongxu = (fragment_gx) gxchid.getChildAt(i);
String values = gongxu.GetValues();
if (!values.isEmpty()) {
data += gongxu.model.name + "," + values + "|";
desc += values + ",";
}
}

if (data.isEmpty()) {
IsVerify = false;
description += "物料-不能为空,请勾选一个物料\n";
}
} else {
pf.materialType = 1;
for (int i = 0; i < gxchid.getChildCount(); i++) {
fragment_gx gongxu = (fragment_gx) gxchid.getChildAt(i);
String values = gongxu.GetValues();
if (values.isEmpty()) {
IsVerify = false;
description += gongxu.model.name + "-不能为空\n";
} else {
data += gongxu.model.name + "," + values + "|";
desc += values + ",";
}
}
}
if (IsVerify) {
pf.processname = name;
pf.processms = name + "(" + desc.substring(0, desc.length() - 1) + ")";
pf.processvalue = data.substring(0, data.length() - 1);
return pf;
} else {
ToastUtils.info("数据验证失败,原因:" + description);
return null;
}
} catch (Exception ex) {
return null;
}
}
private void initTopBar() {
mTopBar.setBackgroundColor(ContextCompat.getColor(getContext(), R.color.topbj1));
mTopBar.setTitle("编辑菜谱");
mTopBar.addLeftImageButton(R.mipmap.fanhui, R.id.topbar).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
finish();
}
});
}

/**
* 点击事件
*
* @param view
*/
@OnClick({R.id.add_hrgx, R.id.update_gx, R.id.delete_gx, R.id.shangyi, R.id.xiayi, R.id.caozuomoshi, R.id.shengchengcaipu, R.id.shengchengnewcaipu, R.id.cpfm})
public void onViewClicked(View view) {
switch (view.getId()) {
case R.id.cpfm://菜谱封面
// 跳转到登录页面
Intent intent = new Intent(getContext(), ImageChooseActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
break;
case R.id.add_hrgx://添加工序
BPA_GOODSRECIPE goodsrecipe = GetSelectItemFromValue();
if (goodsrecipe != null) {
if(goodsrecipe.processname.equals("加热"))
{
boolean isfa=false;
for (BPA_GOODSRECIPE item:bpa_goodsrecipes)
{
if(item.processname.equals("搅拌"))
{
isfa=true;
}
}
if(isfa==false)
{
ToastUtils.warning("加热工序之前,必须先添加搅拌工序!");
return;
}
}
bpa_goodsrecipes.add(GetSelectItemFromValue());
gxbz_adapter.notifyDataSetChanged();
}
break;
case R.id.update_gx://修改工序
int index_update = gxbz_adapter.getSelectedPosition();
if (index_update >= 0 && index_update < bpa_goodsrecipes.size()) {
BPA_GOODSRECIPE obj_update = (BPA_GOODSRECIPE) bpa_goodsrecipes.get(index_update);
String selectname = hrgx.getSelectedItem().toString();
if (!obj_update.processname.equals(selectname)) {
ToastUtils.info("请先选择工序!");
return;
}
bpa_goodsrecipes.set(index_update, GetSelectItemFromValue());
gxbz_adapter.notifyDataSetChanged();
ToastUtils.info("修改步骤" + (index_update + 1) + ":" + obj_update.processname + "成功!");
} else {
ToastUtils.info("请先选择工序!");
}
break;
case R.id.delete_gx://删除工序
int index_delete = gxbz_adapter.getSelectedPosition();
if (index_delete >= 0 && index_delete < bpa_goodsrecipes.size()) {
BPA_GOODSRECIPE obj_delete = (BPA_GOODSRECIPE) bpa_goodsrecipes.get(index_delete);
bpa_goodsrecipes.remove(obj_delete);
gxbz_adapter.notifyDataSetChanged();

//移动光标
if (index_delete - 1 >= 0) {
SetSelectPos(index_delete - 1);
}
ToastUtils.info("删除工序" + obj_delete.processname + "成功!");
} else {
ToastUtils.info("请先选择工序!");
}
break;
case R.id.shangyi://上移
int index_up = gxbz_adapter.getSelectedPosition();
;
if (index_up > 0) {
BPA_GOODSRECIPE obj_up = (BPA_GOODSRECIPE) bpa_goodsrecipes.get(index_up);
bpa_goodsrecipes.remove(obj_up);
bpa_goodsrecipes.add(index_up - 1, obj_up);
gxbz_adapter.notifyDataSetChanged();

//移动光标
SetSelectPos(index_up - 1);
} else {
ToastUtils.info("已经最顶部!");
}
break;
case R.id.xiayi://下移
int index_down = gxbz_adapter.getSelectedPosition();
if (index_down < bpa_goodsrecipes.size() - 1 && index_down >= 0) {
BPA_GOODSRECIPE obj_down = (BPA_GOODSRECIPE) bpa_goodsrecipes.get(index_down);
bpa_goodsrecipes.remove(obj_down);
bpa_goodsrecipes.add(index_down + 1, obj_down);
gxbz_adapter.notifyDataSetChanged();

//移动光标
SetSelectPos(index_down + 1);
} else {
ToastUtils.info("已经最底部!");
}
break;
case R.id.caozuomoshi://操作模式
Intent intent1 = new Intent(getContext(), DiyMemoryActivity.class);
intent1.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent1);
break;
case R.id.shengchengnewcaipu:
String name1 = edittext.getText().toString();
if (name1.isEmpty()) {
ToastUtils.info("菜谱名称不能为空!");
return;
} else {
boolean isSucess = QueryDB.GetGoodsIs(name1);
if (isSucess) {
ToastUtils.info("菜谱名称已存在!");
return;
}

if(!IsHotJ())
{
ToastUtils.warning("加热工序之前,必须先添加搅拌工序!");
return;
}

//按钮点击
String title = "生成菜谱操作提示!";
String message = "请问客官确定要生成[" + name1 + "]菜谱吗?";
AlertDialogUtils.showDialog(view.getContext(), title, message, new QMUIDialogAction.ActionListener() {
@Override
public void onClick(QMUIDialog dialog, int index) {
int sc = 60 * 3;
if (!zzsc.getText().toString().isEmpty() && !zzsc.getText().toString().equals("0")) {
sc = Integer.parseInt(zzsc.getText().toString());
}

ArrayList<BPA_GOODS> goods = QueryDB.GetGoodsALL();
BPA_GOODS good1 = new BPA_GOODS();
good1.name = name1;
good1.status = 1;
good1.sort = goods.size() + 1;
good1.maketime = sc;
good1.issc = check.isChecked() ? 1 : 0;
good1.url = good.url;
QueryDB.AddGoods(good1);
for (int k = 0; k < bpa_goodsrecipes.size(); k++) {
BPA_GOODSRECIPE item = bpa_goodsrecipes.get(k);
item.id = java.util.UUID.randomUUID().toString();
item.goodsID = good1.id;
item.sort = k + 1;
QueryDB.AddGoodsSrecipe(item);
}
ToastUtils.info("菜谱复刻成功!");
dialog.dismiss();
MessageManager.getInstance().sendMessage(MessageName.ScGood, "Good");
finish();
}
});

}
break;
case R.id.shengchengcaipu://修改菜谱
String name = edittext.getText().toString();
if (name.isEmpty()) {
ToastUtils.info("菜谱名称不能为空!");
return;
} else {
boolean isSucess = QueryDB.GetGoodsIs(name, good.id);
if (isSucess) {
ToastUtils.info("菜谱名称已存在!");
return;
}
if(!IsHotJ())
{
ToastUtils.warning("加热工序之前,必须先添加搅拌工序!");
return;
}
//按钮点击
String title = "保存菜谱操作提示!";
String message = "请问客官确定要保存[" + name + "]菜谱吗?";
AlertDialogUtils.showDialog(view.getContext(), title, message, new QMUIDialogAction.ActionListener() {
@Override
public void onClick(QMUIDialog dialog, int index) {
int sc = 60 * 3;
if (!zzsc.getText().toString().isEmpty() && !zzsc.getText().toString().equals("0")) {
sc = Integer.parseInt(zzsc.getText().toString());
}
good.maketime = sc;
good.issc = check.isChecked() ? 1 : 0;
good.name = name;
QueryDB.UpdateGoods(good);
ArrayList<BPA_GOODSRECIPE> pe = QueryDB.GetGoodsSrecipeID(good.id);
for (BPA_GOODSRECIPE item : pe) {
QueryDB.DeleteGoodsSrecipe(item);
}
for (int k = 0; k < bpa_goodsrecipes.size(); k++) {
BPA_GOODSRECIPE item = bpa_goodsrecipes.get(k);
item.goodsID = good.id;
item.sort = k + 1;
QueryDB.AddGoodsSrecipe(item);
}
ToastUtils.info("菜谱修改成功!");
dialog.dismiss();
MessageManager.getInstance().sendMessage(MessageName.ScGood, "Good");
finish();
}
});

}
break;
}
}

/**
* 判断数据是否合法
*/
public boolean IsHotJ()
{
int index=1;
int k=0;int j=0;
for(BPA_GOODSRECIPE item:bpa_goodsrecipes)
{
if(item.processname.contains("搅拌") && k==0)
{
k=index;
}

if(item.processname.contains("加热") && j==0)
{
j=index;
}
index++;
}

if(j<k)
{
return false;
}else
{
return true;
}
}

public void SetSelectPos(int index) {
//移动光标
gxbz_adapter.setSelectedPosition(index);
gxbz_adapter.notifyDataSetInvalidated();
}

@Override
public void onDestroy() {
super.onDestroy();
}

@Override
protected boolean canDragBack() {
return false;
}

}

+ 698
- 0
app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/DiyUpdateActivity.java Näytä tiedosto

@@ -0,0 +1,698 @@
package com.bonait.bnframework.modules.home.fragment.from;

import static com.bonait.bnframework.MainApplication.getContext;

import android.content.Intent;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.View;
import android.view.WindowManager;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.Spinner;

import com.bonait.bnframework.R;
import com.bonait.bnframework.common.base.BaseActivity;
import com.bonait.bnframework.common.constant.DataBus;
import com.bonait.bnframework.common.constant.MessageName;
import com.bonait.bnframework.common.db.QueryDB;
import com.bonait.bnframework.common.db.mode.BPA_GOODS;
import com.bonait.bnframework.common.db.mode.BPA_GOODSRECIPE;
import com.bonait.bnframework.common.db.mode.BPA_MATERIAL;
import com.bonait.bnframework.common.db.mode.BPA_PROCESS;
import com.bonait.bnframework.common.db.mode.BPA_PROCESSModel;
import com.bonait.bnframework.common.image.MyBitmapUtils;
import com.bonait.bnframework.common.message.MessageLooper;
import com.bonait.bnframework.common.message.MessageManager;
import com.bonait.bnframework.common.utils.AlertDialogUtils;
import com.bonait.bnframework.common.utils.ToastUtils;
import com.bonait.bnframework.modules.home.adapter.gongxubuzhou_adapter;
import com.bonait.bnframework.modules.home.fragment.mode.fragment_gx;
import com.bonait.bnframework.modules.home.fragment.mode.item_gx;
import com.qmuiteam.qmui.widget.QMUITopBarLayout;
import com.qmuiteam.qmui.widget.dialog.QMUIDialog;
import com.qmuiteam.qmui.widget.dialog.QMUIDialogAction;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class DiyUpdateActivity extends BaseActivity {

@BindView(R.id.topbar)
QMUITopBarLayout mTopBar;
@BindView(R.id.edittext)
EditText edittext;//菜谱名称
@BindView(R.id.cpfm)
ImageView cpfm;//菜谱封面
@BindView(R.id.zzsc)
EditText zzsc;//制作时长
@BindView(R.id.check)
CheckBox check;//默认收藏
// @BindView(R.id.Banner_Main)
// Banner Banner_Main;//轮播图
//用于存放获取的图片
List<Drawable> Banner_list = new ArrayList<>();

@BindView(R.id.hrgx)
Spinner hrgx;//工序
Map<String,String> hrgx_map = new LinkedHashMap<>();
Map<String,Integer> hrgx_map_index = new LinkedHashMap<>();

@BindView(R.id.gxchid)
LinearLayout gxchid;//工序子集

@BindView(R.id.datatab_gxbz)
ListView datatab_gxbz;//工序步骤
public gongxubuzhou_adapter gxbz_adapter=null;
/**
* 工序步骤
*/
public ArrayList<BPA_GOODSRECIPE> bpa_goodsrecipes=new ArrayList<>();

/**
* 是否人工单击
*/
public boolean isUserClicked =false;
/**
* 当前商品
*/
public BPA_GOODS good=null;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_diy_update);
ButterKnife.bind(this);
initTopBar();
initData();
SetGood();
}
private void initData()
{
//1.初始化轮播图
//Drawable_Get(Banner_list);
//2.初始化工序
ArrayList<BPA_PROCESS> data=QueryDB.GetProcessALL();
int i=0;String id="";
for (BPA_PROCESS item:data)
{
hrgx_map.put(item.name,item.id);
hrgx_map_index.put(item.name,i);
if(i==0)
{
id= item.id;
}
i++;
}
ArrayAdapter<String> adapter_kk = new ArrayAdapter<>(getContext(), R.layout.spinner_text_item, new ArrayList<>(hrgx_map.keySet()));
adapter_kk.setDropDownViewResource(R.layout.spinner_dropdown_item);
hrgx.setAdapter(adapter_kk);

hrgx.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
isUserClicked = true;
view.performClick();
return false;
}
});
hrgx.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
if(isUserClicked)//不是用户点击返回
{
String id= hrgx_map.get(hrgx.getSelectedItem().toString());
SelectItemFrom(id);
isUserClicked=false;
}
}
@Override
public void onNothingSelected(AdapterView<?> adapterView) {
}
});
SelectItemFrom(id);
//3.工序步骤
gxbz_adapter = new gongxubuzhou_adapter(getContext(), R.layout.gx_item, (List<BPA_GOODSRECIPE>) bpa_goodsrecipes,null);
datatab_gxbz.setAdapter(gxbz_adapter);
datatab_gxbz.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long l) {
// TODO Auto-generated method stub
gxbz_adapter.setSelectedPosition(position);
gxbz_adapter.notifyDataSetInvalidated();

SetSelectGX(bpa_goodsrecipes.get(position));//单击工序行,显示变量
}
});
//图标选择
MessageManager.getInstance().registerMessageReceiver(this, MessageName.ClickImage, new MessageLooper.OnMessageListener() {
@Override
public void onMessage(Object msg) {
if (msg != null) {
good.url=(String) msg;
new MyBitmapUtils().disPlay(cpfm,good.url);
}
}
});

//图标选择
MessageManager.getInstance().registerMessageReceiver(this, MessageName.DIY, new MessageLooper.OnMessageListener() {
@Override
public void onMessage(Object msg) {
if (msg != null) {
bpa_goodsrecipes.clear();
for(BPA_GOODSRECIPE item: DataBus.getInstance().bpa_goodsrecipes)
{
bpa_goodsrecipes.add(item);
}
zzsc.setText(DataBus.getInstance().TimeOut+"");
gxbz_adapter.notifyDataSetChanged();
}
}
});
}

/**
* 根据选中步骤显示变量
* @param goodsrecipe
*/
public void SetSelectGX(BPA_GOODSRECIPE goodsrecipe)
{
try
{
//1.根据工序名称显示工序集合
hrgx.setSelection(hrgx_map_index.get(goodsrecipe.processname));
String id= hrgx_map.get(hrgx.getSelectedItem().toString());
SelectItemFrom(id);

//2.根据工序变量集合-获取变量名称和值
final HashMap<String,String> formulation=new HashMap<>();
//region 获取变量名称和值
String text=goodsrecipe.processvalue;
List<String> data=new ArrayList<>();
if(text.contains("|"))
{
String[] res= text.split("[|]");
for (int i=0;i<res.length;i++)
{
data.add(res[i]);
}
}else
{
data.add(text);
}
for(String item:data)
{
if(!item.isEmpty() && item.contains(","))
{
String[] wl= item.split("[,]");
if (wl != null && wl.length == 2)
{
String name=wl[0];
String val=wl[1];
formulation.put(name,val);
}
}
}
//endregion

//3.查询子集-填充变量
for (Map.Entry<String, String> entry : formulation.entrySet()) {
String key = entry.getKey();
String value = entry.getValue();
String STR= formulation.get(key);
}

for (int i = 0; i < gxchid.getChildCount(); i++) {
fragment_gx gongxu = (fragment_gx) gxchid.getChildAt(i);
String res= formulation.get(gongxu.model.name);
if(res!=null)
{
gongxu.SetValues(res);
}
}
}catch (Exception ex)
{
}
}
/**
* 设置当前商品
* @param
*/
public void SetGood()
{
try
{
Intent intent = getIntent();
String id = intent.getStringExtra("id");
if(!id.isEmpty())
{
good=QueryDB.GetGoodsId(id);
if(good!=null)
{
bpa_goodsrecipes.clear();
ArrayList<BPA_GOODSRECIPE> goodsrecipes=QueryDB.GetGoodsSrecipeID(good.id);
for (BPA_GOODSRECIPE item :goodsrecipes)
{
bpa_goodsrecipes.add(item);
}
edittext.setText(good.name);
check.setChecked(good.issc==1);
zzsc.setText(good.maketime+"");
gxbz_adapter.notifyDataSetChanged();//刷新商品配方
new MyBitmapUtils().disPlay(cpfm,good.url);
}
}
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
}catch (Exception ex)
{

}
}
/**
* 根据选中工序id显示集合
* @param id
*/
public void SelectItemFrom(String id)
{
try
{
gxchid.removeAllViews();
ArrayList<BPA_PROCESSModel> mode= QueryDB.GetProcessModelProcessID(id);
if(mode.size()>0)//工序
{
for (BPA_PROCESSModel item : mode)
{
item_gx gx=new item_gx();
gx.datatype=item.datatype;
gx.name=item.name;
gx.data=item.data;
gx.IsWL=false;
fragment_gx gongxu=new fragment_gx(this,null,gx);
gxchid.addView(gongxu);
}
}else //物料
{
ArrayList<BPA_MATERIAL> materials= QueryDB.GetMaterialALL();
for (BPA_MATERIAL item2 : materials)
{
item_gx gx=new item_gx();
gx.datatype=0;//液体料都是数字
gx.name=item2.name;
gx.IsWL=true;
fragment_gx gongxu=new fragment_gx(this,null,gx);
gxchid.addView(gongxu);
}
}
}catch (Exception ex)
{
}
}

/**
* 获取选中行的变量
* @return
*/
public BPA_GOODSRECIPE GetSelectItemFromValue()
{
BPA_GOODSRECIPE pf=new BPA_GOODSRECIPE();
try
{
String name= hrgx.getSelectedItem().toString();
boolean IsVerify=true;
String description="";
// 延迟,100|延迟,100|延迟,100|延迟,100|
String data="";
String desc="";
if(name.contains("液体料"))
{
pf.materialType=0;
for (int i = 0; i < gxchid.getChildCount(); i++) {
fragment_gx gongxu = (fragment_gx) gxchid.getChildAt(i);
String values= gongxu.GetValues();
if(!values.isEmpty())
{
data+=gongxu.model.name+","+values+"|";
desc+=values+",";
}
}

if(data.isEmpty())
{
IsVerify=false;
description+="物料-不能为空,请勾选一个物料\n";
}
}else
{
pf.materialType=1;
for (int i = 0; i < gxchid.getChildCount(); i++) {
fragment_gx gongxu = (fragment_gx) gxchid.getChildAt(i);
String values= gongxu.GetValues();
if(values.isEmpty())
{
IsVerify=false;
description+=gongxu.model.name +"-不能为空\n";
}else
{
data+=gongxu.model.name+","+values+"|";
desc+=values+",";
}
}
}
if(IsVerify)
{
pf.processname=name;
pf.processms= name+"("+desc.substring(0,desc.length()-1) +")";
pf.processvalue=data.substring(0,data.length()-1);
return pf;
}else
{
ToastUtils.info("数据验证失败,原因:"+description);
return null;
}
}catch (Exception ex)
{
return null;
}
}
private void initTopBar() {
mTopBar.setTitle("菜谱信息修改");
mTopBar.addLeftImageButton(R.mipmap.fanhui,R.id.topbar).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
finish();
}
});
}
/**
* 获取图片存放到list中
* @param arrayList
*/
private void Drawable_Get(List arrayList) {
//把他们存放到一个list集合中
arrayList.add(getResources().getDrawable(R.mipmap.image1));
arrayList.add(getResources().getDrawable(R.mipmap.image2));
arrayList.add(getResources().getDrawable(R.mipmap.image3));
arrayList.add(getResources().getDrawable(R.mipmap.image4));
//调用轮播图设置方法
Banner_Set(Banner_list);
}
/**
* 将图片存放到轮播图中
* @param arrayList
*/
private void Banner_Set(List arrayList) {
//这是设置轮播图的关键位置,setImages(list) 设置轮播图的图片资源
//setImageLoader(一个实体类)用于加载图片到手机页面上显示
//Banner_Main.setImages(Banner_list).setImageLoader(new MyImage()).start();
}
/**
* 点击事件
* @param view
*/
@OnClick({R.id.add_hrgx,R.id.update_gx,R.id.delete_gx,R.id.shangyi,R.id.xiayi,R.id.caozuomoshi,R.id.shengchengcaipu,R.id.shengchengnewcaipu,R.id.cpfm})
public void onViewClicked(View view) {
switch (view.getId()) {
case R.id.cpfm://菜谱封面
// 跳转到登录页面
Intent intent = new Intent(getContext(), ImageChooseActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
break;
case R.id.add_hrgx://添加工序
BPA_GOODSRECIPE goodsrecipe= GetSelectItemFromValue();
if(goodsrecipe!=null)
{
if(goodsrecipe.processname.equals("加热"))
{
boolean isfa=false;
for (BPA_GOODSRECIPE item:bpa_goodsrecipes)
{
if(item.processname.equals("搅拌"))
{
isfa=true;
}
}
if(isfa==false)
{
ToastUtils.warning("加热工序之前,必须先添加搅拌工序!");
return;
}
}
bpa_goodsrecipes.add(GetSelectItemFromValue());
gxbz_adapter.notifyDataSetChanged();
}
break;
case R.id.update_gx://修改工序
int index_update= gxbz_adapter.getSelectedPosition();
if(index_update>=0 && index_update<bpa_goodsrecipes.size())
{
BPA_GOODSRECIPE obj_update= (BPA_GOODSRECIPE)bpa_goodsrecipes.get(index_update);
String selectname= hrgx.getSelectedItem().toString();
if(!obj_update.processname.equals(selectname))
{
ToastUtils.info("请先选择工序!");
return;
}
bpa_goodsrecipes.set(index_update,GetSelectItemFromValue());
gxbz_adapter.notifyDataSetChanged();
ToastUtils.info("修改步骤"+(index_update+1)+":"+obj_update.processname+"成功!");
}else
{
ToastUtils.info("请先选择工序!");
}
break;
case R.id.delete_gx://删除工序
int index_delete= gxbz_adapter.getSelectedPosition();
if(index_delete>=0 && index_delete<bpa_goodsrecipes.size())
{
BPA_GOODSRECIPE obj_delete= (BPA_GOODSRECIPE)bpa_goodsrecipes.get(index_delete);
bpa_goodsrecipes.remove(obj_delete);
gxbz_adapter.notifyDataSetChanged();

//移动光标
if(index_delete-1>=0)
{
SetSelectPos(index_delete-1);
}
ToastUtils.info("删除工序"+obj_delete.processname+"成功!");
}else
{
ToastUtils.info("请先选择工序!");
}
break;
case R.id.shangyi://上移
int index_up= gxbz_adapter.getSelectedPosition();;
if(index_up>0)
{
BPA_GOODSRECIPE obj_up= (BPA_GOODSRECIPE)bpa_goodsrecipes.get(index_up);
bpa_goodsrecipes.remove(obj_up);
bpa_goodsrecipes.add(index_up-1,obj_up);
gxbz_adapter.notifyDataSetChanged();

//移动光标
SetSelectPos(index_up-1);
}else
{
ToastUtils.info("已经最顶部!");
}
break;
case R.id.xiayi://下移
int index_down= gxbz_adapter.getSelectedPosition();
if(index_down<bpa_goodsrecipes.size()-1 && index_down>=0)
{
BPA_GOODSRECIPE obj_down= (BPA_GOODSRECIPE)bpa_goodsrecipes.get(index_down);
bpa_goodsrecipes.remove(obj_down);
bpa_goodsrecipes.add(index_down+1,obj_down);
gxbz_adapter.notifyDataSetChanged();

//移动光标
SetSelectPos(index_down+1);
}else
{
ToastUtils.info("已经最底部!");
}
break;
case R.id.caozuomoshi://操作模式
Intent intent1 = new Intent(getContext(), DiyMemoryActivity.class);
intent1.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent1);
break;
case R.id.shengchengnewcaipu:
String name1=edittext.getText().toString();
if(name1.isEmpty())
{
ToastUtils.info("菜谱名称不能为空!");
return;
}else
{
boolean isSucess= QueryDB.GetGoodsIs(name1);
if(isSucess)
{
ToastUtils.info("菜谱名称已存在!");
return;
}

if(!IsHotJ())
{
ToastUtils.warning("加热工序之前,必须先添加搅拌工序!");
return;
}

//按钮点击
String title = "生成菜谱操作提示!";
String message = "请问客官确定要生成["+name1+"]菜谱吗?";
AlertDialogUtils.showDialog(view.getContext(), title, message, new QMUIDialogAction.ActionListener() {
@Override
public void onClick(QMUIDialog dialog, int index) {
int sc=60*3;
if(!zzsc.getText().toString().isEmpty() && !zzsc.getText().toString().equals("0"))
{
sc=Integer.parseInt(zzsc.getText().toString());
}

ArrayList<BPA_GOODS> goods=QueryDB.GetGoodsALL();
BPA_GOODS good1=new BPA_GOODS();
good1.name=name1;
good1.status=1;
good1.sort=goods.size()+1;
good1.maketime=sc;
good1.issc=check.isChecked()?1:0;
good1.url=good.url;
QueryDB.AddGoods(good1);
for (int k=0;k<bpa_goodsrecipes.size();k++)
{
BPA_GOODSRECIPE item=bpa_goodsrecipes.get(k);
item.id=java.util.UUID.randomUUID().toString();
item.goodsID=good1.id;
item.sort=k+1;
QueryDB.AddGoodsSrecipe(item);
}
ToastUtils.info("菜谱复刻成功!");
dialog.dismiss();
MessageManager.getInstance().sendMessage(MessageName.ScGood,"Good");
finish();
}
});

}
break;
case R.id.shengchengcaipu://修改菜谱
String name=edittext.getText().toString();
if(name.isEmpty())
{
ToastUtils.info("菜谱名称不能为空!");
return;
}else
{
boolean isSucess= QueryDB.GetGoodsIs(name,good.id);
if(isSucess)
{
ToastUtils.info("菜谱名称已存在!");
return;
}

if(!IsHotJ())
{
ToastUtils.warning("加热工序之前,必须先添加搅拌工序!");
return;
}
//按钮点击
String title = "保存菜谱操作提示!";
String message = "请问客官确定要保存["+name+"]菜谱吗?";
AlertDialogUtils.showDialog(view.getContext(), title, message, new QMUIDialogAction.ActionListener() {
@Override
public void onClick(QMUIDialog dialog, int index) {
int sc=60*3;
if(!zzsc.getText().toString().isEmpty() && !zzsc.getText().toString().equals("0"))
{
sc=Integer.parseInt(zzsc.getText().toString());
}
good.maketime=sc;
good.issc=check.isChecked()?1:0;
good.name=name;
QueryDB.UpdateGoods(good);
ArrayList<BPA_GOODSRECIPE> pe=QueryDB.GetGoodsSrecipeID(good.id);
for (BPA_GOODSRECIPE item:pe)
{
QueryDB.DeleteGoodsSrecipe(item);
}
for (int k=0;k<bpa_goodsrecipes.size();k++)
{
BPA_GOODSRECIPE item=bpa_goodsrecipes.get(k);
item.goodsID=good.id;
item.sort=k+1;
QueryDB.AddGoodsSrecipe(item);
}
ToastUtils.info("菜谱修改成功!");
dialog.dismiss();
MessageManager.getInstance().sendMessage(MessageName.ScGood,"Good");
finish();
}
});

}
break;
}
}

/**
* 判断数据是否合法
*/
public boolean IsHotJ()
{
int index=1;
int k=0;int j=0;
for(BPA_GOODSRECIPE item:bpa_goodsrecipes)
{
if(item.processname.contains("搅拌") && k==0)
{
k=index;
}

if(item.processname.contains("加热") && j==0)
{
j=index;
}
index++;
}

if(j<k)
{
return false;
}else
{
return true;
}
}

public void SetSelectPos(int index)
{
//移动光标
gxbz_adapter.setSelectedPosition(index);
gxbz_adapter.notifyDataSetInvalidated();
}

@Override
public void onDestroy() {
super.onDestroy();
}
@Override
protected boolean canDragBack() {
return false;
}

}

+ 199
- 0
app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/QDListSectionAdapter.java Näytä tiedosto

@@ -0,0 +1,199 @@
package com.bonait.bnframework.modules.home.fragment.mode;


import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;

import com.bonait.bnframework.R;
import com.bonait.bnframework.business.ConfigData;
import com.bonait.bnframework.common.constant.MessageName;
import com.bonait.bnframework.common.db.QueryDB;
import com.bonait.bnframework.common.helper.I.MyClickListener;
import com.bonait.bnframework.common.image.MyBitmapUtils;
import com.bonait.bnframework.common.message.MessageManager;
import com.bonait.bnframework.common.utils.AlertDialogUtils;
import com.bonait.bnframework.common.utils.ToastUtils;
import com.qmuiteam.qmui.widget.dialog.QMUIDialog;
import com.qmuiteam.qmui.widget.dialog.QMUIDialogAction;
import com.qmuiteam.qmui.widget.section.QMUIDefaultStickySectionAdapter;
import com.qmuiteam.qmui.widget.section.QMUISection;

public class QDListSectionAdapter extends QMUIDefaultStickySectionAdapter {
private TextView tvTag ,tvNote,tvAccount,Sc_text,delete_text;

private ImageView ImageUrl;//图片

private ImageView sc_image;//是否收藏

public boolean IsSC=false;

//图标
private MyBitmapUtils myBitmapUtils=new MyBitmapUtils();
/**
* 点击事件
*/
public MyClickListener mListener=null;

@NonNull
@Override
protected ViewHolder onCreateSectionHeaderViewHolder(@NonNull ViewGroup viewGroup) {
return new ViewHolder(new QDSectionHeaderView(viewGroup.getContext()));
}
public QDListSectionAdapter() {
}

@Override
protected void onBindSectionHeader(final ViewHolder holder, final int position, QMUISection section) {

QDSectionHeaderView itemView = (QDSectionHeaderView) holder.itemView;
itemView.render((SectionHeader) section.getHeader(), section.isFold());
//点击事件
itemView.getArrowView().setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
int pos = holder.isForStickyHeader ? position : holder.getAdapterPosition();
toggleFold(pos, false);
}
});
}

@Override
protected void onBindSectionItem(ViewHolder holder, int position, QMUISection section, int itemIndex) {
//获取id
tvTag = holder.itemView.findViewById(R.id.Tag_text);
tvNote = holder.itemView.findViewById(R.id.Note_text);
Sc_text = holder.itemView.findViewById(R.id.Sc_text);
delete_text = holder.itemView.findViewById(R.id.delete_text);
sc_image=holder.itemView.findViewById(R.id.sc_image);//收藏
ImageUrl=holder.itemView.findViewById(R.id.ImageUrl);//图片
//设置文本

String name=((SectionItem)section.getItemAt(itemIndex)).getTag();
IsSC=((SectionItem)section.getItemAt(itemIndex)).getIsSC();
String id= ((SectionItem)section.getItemAt(itemIndex)).getAccount();
String url=((SectionItem)section.getItemAt(itemIndex)).getAddress();
boolean isCloud=((SectionItem)section.getItemAt(itemIndex)).getIsCloud();//是否云端商品
if(isCloud)
{
Sc_text.setText("下载");
delete_text.setVisibility(View.GONE);
sc_image.setVisibility(View.GONE);
if(((SectionItem)section.getItemAt(itemIndex)).getIsdownload())
{
Sc_text.setVisibility(View.GONE);
}
}else
{
Sc_text.setText("上传");
delete_text.setVisibility(View.VISIBLE);
sc_image.setVisibility(View.VISIBLE);
Sc_text.setVisibility(View.VISIBLE);
}
tvTag.setText(name);
tvNote.setText("时间:"+ ((SectionItem)section.getItemAt(itemIndex)).getNote()+"秒");
//设置图片
if(url!=null && !url.isEmpty() &&!url.equals("未知"))
{
myBitmapUtils.disPlay(ImageUrl,url);
}
//ImageUrl.setBackground(holder.itemView.getContext().getResources().getDrawable(R.mipmap.hgr));
//上传按钮点击
Sc_text.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if(isCloud)
{
ConfigData.getInstance().GetGoodProcess(holder.itemView.getContext(),id,true);
}else
{
// ArrayList<BPA_GOODS> goods= QueryDB.GetGoodsALL();
// for (BPA_GOODS good:goods)
// {
// ConfigData.getInstance().UploadGoods(holder.itemView.getContext(),good.id);
// }
ConfigData.getInstance().UploadGoods(holder.itemView.getContext(),id);
}
}
});
//删除按钮点击
delete_text.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
//按钮点击
String title = "删除菜品操作提示!";
String message = "请问客官确定要删除["+name+"]菜品吗?";
AlertDialogUtils.showDialog(holder.itemView.getContext(), title, message, new QMUIDialogAction.ActionListener() {
@Override
public void onClick(QMUIDialog dialog, int index) {
MessageManager.getInstance().sendMessage(MessageName.DeleteGood, ((SectionItem)section.getItemAt(itemIndex)));
dialog.dismiss();
}
});
}
});
SetImage(sc_image,IsSC);
//收藏按钮点击
sc_image.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
IsSC=((SectionItem)section.getItemAt(itemIndex)).getIsSC();
//按钮点击
String title = "收藏菜品操作提示!";
String message = "请问客官确定要["+(IsSC?"取消收藏":"收藏")+"]菜品吗?";
AlertDialogUtils.showDialog(holder.itemView.getContext(), title, message, new QMUIDialogAction.ActionListener() {
@Override
public void onClick(QMUIDialog dialog, int index) {
IsSC=!IsSC;
((SectionItem)section.getItemAt(itemIndex)).SetIsSC(IsSC);
SetImage(sc_image,IsSC);
notifyDataSetChanged();

SectionItem item=((SectionItem)section.getItemAt(itemIndex));
QueryDB.UpdateGoodsSC(item.getAccount(),item.getIsSC()?1:0);
MessageManager.getInstance().sendMessage(MessageName.ScGood,"Good");
dialog.dismiss();
}
});
}
});
//点击查看当前商品信息
ImageUrl.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if(isCloud)
{
ToastUtils.warning("请先下载该商品!");
}else
{
MessageManager.getInstance().sendMessage(MessageName.ClickGood, ((SectionItem)section.getItemAt(itemIndex)));
}
}
});
}

public void SetImage(ImageView image,boolean isxz)
{
if(isxz)
{
image.setImageResource(R.mipmap.sc3);
}else
{
image.setImageResource(R.mipmap.wsc3);
}
}

@NonNull
@Override
protected ViewHolder onCreateSectionItemViewHolder(@NonNull ViewGroup viewGroup) {
Context context = viewGroup.getContext();
//这里是通过xml绑定布局,当然你也可以用代码new出来,方法请看头部视图
View itemView = LayoutInflater.from(context).inflate(R.layout.note_rv_tree_second, viewGroup, false);
return new ViewHolder(itemView);
}
}

+ 62
- 0
app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/QDSectionHeaderView.java Näytä tiedosto

@@ -0,0 +1,62 @@
package com.bonait.bnframework.modules.home.fragment.mode;

import android.content.Context;
import android.graphics.Color;
import android.util.AttributeSet;
import android.view.Gravity;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import androidx.annotation.Nullable;
import androidx.appcompat.widget.AppCompatImageView;

import com.bonait.bnframework.R;
import com.qmuiteam.qmui.util.QMUIDisplayHelper;
import com.qmuiteam.qmui.util.QMUIResHelper;

public class QDSectionHeaderView extends LinearLayout {
private TextView mTitleTv;
private ImageView mArrowView;

private int headerHeight = QMUIDisplayHelper.dp2px(getContext(), 56);

public QDSectionHeaderView(Context context) {
this(context, null);
}

public QDSectionHeaderView(Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
setOrientation(LinearLayout.HORIZONTAL);
setGravity(Gravity.CENTER_VERTICAL);
setBackgroundColor(Color.parseColor("#DEE0E2")); // android:background="@drawable/qmui_list_item_bg_with_border_bottom"
int paddingHor = QMUIDisplayHelper.dp2px(context, 24);
mTitleTv = new TextView(getContext());
mTitleTv.setTextSize(16);
mTitleTv.setTextColor(Color.BLACK);
mTitleTv.setPadding(paddingHor, 10, paddingHor, 0);
addView(mTitleTv, new LayoutParams(
0, ViewGroup.LayoutParams.WRAP_CONTENT, 1f));
mArrowView = new AppCompatImageView(context);
mArrowView.setImageDrawable(QMUIResHelper.getAttrDrawable(getContext(),
R.attr.qmui_common_list_item_chevron));
mArrowView.setScaleType(ImageView.ScaleType.CENTER);
addView(mArrowView, new LayoutParams(headerHeight, headerHeight));
}

public ImageView getArrowView() {
return mArrowView;
}

public void render(SectionHeader header, boolean isFold) {
mTitleTv.setText(header.getText());
mArrowView.setRotation(isFold ? 0f : 90f);
}

@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec,
MeasureSpec.makeMeasureSpec(headerHeight, MeasureSpec.EXACTLY));
}
}

+ 64
- 0
app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/SectionHeader.java Näytä tiedosto

@@ -0,0 +1,64 @@
/*
* Tencent is pleased to support the open source community by making QMUI_Android available.
*
* Copyright (C) 2017-2018 THL A29 Limited, a Tencent company. All rights reserved.
*
* Licensed under the MIT License (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
*
* http://opensource.org/licenses/MIT
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is
* distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the specific language governing permissions and
* limitations under the License.
*/


package com.bonait.bnframework.modules.home.fragment.mode;

import com.qmuiteam.qmui.widget.section.QMUISection;

/**
* 选中头
*/
public class SectionHeader implements QMUISection.Model<SectionHeader> {

private String tvText;
private String tvDate;
private String tvTotalAmount;
public SectionHeader(String name1, String name2, String name3) {
this.tvText = name1;
this.tvDate = name2;
this.tvTotalAmount = name3;
}

public String getText() {
return tvText;
}

public String getDate() {
return tvDate;
}

public String getTotalAmount() {
return tvTotalAmount;
}

@Override

public SectionHeader cloneForDiff() {
return new SectionHeader(getText(), getDate(), getTotalAmount());
}

@Override
public boolean isSameItem(SectionHeader other) {
return tvText == other.tvText || (tvText != null && tvText.equals(other.tvText))
&& tvDate == other.tvDate || (tvDate != null && tvDate.equals(other.tvDate))
&& tvTotalAmount == other.tvTotalAmount || (tvTotalAmount != null && tvTotalAmount.equals(other.tvTotalAmount));
}
@Override
public boolean isSameContent(SectionHeader other) {
return true;
}
}

+ 118
- 0
app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/SectionItem.java Näytä tiedosto

@@ -0,0 +1,118 @@
/*
* Tencent is pleased to support the open source community by making QMUI_Android available.
*
* Copyright (C) 2017-2018 THL A29 Limited, a Tencent company. All rights reserved.
*
* Licensed under the MIT License (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
*
* http://opensource.org/licenses/MIT
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is
* distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the specific language governing permissions and
* limitations under the License.
*/


package com.bonait.bnframework.modules.home.fragment.mode;

import com.qmuiteam.qmui.widget.section.QMUISection;

/**
* 选中Item
*/
public class SectionItem implements QMUISection.Model<SectionItem> {
/**
* 标签
*/
private String tvTag;
/**
* 备注
*/
private String tvNote;
/**
* 金额
*/
private String tvAccount;
/**
* 是否收藏
*/
private Boolean IsSC;
/**
* Url
*/
private String address;

/**
* 数据来源
*/
private Boolean IsCloud;

private Boolean Isdownload;


public SectionItem(String name1, String name2, String name3, String address, boolean isSC, boolean isCloud, boolean isdownload) {
this.tvTag = name1;
this.tvNote = name2;
this.tvAccount = name3;
this.IsSC = isSC;
this.address = address;
this.IsCloud = isCloud;
this.Isdownload=isdownload;
}

public String getTag() {
return tvTag;
}

public String getNote() {
return tvNote;
}

public String getAccount() {
return tvAccount;
}

public Boolean getIsSC() {
return IsSC;
}

public String getAddress() {
return address;
}

public Boolean getIsCloud() {
return IsCloud;
}

public Boolean getIsdownload() {
return Isdownload;
}

public void SetIsSC(boolean isSC) {
this.IsSC = isSC;
}


@Override
public SectionItem cloneForDiff() {
return new SectionItem(getTag(), getNote(), getAccount(), getAddress(), getIsSC(), getIsCloud(),getIsdownload());
}

@Override
public boolean isSameItem(SectionItem other) {
return tvTag == other.tvTag || (tvTag != null && tvTag.equals(other.tvTag))
&& tvNote == other.tvNote || (tvNote != null && tvNote.equals(other.tvNote))
&& IsSC == other.IsSC || (IsSC != null && IsSC.equals(other.IsSC))
&& IsCloud == other.IsCloud || (IsCloud != null && IsCloud.equals(other.IsCloud))
&& Isdownload == other.Isdownload || (Isdownload != null && Isdownload.equals(other.Isdownload))
&& address == other.address || (address != null && address.equals(other.address))
&& tvAccount == other.tvAccount || (tvAccount != null && tvAccount.equals(other.tvAccount));
}

@Override
public boolean isSameContent(SectionItem other) {
return true;
}
}

+ 170
- 0
app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/fragment_gx.java Näytä tiedosto

@@ -0,0 +1,170 @@
package com.bonait.bnframework.modules.home.fragment.mode;

import android.content.Context;
import android.text.InputType;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.Spinner;
import android.widget.TextView;

import androidx.annotation.Nullable;

import com.bonait.bnframework.R;

import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.Map;

import butterknife.BindView;
import butterknife.ButterKnife;

public class fragment_gx extends LinearLayout {
@BindView(R.id.name)
TextView name;
@BindView(R.id.editsp_PF)
Spinner editsp;
Map<String,Integer> editsp_map = new LinkedHashMap<>();
@BindView(R.id.edittextPF)
EditText edittext;
@BindView(R.id.check_PF)
CheckBox check;
private View root;
public item_gx model;
public fragment_gx(Context context, @Nullable AttributeSet attrs,item_gx mode) {
super(context, attrs);
root=LayoutInflater.from(context).inflate(R.layout.fragment_item_gx, this);
ButterKnife.bind(this, root);
model=mode;
Init();
}
public void Init()
{
name.setText(model.name);
if(model.IsWL)
{
check.setVisibility(View.VISIBLE);
}else
{
check.setVisibility(View.GONE);
}
check.setChecked(false);
switch (model.datatype)
{
case 0://数字
editsp.setVisibility(View.GONE);
edittext.setVisibility(View.VISIBLE);
if(model.IsWL)
{
edittext.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL);
}else
{
edittext.setInputType(InputType.TYPE_CLASS_NUMBER);
}
edittext.setText("0".toCharArray(), 0, "0".length());
break;
case 1://字符串
editsp.setVisibility(View.GONE);
edittext.setVisibility(View.VISIBLE);
edittext.setInputType(InputType.TYPE_CLASS_TEXT);
break;
case 2://选项
editsp.setVisibility(View.VISIBLE);
edittext.setVisibility(View.VISIBLE);
if(!model.data.isEmpty() && model.data.contains("、"))
{
String[] res = model.data.split("[、]");
int index=1;
for (String item: res)
{
editsp_map.put(item,index);
index++;
}
}else
{
editsp_map.put(model.data,1);
}
ArrayAdapter<String> adapter2 = new ArrayAdapter<>(getContext(), R.layout.spinner_text_item, new ArrayList<>(editsp_map.keySet()));
adapter2.setDropDownViewResource(R.layout.spinner_dropdown_item);
editsp.setAdapter(adapter2);
break;
}
}
/**
* 获取选择变量
* @return
*/
public String GetValues()
{
String ResStu="";
switch (model.datatype)
{
case 0://数字
String text= edittext.getText().toString();
if(text.isEmpty())
{
text="0";
}

if(model.IsWL)
{
double val=Double.parseDouble(text);
if(check.isChecked())
{
ResStu=String.format("%.1f", val);
}
}else
{
int val=Integer.parseInt(text);
ResStu=String.valueOf(val);
}
break;
case 1://字符串
if(model.IsWL)
{
if(check.isChecked())
{
ResStu=edittext.getText().toString();
}
}else
{
ResStu=edittext.getText().toString();
}
break;
case 2://选项
ResStu=editsp.getSelectedItem().toString();
break;
}
return ResStu;
}

/**
* 设置变量
* @param value
*/
public void SetValues(String value)
{
switch (model.datatype)
{
case 0://数字
case 1://字符串
edittext.setText(value);
if(model.IsWL)
{
check.setChecked(true);
}
break;
case 2://选项
Object res= editsp_map.get(value);
if(res!=null)
{
editsp.setSelection((int)res-1);
}
break;
}
}
}

+ 266
- 0
app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/huoli_control.java Näytä tiedosto

@@ -0,0 +1,266 @@
package com.bonait.bnframework.modules.home.fragment.mode;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;

import androidx.annotation.Nullable;

import com.bonait.bnframework.R;
import com.bonait.bnframework.business.ExecuteTheRecipe;
import com.bonait.bnframework.common.constant.ConfigName;
import com.bonait.bnframework.common.helper.I.MyClickListener;
import com.bonait.bnframework.common.utils.ToastUtils;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class huoli_control extends LinearLayout {
@BindView(R.id.colse)
ImageView colse;
@BindView(R.id.hl1)
ImageView hl1;
@BindView(R.id.hl2)
ImageView hl2;
@BindView(R.id.hl3)
ImageView hl3;
@BindView(R.id.hl4)
ImageView hl4;
@BindView(R.id.hl5)
ImageView hl5;
@BindView(R.id.hl6)
ImageView hl6;
@BindView(R.id.hl7)
ImageView hl7;
@BindView(R.id.hl8)
ImageView hl8;

List<ImageView> ImageViews=new ArrayList<>();
/**
* 当前状态
*/
public boolean Status=false;
/**
* 当前火力级别
*/
public int level=0;
/**
* 点击事件
*/
public MyClickListener mListener=null;
private View root;

public huoli_control(Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
root=LayoutInflater.from(context).inflate(R.layout.item_huolikongzhi, this);
ButterKnife.bind(this, root);
Init();
}

public void Init()
{
ImageViews.add(hl1);
ImageViews.add(hl2);
ImageViews.add(hl3);
ImageViews.add(hl4);
ImageViews.add(hl5);
ImageViews.add(hl6);
ImageViews.add(hl7);
ImageViews.add(hl8);
if(ConfigName.getInstance().HeatingGear.get(ConfigName.getInstance().HuoLi)!=null)
{
int k= ConfigName.getInstance().HeatingGear.get(ConfigName.getInstance().HuoLi);
for (int i = 0; i<ImageViews.size(); i++)
{
if((i)>(k-1))
{
ImageViews.get(i).setVisibility(View.GONE);
}
}
}

//设置 关闭
SetLevel(0);
}

@OnClick({R.id.colse,
R.id.hl1, R.id.hl2, R.id.hl3, R.id.hl4, R.id.hl5, R.id.hl6, R.id.hl7, R.id.hl8})
public void onViewClicked(View view) {
if (view.getId()!= R.id.colse)
{
Object OBJ = ExecuteTheRecipe.getListingValue("搅拌");
if (!(OBJ != null && (boolean) OBJ)) {
ToastUtils.warning("请先打开搅拌!");
return;
}
}
switch (view.getId()) {
case R.id.colse://选择菜谱按钮点击
if(Status)
{
SetLevel(0);
}else
{
SetLevel(1);
}
break;
case R.id.hl1:
SetLevel(1);
break;
case R.id.hl2:
SetLevel(2);
break;
case R.id.hl3:
SetLevel(3);
break;
case R.id.hl4:
SetLevel(4);
break;
case R.id.hl5:
SetLevel(5);
break;
case R.id.hl6:
SetLevel(6);
break;
case R.id.hl7:
SetLevel(7);
break;
case R.id.hl8:
SetLevel(8);
break;
}

if(mListener!=null)
{
mListener.clickListener(root,level);
}
}

/**
* 设置级别
* @param value
*/
public void SetLevel(int value)
{
level=value;
if(value==1)
{
Status=true;
colse.setImageResource(R.mipmap.kaiji);
hl1.setImageResource(R.mipmap.hlqd);
hl2.setImageResource(R.mipmap.hlwqd);
hl3.setImageResource(R.mipmap.hlwqd);
hl4.setImageResource(R.mipmap.hlwqd);
hl5.setImageResource(R.mipmap.hlwqd);
hl6.setImageResource(R.mipmap.hlwqd);
hl7.setImageResource(R.mipmap.hlwqd);
hl8.setImageResource(R.mipmap.hlwqd);
}else if(value==2)
{
Status=true;
colse.setImageResource(R.mipmap.kaiji);
hl1.setImageResource(R.mipmap.hlqd);
hl2.setImageResource(R.mipmap.hlqd);
hl3.setImageResource(R.mipmap.hlwqd);
hl4.setImageResource(R.mipmap.hlwqd);
hl5.setImageResource(R.mipmap.hlwqd);
hl6.setImageResource(R.mipmap.hlwqd);
hl7.setImageResource(R.mipmap.hlwqd);
hl8.setImageResource(R.mipmap.hlwqd);
}else if(value==3)
{
Status=true;
colse.setImageResource(R.mipmap.kaiji);
hl1.setImageResource(R.mipmap.hlqd);
hl2.setImageResource(R.mipmap.hlqd);
hl3.setImageResource(R.mipmap.hlqd);
hl4.setImageResource(R.mipmap.hlwqd);
hl5.setImageResource(R.mipmap.hlwqd);
hl6.setImageResource(R.mipmap.hlwqd);
hl7.setImageResource(R.mipmap.hlwqd);
hl8.setImageResource(R.mipmap.hlwqd);
}else if(value==4)
{
Status=true;
colse.setImageResource(R.mipmap.kaiji);
hl1.setImageResource(R.mipmap.hlqd);
hl2.setImageResource(R.mipmap.hlqd);
hl3.setImageResource(R.mipmap.hlqd);
hl4.setImageResource(R.mipmap.hlqd);
hl5.setImageResource(R.mipmap.hlwqd);
hl6.setImageResource(R.mipmap.hlwqd);
hl7.setImageResource(R.mipmap.hlwqd);
hl8.setImageResource(R.mipmap.hlwqd);
}else if(value==5)
{
Status=true;
colse.setImageResource(R.mipmap.kaiji);
hl1.setImageResource(R.mipmap.hlqd);
hl2.setImageResource(R.mipmap.hlqd);
hl3.setImageResource(R.mipmap.hlqd);
hl4.setImageResource(R.mipmap.hlqd);
hl5.setImageResource(R.mipmap.hlqd);
hl6.setImageResource(R.mipmap.hlwqd);
hl7.setImageResource(R.mipmap.hlwqd);
hl8.setImageResource(R.mipmap.hlwqd);
}
else if(value==6)
{
Status=true;
colse.setImageResource(R.mipmap.kaiji);
hl1.setImageResource(R.mipmap.hlqd);
hl2.setImageResource(R.mipmap.hlqd);
hl3.setImageResource(R.mipmap.hlqd);
hl4.setImageResource(R.mipmap.hlqd);
hl5.setImageResource(R.mipmap.hlqd);
hl6.setImageResource(R.mipmap.hlqd);
hl7.setImageResource(R.mipmap.hlwqd);
hl8.setImageResource(R.mipmap.hlwqd);
}
else if(value==7)
{
Status=true;
colse.setImageResource(R.mipmap.kaiji);
hl1.setImageResource(R.mipmap.hlqd);
hl2.setImageResource(R.mipmap.hlqd);
hl3.setImageResource(R.mipmap.hlqd);
hl4.setImageResource(R.mipmap.hlqd);
hl5.setImageResource(R.mipmap.hlqd);
hl6.setImageResource(R.mipmap.hlqd);
hl7.setImageResource(R.mipmap.hlqd);
hl8.setImageResource(R.mipmap.hlwqd);
}
else if(value==8)
{
Status=true;
colse.setImageResource(R.mipmap.kaiji);
hl1.setImageResource(R.mipmap.hlqd);
hl2.setImageResource(R.mipmap.hlqd);
hl3.setImageResource(R.mipmap.hlqd);
hl4.setImageResource(R.mipmap.hlqd);
hl5.setImageResource(R.mipmap.hlqd);
hl6.setImageResource(R.mipmap.hlqd);
hl7.setImageResource(R.mipmap.hlqd);
hl8.setImageResource(R.mipmap.hlqd);
}else
{
Status=false;
colse.setImageResource(R.mipmap.guangji);
hl1.setImageResource(R.mipmap.hlwqd);
hl2.setImageResource(R.mipmap.hlwqd);
hl3.setImageResource(R.mipmap.hlwqd);
hl4.setImageResource(R.mipmap.hlwqd);
hl5.setImageResource(R.mipmap.hlwqd);
hl6.setImageResource(R.mipmap.hlwqd);
hl7.setImageResource(R.mipmap.hlwqd);
hl8.setImageResource(R.mipmap.hlwqd);
}
}
}

+ 12
- 0
app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/item_gx.java Näytä tiedosto

@@ -0,0 +1,12 @@
package com.bonait.bnframework.modules.home.fragment.mode;

public class item_gx {
public String name;
public int datatype;
/**
* 数据集合 [停止、一档、二档、三档、四档、五档]
*/
public String data;

public boolean IsWL=false;
}

+ 13
- 0
app/src/main/res/drawable/input_bj1.xml Näytä tiedosto

@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>

<!-- 在Topbar下方的Tab面板的背景,带底部分割线 -->
<inset xmlns:android="http://schemas.android.com/apk/res/android"
>
<shape>
<solid android:color="#c6d7ed" />
<corners android:radius="10dp" />
<stroke
android:width="1dp"
android:color="#c6d7ed" />
</shape>
</inset>

+ 27
- 0
app/src/main/res/layout/activity_cp.xml Näytä tiedosto

@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<com.qmuiteam.qmui.widget.QMUIWindowInsetLayout 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:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".modules.home.fragment.from.CpActivity">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="?attr/qmui_topbar_height"
android:background="@color/activity_background">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<com.qmuiteam.qmui.widget.section.QMUIStickySectionLayout
android:id="@+id/qmuisection_layout"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</RelativeLayout>
</ScrollView>
<com.qmuiteam.qmui.widget.QMUITopBarLayout
android:id="@+id/topbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/app_color_blue" />
</com.qmuiteam.qmui.widget.QMUIWindowInsetLayout>

+ 318
- 0
app/src/main/res/layout/activity_diy.xml Näytä tiedosto

@@ -0,0 +1,318 @@
<?xml version="1.0" encoding="utf-8"?>
<com.qmuiteam.qmui.widget.QMUIWindowInsetLayout 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:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".modules.home.fragment.from.DiyActivity"
android:orientation="vertical"
android:background="@color/app_color_blue"
android:fitsSystemWindows="true"
app:qmui_skin_background="?attr/app_skin_common_background">

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="?attr/qmui_topbar_height"
android:background="@color/qmui_config_color_white">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_marginLeft="30dp"
android:layout_marginRight="30dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
>
<LinearLayout
android:layout_marginTop="@dimen/dp_10"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@color/color1">

<ImageView
android:id="@+id/cpfm"
android:layout_width="160dp"
android:layout_height="100dp"
android:layout_marginStart="3dp"
android:layout_marginTop="3dp"
android:layout_marginEnd="3dp"
android:layout_marginBottom="3dp"
android:src="@mipmap/loading3" />
</RelativeLayout>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAlignment="center"
android:text="菜谱封面"/>
</LinearLayout>

<LinearLayout
android:layout_marginLeft="@dimen/dp_40"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_marginTop="@dimen/dp_10"
android:layout_marginBottom="12dp"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.qmuiteam.qmui.widget.textview.QMUILinkTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="菜谱名称:"/>
<!--账号输入框-->
<EditText
android:id="@+id/edittext"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:background="@drawable/input_bj"
android:hint="请输入菜谱名称"
android:inputType="text"
android:maxLines="1"
android:padding="3dp"
android:textSize="12dp" />
</LinearLayout>
<LinearLayout
android:layout_marginBottom="12dp"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.qmuiteam.qmui.widget.textview.QMUILinkTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="制作时长:"/>
<!--账号输入框-->
<EditText
android:id="@+id/zzsc"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:background="@drawable/input_bj"
android:hint="请输入制作时长"
android:inputType="number"
android:maxLines="1"
android:padding="3dp"
android:textSize="12dp"
android:text="0"/>
</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<CheckBox
android:layout_marginLeft="70dp"
android:id="@+id/check"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:buttonTint="@color/radiusImageView_selected_mask_color"
android:text="默认收藏"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
<!--边框分割细线-->
<LinearLayout
android:layout_alignParentBottom="true"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginBottom="@dimen/dp_10"
android:background="@color/color3" />
<LinearLayout android:layout_width="match_parent"
android:layout_height="400dp">
<RelativeLayout
android:layout_width="160dp"
android:layout_height="wrap_content">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<com.qmuiteam.qmui.widget.textview.QMUILinkTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="步骤:"/>
<Button
android:id="@+id/shangyi"
android:layout_width="50dp"
android:layout_height="26dp"
android:background="@drawable/button"
android:text="上移"
android:textColor="@color/black"
android:textSize="14dp"/>
<Button
android:id="@+id/xiayi"
android:layout_marginLeft="@dimen/dp_10"
android:layout_width="50dp"
android:layout_height="26dp"
android:background="@drawable/button"
android:text="下移"
android:textColor="@color/black"
android:textSize="14dp"/>
</LinearLayout>
<ListView
android:id="@+id/datatab_gxbz"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:divider="#00000000"
android:layout_marginTop="10dp"
android:layout_marginBottom="@dimen/dp_40"
android:dividerHeight="3dp" />
</LinearLayout>

<Button
android:id="@+id/caozuomoshi"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"
android:layout_width="wrap_content"
android:layout_height="26dp"
android:background="@drawable/button1"
android:text="操作模式"
android:textColor="@color/black"
android:textSize="14dp"/>
</RelativeLayout>

<RelativeLayout
android:layout_marginLeft="@dimen/dp_10"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<!--边框分割细线-->
<RelativeLayout
android:layout_alignParentLeft="true"
android:layout_width="@dimen/dp_10"
android:layout_height="match_parent">

<LinearLayout
android:layout_width="1dp"
android:layout_height="match_parent"
android:layout_centerInParent="true"
android:layout_marginTop="@dimen/dp_40"
android:layout_marginBottom="@dimen/dp_40"
android:background="@color/color3" />
</RelativeLayout>

<LinearLayout
android:layout_marginLeft="@dimen/dp_10"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="烹饪工序:"/>
<Spinner
android:id="@+id/hrgx"
style="@style/commonSpinnerStyle"
android:layout_width="match_parent"
android:layout_height="24dp"
android:layout_centerVertical="true"
/>
</LinearLayout>

<ScrollView
android:layout_width="match_parent"
android:layout_marginBottom="40dp"
android:layout_marginTop="20dp"
android:layout_height="match_parent">
<LinearLayout
android:id="@+id/gxchid"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
</LinearLayout>
</ScrollView>

</LinearLayout>

<LinearLayout
android:layout_marginTop="@dimen/dp_10"
android:layout_marginLeft="@dimen/dp_10"
android:layout_alignParentBottom="true"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Button
android:id="@+id/add_hrgx"
android:layout_width="50dp"
android:layout_height="26dp"
android:background="@drawable/button1"
android:text="添加"
android:textColor="@color/black"
android:textSize="14dp"/>
<Button
android:id="@+id/update_gx"
android:layout_marginLeft="@dimen/dp_10"
android:layout_width="50dp"
android:layout_height="26dp"
android:background="@drawable/button"
android:text="修改"
android:textColor="@color/black"
android:textSize="14dp"/>
<Button
android:id="@+id/delete_gx"
android:layout_marginLeft="@dimen/dp_10"
android:layout_width="50dp"
android:layout_height="26dp"
android:background="@drawable/button"
android:text="删除"
android:textColor="@color/black"
android:textSize="14dp"/>
</LinearLayout>
</RelativeLayout>

</LinearLayout>
<RelativeLayout
android:layout_marginTop="30dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="30dp">
<Button
android:id="@+id/shengchengcaipu"
android:layout_width="match_parent"
android:layout_height="45dp"
android:background="@drawable/bg_btn_login_selected"
android:text="生成菜谱"
android:textColor="@color/white"
android:textSize="18sp"/>
</RelativeLayout>
</LinearLayout>
</ScrollView>
<!-- <RelativeLayout-->
<!-- android:layout_alignParentBottom="true"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout_marginLeft="10dp"-->
<!-- android:layout_marginRight="10dp">-->
<!-- <com.youth.banner.Banner-->
<!-- android:id="@+id/Banner_Main"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="160dp"-->
<!-- android:layout_gravity="center"-->
<!-- app:image_scale_type="fit_xy"-->
<!-- app:indicator_height="10dp"-->
<!-- app:indicator_margin="5dp"-->
<!-- app:indicator_width="10dp" />-->
<!-- </RelativeLayout>-->
</RelativeLayout>

<com.qmuiteam.qmui.widget.QMUITopBarLayout
android:id="@+id/topbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/app_color_blue"/>
</com.qmuiteam.qmui.widget.QMUIWindowInsetLayout>

+ 332
- 0
app/src/main/res/layout/activity_diy_update.xml Näytä tiedosto

@@ -0,0 +1,332 @@
<?xml version="1.0" encoding="utf-8"?>
<com.qmuiteam.qmui.widget.QMUIWindowInsetLayout 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:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".modules.home.fragment.from.DiyUpdateActivity"
android:orientation="vertical"
android:background="@color/app_color_blue"
android:fitsSystemWindows="true">

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="?attr/qmui_topbar_height"
android:background="@color/qmui_config_color_white">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_marginLeft="30dp"
android:layout_marginRight="30dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_marginTop="@dimen/dp_10"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@color/color1">

<ImageView
android:id="@+id/cpfm"
android:layout_width="160dp"
android:layout_height="100dp"
android:layout_marginStart="3dp"
android:layout_marginTop="3dp"
android:layout_marginEnd="3dp"
android:layout_marginBottom="3dp"
android:src="@mipmap/loading3" />
</RelativeLayout>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAlignment="center"
android:text="菜谱封面"/>
</LinearLayout>

<LinearLayout
android:layout_marginLeft="@dimen/dp_40"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_marginTop="@dimen/dp_10"
android:layout_marginBottom="12dp"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.qmuiteam.qmui.widget.textview.QMUILinkTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="菜谱名称:"/>
<!--账号输入框-->
<EditText
android:id="@+id/edittext"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:background="@drawable/input_bj"
android:hint="请输入菜谱名称"
android:inputType="text"
android:maxLines="1"
android:padding="3dp"
android:textSize="12dp" />
</LinearLayout>
<LinearLayout
android:layout_marginBottom="12dp"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.qmuiteam.qmui.widget.textview.QMUILinkTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="制作时长:"/>
<!--账号输入框-->
<EditText
android:id="@+id/zzsc"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:background="@drawable/input_bj"
android:hint="请输入制作时长"
android:inputType="number"
android:maxLines="1"
android:padding="3dp"
android:textSize="12dp"
android:text="0"/>
</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<CheckBox
android:layout_marginLeft="70dp"
android:id="@+id/check"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:buttonTint="@color/radiusImageView_selected_mask_color"
android:text="默认收藏"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
<!--边框分割细线-->
<LinearLayout
android:layout_alignParentBottom="true"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginBottom="@dimen/dp_10"
android:background="@color/color3" />
<LinearLayout android:layout_width="match_parent"
android:layout_height="400dp">
<RelativeLayout
android:layout_width="160dp"
android:layout_height="wrap_content">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<com.qmuiteam.qmui.widget.textview.QMUILinkTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="步骤:"/>
<Button
android:id="@+id/shangyi"
android:layout_width="50dp"
android:layout_height="26dp"
android:background="@drawable/button"
android:text="上移"
android:textColor="@color/black"
android:textSize="14dp"/>
<Button
android:id="@+id/xiayi"
android:layout_marginLeft="@dimen/dp_10"
android:layout_width="50dp"
android:layout_height="26dp"
android:background="@drawable/button"
android:text="下移"
android:textColor="@color/black"
android:textSize="14dp"/>
</LinearLayout>
<ListView
android:id="@+id/datatab_gxbz"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:divider="#00000000"
android:layout_marginTop="10dp"
android:layout_marginBottom="@dimen/dp_40"
android:dividerHeight="3dp" />
</LinearLayout>

<Button
android:id="@+id/caozuomoshi"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"
android:layout_width="wrap_content"
android:layout_height="26dp"
android:background="@drawable/button1"
android:text="操作模式"
android:textColor="@color/black"
android:textSize="14dp"/>
</RelativeLayout>

<RelativeLayout
android:layout_marginLeft="@dimen/dp_10"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<!--边框分割细线-->
<RelativeLayout
android:layout_alignParentLeft="true"
android:layout_width="@dimen/dp_10"
android:layout_height="match_parent">

<LinearLayout
android:layout_width="1dp"
android:layout_height="match_parent"
android:layout_centerInParent="true"
android:layout_marginTop="@dimen/dp_40"
android:layout_marginBottom="@dimen/dp_40"
android:background="@color/color3" />
</RelativeLayout>

<LinearLayout
android:layout_marginLeft="@dimen/dp_10"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="烹饪工序:"/>
<Spinner
android:id="@+id/hrgx"
style="@style/commonSpinnerStyle"
android:layout_width="match_parent"
android:layout_height="24dp"
android:layout_centerVertical="true"
/>
</LinearLayout>

<ScrollView
android:layout_width="match_parent"
android:layout_marginBottom="40dp"
android:layout_marginTop="20dp"
android:layout_height="match_parent">
<LinearLayout
android:id="@+id/gxchid"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
</LinearLayout>
</ScrollView>

</LinearLayout>

<LinearLayout
android:layout_marginTop="@dimen/dp_10"
android:layout_marginLeft="@dimen/dp_10"
android:layout_alignParentBottom="true"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Button
android:id="@+id/add_hrgx"
android:layout_width="50dp"
android:layout_height="26dp"
android:background="@drawable/button1"
android:text="添加"
android:textColor="@color/black"
android:textSize="14dp"/>
<Button
android:id="@+id/update_gx"
android:layout_marginLeft="@dimen/dp_10"
android:layout_width="50dp"
android:layout_height="26dp"
android:background="@drawable/button"
android:text="修改"
android:textColor="@color/black"
android:textSize="14dp"/>
<Button
android:id="@+id/delete_gx"
android:layout_marginLeft="@dimen/dp_10"
android:layout_width="50dp"
android:layout_height="26dp"
android:background="@drawable/button"
android:text="删除"
android:textColor="@color/black"
android:textSize="14dp"/>
</LinearLayout>
</RelativeLayout>

</LinearLayout>
<RelativeLayout
android:layout_marginTop="30dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="30dp">
<LinearLayout
android:layout_centerHorizontal="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<Button
android:id="@+id/shengchengcaipu"
android:layout_width="160dp"
android:layout_height="45dp"
android:background="@drawable/bg_btn_login_selected"
android:text="修改菜谱"
android:textColor="@color/white"
android:textSize="18sp"/>
<Button
android:layout_marginLeft="@dimen/dp_40"
android:id="@+id/shengchengnewcaipu"
android:layout_width="160dp"
android:layout_height="45dp"
android:background="@drawable/bg_btn_login_selected"
android:text="生成新菜谱"
android:textColor="@color/white"
android:textSize="18sp"/>
</LinearLayout>

</RelativeLayout>
</LinearLayout>
</ScrollView>
<!-- <RelativeLayout-->
<!-- android:layout_alignParentBottom="true"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout_marginLeft="10dp"-->
<!-- android:layout_marginRight="10dp">-->
<!-- <com.youth.banner.Banner-->
<!-- android:id="@+id/Banner_Main"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="160dp"-->
<!-- android:layout_gravity="center"-->
<!-- app:image_scale_type="fit_xy"-->
<!-- app:indicator_height="10dp"-->
<!-- app:indicator_margin="5dp"-->
<!-- app:indicator_width="10dp" />-->
<!-- </RelativeLayout>-->
</RelativeLayout>

<com.qmuiteam.qmui.widget.QMUITopBarLayout
android:id="@+id/topbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/app_color_blue"/>
</com.qmuiteam.qmui.widget.QMUIWindowInsetLayout>

+ 343
- 0
app/src/main/res/layout/activity_diy_update1.xml Näytä tiedosto

@@ -0,0 +1,343 @@
<?xml version="1.0" encoding="utf-8"?>
<com.qmuiteam.qmui.widget.QMUIWindowInsetLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/topbj1"
android:fitsSystemWindows="true"
android:orientation="vertical"
tools:context=".modules.home.fragment.from.DiyUpdate1Activity">

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="?attr/qmui_topbar_height"
android:background="@color/qmui_config_color_white">

<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="30dp"
android:layout_marginRight="30dp"
android:orientation="vertical">

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_10"
android:orientation="horizontal">

<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:orientation="vertical">

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">

<!-- <com.bonait.bnframework.common.view.RoundCornerImageView-->
<!-- android:id="@+id/cpfm"-->
<!-- android:layout_width="150dp"-->
<!-- android:layout_height="150dp"-->
<!-- android:background="@drawable/border1"-->
<!-- android:scaleType="centerCrop"-->
<!-- android:src="@mipmap/image3"-->
<!-- android:layout_centerInParent="true"/>-->
<com.bonait.bnframework.common.view.CircleImageView
android:id="@+id/cpfm"
android:layout_width="150dp"
android:layout_height="150dp"
android:layout_centerInParent="true"
android:scaleType="centerCrop"
android:src="@mipmap/image3" />


</RelativeLayout>

<EditText
android:id="@+id/edittext"
android:layout_width="300dp"
android:layout_height="50dp"
android:layout_marginLeft="5dp"
android:layout_marginTop="@dimen/dp_10"
android:layout_marginBottom="@dimen/dp_10"
android:background="@drawable/input_bj1"
android:hint="请输入菜谱名称"
android:inputType="text"
android:lines="1"
android:padding="3dp"
android:textSize="19dp" />
</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="@dimen/dp_40"
android:orientation="vertical"
android:visibility="gone">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_10"
android:layout_marginBottom="12dp">

<com.qmuiteam.qmui.widget.textview.QMUILinkTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="菜谱名称:" />
<!--账号输入框-->
</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="12dp">

<com.qmuiteam.qmui.widget.textview.QMUILinkTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="制作时长:" />
<!--账号输入框-->
<EditText
android:id="@+id/zzsc"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:background="@drawable/input_bj"
android:hint="请输入制作时长"
android:inputType="number"
android:maxLines="1"
android:padding="3dp"
android:text="0"
android:textSize="12dp" />
</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">

<CheckBox
android:id="@+id/check"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="70dp"
android:buttonTint="@color/radiusImageView_selected_mask_color"
android:text="默认收藏" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>
<!--边框分割细线-->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_alignParentBottom="true"
android:layout_marginBottom="@dimen/dp_10"
android:background="@color/color3" />

<LinearLayout
android:layout_width="match_parent"
android:layout_height="400dp">

<RelativeLayout
android:layout_width="200dp"
android:layout_height="wrap_content">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">

<com.qmuiteam.qmui.widget.textview.QMUILinkTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="步骤:"
android:textColor="#567722"
android:textSize="19dp" />

<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true">

<ImageView
android:id="@+id/shangyi"
android:layout_width="35dp"
android:layout_height="35dp"
android:src="@mipmap/ll5" />

<ImageView
android:id="@+id/xiayi"
android:layout_width="35dp"
android:layout_height="35dp"
android:layout_marginLeft="15dp"
android:src="@mipmap/ll6" />
</LinearLayout>

</RelativeLayout>

<ListView
android:id="@+id/datatab_gxbz"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="10dp"
android:layout_marginBottom="50dp"
android:divider="#00000000"
android:dividerHeight="3dp" />
</LinearLayout>

<ImageView
android:visibility="gone"
android:id="@+id/caozuomoshi"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:src="@mipmap/ll4" />
</RelativeLayout>

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_10">
<!--边框分割细线-->
<RelativeLayout
android:layout_width="@dimen/dp_10"
android:layout_height="match_parent"
android:layout_alignParentLeft="true">

<LinearLayout
android:layout_width="1dp"
android:layout_height="match_parent"
android:layout_centerInParent="true"
android:layout_marginTop="@dimen/dp_40"
android:layout_marginBottom="@dimen/dp_40"
android:background="@color/color3" />
</RelativeLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="@dimen/dp_10"
android:orientation="vertical">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="烹饪工序:"
android:textColor="#BEAA6A"
android:textSize="19dp" />

<Spinner
android:id="@+id/hrgx"
style="@style/commonSpinnerStyle"
android:layout_width="match_parent"
android:layout_height="30dp"
android:layout_centerVertical="true" />
</LinearLayout>

<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="20dp"
android:layout_marginBottom="50dp">

<LinearLayout
android:id="@+id/gxchid"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"></LinearLayout>
</ScrollView>

</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginLeft="@dimen/dp_10"
android:layout_marginTop="@dimen/dp_10">

<ImageView
android:id="@+id/add_hrgx"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@mipmap/ll3" />

<ImageView
android:id="@+id/update_gx"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:src="@mipmap/ll2" />

<ImageView
android:id="@+id/delete_gx"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:src="@mipmap/ll1" />
</LinearLayout>
</RelativeLayout>

</LinearLayout>

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="30dp"
android:layout_marginBottom="30dp">

<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:orientation="horizontal">

<Button
android:id="@+id/shengchengcaipu"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@mipmap/xgcp1"
android:textColor="@color/white"
android:textSize="18sp" />

<Button
android:id="@+id/shengchengnewcaipu"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_40"
android:background="@mipmap/scxcp1"
android:textColor="@color/white"
android:textSize="18sp" />
</LinearLayout>

</RelativeLayout>
</LinearLayout>
</ScrollView>
</RelativeLayout>

<com.qmuiteam.qmui.widget.QMUITopBarLayout
android:id="@+id/topbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/app_color_blue" />
</com.qmuiteam.qmui.widget.QMUIWindowInsetLayout>

+ 115
- 0
app/src/main/res/layout/item/layout/item_huolikongzhi.xml Näytä tiedosto

@@ -0,0 +1,115 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
tools:ignore="MissingDefaultResource">
<RelativeLayout
android:layout_marginLeft="@dimen/dp_10"
android:layout_width="wrap_content"
android:layout_height="match_parent">
<ImageView
android:id="@+id/colse"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:src="@mipmap/guangji"/>
</RelativeLayout>

<RelativeLayout
android:layout_marginLeft="@dimen/dp_10"
android:layout_width="wrap_content"
android:layout_height="match_parent">
<ImageView
android:id="@+id/hl1"
android:layout_width="35dp"
android:layout_height="35dp"
android:layout_centerVertical="true"
android:src="@mipmap/hlwqd"/>
</RelativeLayout>

<RelativeLayout
android:layout_marginLeft="@dimen/dp_10"
android:layout_width="wrap_content"
android:layout_height="match_parent">
<ImageView
android:id="@+id/hl2"
android:layout_width="35dp"
android:layout_height="35dp"
android:layout_centerVertical="true"
android:src="@mipmap/hlwqd"/>
</RelativeLayout>

<RelativeLayout
android:layout_marginLeft="@dimen/dp_10"
android:layout_width="wrap_content"
android:layout_height="match_parent">
<ImageView
android:id="@+id/hl3"
android:layout_width="35dp"
android:layout_height="35dp"
android:layout_centerVertical="true"
android:src="@mipmap/hlwqd"/>
</RelativeLayout>

<RelativeLayout
android:layout_marginLeft="@dimen/dp_10"
android:layout_width="wrap_content"
android:layout_height="match_parent">
<ImageView
android:id="@+id/hl4"
android:layout_width="35dp"
android:layout_height="35dp"
android:layout_centerVertical="true"
android:src="@mipmap/hlwqd"/>
</RelativeLayout>

<RelativeLayout
android:layout_marginLeft="@dimen/dp_10"
android:layout_width="wrap_content"
android:layout_height="match_parent">
<ImageView android:id="@+id/hl5"

android:layout_width="35dp"
android:layout_height="35dp"
android:layout_centerVertical="true"
android:src="@mipmap/hlwqd"/>
</RelativeLayout>

<RelativeLayout
android:layout_marginLeft="@dimen/dp_10"
android:layout_width="wrap_content"
android:layout_height="match_parent">
<ImageView android:id="@+id/hl6"

android:layout_width="35dp"
android:layout_height="35dp"
android:layout_centerVertical="true"
android:src="@mipmap/hlwqd"/>
</RelativeLayout>

<RelativeLayout
android:layout_marginLeft="@dimen/dp_10"
android:layout_width="wrap_content"
android:layout_height="match_parent">
<ImageView android:id="@+id/hl7"

android:layout_width="35dp"
android:layout_height="35dp"
android:layout_centerVertical="true"
android:src="@mipmap/hlwqd"/>
</RelativeLayout>

<RelativeLayout
android:layout_marginLeft="@dimen/dp_10"
android:layout_width="wrap_content"
android:layout_height="match_parent">
<ImageView android:id="@+id/hl8"

android:layout_width="35dp"
android:layout_height="35dp"
android:layout_centerVertical="true"
android:src="@mipmap/hlwqd"/>
</RelativeLayout>
</LinearLayout>

+ 75
- 0
app/src/main/res/layout/item/layout/note_rv_tree_second.xml Näytä tiedosto

@@ -0,0 +1,75 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="150dp"
android:layout_height="180dp"
android:background="@color/white"
android:layout_marginTop="5dp"
android:layout_marginLeft="5dp"
android:layout_marginBottom="5dp">


<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<ImageView
android:id="@+id/ImageUrl"
android:layout_margin="5dp"
android:layout_width="match_parent"
android:layout_height="110dp"
android:src="@mipmap/loading123"
android:scaleType="fitXY"
/>
<TextView
android:id="@+id/Tag_text"
android:layout_marginLeft="5dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:ignore="MissingConstraints"
android:textColor="@color/gray_deep"
android:text="清炒三月瓜"/>
<TextView
android:id="@+id/Note_text"
android:textSize="10dp"
android:textColor="@color/gray"
android:layout_marginLeft="5dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:ignore="MissingConstraints"
android:text="时间:185秒"/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="5dp">
<TextView
android:id="@+id/Sc_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:textSize="12dp"
android:textColor="@color/light_blue_primary"
android:text="上传"/>
<TextView
android:id="@+id/delete_text"
android:layout_marginRight="20dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="12dp"
android:layout_alignParentRight="true"
android:textColor="@color/red_primary_dark"
android:text="删除"/>

</RelativeLayout>
</LinearLayout>

<ImageView
android:id="@+id/sc_image"

android:layout_alignParentRight="true"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_marginTop="@dimen/dp_10"
android:layout_marginRight="@dimen/dp_10"
android:src="@mipmap/wsc3"/>
</RelativeLayout>














+ 1
- 0
app/src/main/res/values/colors.xml Näytä tiedosto

@@ -14,6 +14,7 @@
<color name="colorPrimary">#3F51B5</color>
<color name="colorPrimaryDark">#303F9F</color>
<color name="colorAccent">#FF4081</color>
<color name="topbj1">#BEAA6A</color>
<color name="blue">#44B2FE</color>
<color name="file_picker_title">#4A4A4A</color>
<color name="file_picker_des">#86848B</color>


Ladataan…
Peruuta
Tallenna