|
|
@@ -54,7 +54,7 @@ public class yfpf_activity extends AppCompatActivity implements View.OnClickList |
|
|
|
/** |
|
|
|
* 商品数据 |
|
|
|
*/ |
|
|
|
ArrayList<BPA_GOODS> bpa_goods=new ArrayList<>(); |
|
|
|
ArrayList<BPA_GOODS> bpa_goods = new ArrayList<>(); |
|
|
|
//endregion |
|
|
|
|
|
|
|
//region 私有函数 |
|
|
@@ -72,13 +72,13 @@ public class yfpf_activity extends AppCompatActivity implements View.OnClickList |
|
|
|
/** |
|
|
|
* 初始化 |
|
|
|
*/ |
|
|
|
private void Init(){ |
|
|
|
private void Init() { |
|
|
|
gongneng_fanhui = this.findViewById(R.id.gongneng_fanhui); |
|
|
|
gongneng_title = this.findViewById(R.id.gongneng_title); |
|
|
|
buttonaddpf=this.findViewById(R.id.buttonaddpf); |
|
|
|
datatab= this.findViewById(R.id.datatab); |
|
|
|
buttonaddpf = this.findViewById(R.id.buttonaddpf); |
|
|
|
datatab = this.findViewById(R.id.datatab); |
|
|
|
//通过Activity.getIntent()获取当前页面接收到的Intent。 getXxxExtra方法获取Intent传递过来的数据 |
|
|
|
String msg=getIntent().getStringExtra("data"); |
|
|
|
String msg = getIntent().getStringExtra("data"); |
|
|
|
gongneng_title.setText(msg); |
|
|
|
Initdata();//初始化数据 |
|
|
|
RegisterMessage();//消息中心事件接收 |
|
|
@@ -95,19 +95,19 @@ public class yfpf_activity extends AppCompatActivity implements View.OnClickList |
|
|
|
/** |
|
|
|
* 初始化数据加载 |
|
|
|
*/ |
|
|
|
public void Initdata() |
|
|
|
{ |
|
|
|
try{ |
|
|
|
bpa_goods= QueryDB.GetGoodsALL(); |
|
|
|
sp_adapter adapter = new sp_adapter(yfpf_activity.this, R.layout.sp_item, bpa_goods,this); |
|
|
|
public void Initdata() { |
|
|
|
try { |
|
|
|
bpa_goods = QueryDB.GetGoodsALL(); |
|
|
|
sp_adapter adapter = new sp_adapter(yfpf_activity.this, R.layout.sp_item, bpa_goods, this); |
|
|
|
datatab.setAdapter(adapter); |
|
|
|
}catch(Exception e){ |
|
|
|
} catch (Exception e) { |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
//endregion |
|
|
|
|
|
|
|
//region 点击事件 |
|
|
|
|
|
|
|
/** |
|
|
|
* 本页面点击事件监听22 |
|
|
|
* |
|
|
@@ -132,89 +132,82 @@ public class yfpf_activity extends AppCompatActivity implements View.OnClickList |
|
|
|
* 接口方法,响应ListView按钮点击事件 |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public void clickListener(View v,Object data) { |
|
|
|
switch (v.getId()) |
|
|
|
{ |
|
|
|
public void clickListener(View v, Object data) { |
|
|
|
switch (v.getId()) { |
|
|
|
case R.id.button_item://删除按钮 |
|
|
|
int sort=((BPA_GOODS)data).sort; |
|
|
|
String id=((BPA_GOODS)data).id; |
|
|
|
Log.i("日志",sort + "--- "+id); |
|
|
|
QueryDB.DeleteGoods((BPA_GOODS)data); |
|
|
|
int sort = ((BPA_GOODS) data).sort; |
|
|
|
String id = ((BPA_GOODS) data).id; |
|
|
|
Log.i("日志", sort + "--- " + id); |
|
|
|
QueryDB.DeleteGoods((BPA_GOODS) data); |
|
|
|
Initdata(); |
|
|
|
for (BPA_GOODS k:bpa_goods) { |
|
|
|
if(k.sort>sort) |
|
|
|
{ |
|
|
|
QueryDB.GetGoodsSort(k,1); |
|
|
|
for (BPA_GOODS k : bpa_goods) { |
|
|
|
if (k.sort > sort) { |
|
|
|
QueryDB.GetGoodsSort(k, 1); |
|
|
|
} |
|
|
|
} |
|
|
|
Initdata(); |
|
|
|
break; |
|
|
|
case R.id.button_item_Up://上移动按钮 |
|
|
|
BPA_GOODS good=(BPA_GOODS)data; |
|
|
|
if(good.sort==1) |
|
|
|
{ |
|
|
|
BPA_GOODS good = (BPA_GOODS) data; |
|
|
|
if (good.sort == 1) { |
|
|
|
T.show(this, "已是最顶部!"); |
|
|
|
return; |
|
|
|
} |
|
|
|
QueryDB.GetGoodsSort((BPA_GOODS)data,1); |
|
|
|
QueryDB.GetGoodsSort((BPA_GOODS) data, 1); |
|
|
|
Initdata(); |
|
|
|
break; |
|
|
|
case R.id.button_item_Down://下移动按钮 |
|
|
|
BPA_GOODS good2=(BPA_GOODS)data; |
|
|
|
if(good2.sort==bpa_goods.size()) |
|
|
|
{ |
|
|
|
BPA_GOODS good2 = (BPA_GOODS) data; |
|
|
|
if (good2.sort == bpa_goods.size()) { |
|
|
|
T.show(this, "已是最底部!"); |
|
|
|
return; |
|
|
|
} |
|
|
|
QueryDB.GetGoodsSort((BPA_GOODS)data,0); |
|
|
|
QueryDB.GetGoodsSort((BPA_GOODS) data, 0); |
|
|
|
Initdata(); |
|
|
|
break; |
|
|
|
case R.id.button_item_update://修改按钮 |
|
|
|
Intent intent = new Intent(this, add_pf_activity.class); |
|
|
|
intent.putExtra("title", "修改配方"); |
|
|
|
intent.putExtra("data",new Json().objectToJson(BPA_GOODS.class,data)); |
|
|
|
intent.putExtra("data", new Json().objectToJson(BPA_GOODS.class, data)); |
|
|
|
startActivity(intent); |
|
|
|
break; |
|
|
|
case R.id.button_xf://下发按钮 |
|
|
|
BusinessServer.get().AddCommodity(((BPA_GOODS)data).id); |
|
|
|
BusinessServer.Get().AddCommodity(((BPA_GOODS) data).id); |
|
|
|
T.show(this, "下发成功!"); |
|
|
|
break; |
|
|
|
case R.id.button_qy://启用按钮 |
|
|
|
BPA_GOODS good3=(BPA_GOODS)data; |
|
|
|
good3.status=1; |
|
|
|
BPA_GOODS good3 = (BPA_GOODS) data; |
|
|
|
good3.status = 1; |
|
|
|
QueryDB.UpdateGoods(good3); |
|
|
|
Initdata(); |
|
|
|
T.show(this, good3.name+"-启用成功!"); |
|
|
|
T.show(this, good3.name + "-启用成功!"); |
|
|
|
break; |
|
|
|
case R.id.button_jy://下发按钮 |
|
|
|
BPA_GOODS good4=(BPA_GOODS)data; |
|
|
|
good4.status=0; |
|
|
|
BPA_GOODS good4 = (BPA_GOODS) data; |
|
|
|
good4.status = 0; |
|
|
|
QueryDB.UpdateGoods(good4); |
|
|
|
Initdata(); |
|
|
|
T.show(this, good4.name+"-禁用成功!"); |
|
|
|
T.show(this, good4.name + "-禁用成功!"); |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
//endregion |
|
|
|
|
|
|
|
//region 接收事件 |
|
|
|
public void RegisterMessage() |
|
|
|
{ |
|
|
|
public void RegisterMessage() { |
|
|
|
//配方界面关闭事件 |
|
|
|
MessageManager.getInstance().registerMessageReceiver(this, MessageName.PF_From_Close.name(), new MessageLooper.OnMessageListener() { |
|
|
|
@Override |
|
|
|
public void onMessage(Object msg) { |
|
|
|
if (msg != null) { |
|
|
|
if(msg.equals("Close")) |
|
|
|
{ |
|
|
|
if (msg.equals("Close")) { |
|
|
|
Initdata(); |
|
|
|
} |
|
|
|
}else |
|
|
|
{ |
|
|
|
} else { |
|
|
|
runOnUiThread(new Runnable() { |
|
|
|
@Override |
|
|
|
public void run() { |
|
|
|
T.show(yfpf_activity.this,"服务器异常,请稍后重试!"); |
|
|
|
T.show(yfpf_activity.this, "服务器异常,请稍后重试!"); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
@@ -225,16 +218,14 @@ public class yfpf_activity extends AppCompatActivity implements View.OnClickList |
|
|
|
@Override |
|
|
|
public void onMessage(Object msg) { |
|
|
|
if (msg != null) { |
|
|
|
if(msg.equals("Close")) |
|
|
|
{ |
|
|
|
if (msg.equals("Close")) { |
|
|
|
Initdata(); |
|
|
|
} |
|
|
|
}else |
|
|
|
{ |
|
|
|
} else { |
|
|
|
runOnUiThread(new Runnable() { |
|
|
|
@Override |
|
|
|
public void run() { |
|
|
|
T.show(yfpf_activity.this,"服务器异常,请稍后重试!"); |
|
|
|
T.show(yfpf_activity.this, "服务器异常,请稍后重试!"); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|