[FIX] 修正直接購買(購物車版)未跳購物車品項頁的真因;升版 v89
1. 真因:DialogProductDetail 取 SaleFlowHandler 時用 onCreate 的 getContext(),那是 AlertDialog 包裝過的 ContextThemeWrapper,instanceof FontendActivity 為 false,導致 openCartList 靜默 return(一般版因 requestBuy 有 new BuyDialog 後路才照常開支付頁,故僅購物車版受影響)。 2. 修法:建構子保存原始傳入的 Context(真正的 FontendActivity)為 hostContext,openCartList/requestBuy 改用 hostContext 做 instanceof 與取 SaleFlowHandler。 3. 升版號 verPatch 88 → 89。 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
1c9022cc5e
commit
d7bef7b827
@ -10,7 +10,7 @@ plugins {
|
||||
// 避免不同尺寸機台間版本號產生衝突。
|
||||
// =========================================================================
|
||||
def verMinor = 1
|
||||
def verPatch = 88
|
||||
def verPatch = 89
|
||||
|
||||
|
||||
|
||||
|
||||
@ -28,10 +28,15 @@ public class DialogProductDetail extends DialogAbstract {
|
||||
|
||||
private DialogProductDetailBinding binding;
|
||||
private final SlotStructure slot;
|
||||
// 建構子傳入的原始 Context(真正的 FontendActivity)。
|
||||
// 不可用 onCreate 的 getContext(),那是 AlertDialog 包裝過的 ContextThemeWrapper,
|
||||
// instanceof FontendActivity 會是 false,導致購物車頁/結帳入口取不到 SaleFlowHandler。
|
||||
private final Context hostContext;
|
||||
private int quantity = 1;
|
||||
|
||||
public DialogProductDetail(Context context, HandlerMain srcHandlerMain, SlotStructure slot) {
|
||||
super(context, srcHandlerMain);
|
||||
this.hostContext = context;
|
||||
this.slot = slot;
|
||||
}
|
||||
|
||||
@ -121,14 +126,14 @@ public class DialogProductDetail extends DialogAbstract {
|
||||
addSelectedQuantityToCart();
|
||||
// 先切到購物車品項頁(於詳情頁視窗後方),再關閉詳情頁顯示出來,
|
||||
// 避免「關閉對話框」與「fragment 切換」時序互相干擾導致沒跳頁。
|
||||
openCartList(context);
|
||||
openCartList();
|
||||
cancel();
|
||||
} else {
|
||||
MyApp.getInstance().getBuyList().clear();
|
||||
MyApp.getInstance().getBuyList().add(
|
||||
new BuyStructure(slot.getField(), slot.getSlot(), slot.getProduct(), quantity));
|
||||
cancel();
|
||||
requestBuy(context);
|
||||
requestBuy();
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -141,9 +146,9 @@ public class DialogProductDetail extends DialogAbstract {
|
||||
}
|
||||
|
||||
/** 前往購物車列表頁(沿用各 flavor 的購物車入口)。 */
|
||||
private void openCartList(Context context) {
|
||||
if (context instanceof FontendActivity) {
|
||||
SaleFlowHandler handler = ((FontendActivity) context).getSaleFlowHandler();
|
||||
private void openCartList() {
|
||||
if (hostContext instanceof FontendActivity) {
|
||||
SaleFlowHandler handler = ((FontendActivity) hostContext).getSaleFlowHandler();
|
||||
if (handler != null) {
|
||||
handler.onShoppingCartRequested();
|
||||
}
|
||||
@ -157,14 +162,14 @@ public class DialogProductDetail extends DialogAbstract {
|
||||
}
|
||||
|
||||
/** 沿用各 flavor 的結帳入口(basic→BuyDialog);非 FontendActivity 時直接開 BuyDialog。 */
|
||||
private void requestBuy(Context context) {
|
||||
if (context instanceof FontendActivity) {
|
||||
SaleFlowHandler handler = ((FontendActivity) context).getSaleFlowHandler();
|
||||
private void requestBuy() {
|
||||
if (hostContext instanceof FontendActivity) {
|
||||
SaleFlowHandler handler = ((FontendActivity) hostContext).getSaleFlowHandler();
|
||||
if (handler != null) {
|
||||
handler.onBuyRequested();
|
||||
return;
|
||||
}
|
||||
}
|
||||
new BuyDialog(context, getSrcHandlerMain()).show();
|
||||
new BuyDialog(hostContext, getSrcHandlerMain()).show();
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user