From dfbe72bd94593968a84bda0d9eb84ed23f73e6ac Mon Sep 17 00:00:00 2001 From: maxwen Date: Sat, 27 Oct 2012 15:05:44 +0200 Subject: Fix for NPE in showAllAppsCling Added check for getTabHost() E/AndroidRuntime( 1880): FATAL EXCEPTION: main E/AndroidRuntime( 1880): java.lang.NullPointerException E/AndroidRuntime( 1880): at com.cyanogenmod.trebuchet.AppsCustomizePagedView.showAllAppsCling(AppsCustomizePagedView.java:575) E/AndroidRuntime( 1880): at com.cyanogenmod.trebuchet.AppsCustomizeTabHost.onLauncherTransitionEnd(AppsCustomizeTabHost.java:455) E/AndroidRuntime( 1880): at com.cyanogenmod.trebuchet.Launcher.dispatchOnLauncherTransitionEnd(Launcher.java:2401) E/AndroidRuntime( 1880): at com.cyanogenmod.trebuchet.Launcher.access$2100(Launcher.java:120) E/AndroidRuntime( 1880): at com.cyanogenmod.trebuchet.Launcher$14.onAnimationEnd(Launcher.java:2519) E/AndroidRuntime( 1880): at android.animation.AnimatorSet$AnimatorSetListener.onAnimationEnd(AnimatorSet.java:765) E/AndroidRuntime( 1880): at com.cyanogenmod.trebuchet.LauncherViewPropertyAnimator.onAnimationEnd(LauncherViewPropertyAnimator.java:111) Change-Id: I4aa0b4bacc03fb7aa87029d3e9406570bc82830f --- .../trebuchet/AppsCustomizePagedView.java | 35 ++++++++++++---------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/src/com/cyanogenmod/trebuchet/AppsCustomizePagedView.java b/src/com/cyanogenmod/trebuchet/AppsCustomizePagedView.java index 364b3b30e..86dcce8a5 100644 --- a/src/com/cyanogenmod/trebuchet/AppsCustomizePagedView.java +++ b/src/com/cyanogenmod/trebuchet/AppsCustomizePagedView.java @@ -572,22 +572,25 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen } void showAllAppsCling() { - Cling allAppsCling = (Cling) getTabHost().findViewById(R.id.all_apps_cling); - if (!mHasShownAllAppsCling && isDataReady()) { - mHasShownAllAppsCling = true; - // Calculate the position for the cling punch through - int[] offset = new int[2]; - int[] pos = mWidgetSpacingLayout.estimateCellPosition(mClingFocusedX, mClingFocusedY); - mLauncher.getDragLayer().getLocationInDragLayer(this, offset); - // PagedViews are centered horizontally but top aligned - pos[0] += (getMeasuredWidth() - mWidgetSpacingLayout.getMeasuredWidth()) / 2 + - offset[0]; - pos[1] += offset[1]; - mLauncher.showFirstRunAllAppsCling(pos); - } else if (!mHasShownAllAppsSortCling && isDataReady() && - allAppsCling != null && allAppsCling.isDismissed()) { - mHasShownAllAppsSortCling = true; - mLauncher.showFirstRunAllAppsSortCling(); + AppsCustomizeTabHost tabHost = getTabHost(); + if (tabHost != null) { + Cling allAppsCling = (Cling) tabHost.findViewById(R.id.all_apps_cling); + if (!mHasShownAllAppsCling && isDataReady()) { + mHasShownAllAppsCling = true; + // Calculate the position for the cling punch through + int[] offset = new int[2]; + int[] pos = mWidgetSpacingLayout.estimateCellPosition(mClingFocusedX, mClingFocusedY); + mLauncher.getDragLayer().getLocationInDragLayer(this, offset); + // PagedViews are centered horizontally but top aligned + pos[0] += (getMeasuredWidth() - mWidgetSpacingLayout.getMeasuredWidth()) / 2 + + offset[0]; + pos[1] += offset[1]; + mLauncher.showFirstRunAllAppsCling(pos); + } else if (!mHasShownAllAppsSortCling && isDataReady() && + allAppsCling != null && allAppsCling.isDismissed()) { + mHasShownAllAppsSortCling = true; + mLauncher.showFirstRunAllAppsSortCling(); + } } } -- cgit v1.2.3