am 8d8fc469: Merge "Don\'t orphan footers with transient state Bug #8725945" into jb-mr2-dev

* commit '8d8fc469952ffe3feb45e52388f2129f8dd5e40c':
  Don't orphan footers with transient state Bug #8725945
diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java
index bbf5ae9..6b2ed91 100644
--- a/core/java/android/view/ViewRootImpl.java
+++ b/core/java/android/view/ViewRootImpl.java
@@ -2829,6 +2829,7 @@
 
         setAccessibilityFocus(null, null);
 
+        mView.assignParent(null);
         mView = null;
         mAttachInfo.mRootView = null;
         mAttachInfo.mSurface = null;
diff --git a/core/java/android/widget/AbsListView.java b/core/java/android/widget/AbsListView.java
index bf66292..219891c 100644
--- a/core/java/android/widget/AbsListView.java
+++ b/core/java/android/widget/AbsListView.java
@@ -6390,7 +6390,7 @@
             int viewType = lp.viewType;
             final boolean scrapHasTransientState = scrap.hasTransientState();
             if (!shouldRecycleViewType(viewType) || scrapHasTransientState) {
-                if (viewType != ITEM_VIEW_TYPE_HEADER_OR_FOOTER || scrapHasTransientState) {
+                if (viewType != ITEM_VIEW_TYPE_HEADER_OR_FOOTER && scrapHasTransientState) {
                     if (mSkippedScrap == null) {
                         mSkippedScrap = new ArrayList<View>();
                     }
@@ -6464,7 +6464,7 @@
                     final boolean scrapHasTransientState = victim.hasTransientState();
                     if (!shouldRecycleViewType(whichScrap) || scrapHasTransientState) {
                         // Do not move views that should be ignored
-                        if (whichScrap != ITEM_VIEW_TYPE_HEADER_OR_FOOTER ||
+                        if (whichScrap != ITEM_VIEW_TYPE_HEADER_OR_FOOTER &&
                                 scrapHasTransientState) {
                             removeDetachedView(victim, false);
                         }