Commit 432aae5f by Wyh

1、退出SN消耗頁面時提示

parent 8e439e3b
......@@ -211,7 +211,7 @@ public class WarehouseDetailsPresenter extends BasePresenter<WarehouseDetailsCon
} else if (baseResult != null && TextUtil.isNotEmptyOrNullOrUndefined(baseResult.getErrMsg())) {
mRootView.showMessage(baseResult.getErrMsg());
} else {
mRootView.showMessage(PurchaseConstant.GET_INFO_ERROR);
mRootView.showMessage(PurchaseConstant.UPDATE_FAIL);
}
}
});
......
package com.gingersoft.supply_chain.mvp.ui.fragment.warehouse;
import android.animation.LayoutTransition;
import android.app.Dialog;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.view.LayoutInflater;
......@@ -27,6 +28,7 @@ import com.gingersoft.gsa.cloud.common.utils.glide.GlideUtils;
import com.gingersoft.gsa.cloud.common.utils.other.TextUtil;
import com.gingersoft.gsa.cloud.common.utils.time.TimeUtils;
import com.gingersoft.gsa.cloud.common.utils.view.LayoutToBitmapUtils;
import com.gingersoft.gsa.cloud.ui.utils.AppDialog;
import com.gingersoft.supply_chain.R;
import com.gingersoft.supply_chain.R2;
import com.gingersoft.supply_chain.di.component.DaggerWarehouseDetailsComponent;
......@@ -531,4 +533,28 @@ public class WarehouseDetailsFragment extends BaseSupplyChainFragment<WarehouseD
}
}
/**
* 因為關閉頁面也是調用的onBackPressedSupport,所以用戶選擇了關閉頁面,那麼就用修改這個值
*/
boolean isLeave = false;
@Override
public boolean onBackPressedSupport() {
if (isLeave) {
return super.onBackPressedSupport();
}
if (inventoryConsumptionView != null) {
if (scanSnView != null && scanSnView.getSnSize() > 0) {
//當前顯示著掃SN碼消耗,判斷有沒有SN碼,有的話提示是否保存
AppDialog.getInstance().showTipDialog(requireContext(), getString(R.string.str_info_not_save_about_to_leave), (view, dialog) -> {
isLeave = true;
showList(View.VISIBLE);
}, (view, dialog) -> isLeave = false);
} else {
showList(View.VISIBLE);
}
return true;
}
return super.onBackPressedSupport();
}
}
......@@ -149,36 +149,7 @@ public class ScanSnView extends FrameLayout {
if (showScan) {
btnScanSn.setVisibility(VISIBLE);
//掃描sn媽
btnScanSn.setOnClickListener(v ->
{
if (fragment == null) {
ToastUtils.show(getContext(), "掃碼功能無法啟用,請聯繫開發人員");
return;
}
XPermissionUtils.launchCamera(fragment, (allGranted, grantedList, deniedList) -> {
if (allGranted) {
//去掃碼頁面
CC.obtainBuilder(ComponentName.COMPONENT_SCAN)
.setActionName("openScanActivity")
.addParam("scanMode", BarcodeType.ONE_DIMENSION)
.build()
.callAsyncCallbackOnMainThread((cc, result) -> {
Object qrCodeResult = result.getDataItem("qrCodeResult");
if (qrCodeResult != null) {
String snCode = String.valueOf(qrCodeResult);
for (PurchaseFoodEncodeSn purchaseFoodEncodeSn : adapter.getData()) {
if (purchaseFoodEncodeSn.getEncodeSnNo().equals(snCode)) {
ToastUtils.show(getContext(), "商品已存在,不能重複添加");
return;
}
}
addSnCode(adapter, snCode);
}
});
}
});
}
);
btnScanSn.setOnClickListener(v -> scanSn());
} else {
btnScanSn.setVisibility(GONE);
tvScanSn.setText(R.string.str_enter_sn);
......@@ -242,6 +213,35 @@ public class ScanSnView extends FrameLayout {
return this;
}
private void scanSn() {
if (fragment == null) {
ToastUtils.show(getContext(), "掃碼功能無法啟用,請聯繫開發人員");
return;
}
XPermissionUtils.launchCamera(fragment, (allGranted, grantedList, deniedList) -> {
if (allGranted) {
//去掃碼頁面
CC.obtainBuilder(ComponentName.COMPONENT_SCAN)
.setActionName("openScanActivity")
.addParam("scanMode", BarcodeType.ONE_DIMENSION)
.build()
.callAsyncCallbackOnMainThread((cc, result) -> {
Object qrCodeResult = result.getDataItem("qrCodeResult");
if (qrCodeResult != null) {
String snCode = String.valueOf(qrCodeResult);
for (PurchaseFoodEncodeSn purchaseFoodEncodeSn : adapter.getData()) {
if (purchaseFoodEncodeSn.getEncodeSnNo().equals(snCode)) {
ToastUtils.show(getContext(), "商品已存在,不能重複添加");
return;
}
}
addSnCode(adapter, snCode);
}
});
}
});
}
public void setConfirmBtnState() {
if (minCodeSize == -1 || newCodeSize == minCodeSize) {
btnFoodIngredientsConfirm.setBackground(ContextCompat.getDrawable(getContext(), R.drawable.shape_app_btn));
......@@ -341,6 +341,14 @@ public class ScanSnView extends FrameLayout {
void onCancel();
}
public int getSnSize() {
if (adapter != null) {
return adapter.getItemCount();
} else {
return 0;
}
}
public static class SnCodeAdapter extends BaseQuickAdapter<PurchaseFoodEncodeSn, BaseViewHolder> {
public SnCodeAdapter(int layoutResId, @org.jetbrains.annotations.Nullable List<PurchaseFoodEncodeSn> data) {
......
......@@ -4,6 +4,7 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:animateLayoutChanges="true"
android:background="@color/supply_chain_bg_color"
android:orientation="vertical">
......
......@@ -99,7 +99,7 @@
android:layout_height="wrap_content"
android:text="入庫日期:"
android:textColor="@color/color_3c"
android:textSize="@dimen/sp_16" />
android:textSize="@dimen/sp_16"/>
<TextView
android:id="@+id/tv_warehouse_details_time"
......@@ -111,10 +111,19 @@
tools:text="2020-11-20" />
<TextView
android:id="@+id/tv_warehouse_details_remarks"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/color_3c"
android:textSize="@dimen/sp_14"
android:visibility="gone"
tools:text="備註:是打飛機死垃圾分類三代機福利社利社的" />
<TextView
android:id="@+id/tv_warehouse_details_reason"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_height="wrap_content"
android:gravity="end"
android:textColor="@color/color_3c"
android:textSize="@dimen/sp_14"
......@@ -129,9 +138,9 @@
<TextView
android:id="@+id/tv_warehouse_state"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:layout_marginRight="@dimen/dp_4"
android:layout_weight="1"
android:paddingLeft="@dimen/dp_10"
android:paddingTop="@dimen/dp_4"
android:paddingRight="@dimen/dp_10"
......
......@@ -242,6 +242,7 @@
<string name="str_serial_number">序號</string>
<string name="str_info_no_save_leave">信息未保存,是否離開?</string>
<string name="str_about_to_leave">即將離開,信息是否保存?</string>
<string name="str_info_not_save_about_to_leave">信息未保存,是否離開?</string>
<string name="str_save_and_leave">保存並離開</string>
<string name="str_leave">離開</string>
......
......@@ -109,6 +109,13 @@ public class AppDialog {
showTipDialog(context, title, context.getString(R.string.str_determine), context.getString(R.string.str_cancel), sureOnclickListenter, null);
}
/**
* 藍色的提示框
*/
public void showTipDialog(Context context, String title, DialogOnClickListenter sureOnclickListenter, DialogOnClickListenter onCancelListener) {
showTipDialog(context, title, context.getString(R.string.str_determine), context.getString(R.string.str_cancel), sureOnclickListenter, onCancelListener);
}
public void showTipDialog(Context context, String title, String sureBtnText, String cancelBtnText, DialogOnClickListenter sureOnclickListener, DialogOnClickListenter onCancelListener) {
new DialogUtils(context, R.layout.dialog_tip) {
@Override
......
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 to comment