summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Reck <jreck@google.com>2012-10-23 13:44:58 -0700
committerJohn Reck <jreck@google.com>2012-10-23 15:01:58 -0700
commit03e18995f4a2c71381048b2e264bcac11cd17950 (patch)
tree4b913c60ca56b1f9ef50f97b34a32249dc5e5d83
parent3a6614628f8d33f8ce881d85355cebf2b9523252 (diff)
downloadandroid_packages_apps_Snap-03e18995f4a2c71381048b2e264bcac11cd17950.tar.gz
android_packages_apps_Snap-03e18995f4a2c71381048b2e264bcac11cd17950.tar.bz2
android_packages_apps_Snap-03e18995f4a2c71381048b2e264bcac11cd17950.zip
Fix NPE
Bug: 7399438 Change-Id: Ida0bcc0689d5a797e3c60c3ee51542512fbadf1e
-rw-r--r--src/com/android/gallery3d/ui/PhotoView.java20
1 files changed, 11 insertions, 9 deletions
diff --git a/src/com/android/gallery3d/ui/PhotoView.java b/src/com/android/gallery3d/ui/PhotoView.java
index 7e795fa0f..f129961ff 100644
--- a/src/com/android/gallery3d/ui/PhotoView.java
+++ b/src/com/android/gallery3d/ui/PhotoView.java
@@ -232,15 +232,17 @@ public class PhotoView extends GLView {
// item. The value Integer.MAX_VALUE means there is no such hint.
private int mUndoIndexHint = Integer.MAX_VALUE;
+ private Context mContext;
+
public PhotoView(AbstractGalleryActivity activity) {
mTileView = new TileImageView(activity);
addComponent(mTileView);
- Context context = activity.getAndroidContext();
- mPlaceholderColor = context.getResources().getColor(
+ mContext = activity.getAndroidContext();
+ mPlaceholderColor = mContext.getResources().getColor(
R.color.photo_placeholder);
- mEdgeView = new EdgeView(context);
+ mEdgeView = new EdgeView(mContext);
addComponent(mEdgeView);
- mUndoBar = new UndoBarView(context);
+ mUndoBar = new UndoBarView(mContext);
addComponent(mUndoBar);
mUndoBar.setVisibility(GLView.INVISIBLE);
mUndoBar.setOnClickListener(new OnClickListener() {
@@ -251,15 +253,15 @@ public class PhotoView extends GLView {
}
});
mNoThumbnailText = StringTexture.newInstance(
- context.getString(R.string.no_thumbnail),
+ mContext.getString(R.string.no_thumbnail),
DEFAULT_TEXT_SIZE, Color.WHITE);
mHandler = new MyHandler(activity.getGLRoot());
mGestureListener = new MyGestureListener();
- mGestureRecognizer = new GestureRecognizer(context, mGestureListener);
+ mGestureRecognizer = new GestureRecognizer(mContext, mGestureListener);
- mPositionController = new PositionController(context,
+ mPositionController = new PositionController(mContext,
new PositionController.Listener() {
@Override
@@ -292,7 +294,7 @@ public class PhotoView extends GLView {
mEdgeView.onAbsorb(velocity, direction);
}
});
- mVideoPlayIcon = new ResourceTexture(context, R.drawable.ic_control_play);
+ mVideoPlayIcon = new ResourceTexture(mContext, R.drawable.ic_control_play);
for (int i = -SCREEN_NAIL_MAX; i <= SCREEN_NAIL_MAX; i++) {
if (i == 0) {
mPictures.put(i, new FullPicture());
@@ -554,7 +556,7 @@ public class PhotoView extends GLView {
// The second is that it assumes landscape is a 90 rotation from portrait,
// however on landscape devices this is not true. Thus, if we are in portrait
// on a landscape device, we need to invert the output
- int orientation = getGLRoot().getContext().getResources().getConfiguration().orientation;
+ int orientation = mContext.getResources().getConfiguration().orientation;
boolean invertPortrait = (orientation == Configuration.ORIENTATION_PORTRAIT
&& (mDisplayRotation == 90 || mDisplayRotation == 270));
boolean invert = (mDisplayRotation >= 180);