diff --git a/app/src/main/java/com/example/jingyuan_mes/store/InventoryTaskCreateActivity.java b/app/src/main/java/com/example/jingyuan_mes/store/InventoryTaskCreateActivity.java index 7776916..5389588 100644 --- a/app/src/main/java/com/example/jingyuan_mes/store/InventoryTaskCreateActivity.java +++ b/app/src/main/java/com/example/jingyuan_mes/store/InventoryTaskCreateActivity.java @@ -43,19 +43,21 @@ public class InventoryTaskCreateActivity extends BaseActivity implements Adapter private List list; private Map map; private int pageNum = 1; + private int pageSize = 1; private int warehouseId; private Intent intent; + private String warehouseName; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); binding = DataBindingUtil.setContentView(this, R.layout.activity_inventory_task_create); adapter = new InventoryLocationAdapter(this); + list = new ArrayList<>(); + adapter.setList(list); binding.setAdapter(adapter); binding.inventoryCreateRefresh.setOnLoadMoreListener(this); - intent = new Intent(this, InventoryWorkActivity.class); - map = new HashMap<>(); lpw = new ListPopupWindow(this); lpw.setAnchorView(binding.inventoryCreateHouse); @@ -67,8 +69,9 @@ public class InventoryTaskCreateActivity extends BaseActivity implements Adapter if (warehouseId == 0) { initRequest(); } else { - var warehouseName = intent.getStringExtra("warehouseName"); - createLocation(warehouseId, warehouseName); + warehouseName = intent.getStringExtra("warehouseName"); + list.clear(); + createLocation(1); } } @@ -103,32 +106,39 @@ public class InventoryTaskCreateActivity extends BaseActivity implements Adapter warehouseId = warehouseBeen.getWarehouseId(); lpw.dismiss(); pageNum = 1; - createLocation(warehouseId, warehouseBeen.getWarehouseName()); + warehouseName = warehouseBeen.getWarehouseName(); + createLocation(pageNum); } + private int total; + // 请求库位 - private void createLocation(int warehouseId, String warehouseName) { + private void createLocation(int pageNum) { binding.inventoryCreateHouse.setText(warehouseName); map.put("warehouseId", warehouseId); OkGo.get(url + "/wms/mobile/getLocations").tag(this) .headers("Authorization", SharedPreferencesUtils.getstring("access_token", "")) .params("warehouseId", warehouseId) .params("pageNum", pageNum) - .params("pagesize", 10) + .params("pageSize", pageSize) .execute(new MyRecultCall(dialog, this) { @SuppressLint("NotifyDataSetChanged") @Override public void onSuccess(Response response) { super.onSuccess(response); var body = response.body(); - if (body.getTotal() == 0) { + + total = body.getTotal(); + if (total == 0) { + list.clear(); + adapter.notifyDataSetChanged(); Toast.makeText(context, body.getCode() == 200 ? "暂无记录" : body.getMsg(), Toast.LENGTH_SHORT).show(); return; } - list = gson.fromJson(gson.toJson(body.getRows()), new TypeToken>() { - }.getType()); - adapter.setList(list); + binding.inventoryCreateRefresh.finishLoadMore(500); + list.addAll(gson.fromJson(gson.toJson(body.getRows()), new TypeToken>() { + }.getType())); adapter.notifyDataSetChanged(); } }); @@ -157,7 +167,6 @@ public class InventoryTaskCreateActivity extends BaseActivity implements Adapter super.onSuccess(response); var body = response.body(); if (body.getCode() == 200) { - intent.putExtra("inventoryCheckId", (int) Double.parseDouble(body.getData().toString())); // intent.putExtra("checkStatus",); startActivity(intent); @@ -170,8 +179,13 @@ public class InventoryTaskCreateActivity extends BaseActivity implements Adapter @Override public void onLoadMore(@NonNull RefreshLayout refreshLayout) { + if (pageNum*pageSize>=total){ + binding.inventoryCreateRefresh.finishLoadMore(false); + Toast.makeText(context, "列表加载完成", Toast.LENGTH_SHORT).show(); + return; + } pageNum++; - // createLocation(); + createLocation(pageNum); Log.e("TAG", "onLoadMore"); } } \ No newline at end of file diff --git a/app/src/main/res/layout/activity_inventory_task_create.xml b/app/src/main/res/layout/activity_inventory_task_create.xml index d5471bd..a16c58b 100644 --- a/app/src/main/res/layout/activity_inventory_task_create.xml +++ b/app/src/main/res/layout/activity_inventory_task_create.xml @@ -62,15 +62,16 @@ android:layout_weight="1" app:srlEnableRefresh="false" - > - + > +