소스 검색

现场调试改动99999

master
fyf 1 년 전
부모
커밋
148c22a247
5개의 변경된 파일78개의 추가작업 그리고 26개의 파일을 삭제
  1. +4
    -1
      app/src/main/java/com/example/bpa/config/DataBus.java
  2. +32
    -23
      app/src/main/java/com/example/bpa/db/QueryDB.java
  3. +30
    -0
      app/src/main/java/com/example/bpa/helper/WrapContentLinearLayoutManager.java
  4. +2
    -1
      app/src/main/java/com/example/bpa/view/fragment/HomeFragment.java
  5. +10
    -1
      app/src/main/java/com/example/bpa/view/from/add_pf_activity.java

+ 4
- 1
app/src/main/java/com/example/bpa/config/DataBus.java 파일 보기

@@ -1,5 +1,7 @@
package com.example.bpa.config;

import android.app.Activity;

import com.example.bpa.Model.ResultA;
import com.example.bpa.R;
import com.example.bpa.db.mode.BPA_SUBORDER;
@@ -135,10 +137,11 @@ public class DataBus {
QueryDB.UpdateSubOrder(item.subOrder);
good=item;
}

}
if(good!=null)
{
GoodsMakeOver.add(good);
//GoodsMakeOver.add(good);
GoodsMake.remove(good);
goodmakeadapter.refresh();
}


+ 32
- 23
app/src/main/java/com/example/bpa/db/QueryDB.java 파일 보기

@@ -1661,35 +1661,40 @@ public class QueryDB {
* @return
*/
private static boolean Add(Class c, Object data) {
ContentValues cv = new ContentValues();
Map<String, Object> map = Tools.getObjValue(data);
if (map.get("id").toString().isEmpty())
return false;
for (String key : map.keySet()) {
Object value = map.get(key);
if (value instanceof String) {
cv.put(key, (String) value);
} else if (value instanceof Integer) {
cv.put(key, ((Integer) value).intValue());
} else if (value instanceof Double) {
cv.put(key, ((Double) value).doubleValue());
} else if (value instanceof Float) {
cv.put(key, ((Float) value).floatValue());
} else if (value instanceof Long) {
cv.put(key, ((Long) value).longValue());
} else if (value instanceof Boolean) {
cv.put(key, ((Boolean) value).booleanValue());
}
try {
ContentValues cv = new ContentValues();
Map<String, Object> map = Tools.getObjValue(data);
if (map.get("id").toString().isEmpty())
return false;
for (String key : map.keySet()) {
Object value = map.get(key);
if (value instanceof String) {
cv.put(key, (String) value);
} else if (value instanceof Integer) {
cv.put(key, ((Integer) value).intValue());
} else if (value instanceof Double) {
cv.put(key, ((Double) value).doubleValue());
} else if (value instanceof Float) {
cv.put(key, ((Float) value).floatValue());
} else if (value instanceof Long) {
cv.put(key, ((Long) value).longValue());
} else if (value instanceof Boolean) {
cv.put(key, ((Boolean) value).booleanValue());
}
// else if (value instanceof Date)
// {
// cv.put(key, (Date) value);
// }
}

SQLiteDatabase db = helper.getWritableDatabase();
long insert = db.insert(c.getSimpleName(), null, cv);
db.close();
return insert > 0;
} catch (Exception e) {
return false;
}

SQLiteDatabase db = helper.getWritableDatabase();
long insert = db.insert(c.getSimpleName(), null, cv);
db.close();
return insert > 0;
}

/**
@@ -1700,6 +1705,7 @@ public class QueryDB {
* @return
*/
private static boolean Update(Class c, Object data) {
try {
ContentValues cv = new ContentValues();
Map<String, Object> map = Tools.getObjValue(data);
String id = map.get("id").toString();
@@ -1731,6 +1737,9 @@ public class QueryDB {
db.update(c.getSimpleName(), cv, "id = ?", new String[]{id});
db.close();
return true;
} catch (Exception e) {
return false;
}
}

/**


+ 30
- 0
app/src/main/java/com/example/bpa/helper/WrapContentLinearLayoutManager.java 파일 보기

@@ -0,0 +1,30 @@
package com.example.bpa.helper;

import android.content.Context;
import android.util.AttributeSet;

import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

public class WrapContentLinearLayoutManager extends LinearLayoutManager {
public WrapContentLinearLayoutManager(Context context) {
super(context);
}

public WrapContentLinearLayoutManager(Context context, int orientation, boolean reverseLayout) {
super(context, orientation, reverseLayout);
}

public WrapContentLinearLayoutManager(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
}

@Override
public void onLayoutChildren(RecyclerView.Recycler recycler, RecyclerView.State state) {
try {
super.onLayoutChildren(recycler, state);
} catch (IndexOutOfBoundsException e) {
e.printStackTrace();
}
}
}

+ 2
- 1
app/src/main/java/com/example/bpa/view/fragment/HomeFragment.java 파일 보기

@@ -13,6 +13,7 @@ import android.view.ViewGroup;

import com.example.bpa.R;
import com.example.bpa.config.DataBus;
import com.example.bpa.helper.WrapContentLinearLayoutManager;
import com.example.bpa.view.adapter.maingoods_adapter;
import com.example.bpa.view.adapter.makegood_adapter;
import com.example.bpa.view.control.MyLayoutManager;
@@ -79,7 +80,7 @@ public class HomeFragment extends Fragment implements View.OnClickListener, MyCl
DataBus.getInstance().UpdateMainGoods();//更新商品


MakeGood.setLayoutManager(new LinearLayoutManager(view.getContext(), LinearLayoutManager.HORIZONTAL,false));
MakeGood.setLayoutManager(new WrapContentLinearLayoutManager(view.getContext(), LinearLayoutManager.HORIZONTAL,false));
DataBus.getInstance().goodmakeadapter = new makegood_adapter(getContext());
MakeGood.setAdapter(DataBus.getInstance().goodmakeadapter);
}catch(Exception e){


+ 10
- 1
app/src/main/java/com/example/bpa/view/from/add_pf_activity.java 파일 보기

@@ -228,9 +228,9 @@ public class add_pf_activity extends AppCompatActivity implements View.OnClickLi
T.show(this, "配方信息不能为空!");
return;
}
String name = edittext.getText().toString();
if (good == null)//新增
{
String name = edittext.getText().toString();
if (name.isEmpty()) {
T.show(this, "商品名称不能为空!");
return;
@@ -249,6 +249,15 @@ public class add_pf_activity extends AppCompatActivity implements View.OnClickLi
good=goodx;
}else //修改
{
if (name.isEmpty()) {
T.show(this, "商品名称不能为空!");
return;
}
if (!name.equals(good.name) && QueryDB.GetGoodsIs(name)) {
T.show(this, "商品名称重复,请重新输入后重试!");
return;
}
good.name=name;
QueryDB.UpdateGoods(good);
QueryDB.DeleteGoodsSrecipeList(good.id);
}


불러오는 중...
취소
저장