Prevent GNL from crashing on JB

issue 17433546

Change-Id: Ie5071e516b26400a27473eaaa401023f1af1d840
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index 33cc29e..5c6261d 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -59,6 +59,7 @@
 import android.graphics.drawable.Drawable;
 import android.net.Uri;
 import android.os.AsyncTask;
+import android.os.Build;
 import android.os.Bundle;
 import android.os.Environment;
 import android.os.Handler;
@@ -3378,7 +3379,13 @@
                     if (Utilities.isLmp()) {
                         for (int i = 0; i < layerViews.size(); i++) {
                             View v = layerViews.get(i);
-                            if (v != null && v.isAttachedToWindow()) v.buildLayer();
+                            if (v != null) {
+                                boolean attached = true;
+                                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
+                                    attached = v.isAttachedToWindow();
+                                }
+                                if (attached) v.buildLayer();
+                            }
                         }
                     }
                     mStateAnimation.start();
@@ -3625,7 +3632,13 @@
                     if (Utilities.isLmp()) {
                         for (int i = 0; i < layerViews.size(); i++) {
                             View v = layerViews.get(i);
-                            if (v != null && v.isAttachedToWindow()) v.buildLayer();
+                            if (v != null) {
+                                boolean attached = true;
+                                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
+                                    attached = v.isAttachedToWindow();
+                                }
+                                if (attached) v.buildLayer();
+                            }
                         }
                     }
                     mStateAnimation.start();