完成 仓库下拉加载的测试

master
wangh 7 months ago
parent 8a9763ddb3
commit 6140048236

@ -43,19 +43,21 @@ public class InventoryTaskCreateActivity extends BaseActivity implements Adapter
private List<HouseLocation> list;
private Map<String, Object> 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.<MyResult>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<MyResult> 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<List<HouseLocation>>() {
}.getType());
adapter.setList(list);
binding.inventoryCreateRefresh.finishLoadMore(500);
list.addAll(gson.fromJson(gson.toJson(body.getRows()), new TypeToken<List<HouseLocation>>() {
}.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");
}
}

@ -62,15 +62,16 @@
android:layout_weight="1"
app:srlEnableRefresh="false"
>
<!-- -->
>
<!-- app:srlEnableLoadMoreWhenContentNotFull="false" -->
<androidx.recyclerview.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:adapter="@{adapter}"
android:background="@color/white"
android:overScrollMode="never"
android:padding="5dp" app:srlEnableLoadMoreWhenContentNotFull="false"
android:padding="5dp"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" />
<com.scwang.smart.refresh.footer.ClassicsFooter

Loading…
Cancel
Save