|
@@ -0,0 +1,272 @@
|
|
|
+package com.uas.pda_smart_com.fragment;
|
|
|
+
|
|
|
+import android.os.Bundle;
|
|
|
+import android.view.KeyEvent;
|
|
|
+import android.view.View;
|
|
|
+import android.widget.AdapterView;
|
|
|
+import android.widget.ListView;
|
|
|
+import android.widget.TextView;
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.android.volley.Request;
|
|
|
+import com.android.volley.toolbox.StringRequest;
|
|
|
+import com.handmark.pulltorefresh.library.PullToRefreshBase;
|
|
|
+import com.handmark.pulltorefresh.library.PullToRefreshListView;
|
|
|
+import com.uas.pda_smart_com.R;
|
|
|
+import com.uas.pda_smart_com.activity.FunctionActivity;
|
|
|
+import com.uas.pda_smart_com.adapter.StorageRechargeInspectionAdapter;
|
|
|
+import com.uas.pda_smart_com.bean.StorageRechargeInspectionBean;
|
|
|
+import com.uas.pda_smart_com.global.GloableParams;
|
|
|
+import com.uas.pda_smart_com.listener.MyEditorActionListener;
|
|
|
+import com.uas.pda_smart_com.util.CommonUtil;
|
|
|
+import com.uas.pda_smart_com.util.Constants;
|
|
|
+import com.uas.pda_smart_com.util.FastjsonUtil;
|
|
|
+import com.uas.pda_smart_com.util.FragmentUtils;
|
|
|
+import com.uas.pda_smart_com.util.HttpCallback;
|
|
|
+import com.uas.pda_smart_com.util.HttpParams;
|
|
|
+import com.uas.pda_smart_com.util.JsonUtils;
|
|
|
+import com.uas.pda_smart_com.util.VolleyRequest;
|
|
|
+import com.uas.pda_smart_com.view.ClearableEditText;
|
|
|
+import com.uas.pda_smart_com.view.EmptyLayout;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+public class InventoryDetailsQueryFragment extends BaseFragment implements HttpCallback {
|
|
|
+ private final int RECHARGE_GETLIST_NEEDGET = 31;
|
|
|
+
|
|
|
+ private String mCaller;
|
|
|
+ private ClearableEditText mSearchEditText;
|
|
|
+ private TextView mSearchButton;
|
|
|
+ private PullToRefreshListView mPullToRefreshListView;
|
|
|
+ private StringRequest mStringRequest;
|
|
|
+ private String mKeyword = "";
|
|
|
+ private int mPageIndex = 1, mPageSize = 10;
|
|
|
+ private EmptyLayout mEmptyLayout;
|
|
|
+ private List<StorageRechargeInspectionBean> mStorageRechargeInspectionBeans;
|
|
|
+ private StorageRechargeInspectionAdapter mStorageRechargeInspectionAdapter;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected int getLayout() {
|
|
|
+ return R.layout.fragment_storage_recharge_list;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected void initViews() {
|
|
|
+ Bundle arguments = getArguments();
|
|
|
+ if (arguments != null) {
|
|
|
+ mCaller = arguments.getString(Constants.FLAG.FLAG_RECHARGE_CALLER);
|
|
|
+
|
|
|
+ if ("AcceptNotify!Have".equals(mCaller)) {
|
|
|
+ FunctionActivity.setTitle("已转收料");
|
|
|
+ } else if ("AcceptNotify!Need".equals(mCaller)) {
|
|
|
+ FunctionActivity.setTitle("未转收料");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ mSearchEditText = root.findViewById(R.id.storage_recharge_search_cet);
|
|
|
+ mSearchButton = root.findViewById(R.id.storage_recharge_search_btn);
|
|
|
+ mPullToRefreshListView = root.findViewById(R.id.storage_recharge_list_lv);
|
|
|
+ mPullToRefreshListView.setMode(PullToRefreshBase.Mode.BOTH);
|
|
|
+ mStorageRechargeInspectionBeans = new ArrayList<>();
|
|
|
+ mStorageRechargeInspectionAdapter = new StorageRechargeInspectionAdapter(mActivity, mStorageRechargeInspectionBeans);
|
|
|
+ mStorageRechargeInspectionAdapter.setItemType(StorageRechargeInspectionAdapter.TYPE_STORAGE_RECHARGE);
|
|
|
+ mPullToRefreshListView.setAdapter(mStorageRechargeInspectionAdapter);
|
|
|
+
|
|
|
+ mEmptyLayout = new EmptyLayout(mActivity, mPullToRefreshListView.getRefreshableView());
|
|
|
+ mEmptyLayout.setShowLoadingButton(false);
|
|
|
+ mEmptyLayout.setShowEmptyButton(false);
|
|
|
+ mEmptyLayout.setShowErrorButton(false);
|
|
|
+ mEmptyLayout.setEmptyMessage("数据为空");
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected void initEvents() {
|
|
|
+ CommonUtil.setEditorActionListener(mSearchEditText, new MyEditorActionListener() {
|
|
|
+ @Override
|
|
|
+ public void MyEditorAction(String text, int actionId, KeyEvent event) {
|
|
|
+ mPageIndex = 1;
|
|
|
+ mKeyword = text;
|
|
|
+ progressDialog.show();
|
|
|
+ getList();
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ mSearchButton.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View view) {
|
|
|
+ mPageIndex = 1;
|
|
|
+ mKeyword = mSearchEditText.getText().toString().trim();
|
|
|
+ progressDialog.show();
|
|
|
+ getList();
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ mPullToRefreshListView.setOnRefreshListener(new PullToRefreshBase.OnRefreshListener2<ListView>() {
|
|
|
+ @Override
|
|
|
+ public void onPullDownToRefresh(PullToRefreshBase<ListView> refreshView) {
|
|
|
+ mPageIndex = 1;
|
|
|
+ getList();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onPullUpToRefresh(PullToRefreshBase<ListView> refreshView) {
|
|
|
+ mPageIndex++;
|
|
|
+ getList();
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ mPullToRefreshListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
|
|
+ final int reallyPosition = (int) parent.getItemIdAtPosition(position);
|
|
|
+ StorageRechargeInspectionBean storageRechargeInspectionBean = mStorageRechargeInspectionBeans.get(reallyPosition);
|
|
|
+ StorageRechargeDetailFragment fragment = new StorageRechargeDetailFragment();
|
|
|
+
|
|
|
+ fragment.setOnRechargeSuccessListener(new StorageRechargeDetailFragment.OnRechargeSuccessListener() {
|
|
|
+ @Override
|
|
|
+ public void onRechargeSuccess() {
|
|
|
+ mStorageRechargeInspectionBeans.remove(reallyPosition);
|
|
|
+ mStorageRechargeInspectionAdapter.notifyDataSetChanged();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ Bundle bundle = new Bundle();
|
|
|
+ bundle.putSerializable(Constants.FLAG.FLAG_RECHARGE_DETAIL, storageRechargeInspectionBean);
|
|
|
+ fragment.setArguments(bundle);
|
|
|
+
|
|
|
+ FragmentUtils.switchFragment(InventoryDetailsQueryFragment.this, fragment);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected void initDatas() {
|
|
|
+ mKeyword = "";
|
|
|
+ mPageIndex = 1;
|
|
|
+ progressDialog.show();
|
|
|
+ getList();
|
|
|
+ }
|
|
|
+
|
|
|
+ private void getList() {
|
|
|
+ String url = GloableParams.ADDRESS_INVENTORY_DETAILS_QUERY + "?caller=" + mCaller
|
|
|
+ + "&code=" + mKeyword + "&page=" + mPageIndex + "&pageSize=" + mPageSize;
|
|
|
+ VolleyRequest.getInstance().stringRequest(mStringRequest,
|
|
|
+ new HttpParams.Builder()
|
|
|
+ .url(url)
|
|
|
+ .method(Request.Method.GET)
|
|
|
+ .tag(TAG + "getRechargeList")
|
|
|
+ .flag(RECHARGE_GETLIST_NEEDGET)
|
|
|
+ .build(), this);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onHiddenChanged(boolean hidden) {
|
|
|
+ super.onHiddenChanged(hidden);
|
|
|
+ if (hidden) {
|
|
|
+
|
|
|
+ } else {
|
|
|
+ if ("AcceptNotify!Have".equals(mCaller)) {
|
|
|
+ FunctionActivity.setTitle("已转收料");
|
|
|
+ } else if ("AcceptNotify!Need".equals(mCaller)) {
|
|
|
+ FunctionActivity.setTitle("未转收料");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onSuccess(int flag, Object o) throws Exception {
|
|
|
+ progressDialog.dismiss();
|
|
|
+ if (mPullToRefreshListView.isRefreshing()) {
|
|
|
+ mPullToRefreshListView.onRefreshComplete();
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ if (mPageIndex == 1) {
|
|
|
+ mStorageRechargeInspectionBeans.clear();
|
|
|
+ }
|
|
|
+ if (o != null) {
|
|
|
+ String result = o.toString();
|
|
|
+ if (JsonUtils.validate(result)) {
|
|
|
+ JSONObject resultObject = JSON.parseObject(result);
|
|
|
+ JSONArray dataArray = resultObject.getJSONArray("data");
|
|
|
+ if (dataArray != null) {
|
|
|
+ for (int i = 0; i < dataArray.size(); i++) {
|
|
|
+ JSONObject dataObject = dataArray.getJSONObject(i);
|
|
|
+ if (dataObject != null) {
|
|
|
+ JSONObject mainObject = dataObject.getJSONObject("main");
|
|
|
+
|
|
|
+ StorageRechargeInspectionBean storageRechargeInspectionBean = new StorageRechargeInspectionBean();
|
|
|
+ storageRechargeInspectionBean.setId(FastjsonUtil.getLong(mainObject, "AN_ID"));
|
|
|
+ storageRechargeInspectionBean.setCode(FastjsonUtil.getText(mainObject, "AN_CODE"));
|
|
|
+ storageRechargeInspectionBean.setBillClass(FastjsonUtil.getText(mainObject, ""));
|
|
|
+ storageRechargeInspectionBean.setDate(FastjsonUtil.getLong(mainObject, "AN_DATE"));
|
|
|
+ storageRechargeInspectionBean.setStates(FastjsonUtil.getText(mainObject, "AN_STATUS"));
|
|
|
+ storageRechargeInspectionBean.setRecorder(FastjsonUtil.getText(mainObject, "AN_RECORDER"));
|
|
|
+ storageRechargeInspectionBean.setVendcode(FastjsonUtil.getText(mainObject, "AN_VENDCODE"));
|
|
|
+ storageRechargeInspectionBean.setVendname(FastjsonUtil.getText(mainObject, "AN_VENDNAME"));
|
|
|
+ storageRechargeInspectionBean.setDetailJson(FastjsonUtil.getText(dataObject, "detail"));
|
|
|
+ storageRechargeInspectionBean.setSlipable(FastjsonUtil.getBoolean(dataObject, "ifShowButton"));
|
|
|
+ storageRechargeInspectionBean.setAN_INDATE(FastjsonUtil.getText(mainObject, "AN_INDATE"));
|
|
|
+
|
|
|
+ mStorageRechargeInspectionBeans.add(storageRechargeInspectionBean);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ mStorageRechargeInspectionAdapter.notifyDataSetChanged();
|
|
|
+ if (mStorageRechargeInspectionBeans.size() == 0) {
|
|
|
+ mEmptyLayout.showEmpty();
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ mStorageRechargeInspectionAdapter.notifyDataSetChanged();
|
|
|
+ if (mStorageRechargeInspectionBeans.size() == 0) {
|
|
|
+ mEmptyLayout.showEmpty();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ mStorageRechargeInspectionAdapter.notifyDataSetChanged();
|
|
|
+ if (mStorageRechargeInspectionBeans.size() == 0) {
|
|
|
+ mEmptyLayout.showEmpty();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ mStorageRechargeInspectionAdapter.notifyDataSetChanged();
|
|
|
+ if (mStorageRechargeInspectionBeans.size() == 0) {
|
|
|
+ mEmptyLayout.showEmpty();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ mStorageRechargeInspectionAdapter.notifyDataSetChanged();
|
|
|
+ if (mStorageRechargeInspectionBeans.size() == 0) {
|
|
|
+ mEmptyLayout.showEmpty();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onFail(int flag, String failStr) throws Exception {
|
|
|
+ progressDialog.dismiss();
|
|
|
+ if (mPullToRefreshListView.isRefreshing()) {
|
|
|
+ mPullToRefreshListView.onRefreshComplete();
|
|
|
+ }
|
|
|
+ if (mPageIndex == 1) {
|
|
|
+ mStorageRechargeInspectionBeans.clear();
|
|
|
+ mEmptyLayout.setErrorMessage(failStr);
|
|
|
+ mEmptyLayout.showError();
|
|
|
+ mStorageRechargeInspectionAdapter.notifyDataSetChanged();
|
|
|
+ } else {
|
|
|
+ mPageIndex--;
|
|
|
+ CommonUtil.toastNoRepeat(mActivity, failStr);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public boolean onKeyDown(int keyCode, KeyEvent event) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public boolean onFragmentBackPressed() {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+}
|