|
@@ -25,18 +25,18 @@ import com.emato.ich.entity.vo.PreparedOrderResponseVo;
|
|
|
import com.emato.ich.entity.vo.PreparedOrderVo;
|
|
|
import com.emato.ich.local.LocalStorage;
|
|
|
import com.emato.ich.utils.BaseUtils;
|
|
|
+import com.emato.ich.utils.ButtonUtils;
|
|
|
import com.emato.ich.utils.JacksonUtils;
|
|
|
import com.emato.ich.utils.StringUtils;
|
|
|
import com.emato.ich.utils.TimeOutUtils;
|
|
|
+import com.emato.ich.utils.ToastUtils;
|
|
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
|
|
import com.fasterxml.jackson.core.type.TypeReference;
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
-import com.google.android.material.snackbar.Snackbar;
|
|
|
|
|
|
import org.jetbrains.annotations.NotNull;
|
|
|
|
|
|
import java.io.IOException;
|
|
|
-import java.util.concurrent.atomic.AtomicBoolean;
|
|
|
import java.util.concurrent.atomic.AtomicInteger;
|
|
|
import java.util.regex.Pattern;
|
|
|
|
|
@@ -92,6 +92,11 @@ public class InputInfoFragment extends Fragment {
|
|
|
// 扫码成功回调
|
|
|
Log.d(TAG, "onScanSuccess: " + s);
|
|
|
|
|
|
+ if (timer == null) {
|
|
|
+ // 防止连续扫描时, 倒计时已经到0了, 导致非法参数异常
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
if (mailNoLock.get() == 1) {
|
|
|
Editable text = binding.mailNo.getText();
|
|
|
text.clear();
|
|
@@ -102,7 +107,8 @@ public class InputInfoFragment extends Fragment {
|
|
|
@Override
|
|
|
public void onFailure(@NotNull Call call, @NotNull IOException e) {
|
|
|
// 请求失败
|
|
|
- Snackbar.make(view, "服务器异常! 请手动输入! ", Snackbar.LENGTH_LONG).show();
|
|
|
+ mailNoLock.set(1);
|
|
|
+ ToastUtils.make(getContext(), "服务器异常! 请手动输入! ");
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -120,17 +126,17 @@ public class InputInfoFragment extends Fragment {
|
|
|
binding.delivererPhoneConfirm.setText(collectorPhone);
|
|
|
}
|
|
|
|
|
|
- ICSPResponseCodeEnum.responseHint(view, responseData);
|
|
|
+ ICSPResponseCodeEnum.responseHint(getContext(), responseData);
|
|
|
|
|
|
} catch (JsonProcessingException e) {
|
|
|
Log.e(TAG, "onResponse: 服务器响应错误! 自动获取用户手机号失败! ", e);
|
|
|
- Snackbar.make(view, "网络异常! 请手动输入手机号! ", Snackbar.LENGTH_LONG).show();
|
|
|
+ ToastUtils.make(getContext(), "网络异常! 请手动输入手机号!");
|
|
|
} catch (RuntimeException e) {
|
|
|
Log.e(TAG, "onResponse: 获取用户手机号未知错误! ", e);
|
|
|
- Snackbar.make(view, "未查询到手机号! 请手动输入! ", Snackbar.LENGTH_LONG).show();
|
|
|
+ ToastUtils.make(getContext(), "未查询到手机号! 请手动输入! ");
|
|
|
}
|
|
|
});
|
|
|
-
|
|
|
+ mailNoLock.set(1);
|
|
|
}
|
|
|
});
|
|
|
}
|
|
@@ -148,14 +154,17 @@ public class InputInfoFragment extends Fragment {
|
|
|
if (submitLock.get() == 1) {
|
|
|
submitLock.incrementAndGet();
|
|
|
binding.buttonConfirm.setOnClickListener(view1 -> {
|
|
|
+ if (ButtonUtils.isFastClick()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
Bundle bundle = new Bundle();
|
|
|
String mailNo = binding.mailNo.getText().toString();
|
|
|
// String phone = binding.delivererPhone.getText().toString();
|
|
|
String phoneConfirm = binding.delivererPhoneConfirm.getText().toString();
|
|
|
if (!phonePattern.matcher(phoneConfirm).matches()) {
|
|
|
- Snackbar.make(view1, "请输入正确的手机号!", Snackbar.LENGTH_LONG).show();
|
|
|
+ ToastUtils.make(getContext(), "请输入正确的手机号!");
|
|
|
} else if (StringUtils.isNullOrEmpty(mailNo)) {
|
|
|
- Snackbar.make(view1, "运单号不能为空!请扫描运单号!", Snackbar.LENGTH_LONG).show();
|
|
|
+ ToastUtils.make(getContext(), "运单号不能为空!请扫描运单号!");
|
|
|
} else {
|
|
|
// 验证完 预下单
|
|
|
PreparedOrderVo preparedOrderVo = new PreparedOrderVo();
|
|
@@ -170,7 +179,8 @@ public class InputInfoFragment extends Fragment {
|
|
|
@Override
|
|
|
public void onFailure(@NotNull Call call, @NotNull IOException e) {
|
|
|
// TODO 预下单调用失败
|
|
|
- Snackbar.make(view, "请求服务器失败!网络异常!", Snackbar.LENGTH_LONG).show();
|
|
|
+ submitLock.set(1);
|
|
|
+ ToastUtils.make(getContext(), "请求服务器失败!网络异常!");
|
|
|
Log.e(TAG, "onFailure: 预下单失败! call: " + call.timeout().toString(), e);
|
|
|
}
|
|
|
|
|
@@ -198,7 +208,7 @@ public class InputInfoFragment extends Fragment {
|
|
|
timer.cancel();
|
|
|
NavHostFragment.findNavController(InputInfoFragment.this).navigate(R.id.action_inputInfoFragment_to_sendInfoConfirmFragment);
|
|
|
} else {
|
|
|
- ICSPResponseCodeEnum.responseHint(view, responseData);
|
|
|
+ ICSPResponseCodeEnum.responseHint(getContext(), responseData);
|
|
|
Log.e(TAG, "onResponse: ICSP返回码: " + responseData.getCode() + ", 返回信息: " + responseData.getMsg(), new RuntimeException("系统异常"));
|
|
|
}
|
|
|
} catch (JsonProcessingException e) {
|
|
@@ -221,7 +231,7 @@ public class InputInfoFragment extends Fragment {
|
|
|
binding.inputButton0.setOnClickListener(v -> {
|
|
|
int length = binding.delivererPhoneConfirm.getText().length();
|
|
|
if (length >= 11) {
|
|
|
- Snackbar.make(view1, "手机号不能超过11位", Snackbar.LENGTH_LONG).show();
|
|
|
+ ToastUtils.make(getContext(), "手机号不能超过11位!");
|
|
|
return;
|
|
|
}
|
|
|
int start = binding.delivererPhoneConfirm.getSelectionStart();
|
|
@@ -230,7 +240,7 @@ public class InputInfoFragment extends Fragment {
|
|
|
binding.inputButton1.setOnClickListener(v -> {
|
|
|
int length = binding.delivererPhoneConfirm.getText().length();
|
|
|
if (length >= 11) {
|
|
|
- Snackbar.make(view1, "手机号不能超过11位", Snackbar.LENGTH_LONG).show();
|
|
|
+ ToastUtils.make(getContext(), "手机号不能超过11位!");
|
|
|
return;
|
|
|
}
|
|
|
int start = binding.delivererPhoneConfirm.getSelectionStart();
|
|
@@ -239,7 +249,7 @@ public class InputInfoFragment extends Fragment {
|
|
|
binding.inputButton2.setOnClickListener(v -> {
|
|
|
int length = binding.delivererPhoneConfirm.getText().length();
|
|
|
if (length >= 11) {
|
|
|
- Snackbar.make(view1, "手机号不能超过11位", Snackbar.LENGTH_LONG).show();
|
|
|
+ ToastUtils.make(getContext(), "手机号不能超过11位!");
|
|
|
return;
|
|
|
}
|
|
|
int start = binding.delivererPhoneConfirm.getSelectionStart();
|
|
@@ -248,7 +258,7 @@ public class InputInfoFragment extends Fragment {
|
|
|
binding.inputButton3.setOnClickListener(v -> {
|
|
|
int length = binding.delivererPhoneConfirm.getText().length();
|
|
|
if (length >= 11) {
|
|
|
- Snackbar.make(view1, "手机号不能超过11位", Snackbar.LENGTH_LONG).show();
|
|
|
+ ToastUtils.make(getContext(), "手机号不能超过11位!");
|
|
|
return;
|
|
|
}
|
|
|
int start = binding.delivererPhoneConfirm.getSelectionStart();
|
|
@@ -257,7 +267,7 @@ public class InputInfoFragment extends Fragment {
|
|
|
binding.inputButton4.setOnClickListener(v -> {
|
|
|
int length = binding.delivererPhoneConfirm.getText().length();
|
|
|
if (length >= 11) {
|
|
|
- Snackbar.make(view1, "手机号不能超过11位", Snackbar.LENGTH_LONG).show();
|
|
|
+ ToastUtils.make(getContext(), "手机号不能超过11位!");
|
|
|
return;
|
|
|
}
|
|
|
int start = binding.delivererPhoneConfirm.getSelectionStart();
|
|
@@ -266,7 +276,7 @@ public class InputInfoFragment extends Fragment {
|
|
|
binding.inputButton5.setOnClickListener(v -> {
|
|
|
int length = binding.delivererPhoneConfirm.getText().length();
|
|
|
if (length >= 11) {
|
|
|
- Snackbar.make(view1, "手机号不能超过11位", Snackbar.LENGTH_LONG).show();
|
|
|
+ ToastUtils.make(getContext(), "手机号不能超过11位!");
|
|
|
return;
|
|
|
}
|
|
|
int start = binding.delivererPhoneConfirm.getSelectionStart();
|
|
@@ -275,7 +285,7 @@ public class InputInfoFragment extends Fragment {
|
|
|
binding.inputButton6.setOnClickListener(v -> {
|
|
|
int length = binding.delivererPhoneConfirm.getText().length();
|
|
|
if (length >= 11) {
|
|
|
- Snackbar.make(view1, "手机号不能超过11位", Snackbar.LENGTH_LONG).show();
|
|
|
+ ToastUtils.make(getContext(), "手机号不能超过11位!");
|
|
|
return;
|
|
|
}
|
|
|
int start = binding.delivererPhoneConfirm.getSelectionStart();
|
|
@@ -284,7 +294,7 @@ public class InputInfoFragment extends Fragment {
|
|
|
binding.inputButton7.setOnClickListener(v -> {
|
|
|
int length = binding.delivererPhoneConfirm.getText().length();
|
|
|
if (length >= 11) {
|
|
|
- Snackbar.make(view1, "手机号不能超过11位", Snackbar.LENGTH_LONG).show();
|
|
|
+ ToastUtils.make(getContext(), "手机号不能超过11位!");
|
|
|
return;
|
|
|
}
|
|
|
int start = binding.delivererPhoneConfirm.getSelectionStart();
|
|
@@ -293,7 +303,7 @@ public class InputInfoFragment extends Fragment {
|
|
|
binding.inputButton8.setOnClickListener(v -> {
|
|
|
int length = binding.delivererPhoneConfirm.getText().length();
|
|
|
if (length >= 11) {
|
|
|
- Snackbar.make(view1, "手机号不能超过11位", Snackbar.LENGTH_LONG).show();
|
|
|
+ ToastUtils.make(getContext(), "手机号不能超过11位!");
|
|
|
return;
|
|
|
}
|
|
|
int start = binding.delivererPhoneConfirm.getSelectionStart();
|
|
@@ -302,7 +312,7 @@ public class InputInfoFragment extends Fragment {
|
|
|
binding.inputButton9.setOnClickListener(v -> {
|
|
|
int length = binding.delivererPhoneConfirm.getText().length();
|
|
|
if (length >= 11) {
|
|
|
- Snackbar.make(view1, "手机号不能超过11位", Snackbar.LENGTH_LONG).show();
|
|
|
+ ToastUtils.make(getContext(), "手机号不能超过11位!");
|
|
|
return;
|
|
|
}
|
|
|
int start = binding.delivererPhoneConfirm.getSelectionStart();
|
|
@@ -316,6 +326,11 @@ public class InputInfoFragment extends Fragment {
|
|
|
binding.delivererPhoneConfirm.setSelection(binding.delivererPhoneConfirm.getText().length());
|
|
|
}
|
|
|
});
|
|
|
+ // 长按删除
|
|
|
+ binding.inputButtonCancel.setOnLongClickListener(v -> {
|
|
|
+ binding.delivererPhoneConfirm.getText().clear();
|
|
|
+ return false;
|
|
|
+ });
|
|
|
}
|
|
|
});
|
|
|
|
|
@@ -369,10 +384,18 @@ public class InputInfoFragment extends Fragment {
|
|
|
binding.mailNo.setSelection(binding.mailNo.getText().length());
|
|
|
}
|
|
|
});
|
|
|
+ // 长按删除
|
|
|
+ binding.inputButtonCancel.setOnLongClickListener(v -> {
|
|
|
+ binding.mailNo.getText().clear();
|
|
|
+ return false;
|
|
|
+ });
|
|
|
}
|
|
|
});
|
|
|
|
|
|
binding.returnBtn.setOnClickListener(view1 -> {
|
|
|
+ if (ButtonUtils.isFastClick()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
timer.cancel();
|
|
|
NavHostFragment.findNavController(InputInfoFragment.this)
|
|
|
.navigate(R.id.action_inputInfoFragment_to_chooseCabinetFragment);
|