From 5a7bd5db14eceef7df79c748d1416e9e28fcc707 Mon Sep 17 00:00:00 2001 From: c_yongga Date: Tue, 5 Jan 2016 17:26:44 +0800 Subject: Gallery2: Fix null pointer exception from customer monkey test. The reference is not instantiated before invoking it. Determine whether the reference is instantiated before invoking it. Change-Id: I5448acd8070e01bd6a992d9755fe2d40e3aefbed CRs-Fixed: 951767 --- src/com/android/gallery3d/app/AlbumSetPage.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/com/android') diff --git a/src/com/android/gallery3d/app/AlbumSetPage.java b/src/com/android/gallery3d/app/AlbumSetPage.java index d2cc0ca57..c8916fe16 100644 --- a/src/com/android/gallery3d/app/AlbumSetPage.java +++ b/src/com/android/gallery3d/app/AlbumSetPage.java @@ -244,13 +244,16 @@ public class AlbumSetPage extends ActivityState implements WeakReference mEmptyAlbumToast = null; private void showEmptyAlbumToast(int toastLength) { + //CRs-Fixed:951767 java.lang.NullPointerException: Attempt to invoke virtual method + // 'void android.widget.RelativeLayout.addView(android.view.View + RelativeLayout galleryRoot = (RelativeLayout) ((Activity) mActivity) + .findViewById(R.id.gallery_root); + if (galleryRoot == null) return ; tvEmptyAlbum = new TextView(mActivity); tvEmptyAlbum.setText(R.string.tvEmptyAlbum); tvEmptyAlbum.setTextColor(Color.parseColor("#8A000000")); tvEmptyAlbum.setGravity(Gravity.CENTER); tvEmptyAlbum.setTextSize(TypedValue.COMPLEX_UNIT_SP,20); - RelativeLayout galleryRoot = (RelativeLayout) ((Activity) mActivity) - .findViewById(R.id.gallery_root); RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); -- cgit v1.2.3