From ad35e3b39d897946be9e239c7de394a4b35f4e36 Mon Sep 17 00:00:00 2001 From: Sanjeev Garg Date: Wed, 4 Nov 2015 21:02:59 +0530 Subject: SnapdragonCamera: Handle cam switch icon if numOfCams less than 2 While generalizing SnapdragonCamera app for any number of cameras we have to handle a special case if number of camera's are less than 2. If there is only 1 camera in the app then there is no camera switch option and hence the corresponding switch icon object is null Change-Id: I672708bb98a30054adaf916bb272b50cdd8d0091 --- src/com/android/camera/PhotoModule.java | 12 ++++++++---- src/com/android/camera/VideoModule.java | 12 ++++++++---- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/com/android/camera/PhotoModule.java b/src/com/android/camera/PhotoModule.java index 03235cc90..f709174e2 100644 --- a/src/com/android/camera/PhotoModule.java +++ b/src/com/android/camera/PhotoModule.java @@ -1866,6 +1866,14 @@ public class PhotoModule Log.e(TAG,"loadCameraPreferences() updating camera_id pref"); + IconListPreference switchIconPref = + (IconListPreference)mPreferenceGroup.findPreference( + CameraSettings.KEY_CAMERA_ID); + + //if numOfCams < 2 then switchIconPref will be null as there is no switch icon in this case + if (switchIconPref == null) + return; + int[] iconIds = new int[numOfCams]; String[] entries = new String[numOfCams]; String[] labels = new String[numOfCams]; @@ -1886,10 +1894,6 @@ public class PhotoModule } } - IconListPreference switchIconPref = - (IconListPreference)mPreferenceGroup.findPreference( - CameraSettings.KEY_CAMERA_ID); - switchIconPref.setIconIds(iconIds); switchIconPref.setEntries(entries); switchIconPref.setLabels(labels); diff --git a/src/com/android/camera/VideoModule.java b/src/com/android/camera/VideoModule.java index 8cb372f5e..04aa1fb8f 100644 --- a/src/com/android/camera/VideoModule.java +++ b/src/com/android/camera/VideoModule.java @@ -534,6 +534,14 @@ public class VideoModule implements CameraModule, Log.e(TAG,"loadCameraPreferences() updating camera_id pref"); + IconListPreference switchIconPref = + (IconListPreference)mPreferenceGroup.findPreference( + CameraSettings.KEY_CAMERA_ID); + + //if numOfCams < 2 then switchIconPref will be null as there is no switch icon in this case + if (switchIconPref == null) + return; + int[] iconIds = new int[numOfCams]; String[] entries = new String[numOfCams]; String[] labels = new String[numOfCams]; @@ -554,10 +562,6 @@ public class VideoModule implements CameraModule, } } - IconListPreference switchIconPref = - (IconListPreference)mPreferenceGroup.findPreference( - CameraSettings.KEY_CAMERA_ID); - switchIconPref.setIconIds(iconIds); switchIconPref.setEntries(entries); switchIconPref.setLabels(labels); -- cgit v1.2.3