From 0f08a06d6d4167f3d034bff685ee3da296760baa Mon Sep 17 00:00:00 2001 From: xianming wang Date: Fri, 7 Dec 2018 16:21:50 +0800 Subject: SnapdragonCamera: Fix mSoundPool is NULL and load resource slowly Init the SouldPool when the mCountDownView is not NULL and the SoundPool is NULL. CRs-Fixed: 2360653 Change-Id: I913bbd0c8b190a2a73d0d0123ffa8753d4ec9f91 --- src/com/android/camera/CaptureUI.java | 6 +++++- src/com/android/camera/ui/CountDownView.java | 22 +++++++--------------- 2 files changed, 12 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/com/android/camera/CaptureUI.java b/src/com/android/camera/CaptureUI.java index 85ac9e293..c5875327d 100755 --- a/src/com/android/camera/CaptureUI.java +++ b/src/com/android/camera/CaptureUI.java @@ -1551,7 +1551,11 @@ public class CaptureUI implements FocusOverlayManager.FocusUI, } public void initCountDownView() { - if (mCountDownView == null) initializeCountDown(); + if (mCountDownView == null) { + initializeCountDown(); + } else { + mCountDownView.initSoundPool(); + } } public void releaseSoundPool() { diff --git a/src/com/android/camera/ui/CountDownView.java b/src/com/android/camera/ui/CountDownView.java index f62c99958..0e1acc080 100755 --- a/src/com/android/camera/ui/CountDownView.java +++ b/src/com/android/camera/ui/CountDownView.java @@ -55,15 +55,19 @@ public class CountDownView extends FrameLayout { mContext = context; mCountDownAnim = AnimationUtils.loadAnimation(context, R.anim.count_down_exit); + initSoundPool(); + } + + public void initSoundPool() { if (mSoundPool == null) { // Load the beeps - if (context.getResources().getBoolean(R.bool.force_count_down_sound)) { + if (mContext.getResources().getBoolean(R.bool.force_count_down_sound)) { mSoundPool = new SoundPool(1, AudioManager.STREAM_SYSTEM_ENFORCED, 0); } else { mSoundPool = new SoundPool(1, AudioManager.STREAM_NOTIFICATION, 0); } - mBeepOnce = mSoundPool.load(context, R.raw.beep_once, 1); - mBeepTwice = mSoundPool.load(context, R.raw.beep_twice, 1); + mBeepOnce = mSoundPool.load(mContext, R.raw.beep_once, 1); + mBeepTwice = mSoundPool.load(mContext, R.raw.beep_twice, 1); } } @@ -98,18 +102,6 @@ public class CountDownView extends FrameLayout { mCountDownAnim.reset(); mRemainingSecondsView.clearAnimation(); mRemainingSecondsView.startAnimation(mCountDownAnim); - - if (mSoundPool == null) { - // Load the beeps - if (mContext.getResources().getBoolean(R.bool.force_count_down_sound)) { - mSoundPool = new SoundPool(1, AudioManager.STREAM_SYSTEM_ENFORCED, 0); - } else { - mSoundPool = new SoundPool(1, AudioManager.STREAM_NOTIFICATION, 0); - } - mBeepOnce = mSoundPool.load(mContext, R.raw.beep_once, 1); - mBeepTwice = mSoundPool.load(mContext, R.raw.beep_twice, 1); - } - // Play sound effect for the last 3 seconds of the countdown if (mPlaySound && mSoundPool != null) { if (newVal == 1) { -- cgit v1.2.3