Commit 33d53e1f by 罗翻

处理工单前增加活体检测

parent d46bcf9d
Showing with 1110 additions and 98 deletions
......@@ -379,7 +379,7 @@ public class LivenessActivity extends Activity
/**
* 跳转Activity传递信息
*/
private void handleResult(final int resID, String delta, Map<String, byte[]> images) {
public void handleResult(final int resID, String delta, Map<String, byte[]> images) {
String resultString = getResources().getString(resID);
try {
jsonObject.put("result", resultString);
......
......@@ -38,8 +38,8 @@ public class IDetection {
}
public void animationInit() {
int[] reses = { R.drawable.liveness_head_pitch, R.drawable.liveness_head_yaw,
R.drawable.liveness_mouth_open_closed, R.drawable.liveness_eye_open_closed };
int[] reses = {R.drawable.liveness_head_pitch, R.drawable.liveness_head_yaw,
R.drawable.liveness_mouth_open_closed, R.drawable.liveness_eye_open_closed};
for (int oneRes : reses) {
mDrawableCache.put(oneRes, (mContext.getResources().getDrawable(oneRes)));
}
......@@ -90,7 +90,7 @@ public class IDetection {
if (detectionNameStr != null && detectionNameText != null) {
if (isLarge && !detectionNameText.getText().toString().equals(mContext.getString(R.string.face_too_large))) {
detectionNameText.setText(R.string.face_too_large);
} else if(!isLarge && detectionNameText.getText().toString().equals(mContext.getString(R.string.face_too_large))){
} else if (!isLarge && detectionNameText.getText().toString().equals(mContext.getString(R.string.face_too_large))) {
detectionNameText.setText(detectionNameStr);
}
}
......@@ -151,17 +151,21 @@ public class IDetection {
return detectionName;
}
public void setNum(int n) {
num = n;
}
/**
* 初始化检测动作
*/
public void detectionTypeInit() {
ArrayList<DetectionType> tmpTypes = new ArrayList<Detector.DetectionType>();
ArrayList<DetectionType> tmpTypes = new ArrayList<>();
tmpTypes.add(Detector.DetectionType.BLINK);// 眨眼
tmpTypes.add(Detector.DetectionType.MOUTH);// 张嘴
tmpTypes.add(Detector.DetectionType.POS_PITCH);// 缓慢点头
tmpTypes.add(Detector.DetectionType.POS_YAW);// 左右摇头
Collections.shuffle(tmpTypes);// 打乱顺序
mDetectionSteps = new ArrayList<DetectionType>(num);
mDetectionSteps = new ArrayList<>(num);
for (int i = 0; i < num; i++) {
mDetectionSteps.add(tmpTypes.get(i));
}
......
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
<layout>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/liveness_layout_rootRel"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
android:orientation="vertical">
<TextureView
android:id="@+id/liveness_layout_textureview"
......@@ -32,33 +34,34 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/liveness_layout_head_mask"
android:background="#F6F5F4" >
android:background="#F6F5F4">
<include
android:id="@+id/activity_main_bottomTitle"
layout="@layout/bottom_title_layout"
android:layout_width="match_parent"
android:layout_height="40dip"
android:layout_alignParentBottom="true"
layout="@layout/bottom_title_layout" />
android:visibility="gone" />
<include
android:id="@+id/liveness_layout_first_layout"
layout="@layout/liveness_detection_step"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@+id/activity_main_bottomTitle"
android:layout_marginBottom="15dip"
android:layout_marginTop="15dip"
layout="@layout/liveness_detection_step"
android:visibility="invisible" />
<include
android:id="@+id/liveness_layout_second_layout"
layout="@layout/liveness_detection_step"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@+id/activity_main_bottomTitle"
android:layout_marginBottom="15dip"
android:layout_marginTop="15dip"
layout="@layout/liveness_detection_step"
android:visibility="gone" />
<LinearLayout
......@@ -69,7 +72,7 @@
android:layout_centerHorizontal="true"
android:gravity="center"
android:orientation="vertical"
android:visibility="visible" >
android:visibility="visible">
<TextView
android:id="@+id/liveness_layout_promptText"
......@@ -93,7 +96,7 @@
android:layout_height="35dip"
android:layout_alignParentRight="true"
android:layout_margin="5dip"
android:visibility="invisible" >
android:visibility="invisible">
<TextView
android:id="@+id/detection_step_timeout_garden"
......@@ -119,7 +122,8 @@
android:layout_alignParentTop="true"
android:layout_marginRight="20dp"
android:scaleType="centerInside"
android:src="@drawable/liveness_faceppinside" />
android:src="@drawable/liveness_faceppinside"
android:visibility="gone" />
<ProgressBar
android:id="@+id/liveness_layout_progressbar"
......@@ -128,4 +132,5 @@
android:layout_centerInParent="true"
android:visibility="invisible" />
</RelativeLayout>
\ No newline at end of file
</RelativeLayout>
</layout>
\ No newline at end of file
package com.dayu.common;
import android.text.Editable;
import android.text.TextWatcher;
/**
* Created by luofan
* on 2018/6/20.
*/
public class MyTextWatcher implements TextWatcher {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
@Override
public void afterTextChanged(Editable s) {
}
}
......@@ -31,8 +31,8 @@ public class UserManager {
}
}
public void saveUserForJson(String json){
SPUtils.put("USER_INFO",json);
public void saveUserForJson(String json) {
SPUtils.put("USER_INFO", json);
}
public UserInfo getUser() {
......@@ -63,8 +63,9 @@ public class UserManager {
UserInfo userInfo = getUser();
if (userInfo != null) {
//有数据
//TODO
if (!TextUtils.isEmpty(userInfo.getAccountId()) && !TextUtils.isEmpty(userInfo.getSiteId())
&& !TextUtils.isEmpty(userInfo.getAccountName()) && userInfo.getDetectStatus() == 1) {
&& !TextUtils.isEmpty(userInfo.getAccountName()) && userInfo.getDetectStatus() == 1 && !TextUtils.isEmpty((String) SPUtils.get("USER_IDENTITY", ""))) {
return true;
} else {
return false;
......
......@@ -274,7 +274,8 @@
<string name="send_already">已发货</string>
<string name="modify_part_info">修改信息</string>
<string name="customer_acceptance">客户验收</string>
<string name="scan_code_for_appointment">请扫描二维码验收</string>
<string name="scan_code_for_appointment">请扫描二维码关注大鱼服务公众号</string>
<string name="scan_code_for_appointment_two">点击-我的服务-进行绑定登录后,选择工单付款</string>
<string name="order_record">工单记录</string>
<string name="order_num">工单编号</string>
<string name="order_state">工单状态</string>
......@@ -311,8 +312,8 @@
<string name="order_select_payer_notice">修改费用承担方可能会导致费用争议,请一定要确认清楚之后再操作</string>
<string name="order_payer_prove">费用承担证明</string>
<string name="server_info">服务信息</string>
<string name="payer_baonei">派单方承担(保内)</string>
<string name="payer_baowai">用户承担(保外)</string>
<string name="payer_baonei">派单方承担</string>
<string name="payer_baowai">用户承担</string>
<string name="payer_dialog_content">您还没有选择费用承担方,请选择后再提交验收</string>
<string name="payer_dialog_title">未选择费用承担方</string>
<string name="payer_select_title">确认操作</string>
......
......@@ -68,4 +68,5 @@ dependencies {
//ARouter
annotationProcessor "com.alibaba:arouter-compiler:$arouter_compiler_version"
compile project(':provider')
compile project(':IDCardLib')
}
......@@ -137,4 +137,8 @@ public class OrderApiFactory {
public static Observable<companyManager> getManagerMobile(int companyId, int managerType) {
return Api.getService(OrderService.class).getManagerMobile(companyId,managerType).compose(Api.applySchedulers());
}
public static Observable<Boolean> certificationLive(RequestBody body) {
return Api.getService(OrderService.class).certificationLive(body).compose(Api.applySchedulers());
}
}
......@@ -284,6 +284,7 @@ interface OrderService {
/**
* 单任务多数量提交工单.
*
* @param body
* @return
*/
......@@ -292,6 +293,7 @@ interface OrderService {
/**
* 查看多任务处理工单信息.
*
* @param id
* @return
*/
......@@ -300,8 +302,17 @@ interface OrderService {
/**
* 获取技术支持电话
*
* @return
*/
@GET(OrderConstant.COMPAY_MANAGER_MOBILE)
Observable<BaseResponse<companyManager>> getManagerMobile(@Query("companyId") int companyId, @Query("managerType") int managerType);
/**
* 接单活体检测.
*
* @return
*/
@GET(OrderConstant.FACE_CERTIFICAITON)
Observable<BaseResponse<Boolean>> certificationLive(@Body RequestBody body);
}
package com.dayu.order.api.protocol;
import java.io.Serializable;
import java.util.List;
/**
* 工单列表,异常单列表,工单记录列表的bean
* Created by luofan on 2017/11/14.
*/
public class Order {
public class Order implements Serializable{
/**
* id : 20
* orderNum : 201709249030024287834 接单数
......@@ -53,6 +54,15 @@ public class Order {
private List<Spu> spus;
private Integer commited;
private Integer kaCompanyId;
private Integer faceSwitch ;//0:关闭;1:打开
public Integer getFaceSwitch() {
return faceSwitch;
}
public void setFaceSwitch(Integer faceSwitch) {
this.faceSwitch = faceSwitch;
}
public Integer getKaCompanyId() {
return kaCompanyId;
......
......@@ -47,15 +47,15 @@ public class OrderDetail implements Serializable {
private Object customerCheckComment;
private Integer isPay;
private Object payType;
private Integer doorPrice;
private Double doorPrice;
private String doorPriceComment;
private Integer servicePrice;
private Double servicePrice;
private Object servicePriceComment;
private Integer materialCost;
private Object materialCostComment;
private Integer otherPrice;
private double otherPrice;
private Object otherPriceComment;
private Integer totalPrice;
private Double totalPrice;
private Object cancelOrderReason;
private Object closePhase;
private int siteId;
......@@ -428,11 +428,11 @@ public class OrderDetail implements Serializable {
this.payType = payType;
}
public Integer getDoorPrice() {
public Double getDoorPrice() {
return doorPrice;
}
public void setDoorPrice(Integer doorPrice) {
public void setDoorPrice(Double doorPrice) {
this.doorPrice = doorPrice;
}
......@@ -444,11 +444,11 @@ public class OrderDetail implements Serializable {
this.doorPriceComment = doorPriceComment;
}
public Integer getServicePrice() {
public Double getServicePrice() {
return servicePrice;
}
public void setServicePrice(Integer servicePrice) {
public void setServicePrice(Double servicePrice) {
this.servicePrice = servicePrice;
}
......@@ -476,11 +476,11 @@ public class OrderDetail implements Serializable {
this.materialCostComment = materialCostComment;
}
public Integer getOtherPrice() {
public Double getOtherPrice() {
return otherPrice;
}
public void setOtherPrice(Integer otherPrice) {
public void setOtherPrice(Double otherPrice) {
this.otherPrice = otherPrice;
}
......@@ -492,11 +492,11 @@ public class OrderDetail implements Serializable {
this.otherPriceComment = otherPriceComment;
}
public Integer getTotalPrice() {
public Double getTotalPrice() {
return totalPrice;
}
public void setTotalPrice(Integer totalPrice) {
public void setTotalPrice(Double totalPrice) {
this.totalPrice = totalPrice;
}
......
......@@ -152,4 +152,8 @@ public class OrderConstant {
*/
public final static String COMPAY_MANAGER_MOBILE = "/api-ka-user/" + "companyManager/findCompanyManagerBy";
/**
* 接单活体检测校验.
*/
public final static String FACE_CERTIFICAITON = "/api-third/" +"detect/receiptOrderVerify";
}
......@@ -3,6 +3,7 @@ package com.dayu.order.presenter.multipleprocess;
import com.dayu.base.ui.presenter.BaseListPresenter;
import com.dayu.common.BaseView;
import com.dayu.widgets.listener.OnCloseListener;
import java.util.ArrayList;
import java.util.HashMap;
......@@ -27,6 +28,12 @@ public interface MultipleProcessContract {
void showSignature();
void setPayStatus();
void showSelectPayerDialog(OnCloseListener listener);
void showNoPayerDialog();
boolean getSelectPayer();
}
abstract class Presenter extends BaseListPresenter<View> {
......
package com.dayu.order.presenter.multipleprocess;
import android.databinding.ObservableField;
import android.os.Bundle;
import com.alibaba.android.arouter.launcher.ARouter;
import com.dayu.base.api.BaseApiFactory;
import com.dayu.common.Constants;
import com.dayu.order.R;
import com.dayu.order.api.OrderApiFactory;
import com.dayu.order.api.protocol.Spu;
import com.dayu.order.common.OrderConstant;
import com.dayu.order.ui.activity.QrCodeActivity;
import com.dayu.order.ui.activity.SignatureActivity;
import com.dayu.provider.event.RefreshServe;
import com.dayu.provider.router.RouterPath;
......@@ -41,7 +44,6 @@ public class MultipleProcessPresenter extends MultipleProcessContract.Presenter
private ArrayList<String> mImages = new ArrayList<>();
private Integer mNeedEsignature;
private String mSignatureUrl;
private boolean canPay;
@Override
public void onAttached() {
......@@ -67,12 +69,20 @@ public class MultipleProcessPresenter extends MultipleProcessContract.Presenter
public void process() {
File file = new File(SignatureActivity.path);
if (!file.exists()) {
if (mNeedEsignature == 1 && !file.exists()) {
ToastUtils.showShortToast("请让客户签名!");
return;
}
if (mView.getSelectPayer()) {
mView.showNoPayerDialog();
} else {
mView.showSelectPayerDialog((dialog, confirm) -> {
if (confirm) {
commitePhoto();
}
});
}
}
private void commitePhoto() {
MultipartBody.Part[] parts;
......@@ -154,8 +164,14 @@ public class MultipleProcessPresenter extends MultipleProcessContract.Presenter
RequestBody body = RequestBody.create(MediaType.parse("application/json"), jsonObject.toString());
OrderApiFactory.commitOrder(body).subscribe(baseObserver(integer -> {
ToastUtils.showShortToast("提交验收成功");
if (integer == 6) {
Bundle bundle = new Bundle();
bundle.putInt(Constants.TYPE, 1);
mView.startActivity(QrCodeActivity.class, bundle);
} else {
ARouter.getInstance().build(RouterPath.PATH_MAIN).navigation();
EventBus.getDefault().post(new RefreshServe(1));
}
}));
}
......@@ -175,7 +191,7 @@ public class MultipleProcessPresenter extends MultipleProcessContract.Presenter
}
Integer isPay = detail.getIsPay();
Integer payState = detail.getPayStatus();
if (isPay == 2 && payState == 3) {
if (isPay == 2 && (payState == 3 || payState == 2)) {
mView.setPayStatus();
}
}));
......
......@@ -5,12 +5,18 @@ import android.os.Bundle;
import com.dayu.common.BaseApplication;
import com.dayu.common.Constants;
import com.dayu.provider.event.RefreshTab;
import com.dayu.event.UserInfo;
import com.dayu.order.R;
import com.dayu.order.api.OrderApiFactory;
import com.dayu.order.api.protocol.Order;
import com.dayu.order.common.OrderConstant;
import com.dayu.order.ui.activity.OrderDetailsActivity;
import com.dayu.order.ui.activity.OrderLivenessActivity;
import com.dayu.order.ui.fragment.OrderThreeTabFragment;
import com.dayu.provider.event.RefreshTab;
import com.dayu.utils.AppManager;
import com.dayu.utils.UserManager;
import com.dayu.widgets.CustomDialog;
import com.umeng.analytics.MobclickAgent;
import org.greenrobot.eventbus.EventBus;
......@@ -22,12 +28,15 @@ import io.reactivex.Observable;
import okhttp3.MediaType;
import okhttp3.RequestBody;
import static com.dayu.utils.UIUtils.getString;
/**
* Created by luofan
* on 2017/11/8.
*/
public class OrderDoingPresenter extends orderDoingContract.Presenter {
private ObservableField<Object> datas = new ObservableField<>();
private static final int PAGE_INTO_LIVENESS = 100;
private int mUserId;
private int mSiteId;
private int mState;
......@@ -75,7 +84,7 @@ public class OrderDoingPresenter extends orderDoingContract.Presenter {
@Override
public void getErrorOrder() {
OrderApiFactory.getErrorOrders(mUserId, mSiteId).subscribe(
baseObserver( errorOrder -> {
baseObserver(errorOrder -> {
datas.set(errorOrder);
EventBus.getDefault().post(new RefreshTab(-1));
}, responeThrowable -> datas.set(Constants.FAILED)));
......@@ -104,10 +113,27 @@ public class OrderDoingPresenter extends orderDoingContract.Presenter {
}
@Override
public void dumpToFaceCert(Order order) {
CustomDialog customDialog = new CustomDialog(AppManager.getInstance().currentActivity(), R.style.CustomDialog, "为了保证您的账号安全和用户安全,请您本人进行人脸识别操作",
(dialog, confirm) -> {
if (confirm) {
Bundle bundle = new Bundle();
bundle.putSerializable(OrderConstant.ORDERS,order);
mView.startActivity(OrderLivenessActivity.class, bundle);
}
});
customDialog.setTitle("人脸识别")
.setNegativeButton(getString(R.string.cancle))
.setPositiveButton("去认证");
customDialog.show();
}
@Override
public void dumpDetail(int orderId) {
Bundle bundle = new Bundle();
bundle.putInt(Constants.ORDER_ID,orderId);
mView.startActivity(OrderDetailsActivity.class,bundle);
bundle.putInt(Constants.ORDER_ID, orderId);
mView.startActivity(OrderDetailsActivity.class, bundle);
MobclickAgent.onEvent(BaseApplication.getContext(), "check_order_detail");
}
}
......@@ -2,6 +2,7 @@ package com.dayu.order.presenter.orderdoing;
import com.dayu.common.BaseView;
import com.dayu.order.api.protocol.Order;
import com.dayu.order.presenter.BaseOrderPresenter;
import io.reactivex.Observable;
......@@ -45,5 +46,7 @@ public interface orderDoingContract {
*/
public abstract Observable<Integer> startServer(int orderId, double latitude, double longitude);
public abstract void dumpToFaceCert(Order order);
}
}
package com.dayu.order.presenter.orderliveness;
import com.dayu.base.ui.presenter.BasePresenter;
import com.dayu.common.BaseView;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
/**
* Created by luo
* on 2016/8/4.
*/
public interface OrderLivenessContract {
interface View extends BaseView {
}
abstract class Presenter extends BasePresenter<View> {
public abstract void verifyIdentity(List<String> list);
public abstract void commitePhoto(ArrayList<File> list, String delta);
}
}
package com.dayu.order.presenter.orderliveness;
import android.os.Bundle;
import com.dayu.base.api.BaseApiFactory;
import com.dayu.common.Constants;
import com.dayu.order.R;
import com.dayu.order.api.OrderApiFactory;
import com.dayu.order.api.protocol.Order;
import com.dayu.order.common.OrderConstant;
import com.dayu.order.ui.activity.ServerInfoActivity;
import com.dayu.order.ui.activity.ServerListActivity;
import com.dayu.utils.SPUtils;
import com.dayu.utils.ToastUtils;
import com.dayu.utils.UserManager;
import org.json.JSONObject;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import okhttp3.MediaType;
import okhttp3.MultipartBody;
import okhttp3.RequestBody;
/**
* Created by luofan
* on 2017/11/8.
*/
public class OrderLivenessPresenter extends OrderLivenessContract.Presenter {
private String mDelta;
private Order mOrder;
private String mName;
private String mCardNum;
@Override
public void onAttached() {
Bundle bundle = mView.getBundle();
mOrder = (Order) bundle.getSerializable(OrderConstant.ORDERS);
mName = UserManager.getInstance().getUser().getAccountName();
mCardNum = (String) SPUtils.get("USER_IDENTITY", "");
}
@Override
public void commitePhoto(ArrayList<File> list, String delta) {
mDelta = delta;
BaseApiFactory.uploadPhoto(packPhoto(list), "nowatermark").subscribe(baseObserver(this::verifyIdentity));
}
private MultipartBody.Part[] packPhoto(List<File> files) {
MultipartBody.Part[] part = new MultipartBody.Part[files.size()];
for (int i = 0; i < files.size(); i++) {
RequestBody requestFile =
RequestBody.create(MediaType.parse("multipart/form-data"), files.get(i));
MultipartBody.Part body =
MultipartBody.Part.createFormData("fileUpload", files.get(i).getName(), requestFile);
part[i] = body;
}
return part;
}
@Override
public void verifyIdentity(List<String> list) {
HashMap<String, Object> params = new HashMap<>();
params.put("name", mName);
params.put("cardNumber", mCardNum);
params.put("checkDelta", 0);
params.put("comparisonType", 1);
params.put("delta", mDelta);
params.put("imageAction1Url", list.get(2));
params.put("imageBestUrl", list.get(0));
params.put("imageEnvUrl", list.get(1));
params.put("multiOrientedDetection", 1);
JSONObject jsonObject = new JSONObject(params);
RequestBody body = RequestBody.create(MediaType.parse("application/json"), jsonObject.toString());
mView.showDialog();
Bundle bundle = new Bundle();
OrderApiFactory.certificationLive(body).subscribe(baseObserver(aBoolean -> {
if (aBoolean) {
SPUtils.put(Constants.ORDER_ID+mOrder.getId(),true);
if (mOrder.getKaCompanyId() != null) {
bundle.putInt(OrderConstant.KAADDRESSID, mOrder.getKaCompanyId());
}
if (mOrder.getSpus().size() > 1) {
bundle.putInt(Constants.ID, mOrder.getId());
mView.startActivity(ServerInfoActivity.class, bundle);
} else if (mOrder.getSpus().size() == 1) {
bundle.putInt(Constants.ID, mOrder.getSpus().get(0).getId());
mView.startActivity(ServerListActivity.class, bundle);
}
}
}, responeThrowable -> {
if ("DETECT_ERROR00001".equals(responeThrowable.subCode)) {
ToastUtils.showShortToast(R.string.please_upload_cleare_identity);
} else if ("DETECT_ERROR00003".equals(responeThrowable.subCode)) {
ToastUtils.showShortToast(R.string.please_upload_yourself_face);
} else if ("DETECT_ERROR00003".equals(responeThrowable.subCode)) {
ToastUtils.showShortToast(R.string.server_error);
} else if ("DETECT_ERROR00003".equals(responeThrowable.subCode)) {
ToastUtils.showShortToast(R.string.please_upload_identity_front);
} else {
ToastUtils.showShortToast(R.string.certification_not_pass);
}
mView.dumpBack();
}));
}
}
......@@ -23,12 +23,14 @@ public interface ProcessOrderContract {
/**
* 初始化图片.
*
* @param list
*/
void initPhotoView(ArrayList<String> list);
/**
* 初始化费用承担证明图片.
*
* @param list
*/
void initPayerPhotoView(ArrayList<String> list);
......@@ -59,7 +61,6 @@ public interface ProcessOrderContract {
public abstract void getOrderInfo(int orderId);
/**
*
* @param imageUrl
* @param orderId
* @param editText
......@@ -79,9 +80,9 @@ public interface ProcessOrderContract {
public abstract void commitOrder(List<String> imageUrl, int orderId, String editText, int engineerId,
int isPay, String doorPrice, String doorPriceComment,
String servicePrice, String materialCost, String otherPrice,
String brandName,String productModel,String sn,int repairType,List<String> picsCost);
String brandName, String productModel, String sn, int repairType, List<String> picsCost);
public abstract void commitPhoto(List<String> imageUrl,List<String> payerUrl);
public abstract void commitPhoto(List<String> imageUrl, List<String> payerUrl);
/**
* 保存订单.
......@@ -107,6 +108,5 @@ public interface ProcessOrderContract {
* 显示费用承担方.
*/
public abstract void showPayerDialog();
}
}
......@@ -2,6 +2,8 @@ package com.dayu.order.ui.activity;
import android.content.Intent;
import android.os.Environment;
import android.text.Editable;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
......@@ -15,6 +17,7 @@ import com.bigkoo.pickerview.builder.OptionsPickerBuilder;
import com.bigkoo.pickerview.view.OptionsPickerView;
import com.dayu.base.ui.activity.BaseActivity;
import com.dayu.common.Constants;
import com.dayu.common.MyTextWatcher;
import com.dayu.order.R;
import com.dayu.order.databinding.ActivityMultipleProcessBinding;
import com.dayu.order.presenter.multipleprocess.MultipleProcessContract;
......@@ -23,7 +26,9 @@ import com.dayu.utils.GlideImageLoader;
import com.dayu.utils.ToastUtils;
import com.dayu.utils.UIUtils;
import com.dayu.utils.UtilsScreen;
import com.dayu.widgets.CustomDialog;
import com.dayu.widgets.SwitchImage;
import com.dayu.widgets.listener.OnCloseListener;
import com.luck.picture.lib.PictureSelectionModel;
import com.luck.picture.lib.PictureSelector;
import com.luck.picture.lib.config.PictureConfig;
......@@ -31,6 +36,7 @@ import com.luck.picture.lib.config.PictureMimeType;
import com.luck.picture.lib.entity.LocalMedia;
import java.io.File;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
......@@ -63,6 +69,7 @@ public class MultipleProcessActivity extends BaseActivity<MultipleProcessPresent
private boolean isShowSignature;
private SwitchImage swtich;
private boolean canPay;
private TextView mTotalMoney;
@Override
public void setPresenter() {
......@@ -105,6 +112,7 @@ public class MultipleProcessActivity extends BaseActivity<MultipleProcessPresent
mServerPrice = view.findViewById(R.id.et_serve_price);
mMaterialsPrice = view.findViewById(R.id.et_materials_price);
mOtherPrice = view.findViewById(R.id.et_other_price);
mTotalMoney = view.findViewById(R.id.tv_total_money);
mDoorInfo = view.findViewById(R.id.et_door_info);
mRepairType = view.findViewById(R.id.tv_payer);
mArrow = view.findViewById(R.id.iv_payer);
......@@ -114,7 +122,7 @@ public class MultipleProcessActivity extends BaseActivity<MultipleProcessPresent
mIcon = view.findViewById(R.id.tv_icon);
swtich.setOnClickListener(v -> {
if (true) {
if (canPay) {
ToastUtils.showShortToast("您上次已经收取过客户费用,请勿重新收取!");
} else {
if (swtich.getSwitchButton()) {
......@@ -146,12 +154,50 @@ public class MultipleProcessActivity extends BaseActivity<MultipleProcessPresent
mArrow.setVisibility(View.GONE);
mPayerNotice.setVisibility(View.GONE);
}
mSignature.setOnClickListener(v -> {
startActivityForReult(SignatureActivity.class, 100);
});
mSignature.setOnClickListener(v -> startActivityForReult(SignatureActivity.class, 100));
if (isShowSignature) {
mAllSignature.setVisibility(View.VISIBLE);
}
initTotal();
}
private void initTotal() {
mDoorPrice.addTextChangedListener(new MyTextWatcher() {
@Override
public void afterTextChanged(Editable s) {
mTotalMoney.setText(getSum());
}
});
mServerPrice.addTextChangedListener(new MyTextWatcher() {
@Override
public void afterTextChanged(Editable s) {
mTotalMoney.setText(getSum());
}
});
mMaterialsPrice.addTextChangedListener(new MyTextWatcher() {
@Override
public void afterTextChanged(Editable s) {
mTotalMoney.setText(getSum());
}
});
mOtherPrice.addTextChangedListener(new MyTextWatcher() {
@Override
public void afterTextChanged(Editable s) {
mTotalMoney.setText(getSum());
}
});
}
public String getSum() {
return new DecimalFormat("0.00").format(parseDb(mDoorPrice.getText().toString()) + parseDb(mServerPrice.getText().toString()) + parseDb(mMaterialsPrice.getText().toString()) + parseDb(mOtherPrice.getText().toString()));
}
public Double parseDb(String str) {
if (TextUtils.isEmpty(str)) {
return 0.0;
} else {
return Double.parseDouble(str);
}
}
@Override
......@@ -298,6 +344,32 @@ public class MultipleProcessActivity extends BaseActivity<MultipleProcessPresent
}
@Override
public void showNoPayerDialog() {
CustomDialog customDialog = new CustomDialog(mActivity, R.style.CustomDialog, getString(R.string.payer_dialog_content)
, (dialog, confirm) -> dialog.dismiss());
customDialog.setTitle(getString(R.string.payer_dialog_title))
.setPositiveButton(getString(R.string.comfirm))
.setOneButton(true);
customDialog.show();
}
@Override
public boolean getSelectPayer() {
return TextUtils.isEmpty(mRepairType.getText().toString());
}
@Override
public void showSelectPayerDialog(OnCloseListener listener) {
CustomDialog customDialog = new CustomDialog(mActivity, R.style.CustomDialog, getString(R.string.payer_select_content)
, listener);
customDialog.setTitle(getString(R.string.payer_select_title))
.setNegativeButton(getString(R.string.cancle))
.setPositiveButton(getString(R.string.submit))
.setPositiveButtonColor(UIUtils.getColor(R.color.common_red));
customDialog.show();
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (resultCode == RESULT_OK) {
......
package com.dayu.order.ui.activity;
import android.graphics.SurfaceTexture;
import android.hardware.Camera;
import android.hardware.Camera.CameraInfo;
import android.hardware.Camera.PreviewCallback;
import android.hardware.Camera.Size;
import android.os.Build;
import android.os.Handler;
import android.os.HandlerThread;
import android.view.TextureView;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.dayu.base.ui.activity.BaseActivity;
import com.dayu.order.R;
import com.dayu.order.databinding.LivenessLayoutBinding;
import com.dayu.order.presenter.orderliveness.OrderLivenessContract;
import com.dayu.order.presenter.orderliveness.OrderLivenessPresenter;
import com.dayu.utils.ToastUtils;
import com.megvii.idcardlib.FaceMask;
import com.megvii.idcardlib.util.ConUtil;
import com.megvii.idcardlib.util.DialogUtil;
import com.megvii.idcardlib.util.FaceCamera;
import com.megvii.idcardlib.util.IDetection;
import com.megvii.idcardlib.util.IMediaPlayer;
import com.megvii.idcardlib.util.Screen;
import com.megvii.idcardlib.util.SensorUtil;
import com.megvii.idcardlib.view.CircleProgressBar;
import com.megvii.licensemanager.Manager;
import com.megvii.livenessdetection.DetectionConfig;
import com.megvii.livenessdetection.DetectionFrame;
import com.megvii.livenessdetection.Detector;
import com.megvii.livenessdetection.Detector.DetectionFailedType;
import com.megvii.livenessdetection.Detector.DetectionListener;
import com.megvii.livenessdetection.Detector.DetectionType;
import com.megvii.livenessdetection.FaceQualityManager;
import com.megvii.livenessdetection.FaceQualityManager.FaceQualityErrorType;
import com.megvii.livenessdetection.LivenessLicenseManager;
import com.megvii.livenessdetection.bean.FaceIDDataStruct;
import com.megvii.livenessdetection.bean.FaceInfo;
import org.json.JSONObject;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
public class OrderLivenessActivity extends BaseActivity<OrderLivenessPresenter,LivenessLayoutBinding>
implements PreviewCallback, DetectionListener, TextureView.SurfaceTextureListener ,OrderLivenessContract.View{
private TextureView camerapreview;
private FaceMask mFaceMask;// 画脸位置的类(调试时会用到)
private ProgressBar mProgressBar;// 网络上传请求验证时出现的ProgressBar
private LinearLayout headViewLinear;// "请在光线充足的情况下进行检测"这个视图
private RelativeLayout rootView;// 根视图
private TextView timeOutText;
private RelativeLayout timeOutRel;
private CircleProgressBar mCircleProgressBar;
private Detector mDetector;// 活体检测器
private FaceCamera mICamera;// 照相机工具类
private Handler mainHandler;
private HandlerThread mHandlerThread = new HandlerThread("videoEncoder");
private Handler mHandler;
private JSONObject jsonObject;
private IMediaPlayer mIMediaPlayer;// 多媒体工具类
private IDetection mIDetection;
private DialogUtil mDialogUtil;
private TextView promptText;
private boolean isHandleStart;// 是否开始检测
private FaceQualityManager mFaceQualityManager;
private SensorUtil sensorUtil;
private String uuid;
@Override
public int getLayoutId() {
return R.layout.liveness_layout;
}
@Override
public void initView() {
uuid = ConUtil.getUUIDString(this);
new Thread(() -> {
Manager manager = new Manager(OrderLivenessActivity.this);
LivenessLicenseManager licenseManager = new LivenessLicenseManager(OrderLivenessActivity.this);
manager.registerLicenseManager(licenseManager);
manager.takeLicenseFromNetwork(uuid);
if (licenseManager.checkCachedLicense() < 0) {
runOnUiThread(() -> ToastUtils.showShortToast(getString(R.string.accredit_error)));
} else {
initData();
}
}).start();
init();
}
@Override
public void setPresenter() {
}
private void init() {
sensorUtil = new SensorUtil(this);
Screen.initialize(this);
mainHandler = new Handler();
mHandlerThread.start();
mHandler = new Handler(mHandlerThread.getLooper());
mIMediaPlayer = new IMediaPlayer(this);
mDialogUtil = new DialogUtil(this);
rootView = (RelativeLayout) findViewById(com.megvii.idcardlib.R.id.liveness_layout_rootRel);
mIDetection = new IDetection(this, rootView);
mFaceMask = (FaceMask) findViewById(com.megvii.idcardlib.R.id.liveness_layout_facemask);
mICamera = new FaceCamera();
promptText = (TextView) findViewById(com.megvii.idcardlib.R.id.liveness_layout_promptText);
camerapreview = (TextureView) findViewById(com.megvii.idcardlib.R.id.liveness_layout_textureview);
camerapreview.setSurfaceTextureListener(this);
mProgressBar = (ProgressBar) findViewById(com.megvii.idcardlib.R.id.liveness_layout_progressbar);
mProgressBar.setVisibility(View.INVISIBLE);
headViewLinear = (LinearLayout) findViewById(com.megvii.idcardlib.R.id.liveness_layout_bottom_tips_head);
headViewLinear.setVisibility(View.VISIBLE);
timeOutRel = (RelativeLayout) findViewById(com.megvii.idcardlib.R.id.detection_step_timeoutRel);
timeOutText = (TextView) findViewById(com.megvii.idcardlib.R.id.detection_step_timeout_garden);
mCircleProgressBar = (CircleProgressBar) findViewById(com.megvii.idcardlib.R.id.detection_step_timeout_progressBar);
mIDetection.viewsInit();
}
/**
* 初始化数据
*/
private void initData() {
// 初始化活体检测器
DetectionConfig config = new DetectionConfig.Builder().build();
mDetector = new Detector(this, config);
boolean initSuccess = mDetector.init(this, ConUtil.readModel(this), "");
if (!initSuccess) {
mDialogUtil.showDialog(getString(com.megvii.idcardlib.R.string.meglive_detect_initfailed));
}
// 初始化动画
new Thread(new Runnable() {
@Override
public void run() {
mIDetection.animationInit();
}
}).start();
}
@Override
public void onResume() {
super.onResume();
isHandleStart = false;
int cameraID = 1;
if (!FaceCamera.hasFrontFacingCamera())
cameraID = 0;
// 打开照相机
Camera mCamera = mICamera.openCamera(this, cameraID);
if (mCamera != null) {
CameraInfo cameraInfo = new CameraInfo();
Camera.getCameraInfo(cameraID, cameraInfo);
mFaceMask.setFrontal(cameraInfo.facing == CameraInfo.CAMERA_FACING_FRONT);
// 获取到相机分辨率对应的显示大小,并把这个值复制给camerapreview
RelativeLayout.LayoutParams layout_params = mICamera.getLayoutParam();
camerapreview.setLayoutParams(layout_params);
mFaceMask.setLayoutParams(layout_params);
// 初始化人脸质量检测管理类
mFaceQualityManager = new FaceQualityManager(1 - 0.5f, 0.5f);
mIDetection.mCurShowIndex = -1;
} else {
mDialogUtil.showDialog(getString(com.megvii.idcardlib.R.string.meglive_camera_initfailed));
}
}
/**
* 开始检测
*/
private void handleStart() {
if (isHandleStart)
return;
isHandleStart = true;
// 开始动画
Animation animationIN = AnimationUtils.loadAnimation(OrderLivenessActivity.this, com.megvii.idcardlib.R.anim.liveness_rightin);
Animation animationOut = AnimationUtils.loadAnimation(OrderLivenessActivity.this, com.megvii.idcardlib.R.anim.liveness_leftout);
headViewLinear.startAnimation(animationOut);
mIDetection.mAnimViews[0].setVisibility(View.VISIBLE);
mIDetection.mAnimViews[0].startAnimation(animationIN);
animationOut.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationRepeat(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
timeOutRel.setVisibility(View.VISIBLE);
}
});
// 开始活体检测
mainHandler.post(mTimeoutRunnable);
jsonObject = new JSONObject();
}
private Runnable mTimeoutRunnable = new Runnable() {
@Override
public void run() {
// 倒计时开始
initDetecteSession();
if (mIDetection.mDetectionSteps != null)
changeType(mIDetection.mDetectionSteps.get(0), 10);
}
};
private void initDetecteSession() {
if (mICamera.mCamera == null)
return;
mProgressBar.setVisibility(View.INVISIBLE);
mIDetection.setNum(1);
mIDetection.detectionTypeInit();
mCurStep = 0;
mDetector.reset();
mDetector.changeDetectionType(mIDetection.mDetectionSteps.get(0));
}
/**
* 照相机预览数据回调 (PreviewCallback的接口回调方法)
*/
@Override
public void onPreviewFrame(final byte[] data, Camera camera) {
Size previewsize = camera.getParameters().getPreviewSize();
int angle = 360 - mICamera.getCameraAngle(this);
if (mICamera.cameraId == 0)
angle = angle - 180;
// 活体检测器检测
mDetector.doDetection(data, previewsize.width, previewsize.height, angle);
}
/**
* 活体验证成功 (DetectionListener的接口回调方法)
*/
@Override
public DetectionType onDetectionSuccess(final DetectionFrame validFrame) {
mIMediaPlayer.reset();
mCurStep++;
mFaceMask.setFaceInfo(null);
if (mCurStep == mIDetection.mDetectionSteps.size()) {
mProgressBar.setVisibility(View.VISIBLE);
getLivenessData();
} else
changeType(mIDetection.mDetectionSteps.get(mCurStep), 10);
// 检测器返回值:如果不希望检测器检测则返回DetectionType.DONE,如果希望检测器检测动作则返回要检测的动作
return mCurStep >= mIDetection.mDetectionSteps.size() ? DetectionType.DONE
: mIDetection.mDetectionSteps.get(mCurStep);
}
private void getLivenessData() {
new Thread(new Runnable() {
@Override
public void run() {
final FaceIDDataStruct idDataStruct = mDetector.getFaceIDDataStruct();
final String delta = idDataStruct.delta;
final Map<String, byte[]> images = idDataStruct.images;
runOnUiThread(new Runnable() {
@Override
public void run() {
handleResult(com.megvii.idcardlib.R.string.verify_success, delta, images);
}
});
}
}).start();
}
/**
* 活体检测失败 (DetectionListener的接口回调方法)
*/
@Override
public void onDetectionFailed(final DetectionFailedType type) {
//除下述类型外,还存在其它类型错误,但是不建议提示用户,详细可打印type.toString(),参考活体接口文档
int resourceID = com.megvii.idcardlib.R.string.liveness_detection_failed;
switch (type) {
case ACTIONBLEND:
resourceID = com.megvii.idcardlib.R.string.liveness_detection_failed_action_blend;
break;
case NOTVIDEO:
resourceID = com.megvii.idcardlib.R.string.liveness_detection_failed_not_video;
break;
case TIMEOUT:
resourceID = com.megvii.idcardlib.R.string.liveness_detection_failed_timeout;
break;
}
handleResult(resourceID, null, null);
}
/**
* 活体验证中(这个方法会持续不断的回调,返回照片detection信息) (DetectionListener的接口回调方法)
*/
@Override
public void onFrameDetected(long timeout, DetectionFrame detectionFrame) {
// 如果需要适配加速度传感有问题的机型,可以加入超时自动过垂直判断机制,使用判断条件: sensorUtil.isVertical()||sensorUtil.isSensorFault()
if (sensorUtil.isVertical() || sensorUtil.isSensorFault()) {
faceOcclusion(detectionFrame);
handleNotPass(timeout);
mFaceMask.setFaceInfo(detectionFrame);
} else {
if (sensorUtil.Y == 0 && Build.MANUFACTURER.equals("HUAWEI"))
promptText.setText(com.megvii.idcardlib.R.string.meglive_getpermission_motion);
else
promptText.setText(com.megvii.idcardlib.R.string.meglive_phone_vertical);
}
}
/**
* 照镜子环节
* 流程:1,先从返回的DetectionFrame中获取FaceInfo。在FaceInfo中可以先判断这张照片上的人脸是否有被遮挡的状况
* ,入股有直接return
* 2,如果没有遮挡就把SDK返回的DetectionFramed传入人脸质量检测管理类mFaceQualityManager中获取FaceQualityErrorType的list
* 3.通过返回的list来判断这张照片上的人脸是否合格。
* 如果返回list为空或list中FaceQualityErrorType的对象数量为0则表示这张照片合格开始进行活体检测
*/
private void faceOcclusion(DetectionFrame detectionFrame) {
mFailFrame++;
if (detectionFrame != null) {
FaceInfo faceInfo = detectionFrame.getFaceInfo();
if (faceInfo != null) {
if (faceInfo.eyeLeftOcclusion > 0.5 || faceInfo.eyeRightOcclusion > 0.5) {
if (mFailFrame > 10) {
mFailFrame = 0;
promptText.setText(com.megvii.idcardlib.R.string.meglive_keep_eyes_open);
}
return;
}
if (faceInfo.mouthOcclusion > 0.5) {
if (mFailFrame > 10) {
mFailFrame = 0;
promptText.setText(com.megvii.idcardlib.R.string.meglive_keep_mouth_open);
}
return;
}
boolean faceTooLarge = faceInfo.faceTooLarge;
mIDetection.checkFaceTooLarge(faceTooLarge);
}
}
// 从人脸质量检测管理类中获取错误类型list
faceInfoChecker(mFaceQualityManager.feedFrame(detectionFrame));
}
private int mFailFrame = 0;
public void faceInfoChecker(List<FaceQualityErrorType> errorTypeList) {
if (errorTypeList == null || errorTypeList.size() == 0)
handleStart();
else {
String infoStr = "";
FaceQualityErrorType errorType = errorTypeList.get(0);
if (errorType == FaceQualityErrorType.FACE_NOT_FOUND) {
infoStr = getString(com.megvii.idcardlib.R.string.face_not_found);
} else if (errorType == FaceQualityErrorType.FACE_POS_DEVIATED) {
infoStr = getString(com.megvii.idcardlib.R.string.face_not_found);
} else if (errorType == FaceQualityErrorType.FACE_NONINTEGRITY) {
infoStr = getString(com.megvii.idcardlib.R.string.face_not_found);
} else if (errorType == FaceQualityErrorType.FACE_TOO_DARK) {
infoStr = getString(com.megvii.idcardlib.R.string.face_too_dark);
} else if (errorType == FaceQualityErrorType.FACE_TOO_BRIGHT) {
infoStr = getString(com.megvii.idcardlib.R.string.face_too_bright);
} else if (errorType == FaceQualityErrorType.FACE_TOO_SMALL) {
infoStr = getString(com.megvii.idcardlib.R.string.face_too_small);
} else if (errorType == FaceQualityErrorType.FACE_TOO_LARGE) {
infoStr = getString(com.megvii.idcardlib.R.string.face_too_large);
} else if (errorType == FaceQualityErrorType.FACE_TOO_BLURRY) {
infoStr = getString(com.megvii.idcardlib.R.string.face_too_blurry);
} else if (errorType == FaceQualityErrorType.FACE_OUT_OF_RECT) {
infoStr = getString(com.megvii.idcardlib.R.string.face_out_of_rect);
}
if (mFailFrame > 10) {
mFailFrame = 0;
promptText.setText(infoStr);
}
}
}
/**
* 跳转Activity传递信息
*/
public void handleResult(final int resID, String delta, Map<String, byte[]> images) {
String resultString = getResources().getString(resID);
// try {
// jsonObject.put("result", resultString);
// jsonObject.put("resultcode", resID);
// } catch (JSONException e) {
// e.printStackTrace();
// }
// Intent intent = new Intent();
// Bundle bundle = new Bundle();
// bundle.putString("result", jsonObject.toString());
// bundle.putString("delta", delta);
// bundle.putSerializable("images", (Serializable) images);
// intent.putExtras(bundle);
// setResult(RESULT_OK, intent);
// finish();
boolean isSuccess = resultString.equals(
getResources().getString(R.string.verify_success));
if (isSuccess){
ArrayList<File> list = new ArrayList<>();
byte[] image_best = images.get("image_best");
byte[] image_env = images.get("image_env");
byte[] image_action1 = images.get("image_action1");
list.add(ConUtil.saveJPG(mActivity, image_best, "image_best"));
list.add(ConUtil.saveJPG(mActivity, image_env, "image_env"));
list.add(ConUtil.saveJPG(mActivity, image_action1, "image_action1"));
mPresenter.commitePhoto(list,delta);
}
}
private int mCurStep = 0;// 检测动作的次数
public void changeType(final DetectionType detectiontype, long timeout) {
// 动画切换
mIDetection.changeType(detectiontype, timeout);
mFaceMask.setFaceInfo(null);
// 语音播放
if (mCurStep == 0) {
mIMediaPlayer.doPlay(mIMediaPlayer.getSoundRes(detectiontype));
} else {
mIMediaPlayer.doPlay(com.megvii.idcardlib.R.raw.meglive_well_done);
mIMediaPlayer.setOnCompletionListener(detectiontype);
}
}
public void handleNotPass(final long remainTime) {
if (remainTime > 0) {
mainHandler.post(new Runnable() {
@Override
public void run() {
timeOutText.setText(remainTime / 1000 + "");
mCircleProgressBar.setProgress((int) (remainTime / 100));
}
});
}
}
private boolean mHasSurface = false;
/**
* TextureView启动成功后 启动相机预览和添加活体检测回调
* (TextureView.SurfaceTextureListener的接口回调方法)
*/
@Override
public void onSurfaceTextureAvailable(SurfaceTexture surface, int width, int height) {
mHasSurface = true;
doPreview();
// 添加活体检测回调 (本Activity继承了DetectionListener)
mDetector.setDetectionListener(this);
// 添加相机预览回调(本Activity继承了PreviewCallback)
mICamera.actionDetect(this);
}
@Override
public void onSurfaceTextureSizeChanged(SurfaceTexture surface, int width, int height) {
}
/**
* TextureView销毁后 (TextureView.SurfaceTextureListener的接口回调方法)
*/
@Override
public boolean onSurfaceTextureDestroyed(SurfaceTexture surface) {
mHasSurface = false;
return false;
}
@Override
public void onSurfaceTextureUpdated(SurfaceTexture surface) {
}
private void doPreview() {
if (!mHasSurface)
return;
mICamera.startPreview(camerapreview.getSurfaceTexture());
}
@Override
public void onPause() {
super.onPause();
mainHandler.removeCallbacksAndMessages(null);
mICamera.closeCamera();
mIMediaPlayer.close();
finish();
}
@Override
protected void onDestroy() {
super.onDestroy();
if (mDetector != null)
mDetector.release();
mDialogUtil.onDestory();
mIDetection.onDestroy();
sensorUtil.release();
if (mHandlerThread != null) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
mHandlerThread.quitSafely();
} else {
mHandlerThread.quit();
}
}
}
}
\ No newline at end of file
......@@ -2,6 +2,8 @@ package com.dayu.order.ui.activity;
import android.content.Intent;
import android.os.Environment;
import android.text.Editable;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
......@@ -14,6 +16,7 @@ import com.bigkoo.pickerview.listener.OnOptionsSelectListener;
import com.bigkoo.pickerview.view.OptionsPickerView;
import com.dayu.base.ui.activity.BaseActivity;
import com.dayu.common.Constants;
import com.dayu.common.MyTextWatcher;
import com.dayu.order.R;
import com.dayu.order.databinding.ActivityProcessOrderBinding;
import com.dayu.order.presenter.processorder.ProcessOrderContract;
......@@ -32,6 +35,7 @@ import com.luck.picture.lib.entity.LocalMedia;
import com.umeng.analytics.MobclickAgent;
import java.io.File;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.List;
......@@ -80,6 +84,46 @@ public class ProcessOrderActivity extends BaseActivity<ProcessOrderPresenter, Ac
mBind.ivDelete.setVisibility(View.GONE);
mSnImages.clear();
});
initTotal();
}
private void initTotal() {
mBind.etDoorPrice.addTextChangedListener(new MyTextWatcher() {
@Override
public void afterTextChanged(Editable s) {
mBind.tvTotalMoney.setText(getSum());
}
});
mBind.etServePrice.addTextChangedListener(new MyTextWatcher() {
@Override
public void afterTextChanged(Editable s) {
mBind.tvTotalMoney.setText(getSum());
}
});
mBind.etMaterialsPrice.addTextChangedListener(new MyTextWatcher() {
@Override
public void afterTextChanged(Editable s) {
mBind.tvTotalMoney.setText(getSum());
}
});
mBind.etOtherPrice.addTextChangedListener(new MyTextWatcher() {
@Override
public void afterTextChanged(Editable s) {
mBind.tvTotalMoney.setText(getSum());
}
});
}
public String getSum() {
return new DecimalFormat("0.00").format(parseDb(mBind.etDoorPrice.getText().toString()) + parseDb(mBind.etServePrice.getText().toString()) + parseDb(mBind.etMaterialsPrice.getText().toString()) + parseDb(mBind.etOtherPrice.getText().toString()));
}
public Double parseDb(String str) {
if (TextUtils.isEmpty(str)) {
return 0.0;
} else {
return Double.parseDouble(str);
}
}
@Override
......@@ -206,8 +250,10 @@ public class ProcessOrderActivity extends BaseActivity<ProcessOrderPresenter, Ac
info.setProductModel(mBind.etVersion.getText().toString());
info.setSn(mBind.etSerialNum.getText().toString());
mPresenter.mOrderField.set(info);
}
private void dumpPic(ArrayList<String> list) {
Intent intent = new Intent(this, PreviewActivty.class);
intent.putStringArrayListExtra(Constants.BUNDLE_KEY_ID, list);
......
package com.dayu.order.ui.activity;
import android.os.Bundle;
import com.alibaba.android.arouter.launcher.ARouter;
import com.dayu.base.ui.activity.DataBindingActivity;
import com.dayu.common.Constants;
import com.dayu.order.R;
import com.dayu.order.databinding.QrCodeLayoutBinding;
import com.dayu.provider.event.RefreshServe;
import com.dayu.provider.router.RouterPath;
import org.greenrobot.eventbus.EventBus;
/**
* Created by luofan
......@@ -17,6 +25,15 @@ public class QrCodeActivity extends DataBindingActivity<QrCodeLayoutBinding> {
@Override
public void initView() {
mBind.titleBack.setOnClickListener(v -> finish());
Bundle bundle = getIntent().getBundleExtra(Constants.BUNDLE);
int type = bundle.getInt(Constants.TYPE, 0);
mBind.titleBack.setOnClickListener(v -> {
if (type == 0) {
finish();
} else {
ARouter.getInstance().build(RouterPath.PATH_MAIN).navigation();
EventBus.getDefault().post(new RefreshServe(1));
}
});
}
}
......@@ -24,6 +24,7 @@ import com.dayu.order.ui.activity.SubcribeTimeActivity;
import com.dayu.provider.event.RefreshServe;
import com.dayu.provider.event.RefreshTab;
import com.dayu.utils.ProgressUtil;
import com.dayu.utils.SPUtils;
import com.dayu.utils.UIUtils;
import com.dayu.utils.UtilsDate;
import com.umeng.analytics.MobclickAgent;
......@@ -269,7 +270,7 @@ public class OrderAdapter extends CoreAdapter<Order, FragmentOrderdoingItemBindi
mItem = it;
mBind = h;
if ((mItem.getCreatedSource() == 2 || mItem.getCreatedSource() == 3 || mItem.getCreatedSource() == 4) && mItem.getStatus() == 4) {
dumpServerActivity(mItem, posiiton);
dumpServerActivity(mItem);
} else if (mItem.getStatus() == 4 && mItem.getSubStatus() == 3) {
dumpProcessActivity(mItem, posiiton);
} else if (mItem.getStatus() == 4 && mItem.getSubStatus() == 4) {
......@@ -354,9 +355,13 @@ public class OrderAdapter extends CoreAdapter<Order, FragmentOrderdoingItemBindi
MobclickAgent.onEvent(mContext, "process_order");
}
private void dumpServerActivity(Order order, int adapterPosition) {
private void dumpServerActivity(Order order) {
Intent intent;
Bundle bundle = new Bundle();
boolean flag = (boolean) SPUtils.get(Constants.ORDER_ID + order.getId(), false);
if (!flag && order.getFaceSwitch() != null && order.getFaceSwitch() == 1) {
mPresenter.dumpToFaceCert(order);
} else {
if (order.getSpus().size() > 1) {
intent = new Intent(mContext, ServerInfoActivity.class);
bundle.putInt(Constants.ID, order.getId());
......@@ -372,6 +377,7 @@ public class OrderAdapter extends CoreAdapter<Order, FragmentOrderdoingItemBindi
intent.putExtra(Constants.BUNDLE, bundle);
mContext.startActivity(intent);
}
}
private void dumpSOPActivity(int id, int adapterPosition) {
Intent intent = new Intent(mContext, SopWebViewActivity.class);
......
......@@ -74,5 +74,8 @@
<activity
android:name=".ui.activity.SignatureActivity"
android:screenOrientation="landscape" />
<activity
android:name=".ui.activity.OrderLivenessActivity"
android:screenOrientation="portrait" />
</application>
</manifest>
......@@ -676,6 +676,7 @@
android:textSize="@dimen/sp_13.3" />
<TextView
android:id="@+id/test"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
......@@ -691,42 +692,24 @@
style="@style/line"
android:layout_below="@id/up_other" />
<EditText
android:id="@+id/et_door_info"
android:layout_width="match_parent"
android:layout_height="@dimen/dp_163"
android:layout_below="@id/up_other"
android:layout_centerHorizontal="true"
android:layout_marginLeft="@dimen/dp_13.3"
android:layout_marginRight="@dimen/dp_13.3"
android:layout_marginTop="@dimen/dp_17"
android:background="@drawable/subscribe_time_shape"
android:gravity="top"
android:hint="@string/tv_order_other"
android:paddingTop="@dimen/dp_11"
android:text="@{presenter.mOrderField.otherInfo}"
android:textColor="@color/cl_home_title_text_color"
android:textColorHint="@color/cl_selector_hui"
android:textSize="@dimen/sp_13.3" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/ll_all_money"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/rl_pay"
android:layout_below="@+id/image_two_four_lin"
android:layout_marginLeft="@dimen/dp_13.3"
android:layout_marginRight="@dimen/dp_13.3"
android:layout_marginTop="15.7dp"
android:orientation="horizontal"
android:visibility="gone">
android:layout_marginBottom="15dp"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentLeft="true"
android:text="总金额"
android:textStyle="bold" />
android:textColor="@color/cl_tab_line"
android:textSize="@dimen/sp_13.3" />
<TextView
android:id="@+id/tv_total_money"
......@@ -734,14 +717,40 @@
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_gravity="center"
android:textStyle="bold" />
android:textColor="@color/cl_home_title_text_color"
android:textSize="@dimen/sp_13.3" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:text="元"
android:textStyle="bold" />
android:layout_alignParentRight="true"
android:text="@string/tv_order_yuan"
android:textColor="@color/cl_tab_line"
android:textSize="@dimen/sp_13.3" />
</RelativeLayout>
<ImageView
android:id="@+id/iv_line_total"
style="@style/line"
android:layout_below="@id/ll_all_money" />
<EditText
android:id="@+id/et_door_info"
android:layout_width="match_parent"
android:layout_height="@dimen/dp_163"
android:layout_below="@id/iv_line_total"
android:layout_centerHorizontal="true"
android:layout_marginLeft="@dimen/dp_13.3"
android:layout_marginRight="@dimen/dp_13.3"
android:layout_marginTop="@dimen/dp_17"
android:background="@drawable/subscribe_time_shape"
android:gravity="top"
android:hint="@string/tv_order_other"
android:paddingTop="@dimen/dp_11"
android:text="@{presenter.mOrderField.otherInfo}"
android:textColor="@color/cl_home_title_text_color"
android:textColorHint="@color/cl_selector_hui"
android:textSize="@dimen/sp_13.3" />
</RelativeLayout>
<Button
......@@ -749,7 +758,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@id/ll_all_money"
android:layout_below="@id/rl_pay"
android:layout_marginLeft="@dimen/dp_14"
android:layout_marginTop="@dimen/dp_33"
android:background="@drawable/save_back"
......@@ -763,7 +772,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_below="@id/ll_all_money"
android:layout_below="@id/rl_pay"
android:layout_marginRight="@dimen/dp_16"
android:layout_marginTop="@dimen/dp_33"
android:background="@drawable/save_submit"
......
......@@ -126,15 +126,6 @@
android:orientation="horizontal" />
</LinearLayout>
<TextView
android:layout_width="match_parent"
android:layout_height="43dp"
android:paddingLeft="@dimen/dp_15"
android:paddingTop="@dimen/dp_17"
android:text="收取费用"
android:textColor="@color/tv_cl"
android:textSize="14sp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="51dp"
......@@ -250,6 +241,19 @@
android:text="@string/tv_order_yuan"
android:textColor="@color/cl_tab_line"
android:textSize="@dimen/sp_13.3" />
<TextView
android:layout_width="match_parent"
android:layout_height="43dp"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginBottom="104dp"
android:paddingLeft="@dimen/dp_15"
android:paddingTop="@dimen/dp_17"
android:text="收取费用"
android:textColor="@color/tv_cl"
android:textSize="14sp" />
</RelativeLayout>
<ImageView
......@@ -345,11 +349,53 @@
style="@style/line"
android:layout_below="@id/up_other" />
<RelativeLayout
android:id="@+id/ll_all_money"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/image_two_four_lin"
android:layout_marginBottom="15dp"
android:layout_marginLeft="@dimen/dp_13.3"
android:layout_marginRight="@dimen/dp_13.3"
android:layout_marginTop="15.7dp"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:text="总金额"
android:textColor="@color/cl_tab_line"
android:textSize="@dimen/sp_13.3" />
<TextView
android:id="@+id/tv_total_money"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_gravity="center"
android:textColor="@color/cl_home_title_text_color"
android:textSize="@dimen/sp_13.3" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:text="@string/tv_order_yuan"
android:textColor="@color/cl_tab_line"
android:textSize="@dimen/sp_13.3" />
</RelativeLayout>
<ImageView
android:id="@+id/iv_line_total"
style="@style/line"
android:layout_below="@id/ll_all_money" />
<EditText
android:id="@+id/et_door_info"
android:layout_width="match_parent"
android:layout_height="@dimen/dp_163"
android:layout_below="@id/up_other"
android:layout_below="@id/iv_line_total"
android:layout_centerHorizontal="true"
android:layout_marginLeft="@dimen/dp_13.3"
android:layout_marginRight="@dimen/dp_13.3"
......
......@@ -25,13 +25,13 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:gravity="center_horizontal"
android:orientation="vertical">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="100dp"
android:src="@drawable/icon_appointment_code" />
<TextView
......@@ -42,6 +42,14 @@
android:text="@string/scan_code_for_appointment"
android:textSize="14sp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="@dimen/dp_15"
android:text="@string/scan_code_for_appointment_two"
android:textSize="14sp" />
</LinearLayout>
</LinearLayout>
</layout>
\ No newline at end of file
......@@ -20,4 +20,8 @@ public class RouterPath {
public final static String PATH_ORDER_HISTORY = "/order/history";
/**
* 用户模块.
*/
public final static String PATH_USER_FACE = "/user/face";
}
......@@ -62,5 +62,4 @@ dependencies {
annotationProcessor "com.alibaba:arouter-compiler:$arouter_compiler_version"
compile project(':provider')
compile project(':IDCardLib')
// compile project(':livenesslib')
}
......@@ -60,5 +60,7 @@ public interface LoginContract {
*/
public abstract void dumpAndSave(UserInfo info);
public abstract void getUserInfo(int accountId);
}
}
......@@ -9,9 +9,11 @@ import com.dayu.event.UserInfo;
import com.dayu.provider.router.RouterPath;
import com.dayu.usercenter.R;
import com.dayu.usercenter.api.UserApiFactory;
import com.dayu.usercenter.data.protocol.EngineerInfo;
import com.dayu.usercenter.ui.activity.AgreementActivity;
import com.dayu.usercenter.ui.activity.IdentityCertificationActivity;
import com.dayu.utils.LogUtils;
import com.dayu.utils.SPUtils;
import com.dayu.utils.ToastUtils;
import com.dayu.utils.UIUtils;
import com.dayu.utils.UserManager;
......@@ -20,6 +22,8 @@ import com.hyphenate.EMCallBack;
import com.hyphenate.chat.EMClient;
import com.umeng.analytics.MobclickAgent;
import io.reactivex.functions.Consumer;
/**
* Created by luofan
* on 2017/11/8.
......@@ -72,6 +76,7 @@ public class LoginPresenter extends LoginContract.Presenter {
UserApiFactory.login(userName.get(), password.get()).subscribe(baseObserver(userInfo -> {
if (userInfo.getDetectStatus() == 1) {
loginHx(userInfo.getHxAccount(), userInfo.getHxPwd());
getUserInfo(Integer.parseInt(userInfo.getAccountId()));
dumpAndSave(userInfo);
}
// else if (userInfo.getDetectStatus() == 2) {
......@@ -125,6 +130,16 @@ public class LoginPresenter extends LoginContract.Presenter {
}
@Override
public void getUserInfo(int accountId) {
UserApiFactory.getEngineerInfo(accountId).subscribe(baseObserver(new Consumer<EngineerInfo>() {
@Override
public void accept(EngineerInfo engineerInfo) throws Exception {
SPUtils.put("USER_IDENTITY", engineerInfo.getIdentity());
}
}));
}
@Override
public void dumpAgreement() {
mView.startActivity(AgreementActivity.class);
MobclickAgent.onEvent(BaseApplication.getContext(), "customer_agreement");
......
......@@ -7,8 +7,10 @@ import android.os.Bundle;
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.dayu.base.ui.activity.BaseActivity;
import com.dayu.common.Constants;
import com.dayu.provider.router.RouterPath;
import com.dayu.usercenter.R;
import com.dayu.usercenter.common.UserConstant;
import com.dayu.usercenter.databinding.ActivityFaceCertificationBinding;
......@@ -33,7 +35,7 @@ import static android.os.Build.VERSION_CODES.M;
* Created by luofan
* on 2018/5/10.
*/
@Route(path = RouterPath.PATH_USER_FACE)
public class FaceCertificationActivity extends BaseActivity<FaceCertificaitonPresenter, ActivityFaceCertificationBinding>
implements FaceCertificaitonContract.View {
private String uuid;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment