Browse Source

gengx

tags/old_version_1
fyf 11 months ago
parent
commit
5a602905c6
22 changed files with 991 additions and 709 deletions
  1. +2
    -2
      app/src/main/AndroidManifest.xml
  2. +6
    -1
      app/src/main/java/com/bonait/bnframework/business/ConfigData.java
  3. +38
    -1
      app/src/main/java/com/bonait/bnframework/common/image/MyBitmapUtils.java
  4. +2
    -2
      app/src/main/java/com/bonait/bnframework/common/image/utils/NetCacheUtils.java
  5. +74
    -0
      app/src/main/java/com/bonait/bnframework/common/view/CircleImageView.java
  6. +49
    -0
      app/src/main/java/com/bonait/bnframework/common/view/RoundCornerImageView.java
  7. +6
    -8
      app/src/main/java/com/bonait/bnframework/modules/home/fragment/HomeFragmentPR.java
  8. +16
    -15
      app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/CookingSimulatedActivity.java
  9. +569
    -0
      app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/DiyUpdate1Activity.java
  10. +0
    -542
      app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/DiynewActivity.java
  11. +4
    -0
      app/src/main/res/drawable/border1.xml
  12. +39
    -0
      app/src/main/res/drawable/circular11.xml
  13. +167
    -138
      app/src/main/res/layout/activity_diy_update1.xml
  14. +19
    -0
      app/src/main/res/layout/datatab/layout/gx_item1.xml
  15. BIN
     
  16. BIN
     
  17. BIN
     
  18. BIN
     
  19. BIN
     
  20. BIN
     
  21. BIN
     
  22. BIN
     

+ 2
- 2
app/src/main/AndroidManifest.xml View File

@@ -34,10 +34,10 @@
tools:node="merge"
tools:replace="android:icon">
<activity
android:name=".modules.home.fragment.from.CookingSimulatedActivity"
android:name=".modules.home.fragment.from.DiyUpdate1Activity"
android:exported="false" />
<activity
android:name=".modules.home.fragment.from.DiynewActivity"
android:name=".modules.home.fragment.from.CookingSimulatedActivity"
android:exported="false" />
<activity
android:name=".modules.home.fragment.from.DishTestActivity"


+ 6
- 1
app/src/main/java/com/bonait/bnframework/business/ConfigData.java View File

@@ -874,13 +874,16 @@ public class ConfigData {
*/
public void AddImage(Context context) {
BitmapFactory.Options options = new BitmapFactory.Options();
options.inSampleSize = 2;//宽高压缩为原来的1/2
//options.inSampleSize = 2;//宽高压缩为原来的1/2
options.inPreferredConfig=Bitmap.Config.RGB_565;

Bitmap bitmap1 = BitmapFactory.decodeResource(context.getResources(), R.mipmap.image1, options);
Bitmap bitmap2 = BitmapFactory.decodeResource(context.getResources(), R.mipmap.image2, options);
Bitmap bitmap3 = BitmapFactory.decodeResource(context.getResources(), R.mipmap.image3, options);
Bitmap bitmap4 = BitmapFactory.decodeResource(context.getResources(), R.mipmap.image4, options);
Bitmap bitmap5 = BitmapFactory.decodeResource(context.getResources(), R.mipmap.image5, options);
Bitmap bitmap6 = BitmapFactory.decodeResource(context.getResources(), R.mipmap.image6, options);
Bitmap bitmap7 = BitmapFactory.decodeResource(context.getResources(), R.mipmap.loading123, options);

LocalCacheUtils localCacheUtils = new LocalCacheUtils();
localCacheUtils.setBitmapToLocal("image1.png", bitmap1);
@@ -889,6 +892,8 @@ public class ConfigData {
localCacheUtils.setBitmapToLocal("image4.png", bitmap4);
localCacheUtils.setBitmapToLocal("image5.png", bitmap5);
localCacheUtils.setBitmapToLocal("image6.png", bitmap6);
localCacheUtils.setBitmapToLocal("loading123.png", bitmap7);


}



+ 38
- 1
app/src/main/java/com/bonait/bnframework/common/image/MyBitmapUtils.java View File

@@ -8,6 +8,8 @@ import com.bonait.bnframework.R;
import com.bonait.bnframework.common.image.utils.LocalCacheUtils;
import com.bonait.bnframework.common.image.utils.MemoryCacheUtils;
import com.bonait.bnframework.common.image.utils.NetCacheUtils;
import com.bonait.bnframework.common.view.CircleImageView;
import com.qmuiteam.qmui.widget.QMUIRadiusImageView2;

import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -25,7 +27,6 @@ public class MyBitmapUtils {
mLocalCacheUtils=new LocalCacheUtils();
mNetCacheUtils=new NetCacheUtils(mLocalCacheUtils,mMemoryCacheUtils);
}

public void disPlay(ImageView ivPic, String url) {
ivPic.setImageResource(R.mipmap.loading123);
Bitmap bitmap;
@@ -62,6 +63,42 @@ public class MyBitmapUtils {
mNetCacheUtils.getBitmapFromNet(ivPic,url);
}
}
public void disPlay(CircleImageView ivPic, String url) {
ivPic.setImageResource(R.mipmap.loading123);
Bitmap bitmap;
//内存缓存
String name="";
//https://hbl-1305371387.cos.ap-chengdu.myqcloud.com/Franchisee/jccy@163.com/goods/133381212328681942.jpg
if(url.contains("http"))
{
name=url.substring(url.lastIndexOf('/')+1);
}else
{
name=url;
}

bitmap=mMemoryCacheUtils.getBitmapFromMemory(name);
if (bitmap!=null){
ivPic.setImageBitmap(bitmap);
System.out.println("从内存获取图片啦.....");
return;
}

//本地缓存
bitmap = mLocalCacheUtils.getBitmapFromLocal(name);
if(bitmap !=null){
ivPic.setImageBitmap(bitmap);
System.out.println("从本地获取图片啦.....");
//从本地获取图片后,保存至内存中
mMemoryCacheUtils.setBitmapToMemory(name,bitmap);
return;
}
//网络缓存
if(url.contains("http"))
{
mNetCacheUtils.getBitmapFromNet(ivPic,url);
}
}

/**
* 判断字符串是否为URL


+ 2
- 2
app/src/main/java/com/bonait/bnframework/common/image/utils/NetCacheUtils.java View File

@@ -102,8 +102,8 @@ public class NetCacheUtils {
if (responseCode == 200) {
//图片压缩
BitmapFactory.Options options = new BitmapFactory.Options();
options.inSampleSize=2;//宽高压缩为原来的1/2
options.inPreferredConfig=Bitmap.Config.ARGB_4444;
//options.inSampleSize=2;//宽高压缩为原来的1/2
options.inPreferredConfig=Bitmap.Config.RGB_565;
Bitmap bitmap = BitmapFactory.decodeStream(conn.getInputStream(),null,options);
return bitmap;
}


+ 74
- 0
app/src/main/java/com/bonait/bnframework/common/view/CircleImageView.java View File

@@ -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 android.widget.ImageView;
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);
}
}

}

+ 49
- 0
app/src/main/java/com/bonait/bnframework/common/view/RoundCornerImageView.java View File

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

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Path;
import android.graphics.drawable.GradientDrawable;
import android.os.Build;
import android.util.AttributeSet;

import androidx.annotation.Nullable;

public class RoundCornerImageView extends androidx.appcompat.widget.AppCompatImageView {
private Path path;
private int mWidth,mHeight;
private float radius;

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

public RoundCornerImageView(Context context, @Nullable AttributeSet attrs) {
this(context, attrs,0);
}

public RoundCornerImageView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
path=new Path();
}


@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
mWidth=MeasureSpec.getSize(widthMeasureSpec);
mHeight=MeasureSpec.getSize(heightMeasureSpec);
}

@Override
protected void onDraw(Canvas canvas) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
if(getBackground()!=null){
radius=((GradientDrawable)getBackground()).getCornerRadius();
path.addRoundRect(0,0,mWidth,mHeight,radius,radius, Path.Direction.CW);
canvas.clipPath(path);
}
}
super.onDraw(canvas);
}
}

+ 6
- 8
app/src/main/java/com/bonait/bnframework/modules/home/fragment/HomeFragmentPR.java View File

@@ -41,6 +41,7 @@ import com.bonait.bnframework.common.utils.ToastUtils;
import com.bonait.bnframework.modules.home.adapter.good_adapter;
import com.bonait.bnframework.modules.home.fragment.from.CookingActivity;
import com.bonait.bnframework.modules.home.fragment.from.CookingSimulatedActivity;
import com.bonait.bnframework.modules.home.fragment.from.DiyUpdate1Activity;
import com.bonait.bnframework.modules.home.fragment.from.DiyUpdateActivity;
import com.bonait.bnframework.modules.home.fragment.mode.SectionHeader;
import com.bonait.bnframework.modules.home.fragment.mode.SectionItem;
@@ -141,8 +142,7 @@ public class HomeFragmentPR extends BaseFragment {
String str = (String) msg;
if (str.equals("Good")) {
initData();
if(qupenren.getVisibility()==View.VISIBLE)
{
if (qupenren.getVisibility() == View.VISIBLE) {
qupenren.RefreshData();
}
} else {
@@ -227,7 +227,7 @@ public class HomeFragmentPR extends BaseFragment {
initData();
break;
case 3:
Intent intent = new Intent(getContext(), DiyUpdateActivity.class);
Intent intent = new Intent(getContext(), DiyUpdate1Activity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.putExtra("id", goodid);
startActivity(intent);
@@ -239,16 +239,14 @@ public class HomeFragmentPR extends BaseFragment {
startActivity(intent1);
break;
case 4: //打开查看窗体
qupenren.SetData(item,myClickListener);
qupenren.SetData(item, myClickListener);
qupenren.setVisibility(View.VISIBLE);
break;
case 5: //打开制作窗体
//判断是否正在制作
if(ExecuteTheRecipe.IsStart)
{
if (ExecuteTheRecipe.IsStart) {
ToastUtils.warning("请耐心等待商品制作结束!!!");
}else
{
} else {
MessageManager.getInstance().sendMessage(MessageName.OpenMakeGoodFrom, goodid);
qupenren.setVisibility(View.GONE);
}


+ 16
- 15
app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/CookingSimulatedActivity.java View File

@@ -244,7 +244,7 @@ public class CookingSimulatedActivity extends BaseActivity {
*
* @param view
*/
@OnClick({R.id.kaishimoni,R.id.jieshutuichu,R.id.tuichu})
@OnClick({R.id.kaishimoni, R.id.jieshutuichu, R.id.tuichu})
public void onViewClicked(View view) {
switch (view.getId()) {
case R.id.kaishimoni:
@@ -293,6 +293,7 @@ public class CookingSimulatedActivity extends BaseActivity {

//region 外部调用
private CountDownTimerExt countDownTimer = null;//计时器

/**
* 启动
*/
@@ -317,6 +318,7 @@ public class CookingSimulatedActivity extends BaseActivity {
countDownTimer.start();
}
}

/**
* 停止
*/
@@ -331,6 +333,7 @@ public class CookingSimulatedActivity extends BaseActivity {
Stop();
}
}

/**
* 启动模拟播放
*/
@@ -350,7 +353,7 @@ public class CookingSimulatedActivity extends BaseActivity {

try {
String ms = "";
String text=recipe.processvalue;
String text = recipe.processvalue;
if (recipe.materialType == 0)//正常物料
{
runOnUiThread(new Runnable() {
@@ -378,7 +381,7 @@ public class CookingSimulatedActivity extends BaseActivity {
String[] wl = item.split("[,]");
if (wl != null && wl.length == 2) {
String name = wl[0];
int val = (int)Math.round((Double.parseDouble(wl[1]) * 10));
int val = (int) Math.round((Double.parseDouble(wl[1]) * 10));
//int val = Integer.parseInt(wl[1]);
List<BPA_SILOS> bpa_silos = QueryDB.GetSolisByMaterialName(name);
if (bpa_silos.size() > 0 && val > 0) {
@@ -396,7 +399,7 @@ public class CookingSimulatedActivity extends BaseActivity {
runOnUiThread(new Runnable() {
@Override
public void run() {
CarryOut("液体料|"+key);
CarryOut("液体料|" + key);
}
});
Thread.sleep(2000);
@@ -453,13 +456,13 @@ public class CookingSimulatedActivity extends BaseActivity {
runOnUiThread(new Runnable() {
@Override
public void run() {
CarryOut(recipe.processname+"|未知");
CarryOut(recipe.processname + "|未知");
}
});
Thread.sleep(2000);
break;
case "加热":
int val=0;
int val = 0;
for (HashMap.Entry<String, String> entry : formulation.entrySet()) {
String key = entry.getKey();
String value = entry.getValue();
@@ -471,42 +474,40 @@ public class CookingSimulatedActivity extends BaseActivity {
runOnUiThread(new Runnable() {
@Override
public void run() {
CarryOut(recipe.processname+"|"+writeValue);
CarryOut(recipe.processname + "|" + writeValue);
}
});
Thread.sleep(2000);
}
}

if(val>0)
{
if (val > 0) {
Thread.sleep(val * 1000);
}
break;
case "主料":
String writeValue = "1号位";
val=0;
val = 0;

for (HashMap.Entry<String, String> entry : formulation.entrySet()) {
String key = entry.getKey();
String value = entry.getValue();
if (key.contains("主料位置")) {
writeValue=value;
writeValue = value;
String finalWriteValue = writeValue;
runOnUiThread(new Runnable() {
@Override
public void run() {
CarryOut(recipe.processname+"|"+ finalWriteValue);
CarryOut(recipe.processname + "|" + finalWriteValue);
}
});
Thread.sleep(2000);
}else if (key.contains("(秒)")) {
} else if (key.contains("(秒)")) {
val = Integer.parseInt(value);
}
}

if(val>0)
{
if (val > 0) {
Thread.sleep(val * 1000);
}
break;


+ 569
- 0
app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/DiyUpdate1Activity.java View File

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

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

import androidx.appcompat.app.AppCompatActivity;
import androidx.core.content.ContextCompat;

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.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.QMUIRadiusImageView2;
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) {
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;
}
//按钮点击
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;
}
//按钮点击
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 void SetSelectPos(int index) {
//移动光标
gxbz_adapter.setSelectedPosition(index);
gxbz_adapter.notifyDataSetInvalidated();
}

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

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

}

+ 0
- 542
app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/DiynewActivity.java View File

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

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

import androidx.appcompat.app.AppCompatActivity;
import androidx.core.content.ContextCompat;

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 DiynewActivity 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;

public String imageUrl = "";

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_diynew);
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) {
imageUrl=(String) msg;
new MyBitmapUtils().disPlay(cpfm,imageUrl);
}
}
});
}

/**
* 根据选中步骤显示变量
* @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
{
bpa_goodsrecipes.clear();
for(BPA_GOODSRECIPE item: DataBus.getInstance().bpa_goodsrecipes)
{
bpa_goodsrecipes.add(item);
}
edittext.setText(DataBus.getInstance().ShowGoodName+"");
zzsc.setText(DataBus.getInstance().TimeOut+"");
gxbz_adapter.notifyDataSetChanged();
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.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)
{
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.shengchengnewcaipu:
String name1=edittext.getText().toString();
if(name1.isEmpty())
{
ToastUtils.info("菜谱名称不能为空!");
return;
}else
{
boolean isSucess= QueryDB.GetGoodsIs(name1);
if(isSucess)
{
ToastUtils.info("菜谱名称已存在!");
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=imageUrl;
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");

Intent intent = new Intent(getContext(), CookingSimulatedActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.putExtra("id", good1.id);
startActivity(intent);
finish();
}
});

}
break;
}
}

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

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

+ 4
- 0
app/src/main/res/drawable/border1.xml View File

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<corners android:radius="75dp"></corners>
</shape>

+ 39
- 0
app/src/main/res/drawable/circular11.xml View File

@@ -0,0 +1,39 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">

<!--按压状态下,前景变暗-->
<item android:state_pressed="true">
<layer-list>
<item android:left="4dp" android:top="4dp">
<shape>
<solid android:color="#f0f0f0" />
<corners android:radius="0dp" />
</shape>
</item>
</layer-list>
</item>

<!-- 非按下 -->
<item>
<layer-list>
<!-- 999渐变隐形外层 -->
<item android:left="0dp" android:top="0dp">
<shape>
<solid android:color="@color/white" />
<corners android:radius="2dp" />
</shape>
</item>
<!-- 777渐变阴影中层 -->
<item
android:bottom="1dp"
android:left="0dp"
android:right="0dp"
android:top="0dp">
<shape>
<solid android:color="#00797373" />
<corners android:radius="100dp" />
</shape>
</item>
</layer-list>
</item>
</selector>

app/src/main/res/layout/activity_diynew.xml → app/src/main/res/layout/activity_diy_update1.xml View File

@@ -1,93 +1,111 @@
<?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"
tools:context=".modules.home.fragment.from.DiynewActivity"
android:orientation="vertical"
android:background="@color/topbj1"
android:fitsSystemWindows="true">
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_marginLeft="30dp"
android:layout_marginRight="30dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="30dp"
android:layout_marginRight="30dp"
android:orientation="vertical">
<LinearLayout
android:layout_marginTop="@dimen/dp_10"
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
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="wrap_content"
android:layout_height="wrap_content"
android:background="@color/color1">
android:layout_width="match_parent"
android:layout_height="wrap_content">

<ImageView
<!-- <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="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" />
android:layout_width="150dp"
android:layout_height="150dp"
android:layout_centerInParent="true"
android:scaleType="centerCrop"
android:src="@mipmap/image3"/>
</RelativeLayout>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAlignment="center"
android:text="菜谱封面"/>

<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_marginLeft="@dimen/dp_40"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
android:layout_marginLeft="@dimen/dp_40"
android:orientation="vertical"
android:visibility="gone">

<LinearLayout
android:layout_marginTop="@dimen/dp_10"
android:layout_marginBottom="12dp"
android:layout_width="match_parent"
android:layout_height="wrap_content">
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="菜谱名称:"/>
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">
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="制作时长:"/>
android:text="制作时长:" />
<!--账号输入框-->
<EditText
android:id="@+id/zzsc"
@@ -99,87 +117,106 @@
android:inputType="number"
android:maxLines="1"
android:padding="3dp"
android:textSize="12dp"
android:text="0"/>
android:text="0"
android:textSize="12dp" />
</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:layout_marginLeft="70dp"
android:buttonTint="@color/radiusImageView_selected_mask_color"
android:text="默认收藏"/>
android:text="默认收藏" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</RelativeLayout>
<!--边框分割细线-->
<LinearLayout
android:layout_alignParentBottom="true"
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"

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

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

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

<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="步骤:"/>
<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>
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:divider="#00000000"
android:layout_marginTop="10dp"
android:layout_marginBottom="@dimen/dp_40"
android:layout_marginBottom="50dp"
android:divider="#00000000"
android:dividerHeight="3dp" />
</LinearLayout>

<ImageView
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_marginLeft="@dimen/dp_10"
android:layout_width="match_parent"
android:layout_height="wrap_content">
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_10">
<!--边框分割细线-->
<RelativeLayout
android:layout_alignParentLeft="true"
android:layout_width="@dimen/dp_10"
android:layout_height="match_parent">
android:layout_height="match_parent"
android:layout_alignParentLeft="true">

<LinearLayout
android:layout_width="1dp"
@@ -191,123 +228,115 @@
</RelativeLayout>

<LinearLayout
android:layout_marginLeft="@dimen/dp_10"
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:text="烹饪工序:"
android:textColor="#BEAA6A"
android:textSize="19dp" />

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

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

<LinearLayout
android:id="@+id/gxchid"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
</LinearLayout>
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: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="50dp"
android:layout_height="26dp"
android:background="@drawable/button1"
android:text="添加"
android:textColor="@color/black"
android:textSize="14dp"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@mipmap/ll3" />

<ImageView
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: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_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"/>
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:src="@mipmap/ll1" />
</LinearLayout>
</RelativeLayout>

</LinearLayout>

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

<LinearLayout
android:layout_centerHorizontal="true"
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="200dp"
android:layout_height="45dp"
android:background="@drawable/bg_btn_login_selected"
android:text="保存并模拟炒制"
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"/>
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"/>
android:background="@color/app_color_blue" />
</com.qmuiteam.qmui.widget.QMUIWindowInsetLayout>

+ 19
- 0
app/src/main/res/layout/datatab/layout/gx_item1.xml View File

@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://schemas.android.com/apk/res/android ">
<TextView
android:id="@+id/text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_alignParentLeft="true"
android:layout_marginLeft="@dimen/dp_10"
android:text="序号"
android:textSize="14dp"
android:focusable="false"
android:textColor="#567722"/>
</RelativeLayout>

BIN
View File


BIN
View File


BIN
View File


BIN
View File


BIN
View File


BIN
View File


BIN
View File


BIN
View File


Loading…
Cancel
Save