[FIX] 優化貨道上傳流程與隱藏出貨完成後的取貨確認按鈕

1. 於 DispatchDialog.java 中隱藏出貨流程最後的「取貨確認」按鈕,改為僅以 15 秒倒數後自動關閉對話框,防範使用者干預流程。
2. 於 VmcSlotListActivity.java 調整貨道同步邏輯,在上傳成功後自動返回前一頁。
3. 於 VmcSlotListActivity.java 實作上傳失敗時的彈出對話框,提供「重新嘗試」與「直接返回」選項,防止因返回鍵隱藏而造成介面卡死。
4. 調整 activity_vmc_slot_list.xml 佈局,隱藏「返回」按鈕,並將儲存按鈕文字調整為「上傳後台並返回」。
5. 修改 MqttManager.java,將心跳包定時器初始化延遲設定為 10 秒,避免開機初始化期間發生資源競合。
This commit is contained in:
sky121113 2026-05-18 13:15:30 +08:00
parent d68482a005
commit ab8b828aa2
5 changed files with 36 additions and 5 deletions

View File

@ -144,7 +144,7 @@ public class MqttManager {
} catch (Exception e) {
logs.info("Error in heartbeat scheduler: " + e.getMessage());
}
}, 0, 60, TimeUnit.SECONDS);
}, 10, 60, TimeUnit.SECONDS);
}
/**

View File

@ -57,6 +57,35 @@ public class VmcSlotListActivity extends AppCompatActivityAbstract {
binding.buttonSave.setEnabled(true);
}
super.execute(context, commandCode, message);
// 上傳完成同步成功後自動返回前一頁
if (commandCode == 200) {
finish();
} else {
// 同步失敗彈出確認對話框提供重試直接返回的後路防止因返回鍵隱藏而卡死
if (context instanceof android.app.Activity) {
android.app.Activity activity = (android.app.Activity) context;
if (!activity.isFinishing() && !activity.isDestroyed()) {
new android.app.AlertDialog.Builder(context)
.setTitle("同步失敗")
.setMessage("上傳貨道資料至後台失敗,請檢查網路連線。\n您要重新嘗試同步或是直接返回上一頁")
.setCancelable(false) // 避免誤觸外部關閉對話框
.setPositiveButton("重新嘗試", (dialog, which) -> {
// 重新顯示進度條並鎖定按鈕再次執行同步
if (binding != null && binding.progressLayout != null) {
binding.progressLayout.setVisibility(View.VISIBLE);
binding.buttonBack.setEnabled(false);
binding.buttonSave.setEnabled(false);
}
updateSlotListNum();
})
.setNegativeButton("直接返回", (dialog, which) -> {
// 直接關閉頁面返回
finish();
})
.show();
}
}
}
}
};
}

View File

@ -847,9 +847,9 @@ public class DispatchDialog extends DialogAbstract {
// 隱藏底部倒數文字
binding.tvCountdown.setVisibility(View.GONE);
// 顯示取貨確認按鈕讓使用者可以提前確認取貨
binding.buttonOk.setVisibility(View.VISIBLE);
binding.buttonOk.setEnabled(true);
// 顯示取貨確認按鈕讓使用者可以提前確認取貨 -> 依需求隱藏該按鈕
binding.buttonOk.setVisibility(View.GONE);
binding.buttonOk.setEnabled(false);
binding.buttonOk.setTextColor(Color.BLACK);
setButtonOkText(0); // 顯示取貨確認不帶倒數

View File

@ -64,6 +64,7 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:visibility="gone"
android:backgroundTint="@color/black"
android:text="返回"
android:textSize="28dp"/>
@ -74,7 +75,7 @@
android:layout_height="wrap_content"
android:layout_weight="1"
android:backgroundTint="@color/black"
android:text="@string/upload_to_backend"
android:text="@string/upload_to_backend_and_return"
android:textSize="28dp" />
<Button

View File

@ -311,4 +311,5 @@
<string name="uploading_data">資料上傳中...</string>
<string name="upload_success">資料上傳成功</string>
<string name="upload_failed">資料上傳失敗</string>
<string name="upload_to_backend_and_return">上傳後台並返回</string>
</resources>