|
|
@@ -0,0 +1,189 @@
|
|
|
+package com.uas.uaspda.fragment;
|
|
|
+
|
|
|
+import android.text.TextUtils;
|
|
|
+import android.view.KeyEvent;
|
|
|
+import android.view.View;
|
|
|
+import android.widget.Button;
|
|
|
+import android.widget.TextView;
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.android.volley.Request;
|
|
|
+import com.uas.uaspda.R;
|
|
|
+import com.uas.uaspda.application.PdaApplication;
|
|
|
+import com.uas.uaspda.bean.LineInfoBean;
|
|
|
+import com.uas.uaspda.global.GloableParams;
|
|
|
+import com.uas.uaspda.listener.MyEditorActionListener;
|
|
|
+import com.uas.uaspda.tools.SharedPreUtil;
|
|
|
+import com.uas.uaspda.util.CommonUtil;
|
|
|
+import com.uas.uaspda.util.Constants;
|
|
|
+import com.uas.uaspda.util.FastjsonUtil;
|
|
|
+import com.uas.uaspda.util.HttpCallback;
|
|
|
+import com.uas.uaspda.util.HttpParams;
|
|
|
+import com.uas.uaspda.util.VolleyRequest;
|
|
|
+import com.uas.uaspda.view.ClearableEditText;
|
|
|
+
|
|
|
+/**
|
|
|
+ * SMT飞达料盘解绑子页面
|
|
|
+ * modify:2017-05-15
|
|
|
+ */
|
|
|
+public class SCSMTUnBindFragment extends BaseFragment {
|
|
|
+ private TextView mLinecodeTv;
|
|
|
+ private TextView mTableTv;
|
|
|
+ private TextView mMacodeTv;
|
|
|
+ private ClearableEditText mFeederEt;
|
|
|
+ private TextView mMaterialEt;
|
|
|
+ private TextView mResultTv;
|
|
|
+ private LineInfoBean mLineInfoBean;
|
|
|
+ private String mSmtLocationCache;
|
|
|
+ private Button mConfirmBtn;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected int getLayout() {
|
|
|
+ return R.layout.fragment_scmake_smtfeeder_unbind;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected void initViews() {
|
|
|
+ setTitle("飞达料盘解绑");
|
|
|
+
|
|
|
+ mLinecodeTv = (TextView) root.findViewById(R.id.smt_feeding_bind_linecode_tv);
|
|
|
+ mTableTv = (TextView) root.findViewById(R.id.smt_feeding_bind_table_tv);
|
|
|
+ mMacodeTv = (TextView) root.findViewById(R.id.smt_feeding_bind_macode_tv);
|
|
|
+ mFeederEt = (ClearableEditText) root.findViewById(R.id.smt_feeding_bind_feeder_et);
|
|
|
+ mMaterialEt = (TextView) root.findViewById(R.id.smt_feeding_bind_material_et);
|
|
|
+ mResultTv = (TextView) root.findViewById(R.id.smt_feeding_bind_result_tv);
|
|
|
+ mConfirmBtn = root.findViewById(R.id.smt_feeding_unbind_confirm_btn);
|
|
|
+
|
|
|
+ mLineInfoBean = (LineInfoBean) PdaApplication.getDataCacheFromMap(Constants.FLAG.SMT_DEVICE_LINE_CACHE);
|
|
|
+ mSmtLocationCache = SharedPreUtil.getString(mActivity, Constants.FLAG.SMT_LOCATION_CACHE, null);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected void initEvents() {
|
|
|
+ CommonUtil.setEditorActionListener(mFeederEt, new MyEditorActionListener() {
|
|
|
+ @Override
|
|
|
+ public void MyEditorAction(String text, int actionId, KeyEvent event) {
|
|
|
+ getBarcodeByFeeder();
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ mConfirmBtn.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ unBindMaterial();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private void getBarcodeByFeeder() {
|
|
|
+ String feeder = mFeederEt.getText().toString().trim();
|
|
|
+ if (TextUtils.isEmpty(feeder)) {
|
|
|
+ CommonUtil.toastNoRepeat(mActivity, "请采集飞达");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ mResultTv.setText("");
|
|
|
+ progressDialog.show();
|
|
|
+ VolleyRequest.getInstance()
|
|
|
+ .stringRequest(new HttpParams.Builder()
|
|
|
+ .url(GloableParams.ADDRESS_SMT_GETBARCODEBYFEEDER)
|
|
|
+ .method(Request.Method.POST)
|
|
|
+ .addParam("fe_code", feeder)
|
|
|
+ .build(), new HttpCallback() {
|
|
|
+ @Override
|
|
|
+ public void onSuccess(int flag, Object o) throws Exception {
|
|
|
+ progressDialog.dismiss();
|
|
|
+ try {
|
|
|
+ String result = o.toString();
|
|
|
+ JSONObject resultObject = JSON.parseObject(result);
|
|
|
+ JSONObject dataObject = resultObject.getJSONObject("data");
|
|
|
+ if (dataObject != null) {
|
|
|
+ String fe_barcode = FastjsonUtil.getText(dataObject, "fe_barcode");
|
|
|
+ mMaterialEt.setText(fe_barcode);
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onFail(int flag, String failStr) throws Exception {
|
|
|
+ progressDialog.dismiss();
|
|
|
+ CommonUtil.toastNoRepeat(mActivity, failStr);
|
|
|
+ mResultTv.setTextColor(getResources().getColor(R.color.red));
|
|
|
+ mResultTv.setText(failStr);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ private void unBindMaterial() {
|
|
|
+ String feeder = mFeederEt.getText().toString().trim();
|
|
|
+ if (TextUtils.isEmpty(feeder)) {
|
|
|
+ CommonUtil.toastNoRepeat(mActivity, "请采集飞达");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ mResultTv.setText("");
|
|
|
+ progressDialog.show();
|
|
|
+ VolleyRequest.getInstance()
|
|
|
+ .stringRequest(new HttpParams.Builder()
|
|
|
+ .url(GloableParams.ADDRESS_SMT_UNBINDFEEDER)
|
|
|
+ .method(Request.Method.POST)
|
|
|
+ .addParam("fe_code", feeder)
|
|
|
+ .build(), new HttpCallback() {
|
|
|
+ @Override
|
|
|
+ public void onSuccess(int flag, Object o) throws Exception {
|
|
|
+ progressDialog.dismiss();
|
|
|
+ try {
|
|
|
+ String result = o.toString();
|
|
|
+ JSONObject resultObject = JSON.parseObject(result);
|
|
|
+ JSONObject dataObject = resultObject.getJSONObject("data");
|
|
|
+ mResultTv.setTextColor(getResources().getColor(R.color.green));
|
|
|
+ mResultTv.setText(
|
|
|
+ "飞达:" + FastjsonUtil.getText(dataObject, "fe_code")
|
|
|
+ + " 解绑成功");
|
|
|
+ mFeederEt.setText("");
|
|
|
+ mMaterialEt.setText("");
|
|
|
+ mFeederEt.requestFocus();
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onFail(int flag, String failStr) throws Exception {
|
|
|
+ progressDialog.dismiss();
|
|
|
+ CommonUtil.toastNoRepeat(mActivity, failStr);
|
|
|
+ mResultTv.setTextColor(getResources().getColor(R.color.red));
|
|
|
+ mResultTv.setText(failStr);
|
|
|
+ mFeederEt.setText("");
|
|
|
+ mMaterialEt.setText("");
|
|
|
+ mFeederEt.requestFocus();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected void initDatas() {
|
|
|
+ if (mLineInfoBean != null) {
|
|
|
+ mLinecodeTv.setText(mLineInfoBean.getDL_LINECODE());
|
|
|
+ mTableTv.setText(mLineInfoBean.getDL_TABLE() + "面");
|
|
|
+ mMacodeTv.setText(mLineInfoBean.getDL_MACODE());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public boolean onKeyDown(int keyCode, KeyEvent event) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public boolean onFragmentBackPressed() {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|