|
@@ -3,6 +3,7 @@ package com.uas.huayunuasmes.fragment;
|
|
|
import android.annotation.SuppressLint;
|
|
|
import android.content.Intent;
|
|
|
import android.os.Bundle;
|
|
|
+import android.util.Log;
|
|
|
import android.view.KeyEvent;
|
|
|
import android.view.View;
|
|
|
import android.view.inputmethod.EditorInfo;
|
|
@@ -10,7 +11,9 @@ import android.widget.Button;
|
|
|
import android.widget.LinearLayout;
|
|
|
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.uas.huayunuasmes.R;
|
|
@@ -24,6 +27,7 @@ import com.uas.huayunuasmes.util.FragmentUtils;
|
|
|
import com.uas.huayunuasmes.util.HttpCallback;
|
|
|
import com.uas.huayunuasmes.util.HttpParams;
|
|
|
import com.uas.huayunuasmes.util.PrintUtils;
|
|
|
+import com.uas.huayunuasmes.util.VolleyRequest;
|
|
|
import com.uas.huayunuasmes.util.VollyRequest;
|
|
|
import com.uas.huayunuasmes.view.ClearableEditText;
|
|
|
|
|
@@ -42,7 +46,6 @@ public class LabeLreprintingFragment extends BaseFragment implements View.OnClic
|
|
|
private ClearableEditText storage_recharge_collect_ets;
|
|
|
private LinearLayout line_hint;
|
|
|
private TextView tv_hint1;
|
|
|
- private JSONArray dataArray;
|
|
|
private Button btn_starts;
|
|
|
|
|
|
@Override
|
|
@@ -65,7 +68,7 @@ public class LabeLreprintingFragment extends BaseFragment implements View.OnClic
|
|
|
|
|
|
@Override
|
|
|
protected void initEvents() {
|
|
|
-
|
|
|
+ getPrintTemplate();
|
|
|
storage_recharge_collect_ets.setOnEditorActionListener(new TextView.OnEditorActionListener() {
|
|
|
@Override
|
|
|
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
|
@@ -119,12 +122,13 @@ public class LabeLreprintingFragment extends BaseFragment implements View.OnClic
|
|
|
progressDialog.dismiss();
|
|
|
storage_recharge_collect_ets.setText("");
|
|
|
storage_recharge_collect_ets.requestFocus();
|
|
|
- dataArray = FastjsonUtil.getJSONArray(o.toString(), "data");
|
|
|
+ JSONArray dataArray = FastjsonUtil.getJSONArray(o.toString(), "data");
|
|
|
if (dataArray==null){
|
|
|
CommonUtil.toastNoRepeat(mActivity, "数据为空");
|
|
|
return;
|
|
|
}
|
|
|
printEvent(dataArray);
|
|
|
+
|
|
|
}
|
|
|
@Override
|
|
|
public void onFail(int flag, String failStr) throws Exception {
|
|
@@ -136,6 +140,39 @@ public class LabeLreprintingFragment extends BaseFragment implements View.OnClic
|
|
|
});
|
|
|
|
|
|
|
|
|
+ }
|
|
|
+ private void getPrintTemplate() {
|
|
|
+ VolleyRequest.getInstance().stringRequest(mStringRequest,
|
|
|
+ new HttpParams.Builder()
|
|
|
+ .url(GloableParams.ADDRESS_BARINFO_PRINTMODEL)
|
|
|
+ .method(Request.Method.GET)
|
|
|
+ .flag(0)
|
|
|
+ .tag("barinfoPrint")
|
|
|
+ .addParam("caller", "Lotno!PDAPrint")//Barcode!PDAPrint仓库
|
|
|
+ .build(), new HttpCallback() {
|
|
|
+ @Override
|
|
|
+ public void onSuccess(int flag, Object o) throws Exception {
|
|
|
+ try {
|
|
|
+ String result = o.toString();
|
|
|
+ Log.e("prints", result);
|
|
|
+ if (FastjsonUtil.validate(result)) {
|
|
|
+ JSONObject resultObject = JSON.parseObject(result);
|
|
|
+ JSONArray dataArray = resultObject.getJSONArray("data");
|
|
|
+ if (dataArray != null && dataArray.size() > 0) {
|
|
|
+ SharedPreUtil.saveString(mActivity, Constants.FLAG.PRINT_TEMPLATE_CACHE, dataArray.toJSONString());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onFail(int flag, String failStr) throws Exception {
|
|
|
+ Log.e("printf", failStr);
|
|
|
+ }
|
|
|
+ });
|
|
|
}
|
|
|
public static String removeBrackets(String input) {
|
|
|
return input.replaceAll("\\[", "").replaceAll("\\]", "");
|
|
@@ -162,6 +199,7 @@ public class LabeLreprintingFragment extends BaseFragment implements View.OnClic
|
|
|
for (int i = 0; i < printArray.size(); i++) {
|
|
|
try {
|
|
|
String stingdata = removeBrackets(printArray.toString());
|
|
|
+ Log.e("stingdata",stingdata);
|
|
|
int printResult = PrintUtils.printBar(mActivity, stingdata.toString(), mPrintDpi, null);
|
|
|
if (printResult <= 0) {
|
|
|
isFail = true;
|