Procházet zdrojové kódy

diy功能晚上

tags/old_version_1
fyf před 1 rokem
rodič
revize
cd744223d2
6 změnil soubory, kde provedl 230 přidání a 101 odebrání
  1. +1
    -0
      app/src/main/java/com/bonait/bnframework/common/db/QueryDB.java
  2. +20
    -8
      app/src/main/java/com/bonait/bnframework/modules/home/adapter/gongxubuzhou_adapter.java
  3. +162
    -19
      app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/DiyActivity.java
  4. +11
    -2
      app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/fragment_gx.java
  5. +35
    -72
      app/src/main/res/layout/activity_diy.xml
  6. +1
    -0
      app/src/main/res/layout/datatab/layout/gx_item.xml

+ 1
- 0
app/src/main/java/com/bonait/bnframework/common/db/QueryDB.java Zobrazit soubor

@@ -2388,6 +2388,7 @@ public class QueryDB {
((BPA_GOODSRECIPE) data).materialType = cursor.getInt((int) cursor.getColumnIndex("materialType"));
((BPA_GOODSRECIPE) data).processname = cursor.getString((int) cursor.getColumnIndex("processname"));
((BPA_GOODSRECIPE) data).processvalue = cursor.getString((int) cursor.getColumnIndex("processvalue"));
((BPA_GOODSRECIPE) data).processms = cursor.getString((int) cursor.getColumnIndex("processms"));
break;
case "BPA_ORDER":
data = new BPA_ORDER();


+ 20
- 8
app/src/main/java/com/bonait/bnframework/modules/home/adapter/gongxubuzhou_adapter.java Zobrazit soubor

@@ -1,6 +1,7 @@
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;
@@ -24,6 +25,8 @@ 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);
@@ -31,6 +34,15 @@ public class gongxubuzhou_adapter extends ArrayAdapter<BPA_GOODSRECIPE> {
datas=objects;
this.resource1=resource;
}

public int getSelectedPosition()
{
return selectedPosition;
}

public void setSelectedPosition(int position) {
selectedPosition = position;
}
//每个子项被滚动到屏幕内的时候会被调用
@NonNull
@Override
@@ -41,15 +53,15 @@ public class gongxubuzhou_adapter extends ArrayAdapter<BPA_GOODSRECIPE> {
//分别获取 image view 和 textview 的实例

TextView text = view.findViewById(R.id.text);
text.setText(lc.sort+"、"+lc.processms);
text.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
//view.setBackground(getContext().getResources().getDrawable(R.mipmap.hgr));
if(mListener!=null) mListener.clickListener(view,lc);
}
});
text.setText((position+1)+"、"+lc.processms);

if (selectedPosition == position) {
text.setSelected(true);
text.setTextColor(Color.WHITE);
} else {
text.setSelected(false);
text.setTextColor(Color.BLACK);
}
return view;
}
}

+ 162
- 19
app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/DiyActivity.java Zobrazit soubor

@@ -5,6 +5,7 @@ import static com.bonait.bnframework.MainApplication.getContext;
import androidx.appcompat.app.AppCompatActivity;

import android.annotation.SuppressLint;
import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.util.AttributeSet;
@@ -13,6 +14,7 @@ import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.Spinner;
@@ -22,6 +24,7 @@ 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;
@@ -29,6 +32,7 @@ import com.bonait.bnframework.common.db.mode.BPA_PROCESSModel;
import com.bonait.bnframework.common.helper.I.MyClickListener;
import com.bonait.bnframework.common.helper.MyImage;
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.adapter.lcsz_adapter;
@@ -36,6 +40,7 @@ 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.QMUITopBar;
import com.qmuiteam.qmui.widget.dialog.QMUIDialog;
import com.qmuiteam.qmui.widget.dialog.QMUIDialogAction;
import com.youth.banner.Banner;

import org.xmlpull.v1.XmlPullParser;
@@ -54,6 +59,8 @@ import butterknife.OnClick;
public class DiyActivity extends BaseActivity implements MyClickListener {
@BindView(R.id.topbar)
QMUITopBar mTopBar;
@BindView(R.id.edittext)
EditText edittext;//菜谱名称
@BindView(R.id.Banner_Main)
Banner Banner_Main;//轮播图
//用于存放获取的图片
@@ -107,6 +114,14 @@ public class DiyActivity extends BaseActivity implements MyClickListener {
//3.工序步骤
gxbz_adapter = new gongxubuzhou_adapter(getContext(), R.layout.gx_item, (List<BPA_GOODSRECIPE>) bpa_goodsrecipes,this);
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();
}
});
}
/**
* 根据选中工序id显示集合
@@ -147,18 +162,72 @@ public class DiyActivity extends BaseActivity implements MyClickListener {
{
}
}

/**
* 获取选中行的变量
* @return
*/
int k=1;
public BPA_GOODSRECIPE GetSelectItemFromValue()
{
BPA_GOODSRECIPE pf=new BPA_GOODSRECIPE();
pf.processms="测试物料";
pf.sort=k;
k++;
return pf;
try
{
String name= hrgx.getSelectedItem().toString();
boolean IsVerify=true;
String description="";
// 延迟,100|延迟,100|延迟,100|延迟,100|
String data="";
String desc="";
if(name.equals("液体料"))
{
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模式");
@@ -202,35 +271,109 @@ public class DiyActivity extends BaseActivity implements MyClickListener {
public void onViewClicked(View view) {
switch (view.getId()) {
case R.id.add_hrgx://添加工序
bpa_goodsrecipes.add(GetSelectItemFromValue());
gxbz_adapter.notifyDataSetChanged();
ToastUtils.info("添加工序");
BPA_GOODSRECIPE goodsrecipe= GetSelectItemFromValue();
if(goodsrecipe!=null)
{
bpa_goodsrecipes.add(GetSelectItemFromValue());
gxbz_adapter.notifyDataSetChanged();
}
break;
case R.id.update_gx://修改工序

ToastUtils.info("修改工序");
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);
gxbz_adapter.notifyDataSetChanged();
ToastUtils.info("修改工序"+obj_update.processname+"成功!");
}else
{
ToastUtils.info("请先选择工序!");
}
break;
case R.id.delete_gx://删除工序
BPA_GOODSRECIPE obj= (BPA_GOODSRECIPE)datatab_gxbz.getSelectedItem();
bpa_goodsrecipes.remove(obj);
gxbz_adapter.notifyDataSetChanged();
ToastUtils.info("删除工序");
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();
ToastUtils.info("删除工序"+obj_delete.processname+"成功!");
}else
{
ToastUtils.info("请先选择工序!");
}
break;
case R.id.shangyi://上移

ToastUtils.info("上移");
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();
}else
{
ToastUtils.info("已经最顶部!");
}
break;
case R.id.xiayi://下移

ToastUtils.info("下移");
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();
}else
{
ToastUtils.info("已经最底部!");
}
break;
case R.id.caozuomoshi://操作模式

ToastUtils.info("操作模式");
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;
}
//按钮点击
String title = "生成菜谱操作提示!";
String message = "请问客官确定要生成["+name+"]菜谱吗?";
AlertDialogUtils.showDialog(view.getContext(), title, message, new QMUIDialogAction.ActionListener() {
@Override
public void onClick(QMUIDialog dialog, int index) {
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=60*3;
good.issc=0;
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("菜谱生成成功!");
dialog.dismiss();
}
});

ToastUtils.info("生成菜谱");
}
break;
}
}


+ 11
- 2
app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/fragment_gx.java Zobrazit soubor

@@ -38,7 +38,7 @@ public class fragment_gx extends LinearLayout {
@BindView(R.id.check)
CheckBox check;
private View root;
private item_gx model;
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);
@@ -103,7 +103,16 @@ public class fragment_gx extends LinearLayout {
{
case 0://数字
case 1://字符串
ResStu=edittext.getText().toString();
if(model.IsWL)
{
if(check.isChecked())
{
ResStu=edittext.getText().toString();
}
}else
{
ResStu=edittext.getText().toString();
}
break;
case 2://选项
ResStu=editsp.getSelectedItem().toString();


+ 35
- 72
app/src/main/res/layout/activity_diy.xml Zobrazit soubor

@@ -22,76 +22,41 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<RelativeLayout
android:layout_marginTop="@dimen/dp_10"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.youth.banner.Banner
android:id="@+id/Banner_Main"
android:layout_width="match_parent"
android:layout_height="180dp"
android:layout_gravity="center"
app:image_scale_type="fit_xy"
app:indicator_height="10dp"
app:indicator_margin="5dp"
app:indicator_width="10dp" />
</RelativeLayout>
<LinearLayout
android:layout_marginTop="@dimen/dp_10"
android:layout_marginBottom="@dimen/dp_10"
android:layout_width="match_parent"
android:layout_height="120dp">
<LinearLayout
android:layout_height="wrap_content">
<com.qmuiteam.qmui.widget.textview.QMUILinkTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<com.qmuiteam.qmui.widget.QMUIRadiusImageView
android:layout_width="120dp"
android:layout_height="100dp"
android:src="@mipmap/hgr"
/>
<RelativeLayout
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:layout_centerInParent="true"
android:text="菜谱封面"/>
</RelativeLayout>
</LinearLayout>

<LinearLayout
android:layout_marginLeft="@dimen/dp_10"
android:layout_alignParentRight="true"
android:text="菜谱名称:"/>
<!--账号输入框-->
<EditText
android:id="@+id/edittext"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_marginTop="@dimen/dp_10"
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>

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.youth.banner.Banner
android:id="@+id/Banner_Main"
android:layout_width="match_parent"
android:layout_height="180dp"
android:layout_gravity="center"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"
app:image_scale_type="fit_xy"
app:indicator_height="10dp"
app:indicator_margin="5dp"
app:indicator_width="10dp" />
</RelativeLayout>
</LinearLayout>

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
@@ -139,6 +104,7 @@
</LinearLayout>
<ListView
android:id="@+id/datatab_gxbz"
android:listSelector="@color/green_primary_dark"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:divider="#00000000"
@@ -254,20 +220,17 @@
</LinearLayout>

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

<Button
android:id="@+id/shengchengcaipu"
android:layout_width="180dp"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerInParent="true"
android:layout_marginTop="20dp"
android:background="@drawable/button1"
android:layout_width="match_parent"
android:layout_height="45dp"
android:background="@drawable/bg_btn_login_selected"
android:text="生成菜谱"
android:textColor="@color/black"
android:textSize="19dp" />
android:textColor="@color/white"
android:textSize="18sp"/>
</RelativeLayout>
</LinearLayout>



+ 1
- 0
app/src/main/res/layout/datatab/layout/gx_item.xml Zobrazit soubor

@@ -14,5 +14,6 @@
android:layout_marginLeft="@dimen/dp_10"
android:text="序号"
android:textSize="12dp"
android:focusable="false"
android:textColor="@color/black"/>
</RelativeLayout>

Načítá se…
Zrušit
Uložit