Java Code Examples for android.view.View.isAttachedToWindow()

The following are Jave code examples for showing how to use isAttachedToWindow() of the android.view.View class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: LaunchEnr   File: AnimationLayerSet.java   Source Code and License Vote up 5 votes
@Override
public void onAnimationStart(Animator animation) {
    // Enable all necessary layers
    Iterator<Map.Entry<View, Integer>> itr = mViewsToLayerTypeMap.entrySet().iterator();
    while (itr.hasNext()) {
        Map.Entry<View, Integer> entry = itr.next();
        View v = entry.getKey();
        entry.setValue(v.getLayerType());
        v.setLayerType(View.LAYER_TYPE_HARDWARE, null);
        if (v.isAttachedToWindow() && v.getVisibility() == View.VISIBLE) {
            v.buildLayer();
        }
    }
}
 
Example 2
Project: FrescoLoader   File: FrescoLoader.java   Source Code and License Vote up 5 votes
private static boolean isAttachedToWindow(View view) {
    if (Build.VERSION.SDK_INT >= 19) {
        return view.isAttachedToWindow();
    } else {
        return view.getWindowToken() != null;
    }
}
 
Example 3
Project: FrescoLoader   File: ViewCompat.java   Source Code and License Vote up 5 votes
private boolean isAttachedToWindow(View view) {
    if (Build.VERSION.SDK_INT >= 19) {
        return view.isAttachedToWindow();
    } else {
        return view.getWindowToken() != null;
    }
}
 
Example 4
Project: QuickActionView   File: QuickActionView.java   Source Code and License Vote up 5 votes
private boolean checkAttachedToWindow(View view) {
    if (Build.VERSION.SDK_INT >= 19) {
        return view.isAttachedToWindow();
    }
    //Unfortunately, we have no way of truly knowing on versions less than 19
    return true;
}
 
Example 5
Project: stynico   File: JumpingBeansSpan.java   Source Code and License Vote up 4 votes
private static boolean isAttachedToHierarchy(View v) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        return v.isAttachedToWindow();
    }
    return v.getParent() != null;   // Best-effort fallback (without adding support-v4 just for this...)
}
 
Example 6
Project: letv   File: ViewCompatKitKat.java   Source Code and License Vote up 4 votes
public static boolean isAttachedToWindow(View view) {
    return view.isAttachedToWindow();
}
 
Example 7
Project: PlusGram   File: ChatAttachAlert.java   Source Code and License Vote up 4 votes
private void checkCameraViewPosition() {
    if (!deviceHasGoodCamera) {
        return;
    }
    int count = attachPhotoRecyclerView.getChildCount();
    for (int a = 0; a < count; a++) {
        View child = attachPhotoRecyclerView.getChildAt(a);
        if (child instanceof PhotoAttachCameraCell) {
            if (Build.VERSION.SDK_INT >= 19) {
                if (!child.isAttachedToWindow()) {
                    break;
                }
            }
            child.getLocationInWindow(cameraViewLocation);
            float listViewX = listView.getX() + backgroundPaddingLeft;
            if (cameraViewLocation[0] < listViewX) {
                cameraViewOffsetX = (int) (listViewX - cameraViewLocation[0]);
                if (cameraViewOffsetX >= AndroidUtilities.dp(80)) {
                    cameraViewOffsetX = 0;
                    cameraViewLocation[0] = AndroidUtilities.dp(-100);
                    cameraViewLocation[1] = 0;
                } else {
                    cameraViewLocation[0] += cameraViewOffsetX;
                }
            } else {
                cameraViewOffsetX = 0;
            }
            if (Build.VERSION.SDK_INT >= 21 && cameraViewLocation[1] < AndroidUtilities.statusBarHeight) {
                cameraViewOffsetY = AndroidUtilities.statusBarHeight - cameraViewLocation[1];
                if (cameraViewOffsetY >= AndroidUtilities.dp(80)) {
                    cameraViewOffsetY = 0;
                    cameraViewLocation[0] = AndroidUtilities.dp(-100);
                    cameraViewLocation[1] = 0;
                } else {
                    cameraViewLocation[1] += cameraViewOffsetY;
                }
            } else {
                cameraViewOffsetY = 0;
            }
            applyCameraViewPosition();
            return;
        }
    }
    cameraViewOffsetX = 0;
    cameraViewOffsetY = 0;
    cameraViewLocation[0] = AndroidUtilities.dp(-100);
    cameraViewLocation[1] = 0;
    applyCameraViewPosition();
}
 
Example 8
Project: boohee_v5.6   File: ViewCompatKitKat.java   Source Code and License Vote up 4 votes
public static boolean isAttachedToWindow(View view) {
    return view.isAttachedToWindow();
}
 
Example 9
Project: BookLoadingView   File: JumpingBeansSpan.java   Source Code and License Vote up 4 votes
private static boolean isAttachedToHierarchy(View v) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        return v.isAttachedToWindow();
    }
    return v.getParent() != null;   // Best-effort fallback
}