Commit 432aae5f by Wyh

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

parent 8e439e3b
...@@ -211,7 +211,7 @@ public class WarehouseDetailsPresenter extends BasePresenter<WarehouseDetailsCon ...@@ -211,7 +211,7 @@ public class WarehouseDetailsPresenter extends BasePresenter<WarehouseDetailsCon
} else if (baseResult != null && TextUtil.isNotEmptyOrNullOrUndefined(baseResult.getErrMsg())) { } else if (baseResult != null && TextUtil.isNotEmptyOrNullOrUndefined(baseResult.getErrMsg())) {
mRootView.showMessage(baseResult.getErrMsg()); mRootView.showMessage(baseResult.getErrMsg());
} else { } else {
mRootView.showMessage(PurchaseConstant.GET_INFO_ERROR); mRootView.showMessage(PurchaseConstant.UPDATE_FAIL);
} }
} }
}); });
......
package com.gingersoft.supply_chain.mvp.ui.fragment.warehouse; package com.gingersoft.supply_chain.mvp.ui.fragment.warehouse;
import android.animation.LayoutTransition; import android.animation.LayoutTransition;
import android.app.Dialog;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.os.Bundle; import android.os.Bundle;
import android.view.LayoutInflater; import android.view.LayoutInflater;
...@@ -27,6 +28,7 @@ import com.gingersoft.gsa.cloud.common.utils.glide.GlideUtils; ...@@ -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.other.TextUtil;
import com.gingersoft.gsa.cloud.common.utils.time.TimeUtils; import com.gingersoft.gsa.cloud.common.utils.time.TimeUtils;
import com.gingersoft.gsa.cloud.common.utils.view.LayoutToBitmapUtils; 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.R;
import com.gingersoft.supply_chain.R2; import com.gingersoft.supply_chain.R2;
import com.gingersoft.supply_chain.di.component.DaggerWarehouseDetailsComponent; import com.gingersoft.supply_chain.di.component.DaggerWarehouseDetailsComponent;
...@@ -531,4 +533,28 @@ public class WarehouseDetailsFragment extends BaseSupplyChainFragment<WarehouseD ...@@ -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 { ...@@ -149,36 +149,7 @@ public class ScanSnView extends FrameLayout {
if (showScan) { if (showScan) {
btnScanSn.setVisibility(VISIBLE); btnScanSn.setVisibility(VISIBLE);
//掃描sn媽 //掃描sn媽
btnScanSn.setOnClickListener(v -> btnScanSn.setOnClickListener(v -> 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);
}
});
}
});
}
);
} else { } else {
btnScanSn.setVisibility(GONE); btnScanSn.setVisibility(GONE);
tvScanSn.setText(R.string.str_enter_sn); tvScanSn.setText(R.string.str_enter_sn);
...@@ -242,6 +213,35 @@ public class ScanSnView extends FrameLayout { ...@@ -242,6 +213,35 @@ public class ScanSnView extends FrameLayout {
return this; 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() { public void setConfirmBtnState() {
if (minCodeSize == -1 || newCodeSize == minCodeSize) { if (minCodeSize == -1 || newCodeSize == minCodeSize) {
btnFoodIngredientsConfirm.setBackground(ContextCompat.getDrawable(getContext(), R.drawable.shape_app_btn)); btnFoodIngredientsConfirm.setBackground(ContextCompat.getDrawable(getContext(), R.drawable.shape_app_btn));
...@@ -341,6 +341,14 @@ public class ScanSnView extends FrameLayout { ...@@ -341,6 +341,14 @@ public class ScanSnView extends FrameLayout {
void onCancel(); void onCancel();
} }
public int getSnSize() {
if (adapter != null) {
return adapter.getItemCount();
} else {
return 0;
}
}
public static class SnCodeAdapter extends BaseQuickAdapter<PurchaseFoodEncodeSn, BaseViewHolder> { public static class SnCodeAdapter extends BaseQuickAdapter<PurchaseFoodEncodeSn, BaseViewHolder> {
public SnCodeAdapter(int layoutResId, @org.jetbrains.annotations.Nullable List<PurchaseFoodEncodeSn> data) { public SnCodeAdapter(int layoutResId, @org.jetbrains.annotations.Nullable List<PurchaseFoodEncodeSn> data) {
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:animateLayoutChanges="true"
android:background="@color/supply_chain_bg_color" android:background="@color/supply_chain_bg_color"
android:orientation="vertical"> android:orientation="vertical">
......
...@@ -99,7 +99,7 @@ ...@@ -99,7 +99,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="入庫日期:" android:text="入庫日期:"
android:textColor="@color/color_3c" android:textColor="@color/color_3c"
android:textSize="@dimen/sp_16" /> android:textSize="@dimen/sp_16"/>
<TextView <TextView
android:id="@+id/tv_warehouse_details_time" android:id="@+id/tv_warehouse_details_time"
...@@ -111,10 +111,19 @@ ...@@ -111,10 +111,19 @@
tools:text="2020-11-20" /> tools:text="2020-11-20" />
<TextView <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:id="@+id/tv_warehouse_details_reason"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1" android:layout_weight="1"
android:layout_height="wrap_content"
android:gravity="end" android:gravity="end"
android:textColor="@color/color_3c" android:textColor="@color/color_3c"
android:textSize="@dimen/sp_14" android:textSize="@dimen/sp_14"
...@@ -129,9 +138,9 @@ ...@@ -129,9 +138,9 @@
<TextView <TextView
android:id="@+id/tv_warehouse_state" android:id="@+id/tv_warehouse_state"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginRight="@dimen/dp_4" android:layout_marginRight="@dimen/dp_4"
android:layout_weight="1"
android:paddingLeft="@dimen/dp_10" android:paddingLeft="@dimen/dp_10"
android:paddingTop="@dimen/dp_4" android:paddingTop="@dimen/dp_4"
android:paddingRight="@dimen/dp_10" android:paddingRight="@dimen/dp_10"
......
...@@ -242,6 +242,7 @@ ...@@ -242,6 +242,7 @@
<string name="str_serial_number">序號</string> <string name="str_serial_number">序號</string>
<string name="str_info_no_save_leave">信息未保存,是否離開?</string> <string name="str_info_no_save_leave">信息未保存,是否離開?</string>
<string name="str_about_to_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_save_and_leave">保存並離開</string>
<string name="str_leave">離開</string> <string name="str_leave">離開</string>
......
...@@ -109,6 +109,13 @@ public class AppDialog { ...@@ -109,6 +109,13 @@ public class AppDialog {
showTipDialog(context, title, context.getString(R.string.str_determine), context.getString(R.string.str_cancel), sureOnclickListenter, null); 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) { public void showTipDialog(Context context, String title, String sureBtnText, String cancelBtnText, DialogOnClickListenter sureOnclickListener, DialogOnClickListenter onCancelListener) {
new DialogUtils(context, R.layout.dialog_tip) { new DialogUtils(context, R.layout.dialog_tip) {
@Override @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