|
@@ -5,10 +5,12 @@ import android.os.Bundle;
|
|
|
import android.os.CountDownTimer;
|
|
|
import android.text.Editable;
|
|
|
import android.util.Log;
|
|
|
+import android.view.Gravity;
|
|
|
import android.view.LayoutInflater;
|
|
|
import android.view.View;
|
|
|
import android.view.ViewGroup;
|
|
|
import android.widget.TextView;
|
|
|
+import android.widget.Toast;
|
|
|
|
|
|
import androidx.annotation.NonNull;
|
|
|
import androidx.annotation.Nullable;
|
|
@@ -19,25 +21,25 @@ import com.emato.ich.MainActivity;
|
|
|
import com.emato.ich.R;
|
|
|
import com.emato.ich.api.ICSPClient;
|
|
|
import com.emato.ich.api.ICSPResponseCodeEnum;
|
|
|
-import com.emato.ich.api.SystemConfigConstant;
|
|
|
+import com.emato.ich.contant.SystemConfigConstant;
|
|
|
import com.emato.ich.databinding.FragmentTakeCodeBinding;
|
|
|
import com.emato.ich.entity.vo.PreparedOrderResponseVo;
|
|
|
import com.emato.ich.entity.vo.ResponseData;
|
|
|
import com.emato.ich.entity.vo.TakeParcelVo;
|
|
|
import com.emato.ich.utils.BaseUtils;
|
|
|
+import com.emato.ich.utils.ButtonUtils;
|
|
|
import com.emato.ich.utils.StringUtils;
|
|
|
import com.emato.ich.utils.JacksonUtils;
|
|
|
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.io.InputStream;
|
|
|
-import java.net.URL;
|
|
|
|
|
|
import okhttp3.Call;
|
|
|
import okhttp3.Callback;
|
|
@@ -109,42 +111,92 @@ public class TakeCodeFragment extends Fragment {
|
|
|
binding.editTextTextPersonName6.setOnFocusChangeListener((view1, hasFocus) -> {
|
|
|
if (hasFocus) {
|
|
|
binding.takeInputButton0.setOnClickListener(v -> {
|
|
|
+ int length = binding.editTextTextPersonName6.getText().length();
|
|
|
+ if (length >= 8) {
|
|
|
+ ToastUtils.make(getContext(), "取件码不能超过8位");
|
|
|
+ return;
|
|
|
+ }
|
|
|
int start = binding.editTextTextPersonName6.getSelectionStart();
|
|
|
binding.editTextTextPersonName6.getText().insert(start,"0");
|
|
|
});
|
|
|
binding.takeInputButton1.setOnClickListener(v -> {
|
|
|
+ int length = binding.editTextTextPersonName6.getText().length();
|
|
|
+ if (length >= 8) {
|
|
|
+ ToastUtils.make(getContext(), "取件码不能超过8位");
|
|
|
+ return;
|
|
|
+ }
|
|
|
int start = binding.editTextTextPersonName6.getSelectionStart();
|
|
|
binding.editTextTextPersonName6.getText().insert(start,"1");
|
|
|
});
|
|
|
binding.takeInputButton2.setOnClickListener(v -> {
|
|
|
+ int length = binding.editTextTextPersonName6.getText().length();
|
|
|
+ if (length >= 8) {
|
|
|
+ ToastUtils.make(getContext(), "取件码不能超过8位");
|
|
|
+ return;
|
|
|
+ }
|
|
|
int start = binding.editTextTextPersonName6.getSelectionStart();
|
|
|
binding.editTextTextPersonName6.getText().insert(start,"2");
|
|
|
});
|
|
|
binding.takeInputButton3.setOnClickListener(v -> {
|
|
|
+ int length = binding.editTextTextPersonName6.getText().length();
|
|
|
+ if (length >= 8) {
|
|
|
+ ToastUtils.make(getContext(), "取件码不能超过8位");
|
|
|
+ return;
|
|
|
+ }
|
|
|
int start = binding.editTextTextPersonName6.getSelectionStart();
|
|
|
binding.editTextTextPersonName6.getText().insert(start,"3");
|
|
|
});
|
|
|
binding.takeInputButton4.setOnClickListener(v -> {
|
|
|
+ int length = binding.editTextTextPersonName6.getText().length();
|
|
|
+ if (length >= 8) {
|
|
|
+ ToastUtils.make(getContext(), "取件码不能超过8位");
|
|
|
+ return;
|
|
|
+ }
|
|
|
int start = binding.editTextTextPersonName6.getSelectionStart();
|
|
|
binding.editTextTextPersonName6.getText().insert(start,"4");
|
|
|
});
|
|
|
binding.takeInputButton5.setOnClickListener(v -> {
|
|
|
+ int length = binding.editTextTextPersonName6.getText().length();
|
|
|
+ if (length >= 8) {
|
|
|
+ ToastUtils.make(getContext(), "取件码不能超过8位");
|
|
|
+ return;
|
|
|
+ }
|
|
|
int start = binding.editTextTextPersonName6.getSelectionStart();
|
|
|
binding.editTextTextPersonName6.getText().insert(start,"5");
|
|
|
});
|
|
|
binding.takeInputButton6.setOnClickListener(v -> {
|
|
|
+ int length = binding.editTextTextPersonName6.getText().length();
|
|
|
+ if (length >= 8) {
|
|
|
+ ToastUtils.make(getContext(), "取件码不能超过8位");
|
|
|
+ return;
|
|
|
+ }
|
|
|
int start = binding.editTextTextPersonName6.getSelectionStart();
|
|
|
binding.editTextTextPersonName6.getText().insert(start,"6");
|
|
|
});
|
|
|
binding.takeInputButton7.setOnClickListener(v -> {
|
|
|
+ int length = binding.editTextTextPersonName6.getText().length();
|
|
|
+ if (length >= 8) {
|
|
|
+ ToastUtils.make(getContext(), "取件码不能超过8位");
|
|
|
+ return;
|
|
|
+ }
|
|
|
int start = binding.editTextTextPersonName6.getSelectionStart();
|
|
|
binding.editTextTextPersonName6.getText().insert(start,"7");
|
|
|
});
|
|
|
binding.takeInputButton8.setOnClickListener(v -> {
|
|
|
+ int length = binding.editTextTextPersonName6.getText().length();
|
|
|
+ if (length >= 8) {
|
|
|
+ ToastUtils.make(getContext(), "取件码不能超过8位");
|
|
|
+ return;
|
|
|
+ }
|
|
|
int start = binding.editTextTextPersonName6.getSelectionStart();
|
|
|
binding.editTextTextPersonName6.getText().insert(start,"8");
|
|
|
});
|
|
|
binding.takeInputButton9.setOnClickListener(v -> {
|
|
|
+ int length = binding.editTextTextPersonName6.getText().length();
|
|
|
+ if (length >= 8) {
|
|
|
+ ToastUtils.make(getContext(), "取件码不能超过8位");
|
|
|
+ return;
|
|
|
+ }
|
|
|
int start = binding.editTextTextPersonName6.getSelectionStart();
|
|
|
binding.editTextTextPersonName6.getText().insert(start,"9");
|
|
|
});
|
|
@@ -156,10 +208,18 @@ public class TakeCodeFragment extends Fragment {
|
|
|
binding.editTextTextPersonName6.setSelection(binding.editTextTextPersonName6.getText().length());
|
|
|
}
|
|
|
});
|
|
|
+ // 长按删除
|
|
|
+ binding.takeInputButtonCancel.setOnLongClickListener(v -> {
|
|
|
+ binding.editTextTextPersonName6.getText().clear();
|
|
|
+ return false;
|
|
|
+ });
|
|
|
}
|
|
|
});
|
|
|
|
|
|
binding.takeInputButtonConfirm.setOnClickListener(view1 -> {
|
|
|
+ if (ButtonUtils.isFastClick()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
// TODO 取件逻辑
|
|
|
String takeParcelCode = binding.editTextTextPersonName6.getText().toString();
|
|
|
if (null != takeParcelCode && !"".equals(takeParcelCode.trim()) && takeParcelCode.length() > 0) {
|
|
@@ -171,7 +231,7 @@ public class TakeCodeFragment extends Fragment {
|
|
|
@Override
|
|
|
public void onFailure(@NotNull Call call, @NotNull IOException e) {
|
|
|
// TODO 取件接口请求失败逻辑处理
|
|
|
- Snackbar.make(view, "取件失败!网络异常!", Snackbar.LENGTH_LONG).show();
|
|
|
+ ToastUtils.make(getContext(), "取件失败!网络异常!");
|
|
|
Log.e(TAG, "onFailure: 取件请求失败!", e);
|
|
|
}
|
|
|
|
|
@@ -186,17 +246,17 @@ public class TakeCodeFragment extends Fragment {
|
|
|
try {
|
|
|
responseData = objectMapper.readValue(parseResponse, new TypeReference<ResponseData<PreparedOrderResponseVo>>() {
|
|
|
});
|
|
|
- ICSPResponseCodeEnum.responseHint(view1, responseData);
|
|
|
+ ICSPResponseCodeEnum.responseHint(getContext(), responseData);
|
|
|
} catch (JsonProcessingException e) {
|
|
|
Log.e(TAG, "onResponse: 解析取件开门响应信息失败! ", e);
|
|
|
} catch (RuntimeException e) {
|
|
|
Log.e(TAG, "onResponse: 未知错误! ", e);
|
|
|
- Snackbar.make(view1, "未知错误!", Snackbar.LENGTH_LONG).show();
|
|
|
+ ToastUtils.make(getContext(), "未知错误!");
|
|
|
}
|
|
|
if (null != responseData && responseData.getCode().equals(ICSPResponseCodeEnum.OK.getCode())) {
|
|
|
// 开门
|
|
|
Log.i(TAG, "onResponse: 取件成功! ");
|
|
|
- Snackbar.make(view1, "取件成功!", Snackbar.LENGTH_LONG).show();
|
|
|
+ ToastUtils.make(getContext(), "取件成功!");
|
|
|
Bundle bundle = new Bundle();
|
|
|
bundle.putString("takeParcelCode", takeParcelCode);
|
|
|
bundle.putString("takeCabinetNo", responseData.getData().getLockerName());
|
|
@@ -206,17 +266,20 @@ public class TakeCodeFragment extends Fragment {
|
|
|
}
|
|
|
} catch (RuntimeException e) {
|
|
|
Log.e(TAG, "onResponse: 取件失败! ", e);
|
|
|
- Snackbar.make(view1, "取件失败!", Snackbar.LENGTH_LONG).show();
|
|
|
+ ToastUtils.make(getContext(), "取件失败!");
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
});
|
|
|
} else {
|
|
|
- Snackbar.make(view, "取件失败!取件码不能为空!", Snackbar.LENGTH_LONG).show();
|
|
|
+ ToastUtils.make(getContext(), "取件失败!取件码不能为空!");
|
|
|
}
|
|
|
|
|
|
});
|
|
|
binding.returnBtn.setOnClickListener(view1 -> {
|
|
|
+ if (ButtonUtils.isFastClick()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
timer.cancel();
|
|
|
NavHostFragment.findNavController(TakeCodeFragment.this)
|
|
|
.navigate(R.id.action_takeCodeFragment_to_takeFragment);
|