|
|
@@ -18,25 +18,23 @@ import com.bonait.bnframework.R; |
|
|
|
import com.bonait.bnframework.business.RecordManager; |
|
|
|
import com.bonait.bnframework.common.base.BaseFragment; |
|
|
|
import com.bonait.bnframework.common.constant.ConfigName; |
|
|
|
import com.bonait.bnframework.common.db.mode.BPA_ATTRIBUTE; |
|
|
|
import com.bonait.bnframework.common.db.mode.BPA_GOODS; |
|
|
|
import com.bonait.bnframework.common.db.mode.BPA_GOODS_CLASSIFY; |
|
|
|
import com.bonait.bnframework.common.db.mode.BPA_SUBATTRIBUTE; |
|
|
|
import com.bonait.bnframework.common.db.util.AttributeDBUtil; |
|
|
|
import com.bonait.bnframework.common.db.util.GoodsDBUtil; |
|
|
|
import com.bonait.bnframework.common.db.util.GoodsClassifyDBUtil; |
|
|
|
import com.bonait.bnframework.common.db.util.SubAttributeDBUtil; |
|
|
|
import com.bonait.bnframework.common.db.util.SubAttributeGroupDBUtil; |
|
|
|
import com.bonait.bnframework.common.helper.I.MyClickListener; |
|
|
|
import com.bonait.bnframework.common.utils.AlertDialogUtils; |
|
|
|
import com.bonait.bnframework.databinding.DialogAddClassifyBinding; |
|
|
|
import com.bonait.bnframework.databinding.DialogDeleteClassifyBinding; |
|
|
|
import com.bonait.bnframework.databinding.FragmentGoodEditClassifyBinding; |
|
|
|
import com.bonait.bnframework.ui.adapter.classify.AttributeAdapter; |
|
|
|
import com.bonait.bnframework.ui.adapter.classify.SubattributeAdapter; |
|
|
|
import com.bonait.bnframework.ui.adapter.goods.LocalGoodsAdapter; |
|
|
|
import com.bonait.bnframework.ui.util.DisplayManager; |
|
|
|
import com.bonait.bnframework.ui.widget.NewToastUtil; |
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.LinkedHashMap; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
@@ -62,7 +60,26 @@ public class GoodEditClassifyFragment extends BaseFragment { |
|
|
|
private final List<String> classifyNameList = new ArrayList<>(); |
|
|
|
private boolean isUserClicked = false; |
|
|
|
private int classifyPosition = 0;//选中位置 |
|
|
|
private LocalGoodsAdapter goodsAdapter; |
|
|
|
private boolean isEdit = false; |
|
|
|
|
|
|
|
private String CurrentGoodClassifyId; |
|
|
|
/** |
|
|
|
* 判断重复点击 |
|
|
|
*/ |
|
|
|
private long lastTime; |
|
|
|
private long lastTime2; |
|
|
|
|
|
|
|
private ArrayList<BPA_GOODS> goodsList = new ArrayList<>(); |
|
|
|
|
|
|
|
public boolean isFast2Click(){ |
|
|
|
long curTime = System.currentTimeMillis(); |
|
|
|
if(curTime - lastTime2 < 1000){ |
|
|
|
return true; |
|
|
|
} |
|
|
|
lastTime2 = curTime; |
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
protected View onCreateView() { |
|
|
@@ -79,6 +96,7 @@ public class GoodEditClassifyFragment extends BaseFragment { |
|
|
|
DisplayManager.scaleViewGroup(viewBinding.getRoot()); |
|
|
|
initData(); |
|
|
|
initView(); |
|
|
|
|
|
|
|
// EventBus.getDefault().register(this); |
|
|
|
} |
|
|
|
|
|
|
@@ -89,6 +107,7 @@ public class GoodEditClassifyFragment extends BaseFragment { |
|
|
|
for(BPA_GOODS_CLASSIFY goodsClassify:GoodsClassifyDBUtil.getAll()){ |
|
|
|
classifyList.put(goodsClassify.name,goodsClassify.id); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
@@ -103,6 +122,13 @@ public class GoodEditClassifyFragment extends BaseFragment { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private void setSelectStatus(int value){ |
|
|
|
for(BPA_GOODS good:goodsList){ |
|
|
|
good.status=value; |
|
|
|
} |
|
|
|
goodsAdapter.notifyDataSetChanged(); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 初始化 |
|
|
|
* 修改子属性 |
|
|
@@ -131,6 +157,26 @@ public class GoodEditClassifyFragment extends BaseFragment { |
|
|
|
{ |
|
|
|
selectClassify(i); |
|
|
|
isUserClicked = false; |
|
|
|
if(i>0 && i<classifyNameList.size()){ |
|
|
|
BPA_GOODS_CLASSIFY goodClassify = GoodsClassifyDBUtil.getByName(classifyNameList.get(i)); |
|
|
|
if(goodClassify!=null){ |
|
|
|
CurrentGoodClassifyId=goodClassify.id; |
|
|
|
ArrayList<BPA_GOODS> goods = GoodsDBUtil.getByClassifyId(goodClassify.id); |
|
|
|
Map<String,BPA_GOODS> goodMap = new HashMap<>(); |
|
|
|
if(goods!=null){ |
|
|
|
for (BPA_GOODS good:goods){ |
|
|
|
goodMap.put(good.name,good); |
|
|
|
} |
|
|
|
for(BPA_GOODS good:goodsList){ |
|
|
|
good.status=goodMap.containsKey(good.name)?1:2; |
|
|
|
} |
|
|
|
goodsAdapter.notifyDataSetChanged(); |
|
|
|
} |
|
|
|
} |
|
|
|
}else{ |
|
|
|
setSelectStatus(0); |
|
|
|
CurrentGoodClassifyId=""; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@@ -138,9 +184,57 @@ public class GoodEditClassifyFragment extends BaseFragment { |
|
|
|
public void onNothingSelected(AdapterView<?> adapterView) { |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
goodsAdapter = new LocalGoodsAdapter(){ |
|
|
|
|
|
|
|
@Override |
|
|
|
protected void onItemClick(View v, int position) { |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
protected void uploadGoods(View v, int position) { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
protected void deleteGoods(View v, int position) { |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
protected void selectGoods(View v, int position,boolean isSelect){ |
|
|
|
if(!CurrentGoodClassifyId.equals("")){ |
|
|
|
mData.get(position).goodClassifyid=isSelect?CurrentGoodClassifyId:""; |
|
|
|
BPA_GOODS bg = new BPA_GOODS(); |
|
|
|
bg.name=mData.get(position).name; |
|
|
|
bg.url=mData.get(position).url; |
|
|
|
bg.sort=mData.get(position).sort; |
|
|
|
bg.status=0; |
|
|
|
bg.isCollect=mData.get(position).isCollect; |
|
|
|
bg.propClassifyId=mData.get(position).propClassifyId; |
|
|
|
bg.goodClassifyid=mData.get(position).goodClassifyid; |
|
|
|
|
|
|
|
bg.id=mData.get(position).id; |
|
|
|
bg.createTime=mData.get(position).createTime; |
|
|
|
bg.updateTime=mData.get(position).updateTime; |
|
|
|
bg.deleteTime=mData.get(position).deleteTime; |
|
|
|
bg.deviceID=mData.get(position).deviceID; |
|
|
|
bg.userID=mData.get(position).userID; |
|
|
|
bg.isDelete=mData.get(position).isDelete; |
|
|
|
bg.exp=mData.get(position).exp; |
|
|
|
|
|
|
|
GoodsDBUtil.update(bg); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
protected void addGoods() { |
|
|
|
} |
|
|
|
}; |
|
|
|
viewBinding.recyclerGoods.setAdapter(goodsAdapter); |
|
|
|
goodsList.clear(); |
|
|
|
goodsList.addAll(GoodsDBUtil.getAll()); |
|
|
|
goodsAdapter.setNewData(goodsList); |
|
|
|
} |
|
|
|
|
|
|
|
@SuppressLint("NonConstantResourceId") |
|
|
|
@OnClick({R.id.btn_add_classify,R.id.btn_update_classify,R.id.btn_delete_classify}) |
|
|
@@ -286,7 +380,7 @@ public class GoodEditClassifyFragment extends BaseFragment { |
|
|
|
if(GoodsClassifyDBUtil.deleteById(classifyId)){ |
|
|
|
GoodsClassifyDBUtil.DeleteList(GoodsClassifyDBUtil.getListByName(classifyName)); |
|
|
|
AttributeDBUtil.deleteByClassifyId(classifyId); |
|
|
|
GoodsDBUtil.deleteByClassifyId(classifyId); |
|
|
|
GoodsDBUtil.deleteByGoodClassifyId(classifyId); |
|
|
|
SubAttributeGroupDBUtil.deleteByClassifyId(classifyId); |
|
|
|
SubAttributeDBUtil.deleteByClassifyId(classifyId); |
|
|
|
|
|
|
|