diff options
author | Sunny Goyal <sunnygoyal@google.com> | 2014-11-05 23:23:59 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2014-11-05 23:23:59 +0000 |
commit | b1b201c9af7a53b9ceedb4873b541f85619e6850 (patch) | |
tree | 6db66529cecb62dcbf861d9c5de748b4f4a65bac | |
parent | 2e740944ed8660b8f28177172482f90d3afb7dcf (diff) | |
parent | fafca5299e13e0f44d1d2332d7669d55ad38fdb5 (diff) | |
download | android_packages_apps_Trebuchet-b1b201c9af7a53b9ceedb4873b541f85619e6850.tar.gz android_packages_apps_Trebuchet-b1b201c9af7a53b9ceedb4873b541f85619e6850.tar.bz2 android_packages_apps_Trebuchet-b1b201c9af7a53b9ceedb4873b541f85619e6850.zip |
Merge "Using a proxy call for isAttachedToWindow for pre 19 devices" into ub-now-queens
-rw-r--r-- | src/com/android/launcher3/AppsCustomizePagedView.java | 6 | ||||
-rw-r--r-- | src/com/android/launcher3/Launcher.java | 12 | ||||
-rw-r--r-- | src/com/android/launcher3/Utilities.java | 13 |
3 files changed, 16 insertions, 15 deletions
diff --git a/src/com/android/launcher3/AppsCustomizePagedView.java b/src/com/android/launcher3/AppsCustomizePagedView.java index 064885823..8aa013f8b 100644 --- a/src/com/android/launcher3/AppsCustomizePagedView.java +++ b/src/com/android/launcher3/AppsCustomizePagedView.java @@ -366,11 +366,7 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen // This code triggers requestLayout so must be posted outside of the // layout pass. public void run() { - boolean attached = true; - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { - attached = isAttachedToWindow(); - } - if (attached) { + if (Utilities.isViewAttachedToWindow(AppsCustomizePagedView.this)) { setDataIsReady(); onDataReady(getMeasuredWidth(), getMeasuredHeight()); } diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java index a2de314d3..8b3b2a1e3 100644 --- a/src/com/android/launcher3/Launcher.java +++ b/src/com/android/launcher3/Launcher.java @@ -3597,11 +3597,7 @@ public class Launcher extends Activity for (int i = 0; i < layerViews.size(); i++) { View v = layerViews.get(i); if (v != null) { - boolean attached = true; - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { - attached = v.isAttachedToWindow(); - } - if (attached) v.buildLayer(); + if (Utilities.isViewAttachedToWindow(v)) v.buildLayer(); } } } @@ -3877,11 +3873,7 @@ public class Launcher extends Activity for (int i = 0; i < layerViews.size(); i++) { View v = layerViews.get(i); if (v != null) { - boolean attached = true; - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { - attached = v.isAttachedToWindow(); - } - if (attached) v.buildLayer(); + if (Utilities.isViewAttachedToWindow(v)) v.buildLayer(); } } } diff --git a/src/com/android/launcher3/Utilities.java b/src/com/android/launcher3/Utilities.java index 6caa1cf56..7a16914b9 100644 --- a/src/com/android/launcher3/Utilities.java +++ b/src/com/android/launcher3/Utilities.java @@ -16,6 +16,7 @@ package com.android.launcher3; +import android.annotation.TargetApi; import android.app.Activity; import android.content.ActivityNotFoundException; import android.content.ComponentName; @@ -38,6 +39,8 @@ import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; import android.graphics.drawable.PaintDrawable; import android.os.Build; +import android.os.Build.VERSION; +import android.os.Build.VERSION_CODES; import android.util.Log; import android.util.Pair; import android.util.SparseArray; @@ -495,4 +498,14 @@ public final class Utilities { } return null; } + + @TargetApi(Build.VERSION_CODES.KITKAT) + public static boolean isViewAttachedToWindow(View v) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { + return v.isAttachedToWindow(); + } else { + // A proxy call which returns null, if the view is not attached to the window. + return v.getKeyDispatcherState() != null; + } + } } |