|
|
@@ -1,645 +0,0 @@
|
|
|
-package com.uas.esop.fragment;
|
|
|
-
|
|
|
-import android.app.Activity;
|
|
|
-import android.content.ComponentName;
|
|
|
-import android.content.Context;
|
|
|
-import android.content.DialogInterface;
|
|
|
-import android.content.Intent;
|
|
|
-import android.graphics.drawable.BitmapDrawable;
|
|
|
-import android.net.Uri;
|
|
|
-import android.os.Build;
|
|
|
-import android.os.Handler;
|
|
|
-import android.os.Message;
|
|
|
-import android.support.v4.content.FileProvider;
|
|
|
-import android.text.TextUtils;
|
|
|
-import android.util.Log;
|
|
|
-import android.view.Gravity;
|
|
|
-import android.view.KeyEvent;
|
|
|
-import android.view.LayoutInflater;
|
|
|
-import android.view.View;
|
|
|
-import android.view.ViewGroup;
|
|
|
-import android.view.inputmethod.EditorInfo;
|
|
|
-import android.widget.AdapterView;
|
|
|
-import android.widget.ArrayAdapter;
|
|
|
-import android.widget.Button;
|
|
|
-import android.widget.EditText;
|
|
|
-import android.widget.ImageView;
|
|
|
-import android.widget.LinearLayout;
|
|
|
-import android.widget.ListView;
|
|
|
-import android.widget.PopupWindow;
|
|
|
-import android.widget.TextView;
|
|
|
-import android.widget.Toast;
|
|
|
-
|
|
|
-import com.android.volley.AuthFailureError;
|
|
|
-import com.android.volley.Request;
|
|
|
-import com.android.volley.RequestQueue;
|
|
|
-import com.android.volley.Response;
|
|
|
-import com.android.volley.VolleyError;
|
|
|
-import com.android.volley.toolbox.StringRequest;
|
|
|
-import com.android.volley.toolbox.Volley;
|
|
|
-import com.google.gson.Gson;
|
|
|
-import com.uas.esop.R;
|
|
|
-import com.uas.esop.activity.FunctionActivity;
|
|
|
-import com.uas.esop.bean.WHBreakingBatchGetBarcodeData;
|
|
|
-import com.uas.esop.bean.WHCombineBatchFragmentCombineBtnClickEvent;
|
|
|
-import com.uas.esop.global.GloableParams;
|
|
|
-import com.uas.esop.tools.VolleyUtil;
|
|
|
-import com.uas.esop.util.CameraUtil;
|
|
|
-import com.uas.esop.util.CommonUtil;
|
|
|
-import com.uas.esop.util.Constants;
|
|
|
-import com.uas.esop.util.FileUtils;
|
|
|
-import com.uas.esop.util.JsonTools;
|
|
|
-import com.uas.esop.util.LogUtil;
|
|
|
-import com.uas.esop.view.ClearableEditText;
|
|
|
-import com.uuzuche.lib_zxing.activity.CaptureActivity;
|
|
|
-import com.uuzuche.lib_zxing.activity.CodeUtils;
|
|
|
-
|
|
|
-import org.json.JSONException;
|
|
|
-import org.json.JSONObject;
|
|
|
-
|
|
|
-import java.io.File;
|
|
|
-import java.io.UnsupportedEncodingException;
|
|
|
-import java.net.URLEncoder;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
-
|
|
|
-/**
|
|
|
- * @note:合并批次页面
|
|
|
- */
|
|
|
-
|
|
|
-public class WHCombineBatchFragment extends BaseFragment implements View.OnClickListener {
|
|
|
- private static final int SCAN_BARCODE_CODE = 102;
|
|
|
- private View popView;
|
|
|
- private PopupWindow pop;
|
|
|
- private Button btnConfirm, btnMerge;
|
|
|
- private TextView tvToatal;
|
|
|
- private EditText etBarCode;
|
|
|
- private RequestQueue mRequestQueue;
|
|
|
- private StringRequest stringRequest, stringRequest2, stringRequest3;
|
|
|
- private ListView listView;
|
|
|
- private MyAdapter myAdapter;
|
|
|
- private List<WHBreakingBatchGetBarcodeData.DataBeanX.DataBean> dataList = new ArrayList<>();
|
|
|
- private List<WHCombineBatchFragmentCombineBtnClickEvent.DataBean> dataPrintList = new ArrayList<>();
|
|
|
- private double sum;
|
|
|
- private String strDataList;
|
|
|
- private String strPrintDataList;
|
|
|
- private int lastPress = 0;
|
|
|
- private boolean delState = false;
|
|
|
- private String mPrintUrl = "";
|
|
|
- private Handler mHandler = new Handler() {
|
|
|
- @Override
|
|
|
- public void handleMessage(Message msg) {
|
|
|
- super.handleMessage(msg);
|
|
|
- switch (msg.what) {
|
|
|
- case Constants.CONSTANT.PRINT_SUCCESS:
|
|
|
- if (progressDialog.isShowing())
|
|
|
- progressDialog.dismiss();
|
|
|
- closePopupWindow();
|
|
|
- Toast.makeText(mActivity, R.string.obtain_print_file_success, Toast.LENGTH_LONG).show();
|
|
|
- try {
|
|
|
- Intent intent = new Intent();
|
|
|
- ComponentName comp = new ComponentName("com.dynamixsoftware.printershare", "com.dynamixsoftware.printershare.ActivityPrintPDF");
|
|
|
- intent = new Intent();
|
|
|
- intent.setComponent(comp);
|
|
|
- intent.setAction("android.intent.action.VIEW");
|
|
|
- intent.setType("application/pdf");
|
|
|
- intent.setData(Uri.fromFile(new File(Constants.CONSTANT.PRINT_FILE_PATH, Constants.CONSTANT.PRINT_FILE_NAME)));
|
|
|
- startActivity(intent);
|
|
|
- } catch (Exception e) {
|
|
|
- Toast.makeText(mActivity, "打印失败", Toast.LENGTH_LONG).show();
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- break;
|
|
|
- case Constants.CONSTANT.PRINT_FAILED:
|
|
|
- if (progressDialog.isShowing())
|
|
|
- progressDialog.dismiss();
|
|
|
- Toast.makeText(mActivity, R.string.obtain_print_file_failed, Toast.LENGTH_LONG).show();
|
|
|
- break;
|
|
|
- case Constants.CONSTANT.PRINT_OVERLOAD:
|
|
|
- if (progressDialog.isShowing())
|
|
|
- progressDialog.dismiss();
|
|
|
- Toast.makeText(mActivity, R.string.obtain_print_file_overload, Toast.LENGTH_LONG).show();
|
|
|
- break;
|
|
|
- default:
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- };
|
|
|
- private ImageView mScanImageView;
|
|
|
- private int mFocusId;
|
|
|
-
|
|
|
- @Override
|
|
|
- protected int getLayout() {
|
|
|
- return R.layout.fragment_whcombine_batch;
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- protected void initViews() {
|
|
|
- ((TextView) (getActivity().findViewById(R.id.tv_actionbar_withback))).setText(getString(R.string.title_combinebatch));
|
|
|
- ((FunctionActivity) mActivity).setScanIvVisible(true);
|
|
|
-
|
|
|
- etBarCode = (EditText) root.findViewById(R.id.et_bar_code);
|
|
|
- btnConfirm = (Button) root.findViewById(R.id.btn_confirm);
|
|
|
- tvToatal = (TextView) root.findViewById(R.id.tv_total);
|
|
|
- listView = (ListView) root.findViewById(R.id.list_view);
|
|
|
- mScanImageView = (ImageView) mActivity.findViewById(R.id.btn_actionbar_scan_iv);
|
|
|
-
|
|
|
- myAdapter = new MyAdapter(getActivity(), R.layout.item_list_whcombatchfragment, dataList);
|
|
|
- listView.setAdapter(myAdapter);
|
|
|
- btnMerge = (Button) root.findViewById(R.id.btn_merge);
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- protected void initEvents() {
|
|
|
- listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
|
|
- @Override
|
|
|
- public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
|
|
- if (delState) {
|
|
|
- if (lastPress < parent.getCount()) {
|
|
|
- View childView = parent.getChildAt(lastPress - listView.getFirstVisiblePosition());
|
|
|
- if (childView != null) {
|
|
|
- View delView = childView.findViewById(R.id.linear_del);
|
|
|
- if (null != delView) {
|
|
|
- delView.setVisibility(View.GONE);
|
|
|
- }
|
|
|
- }
|
|
|
- //一定要加上 delState = false; return;
|
|
|
- delState = false;
|
|
|
- return;
|
|
|
- } else {
|
|
|
- Log.d("click:", position + "");
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
- listView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
|
|
|
- private View delview;
|
|
|
-
|
|
|
- @Override
|
|
|
- public boolean onItemLongClick(AdapterView<?> parent, View view, final int position, long id) {
|
|
|
- if (lastPress < parent.getCount()) {
|
|
|
- View childView = parent.getChildAt(lastPress - listView.getFirstVisiblePosition());
|
|
|
- if (childView != null)
|
|
|
- delview = childView.findViewById(R.id.linear_del);
|
|
|
- if (null != delview) {
|
|
|
- delview.setVisibility(View.GONE);
|
|
|
- }
|
|
|
- }
|
|
|
- delview = view.findViewById(R.id.linear_del);
|
|
|
- delview.setVisibility(View.VISIBLE);
|
|
|
- delState = true;
|
|
|
- lastPress = position;
|
|
|
- delview.findViewById(R.id.tv_del).setOnClickListener(new View.OnClickListener() {
|
|
|
- @Override
|
|
|
- public void onClick(View v) {
|
|
|
- //bar_remain总数减去移除的部分
|
|
|
- sum = CommonUtil.doublesubtract(sum, dataList.get(position).getBAR_REMAIN());
|
|
|
- tvToatal.setText(CommonUtil.doubleFormat(sum));
|
|
|
- dataList.remove(position);
|
|
|
- myAdapter.notifyDataSetChanged();
|
|
|
- if (dataList.size() <= 1) {
|
|
|
- btnMerge.setEnabled(false);
|
|
|
- } else {
|
|
|
- btnMerge.setEnabled(true);
|
|
|
- }
|
|
|
- delview.setVisibility(View.GONE);
|
|
|
- delState = false;
|
|
|
- }
|
|
|
- });
|
|
|
- delview.findViewById(R.id.tv_cancel).setOnClickListener(new View.OnClickListener() {
|
|
|
- @Override
|
|
|
- public void onClick(View v) {
|
|
|
- delview.setVisibility(View.GONE);
|
|
|
- delState = false;
|
|
|
- }
|
|
|
- });
|
|
|
- return true;
|
|
|
- }
|
|
|
- });
|
|
|
- btnConfirm.setOnClickListener(this);
|
|
|
- btnMerge.setOnClickListener(this);
|
|
|
-
|
|
|
- CommonUtil.editTextGetFocus(etBarCode);
|
|
|
- CommonUtil.setEnabled(etBarCode, btnConfirm);
|
|
|
- etBarCode.setOnEditorActionListener(new TextView.OnEditorActionListener() {
|
|
|
- @Override
|
|
|
- public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
|
|
- if (actionId == EditorInfo.IME_ACTION_SEND
|
|
|
- || actionId == EditorInfo.IME_ACTION_DONE
|
|
|
- || (event != null && event.getAction() == KeyEvent.ACTION_DOWN && event.getKeyCode() == KeyEvent.KEYCODE_ENTER)) {
|
|
|
- String str = etBarCode.getText().toString().trim();
|
|
|
- etBarCode.setText("");
|
|
|
- if (TextUtils.isEmpty(str)) {
|
|
|
- ((ClearableEditText) etBarCode).setWarnIconVisible();
|
|
|
- return true;
|
|
|
- }
|
|
|
- for (int i = 0; i < dataList.size(); i++) {
|
|
|
- if (str.equals(dataList.get(i).getBAR_CODE())) {
|
|
|
- Toast.makeText(getActivity().getApplicationContext(), "条码重复", Toast.LENGTH_LONG).show();
|
|
|
- CommonUtil.editTextGetFocus(etBarCode);
|
|
|
- return true;
|
|
|
- }
|
|
|
- }
|
|
|
- CommonUtil.closeKeybord(etBarCode, mActivity);
|
|
|
- getLoadingView();
|
|
|
- confirmBtnClick(str);
|
|
|
- etBarCode.setText("");
|
|
|
- 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() {
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- @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_bar_code) {
|
|
|
- etBarCode.setText(result);
|
|
|
- etBarCode.setSelection(result.length());
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public boolean onKeyDown(int keyCode, KeyEvent event) {
|
|
|
- return false;
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public boolean onFragmentBackPressed() {
|
|
|
- return false;
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void onClick(View v) {
|
|
|
- switch (v.getId()) {
|
|
|
- case R.id.btn_confirm:
|
|
|
- String str = etBarCode.getText().toString().trim();
|
|
|
- if (TextUtils.isEmpty(str)) {
|
|
|
- ((ClearableEditText) etBarCode).setWarnIconVisible();
|
|
|
- Toast.makeText(getActivity().getApplicationContext(), "还有必填项值为空", Toast.LENGTH_SHORT).show();
|
|
|
- return;
|
|
|
- }
|
|
|
- if (!str.matches(Constants.REGEX.NO_SYMBOL)) {
|
|
|
- CommonUtil.toastNoRepeat(getActivity(), getResources().getString(R.string.barcode_cannot_contain_special));
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- for (int i = 0; i < dataList.size(); i++) {
|
|
|
- if (str.equals(dataList.get(i).getBAR_CODE())) {
|
|
|
- Toast.makeText(getActivity().getApplicationContext(), "条码重复", Toast.LENGTH_LONG).show();
|
|
|
-
|
|
|
- return;
|
|
|
- }
|
|
|
- }
|
|
|
- CommonUtil.closeKeybord(etBarCode, mActivity);
|
|
|
- //请求详细数据
|
|
|
- btnConfirm.setEnabled(false);
|
|
|
- getLoadingView();
|
|
|
- confirmBtnClick(str);
|
|
|
- break;
|
|
|
- case R.id.btn_merge:
|
|
|
- //返回值只有一条数据,使用popupWindow的方法显示出来
|
|
|
- if (dataList.size() > 1) {
|
|
|
- combineBtnClickEvent();
|
|
|
- }
|
|
|
-
|
|
|
- break;
|
|
|
- case R.id.btn_print:
|
|
|
- if (!CommonUtil.appIsInstalled(getActivity(), Constants.CONSTANT.PRINT_SHARE_PACKAGE)) {
|
|
|
- new android.app.AlertDialog.Builder(getActivity()).setTitle("提示")
|
|
|
- .setMessage("您还未安装打印程序,点击确认开始安装")
|
|
|
- .setPositiveButton("确认", new DialogInterface.OnClickListener() {
|
|
|
- @Override
|
|
|
- public void onClick(DialogInterface dialog, int which) {
|
|
|
- Intent intent = new Intent(Intent.ACTION_VIEW);
|
|
|
- File assetsFileToCacheDir = FileUtils.getAssetsFileToCacheDir(getActivity(), "PrinterShare.apk");
|
|
|
- if (Build.VERSION.SDK_INT >= 24) {
|
|
|
- Uri apkUri = FileProvider.getUriForFile(mActivity, "com.uas.esop.fileprovider", assetsFileToCacheDir);
|
|
|
- //Granting Temporary Permissions to a URI
|
|
|
- intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
|
|
- intent.setDataAndType(apkUri, "application/vnd.android.package-archive");
|
|
|
- } else {
|
|
|
- intent.setDataAndType(Uri.fromFile(assetsFileToCacheDir), "application/vnd.android.package-archive");
|
|
|
- }
|
|
|
- getActivity().startActivity(intent);
|
|
|
-
|
|
|
- }
|
|
|
- })
|
|
|
- .setNegativeButton("取消", null).create().show();
|
|
|
- } else {
|
|
|
- getPrintData();
|
|
|
- }
|
|
|
- break;
|
|
|
- case R.id.btn_close:
|
|
|
- closePopupWindow();
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- /**
|
|
|
- * 创建PopupWindow
|
|
|
- */
|
|
|
- protected void initPopuptWindow(String code, String remain) {
|
|
|
- LayoutInflater inflater = LayoutInflater.from(getActivity());
|
|
|
- popView = inflater.inflate(R.layout.popupwindow_whcombine_bach, null);
|
|
|
- TextView tvNewBarCode = (TextView) popView.findViewById(R.id.tv_new_bar_code);
|
|
|
- TextView tvTotal = (TextView) popView.findViewById(R.id.tv_total);
|
|
|
- tvNewBarCode.setText(code);
|
|
|
- tvTotal.setText(remain);
|
|
|
- Button btnPrint = (Button) popView.findViewById(R.id.btn_print);
|
|
|
- Button btnClose = (Button) popView.findViewById(R.id.btn_close);
|
|
|
- btnPrint.setOnClickListener(this);
|
|
|
- btnClose.setOnClickListener(this);
|
|
|
- // PopupWindow实例化
|
|
|
- pop = new PopupWindow(popView, LinearLayout.LayoutParams.WRAP_CONTENT,
|
|
|
- LinearLayout.LayoutParams.WRAP_CONTENT, true);
|
|
|
- pop.setAnimationStyle(R.style.MenuAnimationFade);
|
|
|
- pop.setBackgroundDrawable(new BitmapDrawable());
|
|
|
- pop.setOnDismissListener(new PopupWindow.OnDismissListener() {
|
|
|
- @Override
|
|
|
- public void onDismiss() {
|
|
|
- closePopupWindow();
|
|
|
- }
|
|
|
- });
|
|
|
- // 弹出窗口显示内容视图,默认以锚定视图的左下角为起点,这里为点击按钮
|
|
|
- pop.showAtLocation(btnConfirm, Gravity.CENTER, 0, 0);
|
|
|
- CommonUtil.setBackgroundAlpha(mActivity, 0.5f);
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 关闭窗口
|
|
|
- */
|
|
|
- private void closePopupWindow() {
|
|
|
- if (pop != null) {
|
|
|
- pop.dismiss();
|
|
|
- pop = null;
|
|
|
- CommonUtil.setBackgroundAlpha(mActivity, 1f);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- /**
|
|
|
- * 并且获取条码的剩余数量
|
|
|
- */
|
|
|
- public static final String CONFIRMBTNCLICK = "confirmBtnClick";
|
|
|
-
|
|
|
- private void confirmBtnClick(String code) {
|
|
|
- mRequestQueue = Volley.newRequestQueue(getActivity());
|
|
|
- String url = GloableParams.ADDRESS_CONFIRMBTNCLICK + "?code=" + code + "&pr_ismsd=" + "false";
|
|
|
- try {
|
|
|
- url = GloableParams.ADDRESS_CONFIRMBTNCLICK + "?code=" + URLEncoder.encode(code, "utf-8") + "&pr_ismsd=" + "false";
|
|
|
- } catch (UnsupportedEncodingException e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
-
|
|
|
- stringRequest = new StringRequest(Request.Method.GET, url, new Response.Listener<String>() {
|
|
|
- @Override
|
|
|
- public void onResponse(String s) {
|
|
|
- WHBreakingBatchGetBarcodeData whc = JsonTools.parseJsonToBean(s, WHBreakingBatchGetBarcodeData.class);
|
|
|
- dataList.add(whc.getData().getData());
|
|
|
- strDataList = new Gson().toJson(dataList);
|
|
|
- LogUtil.e("dataList ", strDataList);
|
|
|
- myAdapter.notifyDataSetChanged();
|
|
|
- getLoadingView();
|
|
|
- sum = CommonUtil.doubleAddition(sum, whc.getData().getData().getBAR_REMAIN());
|
|
|
- tvToatal.setText(CommonUtil.doubleFormat(sum));
|
|
|
- CommonUtil.editTextGetFocus(etBarCode);
|
|
|
- etBarCode.setText("");
|
|
|
- btnConfirm.setEnabled(false);
|
|
|
- if (sum > 0 && dataList.size() > 1) {
|
|
|
- btnMerge.setEnabled(true);
|
|
|
- } else {
|
|
|
- btnMerge.setEnabled(false);
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- }, new Response.ErrorListener() {
|
|
|
- @Override
|
|
|
- public void onErrorResponse(VolleyError error) {
|
|
|
- CommonUtil.showErrorToast(error);
|
|
|
- if (progressDialog.isShowing())
|
|
|
- progressDialog.dismiss();
|
|
|
- etBarCode.setText(null);
|
|
|
- CommonUtil.editTextGetFocus(etBarCode);
|
|
|
- }
|
|
|
- }) {
|
|
|
- @Override
|
|
|
- public Map<String, String> getHeaders() throws AuthFailureError {
|
|
|
- return VolleyUtil.getVolleyUtil().setCookies();
|
|
|
- }
|
|
|
- };
|
|
|
- stringRequest.setTag(CONFIRMBTNCLICK);
|
|
|
- mRequestQueue.add(stringRequest);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 合并按钮点击事件
|
|
|
- */
|
|
|
- public static final String COMBINEBTNCLICKEVENT = "combineBtnClickEvent";
|
|
|
- WHCombineBatchFragmentCombineBtnClickEvent whc2;
|
|
|
-
|
|
|
- private void combineBtnClickEvent() {
|
|
|
- Map<String, String> params = new HashMap<>();
|
|
|
- params.put("total_remain", tvToatal.getText().toString().trim());
|
|
|
- params.put("data", strDataList);
|
|
|
- JSONObject jsonObject = new JSONObject(params);
|
|
|
- LogUtil.e("or_barcode", jsonObject.toString());
|
|
|
- String url = GloableParams.ADDRESS_COMBINEBTNCLICKEVENT + "?total_remain=" + tvToatal.getText().toString().trim();
|
|
|
-// + "&data=" + strDataList;
|
|
|
-
|
|
|
- stringRequest2 = new StringRequest(Request.Method.POST, url, new Response.Listener<String>() {
|
|
|
- @Override
|
|
|
- public void onResponse(String s) {
|
|
|
- LogUtil.e("combineBtnClickEvent onResponse =", s);
|
|
|
- whc2 = JsonTools.parseJsonToBean(s, WHCombineBatchFragmentCombineBtnClickEvent.class);
|
|
|
- dataPrintList.add(whc2.getData());
|
|
|
- strPrintDataList = new Gson().toJson(dataPrintList);
|
|
|
- LogUtil.e("strPrintDataList", strPrintDataList);
|
|
|
- //如果返回成功则初始化状态
|
|
|
- delState = false;
|
|
|
- dataList.clear();
|
|
|
- myAdapter.notifyDataSetChanged();
|
|
|
- sum = 0;
|
|
|
- tvToatal.setText(sum + "");
|
|
|
- btnMerge.setEnabled(false);
|
|
|
- initPopuptWindow(whc2.getData().getBAR_CODE(), CommonUtil.doubleFormat(whc2.getData().getBAR_REMAIN()));
|
|
|
- }
|
|
|
- }, new Response.ErrorListener() {
|
|
|
- @Override
|
|
|
- public void onErrorResponse(VolleyError volleyError) {
|
|
|
- CommonUtil.showErrorToast(volleyError);
|
|
|
- }
|
|
|
- }) {
|
|
|
- @Override
|
|
|
- public Map<String, String> getHeaders() throws AuthFailureError {
|
|
|
- Map map = VolleyUtil.getVolleyUtil().setCookies();
|
|
|
- //不用改动
|
|
|
- map.put("Content-Type", "text/html; charset=UTF-8");
|
|
|
- return map;
|
|
|
- }
|
|
|
-
|
|
|
- //不用改动
|
|
|
- @Override
|
|
|
- public byte[] getBody() throws AuthFailureError {
|
|
|
- byte[] paramByte = new byte[0];
|
|
|
- try {
|
|
|
- //pararm为要传递的参数
|
|
|
- paramByte = strDataList.getBytes("UTF-8");
|
|
|
- } catch (UnsupportedEncodingException e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- Log.e("getBody", new String(paramByte));
|
|
|
- return paramByte;
|
|
|
- }
|
|
|
- };
|
|
|
-
|
|
|
- stringRequest2.setTag(COMBINEBTNCLICKEVENT);
|
|
|
- mRequestQueue.add(stringRequest2);
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- public static final String GETPRINTDATA = "getPrintData";
|
|
|
-
|
|
|
- private void getPrintData() {
|
|
|
- progressDialog.show();
|
|
|
- String url = GloableParams.ADDRESS_LABELPRINT + "?data=" + strPrintDataList;
|
|
|
-
|
|
|
- stringRequest3 = new StringRequest(Request.Method.GET, url, new Response.Listener<String>() {
|
|
|
- @Override
|
|
|
- public void onResponse(String s) {
|
|
|
- try {
|
|
|
- JSONObject resultObject = new JSONObject(s);
|
|
|
- if (resultObject.optBoolean("success")) {
|
|
|
- mPrintUrl = resultObject.optString("data");
|
|
|
- FileUtils.printBarcode(mPrintUrl, mHandler);
|
|
|
- }
|
|
|
- } catch (JSONException e) {
|
|
|
- if (progressDialog.isShowing())
|
|
|
- progressDialog.dismiss();
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- }
|
|
|
- }, new Response.ErrorListener() {
|
|
|
- @Override
|
|
|
- public void onErrorResponse(VolleyError volleyError) {
|
|
|
- if (progressDialog.isShowing())
|
|
|
- progressDialog.dismiss();
|
|
|
- CommonUtil.showErrorToast(volleyError);
|
|
|
- }
|
|
|
- }) {
|
|
|
- @Override
|
|
|
- public Map<String, String> getHeaders() throws AuthFailureError {
|
|
|
- Map map = VolleyUtil.getVolleyUtil().setCookies();
|
|
|
- //不用改动
|
|
|
- map.put("Content-Type", "text/html; charset=UTF-8");
|
|
|
- return map;
|
|
|
- }
|
|
|
- };
|
|
|
- stringRequest3.setTag(GETPRINTDATA);
|
|
|
- mRequestQueue.add(stringRequest3);
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- @Override
|
|
|
- public void onDestroy() {
|
|
|
- progressDialog.dismiss();
|
|
|
- CommonUtil.closeKeybord(etBarCode, mActivity);
|
|
|
- ((TextView) (getActivity().findViewById(R.id.tv_actionbar_withback))).setText(R.string.title_batch_content);
|
|
|
- ((FunctionActivity) mActivity).setScanIvVisible(false);
|
|
|
- super.onDestroy();
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 显示loadingView
|
|
|
- */
|
|
|
- private void getLoadingView() {
|
|
|
- if (!progressDialog.isShowing()) {
|
|
|
- progressDialog.show();
|
|
|
- } else {
|
|
|
- progressDialog.dismiss();
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void onStop() {
|
|
|
- super.onStop();
|
|
|
- if (mRequestQueue != null) {
|
|
|
- mRequestQueue.cancelAll(CONFIRMBTNCLICK);
|
|
|
- mRequestQueue.cancelAll(COMBINEBTNCLICKEVENT);
|
|
|
- mRequestQueue.cancelAll(GETPRINTDATA);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- private class MyAdapter extends ArrayAdapter<WHBreakingBatchGetBarcodeData.DataBeanX.DataBean> {
|
|
|
- private int resourceId;
|
|
|
-
|
|
|
- public MyAdapter(Context context, int resource, List<WHBreakingBatchGetBarcodeData.DataBeanX.DataBean> objects) {
|
|
|
- super(context, resource, objects);
|
|
|
- resourceId = resource;
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public View getView(final int position, View convertView, final ViewGroup parent) {
|
|
|
- WHBreakingBatchGetBarcodeData.DataBeanX.DataBean person = getItem(position);
|
|
|
- convertView = LayoutInflater.from(getContext()).inflate(resourceId, null);
|
|
|
-
|
|
|
- TextView tv_bar_code = (TextView) convertView.findViewById(R.id.tv_bar_code);
|
|
|
- TextView tv_bar_remain = (TextView) convertView.findViewById(R.id.tv_bar_remain);
|
|
|
- TextView tv_bar_prodcode = (TextView) convertView.findViewById(R.id.tv_bar_prodcode);
|
|
|
- TextView tv_pr_detail = (TextView) convertView.findViewById(R.id.tv_pr_detail);
|
|
|
- TextView tv_bar_whcode = (TextView) convertView.findViewById(R.id.tv_bar_whcode);
|
|
|
- TextView tv_bar_location = (TextView) convertView.findViewById(R.id.tv_bar_location);
|
|
|
- TextView tv_bar_batch = (TextView) convertView.findViewById(R.id.tv_bar_batch);
|
|
|
- LinearLayout deleteLayout = (LinearLayout) convertView.findViewById(R.id.linear_del);
|
|
|
-
|
|
|
- tv_bar_code.setText(person.getBAR_CODE());
|
|
|
- tv_bar_remain.setText(person.getBAR_REMAIN() + "");
|
|
|
- tv_bar_prodcode.setText(person.getBAR_PRODCODE());
|
|
|
- tv_pr_detail.setText(person.getPR_DETAIL());
|
|
|
- tv_bar_whcode.setText(person.getBAR_WHCODE());
|
|
|
- tv_bar_location.setText(person.getBAR_LOCATION());
|
|
|
- tv_bar_batch.setText(person.getBAR_BATCHCODE());
|
|
|
-
|
|
|
- if (lastPress == position && delState) {
|
|
|
- deleteLayout.setVisibility(View.VISIBLE);
|
|
|
- }
|
|
|
- return convertView;
|
|
|
- }
|
|
|
- }
|
|
|
-}
|