|
@@ -1,391 +0,0 @@
|
|
|
-package com.uas.pda_smart_com.fragment;
|
|
|
-
|
|
|
-import android.app.ActionBar;
|
|
|
-import android.app.Activity;
|
|
|
-import android.content.Context;
|
|
|
-import android.content.Intent;
|
|
|
-import android.graphics.drawable.BitmapDrawable;
|
|
|
-import android.os.AsyncTask;
|
|
|
-import android.util.Log;
|
|
|
-import android.view.Gravity;
|
|
|
-import android.view.KeyEvent;
|
|
|
-import android.view.View;
|
|
|
-import android.view.Window;
|
|
|
-import android.view.inputmethod.InputMethodManager;
|
|
|
-import android.widget.AdapterView;
|
|
|
-import android.widget.EditText;
|
|
|
-import android.widget.ImageView;
|
|
|
-import android.widget.ListView;
|
|
|
-import android.widget.PopupWindow;
|
|
|
-import android.widget.TextView;
|
|
|
-
|
|
|
-import com.google.gson.reflect.TypeToken;
|
|
|
-import com.uas.pda_smart_com.R;
|
|
|
-import com.uas.pda_smart_com.activity.FunctionActivity;
|
|
|
-import com.uas.pda_smart_com.adapter.WHCheckMakeDetailListAdapter;
|
|
|
-import com.uas.pda_smart_com.adapter.WHCheckMakeMaterialListAdapter;
|
|
|
-import com.uas.pda_smart_com.bean.WHMakeMaterialDetail;
|
|
|
-import com.uas.pda_smart_com.bean.WHMakeMaterialProduct;
|
|
|
-import com.uas.pda_smart_com.global.GloableParams;
|
|
|
-import com.uas.pda_smart_com.tools.DataSourceManager;
|
|
|
-import com.uas.pda_smart_com.tools.GsonUtil;
|
|
|
-import com.uas.pda_smart_com.tools.VolleyUtil;
|
|
|
-import com.uas.pda_smart_com.util.CameraUtil;
|
|
|
-import com.uas.pda_smart_com.util.CommonUtil;
|
|
|
-import com.uas.pda_smart_com.view.ClearableEditText;
|
|
|
-import com.uas.pda_smart_com.view.ConfirmDialog;
|
|
|
-import com.uuzuche.lib_zxing.activity.CaptureActivity;
|
|
|
-import com.uuzuche.lib_zxing.activity.CodeUtils;
|
|
|
-
|
|
|
-import org.json.JSONArray;
|
|
|
-import org.json.JSONException;
|
|
|
-import org.json.JSONObject;
|
|
|
-
|
|
|
-import java.util.List;
|
|
|
-
|
|
|
-/**
|
|
|
- * @note:物料库存核查Fragment
|
|
|
- */
|
|
|
-public class WHCheckMakeMaterialFragment extends BaseFragment implements View.OnClickListener, DataSourceManager.NotifyData, AdapterView.OnItemClickListener, VolleyUtil.VolleyFinishListener {
|
|
|
- private static final int SCAN_BARCODE_CODE = 301;
|
|
|
- ClearableEditText etProdcode, etWhcode;
|
|
|
- TextView tvPrDetail, tvPrSpec;
|
|
|
- TextView btnSearch;
|
|
|
- WHCheckMakeMaterialListAdapter adapter;
|
|
|
- List<WHMakeMaterialProduct> detailItemList;
|
|
|
- int requestType = -1;
|
|
|
- private ListView lvDetail;
|
|
|
- private ImageView mScanImageView;
|
|
|
- private int mFocusId;
|
|
|
-
|
|
|
- @Override
|
|
|
- protected int getLayout() {
|
|
|
- return R.layout.fragment_whcheck_makematerial;
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- protected void initViews() {
|
|
|
- ((FunctionActivity) mActivity).setScanIvVisible(true);
|
|
|
- detailItemList = DataSourceManager.getDataSourceManager().getMakeMaterialCheckItemList();
|
|
|
- //接口回调
|
|
|
- //VolleyUtil.setVolleyHandler(volleyHandler);
|
|
|
- VolleyUtil.getVolleyUtil().setOnVolleyFinishListener(this);
|
|
|
- DataSourceManager.getDataSourceManager().setNotifyData(this);
|
|
|
- //获取组件
|
|
|
- //->List
|
|
|
- lvDetail = (ListView) root.findViewById(R.id.lv_detail_whmm);
|
|
|
- Log.e("tableList", detailItemList.toString());
|
|
|
- adapter = new WHCheckMakeMaterialListAdapter(detailItemList, getActivity());
|
|
|
- lvDetail.setAdapter(adapter);
|
|
|
- //->采集
|
|
|
- etProdcode = (ClearableEditText) root.findViewById(R.id.et_prodcode_whmm);
|
|
|
- etWhcode = (ClearableEditText) root.findViewById(R.id.et_whcode_whmm);
|
|
|
- btnSearch = (TextView) root.findViewById(R.id.btn_search_whmm);
|
|
|
- //->信息显示
|
|
|
- tvPrDetail = (TextView) root.findViewById(R.id.tv_pr_detail);
|
|
|
- tvPrSpec = (TextView) root.findViewById(R.id.tv_pr_spec);
|
|
|
-
|
|
|
- mScanImageView = (ImageView) mActivity.findViewById(R.id.btn_actionbar_scan_iv);
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- protected void initEvents() {
|
|
|
- btnSearch.setOnClickListener(this);
|
|
|
- lvDetail.setOnItemClickListener(this);
|
|
|
- etProdcode.setOnKeyListener(new View.OnKeyListener() {
|
|
|
- @Override
|
|
|
- public boolean onKey(View v, int keyCode, KeyEvent event) {
|
|
|
- if (keyCode == KeyEvent.KEYCODE_ENTER && event.getAction() == KeyEvent.ACTION_UP) {
|
|
|
- disposeOnClickEnter();
|
|
|
- return true;
|
|
|
- }
|
|
|
- return false;
|
|
|
- }
|
|
|
- });
|
|
|
-
|
|
|
- mScanImageView.setOnClickListener(new View.OnClickListener() {
|
|
|
- @Override
|
|
|
- public void onClick(View v) {
|
|
|
- if (CameraUtil.hasCamera()) {
|
|
|
- if (root.findFocus() != null) {
|
|
|
- mFocusId = root.findFocus().getId();
|
|
|
- Intent intent = new Intent();
|
|
|
- intent.setClass(mActivity, CaptureActivity.class);
|
|
|
- startActivityForResult(intent, SCAN_BARCODE_CODE);
|
|
|
- }
|
|
|
- } else {
|
|
|
- CommonUtil.toastNoRepeat(mActivity, getString(R.string.no_camera_detected));
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- protected void initDatas() {
|
|
|
- editTextGetFocus(etProdcode);
|
|
|
- //->Actionbar
|
|
|
- ((TextView) (getActivity().findViewById(R.id.tv_actionbar_withback))).setText(R.string.title_makematerial_whmm);
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
|
|
- super.onActivityResult(requestCode, resultCode, data);
|
|
|
-
|
|
|
- if (resultCode != Activity.RESULT_OK) {
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- if (requestCode == SCAN_BARCODE_CODE && data != null) {
|
|
|
- if (data.getExtras() != null) {
|
|
|
- String result = data.getExtras().getString(CodeUtils.RESULT_STRING);
|
|
|
- if (mFocusId == R.id.et_prodcode_whmm) {
|
|
|
- etProdcode.setText(result);
|
|
|
- etProdcode.setSelection(result.length());
|
|
|
- } else if (mFocusId == R.id.et_whcode_whmm) {
|
|
|
- etWhcode.setText(result);
|
|
|
- etWhcode.setSelection(result.length());
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- //按钮点击事件
|
|
|
- private void disposeOnClickEnter() {
|
|
|
- String strProdcode = etProdcode.getText().toString().trim();
|
|
|
- String strWhcode = etWhcode.getText().toString().trim();
|
|
|
- if (strProdcode.equals("") || strProdcode == null) {
|
|
|
- etProdcode.setWarnIconVisible();
|
|
|
- return;
|
|
|
- }
|
|
|
- //请求详细数据
|
|
|
- showLoadingView();
|
|
|
- requestType = VolleyUtil.FRAGMETN_WHCHECK_PRODUCT_CHECK;
|
|
|
- VolleyUtil.getVolleyUtil().requestMakeMaterialCheck(getActivity(), GloableParams.ADDRESS_WH_PRODUCT, VolleyUtil.METHOD_GET,
|
|
|
- requestType, strProdcode, strWhcode);
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void onDestroy() {
|
|
|
- //清理数据
|
|
|
- detailItemList.removeAll(detailItemList);
|
|
|
- hideKeyboard(etProdcode);
|
|
|
- VolleyUtil.distoryVolley();
|
|
|
-
|
|
|
- ((FunctionActivity) mActivity).setScanIvVisible(false);
|
|
|
- super.onDestroy();
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- /*=============================明细PopWin页面============================*/
|
|
|
-
|
|
|
- /**
|
|
|
- * @注释:明细popwin页面
|
|
|
- */
|
|
|
- PopupWindow detailPopwin;
|
|
|
-
|
|
|
- private void showDetailPopwin(List dataList) {
|
|
|
- if (dataList == null || dataList.size() == 0) {
|
|
|
- showNotice("无明细数据");
|
|
|
- return;
|
|
|
- }
|
|
|
- View contentView = View.inflate(getActivity(), R.layout.popwin_whcheck_detail, null);
|
|
|
- //获取组件
|
|
|
- //->List
|
|
|
- ListView lvDetail = (ListView) contentView.findViewById(R.id.lv_detail);
|
|
|
- WHCheckMakeDetailListAdapter adapter = new WHCheckMakeDetailListAdapter(getActivity(), dataList);
|
|
|
- lvDetail.setAdapter(adapter);
|
|
|
- TextView tv = (TextView) contentView.findViewById(R.id.tv_table_3);
|
|
|
- //PopupWindow
|
|
|
- detailPopwin = new PopupWindow(contentView, ActionBar.LayoutParams.MATCH_PARENT, ActionBar.LayoutParams.WRAP_CONTENT);
|
|
|
- detailPopwin.setBackgroundDrawable(new BitmapDrawable());
|
|
|
- detailPopwin.setFocusable(true);
|
|
|
- detailPopwin.setOutsideTouchable(true);
|
|
|
- View parentView = ((Activity) getActivity()).getWindow().findViewById(Window.ID_ANDROID_CONTENT);
|
|
|
- //当pop菜单超出屏幕时,平移位置
|
|
|
- detailPopwin.showAtLocation(parentView, Gravity.CENTER, 0, 0);
|
|
|
- }
|
|
|
-
|
|
|
- /*=============================公用方法===================================*/
|
|
|
- /**
|
|
|
- * @注释:显示错误提示
|
|
|
- */
|
|
|
- ConfirmDialog noticeDialog;
|
|
|
-
|
|
|
- private void showNotice(String noticeMsg) {
|
|
|
- noticeDialog = new ConfirmDialog(getActivity());
|
|
|
- noticeDialog.show(noticeMsg, ConfirmDialog.NOTICE);
|
|
|
-
|
|
|
- new AsyncTask<String, Void, Float>() {
|
|
|
- @Override
|
|
|
- protected Float doInBackground(String... params) {
|
|
|
- try {
|
|
|
- //notice显示1.5s
|
|
|
- Thread.sleep(1000);
|
|
|
- } catch (InterruptedException e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- return null;
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- protected void onPostExecute(Float aFloat) {
|
|
|
- noticeDialog.dismiss();
|
|
|
- }
|
|
|
- }.execute();
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 获取输入框焦点
|
|
|
- */
|
|
|
- private void editTextGetFocus(EditText editText) {
|
|
|
- editText.setFocusable(true);
|
|
|
- editText.setFocusableInTouchMode(true);
|
|
|
- editText.setEnabled(true);
|
|
|
- editText.setClickable(true);
|
|
|
- editText.requestFocus();
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 显示loadingView
|
|
|
- */
|
|
|
- private void showLoadingView() {
|
|
|
- if (!progressDialog.isShowing()) {
|
|
|
- progressDialog.show();
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- //隐藏键盘
|
|
|
- InputMethodManager inputManager;
|
|
|
-
|
|
|
- private void hideKeyboard(final EditText view) {
|
|
|
- inputManager = (InputMethodManager) view.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
|
|
|
- //获取键盘管理对象
|
|
|
- inputManager.hideSoftInputFromWindow(view.getWindowToken(), 0);
|
|
|
- }
|
|
|
-
|
|
|
- String TAG = "WHCheck:";
|
|
|
-
|
|
|
- /*=============================数据源发生变化===================================*/
|
|
|
- @Override
|
|
|
- public void NotifyDataChanged(int noticeType) {
|
|
|
- //修改信息显示区域的信息
|
|
|
- String strDetail = detailItemList.get(0).getPR_DETAIL();
|
|
|
- String strSpec = detailItemList.get(0).getPR_SPEC();
|
|
|
-
|
|
|
- //信息区域显示
|
|
|
- tvPrDetail.setText("" + strDetail);
|
|
|
- tvPrSpec.setText("" + strSpec);
|
|
|
-
|
|
|
- //table数据源修改
|
|
|
- adapter.notifyDataSetChanged();
|
|
|
- }
|
|
|
-
|
|
|
- /*=========================监听事件===================================*/
|
|
|
- @Override
|
|
|
- public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
|
|
- //获取点击行所对应的detail对象
|
|
|
- WHMakeMaterialProduct tmpProd = detailItemList.get(position);
|
|
|
- String strPrcode = tmpProd.getBAR_PRODCODE().trim();
|
|
|
- String strWhcode = tmpProd.getBAR_WHCODE().trim();
|
|
|
- String strLocation = tmpProd.getBAR_LOCATION();
|
|
|
- if (strLocation == null || strLocation.equals("null") || strLocation.equals("")) {
|
|
|
- strLocation = "null";
|
|
|
- }
|
|
|
- //请求服务器获取明细
|
|
|
- JSONObject paramJson = new JSONObject();
|
|
|
- try {
|
|
|
- paramJson.put("pr_code", strPrcode);
|
|
|
- paramJson.put("wh_code", strWhcode);
|
|
|
- paramJson.put("bar_location", strLocation);
|
|
|
- } catch (JSONException e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- Log.e("WHCheck", "!!!" + paramJson.toString());
|
|
|
- requestType = VolleyUtil.FRAGMETN_WHCHECK_PRODUCT_DETAIL;
|
|
|
- VolleyUtil.getVolleyUtil().requestMakeMaterialDetail(getActivity(), GloableParams.ADDRESS_WH_DETAIL, VolleyUtil.METHOD_GET,
|
|
|
- requestType, strPrcode, strWhcode, strLocation);
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void onClick(View v) {
|
|
|
- disposeOnClickEnter();
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void onVolleyFinish(int isSuccess, Object result) {
|
|
|
- switch (isSuccess) {
|
|
|
- case VolleyUtil.SUCCESS_SUCCESS:
|
|
|
- disposeVolleySuccess(result);
|
|
|
- break;
|
|
|
- case VolleyUtil.FAILED_FAILED:
|
|
|
- disposeVolleyFailed(result);
|
|
|
- break;
|
|
|
- }
|
|
|
- progressDialog.dismiss();
|
|
|
- }
|
|
|
-
|
|
|
- //Volley失败
|
|
|
- private void disposeVolleyFailed(Object result) {
|
|
|
- showNotice(result.toString());
|
|
|
- }
|
|
|
-
|
|
|
- //Volley成功
|
|
|
- private void disposeVolleySuccess(Object result) {
|
|
|
- String str = (String) result;
|
|
|
- switch (requestType) {
|
|
|
- //物料库存核查:Check数据
|
|
|
- case VolleyUtil.FRAGMETN_WHCHECK_PRODUCT_CHECK:
|
|
|
- break;
|
|
|
- //物料库存核查:明细数据
|
|
|
- case VolleyUtil.FRAGMETN_WHCHECK_PRODUCT_DETAIL:
|
|
|
- Log.e("WHCHECK:make", "" + result.toString());
|
|
|
- //显示明细数据弹框
|
|
|
- //disposeVolleyDetail(result);
|
|
|
- showDetailPopwin(disposeVolleyDetail(result));
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- //Volley明细数据->list
|
|
|
- private List disposeVolleyDetail(Object result) {
|
|
|
- List<WHMakeMaterialDetail> list = null;
|
|
|
- String strResult = (String) result;
|
|
|
- try {
|
|
|
- JSONObject resultJson = new JSONObject(strResult);
|
|
|
- JSONArray targetJsonArray = resultJson.getJSONArray("target");
|
|
|
- list = GsonUtil.changeGsonToList(targetJsonArray.toString(),
|
|
|
- new TypeToken<List<WHMakeMaterialDetail>>() {
|
|
|
- }.getType());
|
|
|
- Log.e(TAG, "detaillist:" + list.toString());
|
|
|
- } catch (JSONException e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- return list;
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public boolean onKeyDown(int keyCode, KeyEvent event) {
|
|
|
- if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) {
|
|
|
- if (progressDialog != null && progressDialog.isShowing()) {
|
|
|
-// loadingView.dismiss();
|
|
|
-// VolleyUtil.distoryVolley();
|
|
|
- return true;
|
|
|
- }
|
|
|
- if (detailPopwin != null && detailPopwin.isShowing()) {
|
|
|
- detailPopwin.dismiss();
|
|
|
- return true;
|
|
|
- }
|
|
|
- if (noticeDialog != null && noticeDialog.isShowing()) {
|
|
|
- noticeDialog.dismiss();
|
|
|
- return true;
|
|
|
- }
|
|
|
- }
|
|
|
- return false;
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public boolean onFragmentBackPressed() {
|
|
|
- return false;
|
|
|
- }
|
|
|
-}
|