summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAngus Kong <shkong@google.com>2014-03-06 14:27:23 -0800
committerAngus Kong <shkong@google.com>2014-03-06 14:31:48 -0800
commit8a86a8384010aeaa252c21607d8dd2d2afee7bca (patch)
treefd2d4e85b6b63187712b77a331efc94013698b72 /src
parent2bacca795a1b0adb0daf515c43c48234b44bbba5 (diff)
downloadandroid_packages_apps_Camera2-8a86a8384010aeaa252c21607d8dd2d2afee7bca.tar.gz
android_packages_apps_Camera2-8a86a8384010aeaa252c21607d8dd2d2afee7bca.tar.bz2
android_packages_apps_Camera2-8a86a8384010aeaa252c21607d8dd2d2afee7bca.zip
Add null check for listeners in BottomBar.
bug:13210080 Change-Id: Idd94318cbaed0bbb386ffc14fbdd58bf25adefc3
Diffstat (limited to 'src')
-rw-r--r--src/com/android/camera/ui/BottomBar.java47
1 files changed, 29 insertions, 18 deletions
diff --git a/src/com/android/camera/ui/BottomBar.java b/src/com/android/camera/ui/BottomBar.java
index 4411c2b9b..77f1cf6c8 100644
--- a/src/com/android/camera/ui/BottomBar.java
+++ b/src/com/android/camera/ui/BottomBar.java
@@ -115,6 +115,7 @@ public class BottomBar extends FrameLayout
public void setAdjustPreviewAreaListener(AdjustPreviewAreaListener listener) {
mAdjustPreviewAreaListener = listener;
+ notifyAreaAdjust();
}
public BottomBar(Context context, AttributeSet attrs) {
@@ -310,27 +311,11 @@ public class BottomBar extends FrameLayout
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
super.onLayout(changed, left, top, right, bottom);
+ notifyAreaAdjust();
+
final int width = getWidth();
final int height = getHeight();
- if (width > height) {
- // Portrait
- if (!mOverLayBottomBar) {
- mAlignArea.set(getLeft(), 0, getRight(), getTop());
- } else {
- mAlignArea.set(getLeft(), 0, getRight(), getBottom());
- }
- mAdjustPreviewAreaListener.alignBottomInRect(mAlignArea);
- } else {
- // Landscape
- if (!mOverLayBottomBar) {
- mAlignArea.set(0, getTop(), getLeft(), getBottom());
- } else {
- mAlignArea.set(0, getTop(), getRight(), getBottom());
- }
- mAdjustPreviewAreaListener.alignRightInRect(mAlignArea);
- }
-
if (changed) {
mCirclePath.reset();
mCirclePath.addCircle(
@@ -516,4 +501,30 @@ public class BottomBar extends FrameLayout
transitionDrawable.startTransition(CIRCLE_ANIM_DURATION_MS);
radiusAnimator.start();
}
+
+ private void notifyAreaAdjust() {
+ final int width = getWidth();
+ final int height = getHeight();
+
+ if (width == 0 || height == 0 || mAdjustPreviewAreaListener == null) {
+ return;
+ }
+ if (width > height) {
+ // Portrait
+ if (!mOverLayBottomBar) {
+ mAlignArea.set(getLeft(), 0, getRight(), getTop());
+ } else {
+ mAlignArea.set(getLeft(), 0, getRight(), getBottom());
+ }
+ mAdjustPreviewAreaListener.alignBottomInRect(mAlignArea);
+ } else {
+ // Landscape
+ if (!mOverLayBottomBar) {
+ mAlignArea.set(0, getTop(), getLeft(), getBottom());
+ } else {
+ mAlignArea.set(0, getTop(), getRight(), getBottom());
+ }
+ mAdjustPreviewAreaListener.alignRightInRect(mAlignArea);
+ }
+ }
}