Browse Source

diy功能

tags/old_version_1
fyf 1 year ago
parent
commit
08fef33126
17 changed files with 433 additions and 102 deletions
  1. +9
    -0
      app/build.gradle
  2. +3
    -0
      app/src/main/AndroidManifest.xml
  3. +1
    -0
      app/src/main/java/com/bonait/bnframework/common/db/mode/BPA_PROCESSModel.java
  4. +20
    -0
      app/src/main/java/com/bonait/bnframework/common/helper/MyImage.java
  5. +131
    -1
      app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/DiyActivity.java
  6. +10
    -0
      app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/ResBPA_PROCESSModel.java
  7. +113
    -0
      app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/fragment_gx.java
  8. +12
    -0
      app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/item_gx.java
  9. +95
    -100
      app/src/main/res/layout/activity_diy.xml
  10. +1
    -0
      app/src/main/res/layout/datatab/values/strings.xml
  11. +36
    -0
      app/src/main/res/layout/item/layout/fragment_item_gx.xml
  12. +0
    -0
      app/src/main/res/layout/item/layout/item_huolikongzhi.xml
  13. +0
    -0
      app/src/main/res/layout/item/layout/item_liaochang.xml
  14. +0
    -0
      app/src/main/res/layout/item/layout/item_sp.xml
  15. +0
    -0
      app/src/main/res/layout/item/layout/note_rv_tree_second.xml
  16. +2
    -1
      app/src/main/res/layout/item/layout/spinner_text_item.xml
  17. +0
    -0
      app/src/main/res/layout/item/layout/toast_layout.xml

+ 9
- 0
app/build.gradle View File

@@ -118,4 +118,13 @@ dependencies {
//表格控件
implementation 'com.github.huangyanbin:SmartTable:2.2.0'

//轮播图
implementation 'com.youth.banner:banner:1.4.10'

//图片加载
implementation 'com.github.bumptech.glide:glide:4.11.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0'



}

+ 3
- 0
app/src/main/AndroidManifest.xml View File

@@ -28,6 +28,9 @@
android:theme="@style/AppTheme"
tools:ignore="GoogleAppIndexingWarning"
tools:node="merge">
<activity
android:name=".modules.home.fragment.mode.fragment_gx"
android:exported="false" />
<activity
android:name=".modules.home.fragment.from.fragment.SystemCsFltlFragment"
android:exported="false" />


+ 1
- 0
app/src/main/java/com/bonait/bnframework/common/db/mode/BPA_PROCESSModel.java View File

@@ -24,4 +24,5 @@ public class BPA_PROCESSModel extends ModeBase{
* 排序
*/
public int sort;

}

+ 20
- 0
app/src/main/java/com/bonait/bnframework/common/helper/MyImage.java View File

@@ -0,0 +1,20 @@
package com.bonait.bnframework.common.helper;

import android.content.Context;
import android.view.View;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.youth.banner.loader.ImageLoaderInterface;

public class MyImage implements ImageLoaderInterface {
@Override
public void displayImage(Context context, Object path, View imageView) {
Glide.with(context).load(path).into((ImageView) imageView);
}

@Override
public View createImageView(Context context) {
return null;
}
}

+ 131
- 1
app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/DiyActivity.java View File

@@ -1,12 +1,42 @@
package com.bonait.bnframework.modules.home.fragment.from;

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

import androidx.appcompat.app.AppCompatActivity;

import android.annotation.SuppressLint;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.util.AttributeSet;
import android.util.Xml;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.Spinner;

import com.bonait.bnframework.R;
import com.bonait.bnframework.common.base.BaseActivity;
import com.bonait.bnframework.common.db.QueryDB;
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.helper.MyImage;
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.youth.banner.Banner;

import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;

import java.io.IOException;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

import butterknife.BindView;
import butterknife.ButterKnife;
@@ -14,13 +44,95 @@ import butterknife.ButterKnife;
public class DiyActivity extends BaseActivity {
@BindView(R.id.topbar)
QMUITopBar mTopBar;
@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<>();

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

@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();
for (BPA_PROCESS item:data)
{
hrgx_map.put(item.name,item.id);
}
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.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
String id= hrgx_map.get(hrgx.getSelectedItem().toString());
SelectItemFrom(id);
}
@Override
public void onNothingSelected(AdapterView<?> adapterView) {
}
});
//3.
}

/**
* 根据选中工序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)
{

}
}

private void initTopBar() {
mTopBar.setTitle("DIY模式");
mTopBar.addLeftImageButton(R.mipmap.fanhui,R.id.topbar).setOnClickListener(new View.OnClickListener() {
@@ -30,7 +142,25 @@ public class DiyActivity extends BaseActivity {
}
});
}

//获取图片存放到list中
private void Drawable_Get(List arrayList) {
//从drawable文件夹下获取到事先准备的图片,在这里演示三张图片
Drawable drawable = getResources().getDrawable(R.mipmap.hgr);
Drawable drawable1 = getResources().getDrawable(R.mipmap.hgr);
Drawable drawable2 = getResources().getDrawable(R.mipmap.hgr);
//把他们存放到一个list集合中
arrayList.add(drawable);
arrayList.add(drawable1);
arrayList.add(drawable2);
//调用轮播图设置方法
Banner_Set(Banner_list);
}
//将图片存放到轮播图中
private void Banner_Set(List arrayList) {
//这是设置轮播图的关键位置,setImages(list) 设置轮播图的图片资源
//setImageLoader(一个实体类)用于加载图片到手机页面上显示
Banner_Main.setImages(Banner_list).setImageLoader(new MyImage()).start();
}
@Override
public void onDestroy() {
super.onDestroy();


+ 10
- 0
app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/ResBPA_PROCESSModel.java View File

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

import com.bonait.bnframework.common.db.mode.BPA_PROCESSModel;

public class ResBPA_PROCESSModel extends BPA_PROCESSModel {
/**
* 选中变量
*/
public String val;
}

+ 113
- 0
app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/fragment_gx.java View File

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

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

import android.content.Context;
import android.os.Bundle;
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 com.bonait.bnframework.R;
import com.bonait.bnframework.common.base.BaseFragment;

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)
Spinner editsp;
Map<String,Integer> editsp_map = new LinkedHashMap<>();
@BindView(R.id.edittext)
EditText edittext;
@BindView(R.id.check)
CheckBox check;
private View root;
private 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);
}
switch (model.datatype)
{
case 0://数字
editsp.setVisibility(View.GONE);
edittext.setVisibility(View.VISIBLE);
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://数字
case 1://字符串
ResStu=edittext.getText().toString();
break;
case 2://选项
ResStu=editsp.getSelectedItem().toString();
break;
}
return ResStu;
}
}

+ 12
- 0
app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/item_gx.java View File

@@ -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;
}

+ 95
- 100
app/src/main/res/layout/activity_diy.xml View File

@@ -22,7 +22,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<RelativeLayout
<LinearLayout
android:layout_marginTop="@dimen/dp_10"
android:layout_marginBottom="@dimen/dp_10"
android:layout_width="match_parent"
@@ -32,26 +32,30 @@
android:layout_height="wrap_content"
android:orientation="vertical">
<com.qmuiteam.qmui.widget.QMUIRadiusImageView
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_width="120dp"
android:layout_height="100dp"
android:src="@mipmap/hgr"
/>
<com.qmuiteam.qmui.widget.textview.QMUILinkTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingHorizontal="11dp"
android:text="菜谱封面"/>
<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_marginRight="@dimen/dp_10"
android:layout_marginLeft="@dimen/dp_10"
android:layout_alignParentRight="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_marginTop="@dimen/dp_10"
android:layout_width="wrap_content"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.qmuiteam.qmui.widget.textview.QMUILinkTextView
android:layout_width="wrap_content"
@@ -59,46 +63,45 @@
android:text="菜谱名称:"/>
<!--账号输入框-->
<EditText
android:layout_width="160dp"
android:id="@+id/edittext"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="fill"
android:layout_marginLeft="5dp"
android:background="@drawable/input_bj"
android:paddingLeft="5dp"
android:hint="菜谱名称"
android:maxLength="20"
android:textColor="?attr/qmui_config_color_gray_5"
android:textSize="?attr/qmui_common_list_item_detail_h_text_size" />
android:hint="请输入菜谱名称"
android:inputType="text"
android:maxLines="1"
android:padding="3dp"
android:textSize="12dp" />
</LinearLayout>

<LinearLayout
android:layout_marginTop="20dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<com.qmuiteam.qmui.widget.textview.QMUILinkTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="菜系选择:"/>
<!--账号输入框-->
<Spinner android:layout_width="160dp"
android:layout_height="20dp"
android:layout_gravity="fill"
android:paddingLeft="5dp"
android:background="@drawable/input_bj"
>
</Spinner>
</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>
<!--边框分割细线-->
<LinearLayout
android:layout_alignParentBottom="true"
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@drawable/qmui_s_list_item_bg_with_border_bottom" />
</RelativeLayout>

</LinearLayout>
<!--边框分割细线-->
<LinearLayout
android:layout_alignParentBottom="true"
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@drawable/qmui_s_list_item_bg_with_border_bottom" />

<LinearLayout android:layout_width="match_parent"
android:layout_height="400dp"
android:layout_marginTop="@dimen/dp_10">
android:layout_height="400dp">
<RelativeLayout
android:layout_width="160dp"
android:layout_height="wrap_content">
@@ -107,24 +110,9 @@
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"
android:orientation="horizontal">
<com.qmuiteam.qmui.widget.textview.QMUILinkTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="规格:"/>
<Spinner android:layout_width="match_parent"
android:layout_height="20dp"
android:layout_gravity="fill"
android:paddingLeft="5dp"
android:background="@drawable/input_bj"/>
</LinearLayout>


<LinearLayout
android:layout_marginTop="@dimen/dp_10"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
@@ -159,8 +147,6 @@
android:text="操作模式"
android:textColor="@color/black"
android:textSize="14dp"/>


</RelativeLayout>

<RelativeLayout
@@ -180,54 +166,63 @@
<LinearLayout
android:layout_marginLeft="@dimen/dp_10"
android:layout_width="match_parent"
android:layout_height="wrap_content"
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"
android:orientation="horizontal">
<com.qmuiteam.qmui.widget.textview.QMUILinkTextView
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="烹饪工序:"/>
<Spinner android:layout_width="match_parent"
android:layout_height="20dp"
android:layout_gravity="fill"
android:paddingLeft="5dp"
android:background="@drawable/input_bj"/>
<Spinner
android:id="@+id/hrgx"
style="@style/commonSpinnerStyle"
android:layout_width="match_parent"
android:layout_height="24dp"
android:layout_centerVertical="true"
/>
</LinearLayout>

</LinearLayout>

<LinearLayout
android:layout_marginLeft="@dimen/dp_10"
android:layout_alignParentBottom="true"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Button
android:layout_width="50dp"
android:layout_height="26dp"
android:background="@drawable/button1"
android:text="添加"
android:textColor="@color/black"
android:textSize="14dp"/>
<Button
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
<LinearLayout
android:id="@+id/gxchid"
android:layout_marginTop="20dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
</LinearLayout>
<LinearLayout
android:layout_marginTop="@dimen/dp_10"
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_alignParentBottom="true"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Button
android:layout_width="50dp"
android:layout_height="26dp"
android:background="@drawable/button1"
android:text="添加"
android:textColor="@color/black"
android:textSize="14dp"/>
<Button
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_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>
</LinearLayout>
</RelativeLayout>



+ 1
- 0
app/src/main/res/layout/datatab/values/strings.xml View File

@@ -0,0 +1 @@
<resources></resources>

+ 36
- 0
app/src/main/res/layout/item/layout/fragment_item_gx.xml View File

@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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"
android:layout_marginBottom="@dimen/dp_10"
android:orientation="horizontal">
<CheckBox
android:id="@+id/check"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:buttonTint="@color/radiusImageView_selected_mask_color"/>
<TextView
android:id="@+id/name"
android:layout_width="80dp"
android:layout_height="wrap_content"
android:text="搅拌动作:"/>
<Spinner
android:id="@+id/editsp"
style="@style/commonSpinnerStyle"
android:layout_width="match_parent"
android:layout_height="24dp"
android:layout_centerVertical="true"
android:visibility="gone"/>
<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:inputType="text"
android:maxLines="1"
android:padding="3dp"
android:textSize="12dp" />
</LinearLayout>

app/src/main/res/layout/item_huolikongzhi.xml → app/src/main/res/layout/item/layout/item_huolikongzhi.xml View File


app/src/main/res/layout/item_liaochang.xml → app/src/main/res/layout/item/layout/item_liaochang.xml View File


app/src/main/res/layout/item_sp.xml → app/src/main/res/layout/item/layout/item_sp.xml View File


app/src/main/res/layout/note_rv_tree_second.xml → app/src/main/res/layout/item/layout/note_rv_tree_second.xml View File


+ 2
- 1
app/src/main/res/layout/item/layout/spinner_text_item.xml View File

@@ -9,7 +9,8 @@
android:textAlignment="inherit"
android:gravity="center_vertical"
android:text="请选择"
android:textSize="12dp">
android:textSize="12dp"
android:textColor="@color/black">
</TextView>




app/src/main/res/layout/toast_layout.xml → app/src/main/res/layout/item/layout/toast_layout.xml View File


Loading…
Cancel
Save