[FIX] 修復返回首頁時廣告播放器 NPE 導致廣告消失
1. HomeActivity.startOnSwitchFragment() 的 500ms 延遲重播工作,於執行時補上 videoEoxPlayer == null 判斷。 2. 修正閒置 5 分鐘自動返回首頁時,stopOnSwitchFragment() 在延遲內先清空 static 播放器,使延遲工作呼叫 playMediaByFlag 踩到 null 而拋出 NPE、廣告區從此空白不再恢復的競態問題。 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
84c7ac8933
commit
258aa2f87b
@ -284,7 +284,7 @@ public class HomeActivity extends AppCompatActivityAbstract {
|
||||
videoEoxPlayer = new VideoEoxPlayer(getCtx());
|
||||
|
||||
getHandlerMain().getHandler().postDelayed(() -> {
|
||||
if (isFinishing() || isDestroyed()) return;
|
||||
if (isFinishing() || isDestroyed() || videoEoxPlayer == null) return; // ✅ 防止延遲執行時播放器已被 stopOnSwitchFragment() 清空導致 NPE
|
||||
try {
|
||||
// videoEoxPlayer.playMedia(binding.videoView, binding.imageAd); // ✅ 同時支援影片與圖片輪播
|
||||
videoEoxPlayer.playMediaByFlag("3", binding.videoView, binding.imageAd); // ✅ 同時支援影片與圖片輪播
|
||||
|
||||
Loading…
Reference in New Issue
Block a user