@TargetApi(KITKAT) public S isAttachedToWindow() { isNotNull(); assertThat(actual.isAttachedToWindow()) // .overridingErrorMessage("Expected to be attached to window but was not.") // .isTrue(); return myself; }
@TargetApi(KITKAT) public S isNotAttachedToWindow() { isNotNull(); assertThat(actual.isAttachedToWindow()) // .overridingErrorMessage("Expected to be not attached to window but was.") // .isFalse(); return myself; }
private boolean addToWindow(){ if (wm != null) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { if (!mWindowView.isAttachedToWindow()) { wm.addView(mWindowView, wmParams); isWindowShow = true; return true; } else { return false; } } else { try { if (mWindowView.getParent() == null) { wm.addView(mWindowView, wmParams); isWindowShow = true; } return true; } catch (Exception e) { return false; } } } else { return false; } }
private boolean removeFromWindow(){ boolean isClose = false; if (wm != null) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { if (mWindowView.isAttachedToWindow()) { wm.removeViewImmediate(mWindowView); isWindowShow = false; isClose = true; } } else { try { if (mWindowView.getParent() != null) { wm.removeViewImmediate(mWindowView); isWindowShow = false; isClose = true; } } catch (Exception e) { e.printStackTrace(); } } } if(isClose && mOnWindowListener!=null){ mOnWindowListener.onClose(); } return isClose; }
@Override public void onGlobalLayout() { final View targetView = mView.mPromptOptions.getTargetView(); if (targetView != null) { final boolean isTargetAttachedToWindow; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { isTargetAttachedToWindow = targetView.isAttachedToWindow(); } else { isTargetAttachedToWindow = targetView.getWindowToken() != null; } if (!isTargetAttachedToWindow) { return; } } prepare(); if (mAnimationCurrent == null) { // Force a relayout to update the view's location updateAnimation(1, 1); } } };
public static boolean isAttachedToWindow(View view) { if (view == null){ return false; } if (Build.VERSION.SDK_INT >= 19) { return view.isAttachedToWindow(); } else { return view.getWindowToken() != null; } }
public static boolean isAttachedToWindow(View view) { if (view == null){ return false; } if (Build.VERSION.SDK_INT >= 19) { return view.isAttachedToWindow(); } else { return view.getWindowToken() != null; } }
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 }
@TargetApi(Build.VERSION_CODES.KITKAT) public static boolean isViewAttachedToWindow(View v) { if (ATLEAST_KITKAT) { return v.isAttachedToWindow(); } else { // A proxy call which returns null, if the view is not attached to the window. return v.getKeyDispatcherState() != null; } }
@TargetApi(KITKAT) public S isNotAttachedToWindow() { isNotNull(); assertThat(actual.isAttachedToWindow()) // .overridingErrorMessage("Expected to be not attached to window but was.") // .isFalse(); return myself; }
@TargetApi(KITKAT) public S isAttachedToWindow() { isNotNull(); assertThat(actual.isAttachedToWindow()) // .overridingErrorMessage("Expected to be attached to window but was not.") // .isTrue(); return myself; }
@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(); } } }
/** */ @Override @SuppressWarnings("NewApi") public boolean isAttachedToWindow() { this.ensureDecorator(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) return super.isAttachedToWindow(); else return mDecorator.hasPrivateFlag(PrivateFlags.PFLAG_ATTACHED_TO_WINDOW); }
/** */ @Override @SuppressWarnings("NewApi") public boolean isAttachedToWindow() { this.ensureDecorator(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) return super.isAttachedToWindow(); else return mDecorator.hasPrivateFlag(PrivateFlags.PFLAG_ATTACHED_TO_WINDOW); }
protected void setHasFocus(boolean hasFocus) { if (this.mEnabled && this.mTargetView.getVisibility() == 0 && this.mTargetView.isAttachedToWindow() && this.mTargetView.hasWindowFocus()) { animateFocus(hasFocus); } else { setFocusImmediate(hasFocus); } }
protected void setHasFocus(boolean hasFocus) { if (this.mEnabled && this.mTargetView.getVisibility() == 0 && this.mTargetView.isAttachedToWindow() && this.mTargetView.hasWindowFocus()) { animateFocus(hasFocus); } else { setFocusImmediate(hasFocus); } }
private Rect getDrawRect() { if (mCurrentView != null && mCurrentView.isAttachedToWindow()) { viewToRect(mCurrentView, sTempRect1); if (mShift > 0 && mTargetView != null) { viewToRect(mTargetView, sTempRect2); return RECT_EVALUATOR.evaluate(mShift, sTempRect1, sTempRect2); } else { return sTempRect1; } } return null; }
public void run() { // Check that mCurrentAnimation hasn't changed while // we waited for a layout/draw pass if (mCurrentAnimation != stateAnimation) return; dispatchOnLauncherTransitionStart(fromView, animated, false); dispatchOnLauncherTransitionStart(toView, animated, false); // Enable all necessary layers for (View v : layerViews.keySet()) { if (layerViews.get(v) == BUILD_AND_SET_LAYER) { v.setLayerType(View.LAYER_TYPE_HARDWARE, null); } if (Utilities.ATLEAST_LOLLIPOP && v.isAttachedToWindow()) { v.buildLayer(); } } toView.requestFocus(); stateAnimation.start(); } };
public void prepareEditMode(int rowType) { Iterator it = this.mAllRowsList.iterator(); while (it.hasNext()) { HomeScreenRow row = (HomeScreenRow) it.next(); if (row.getType().getCode() == rowType) { View activeFrame = row.getRowView(); if (activeFrame instanceof ActiveFrame) { for (int i = 0; i < ((ActiveFrame) activeFrame).getChildCount(); i++) { View rowView = ((ActiveFrame) activeFrame).getChildAt(i); if ((rowView instanceof EditableAppsRowView) && ((EditableAppsRowView) rowView).getChildCount() > 0) { if (rowView.isAttachedToWindow()) { beginEditMode((EditableAppsRowView) rowView); } else { ((EditableAppsRowView) rowView).setEditModePending(true); } } } } } } }
private void updateForcedScroll() { if (mForcedScroll != null && (!mForcedScroll.hasFocus() || !mForcedScroll.isAttachedToWindow())) { mForcedScroll = null; } if (mForcedScroll != null) { View expandableView = mForcedScroll; int positionInLinearLayout = getPositionInLinearLayout(expandableView); int targetScroll = targetScrollForView(expandableView, positionInLinearLayout); int outOfViewScroll = positionInLinearLayout + getIntrinsicHeight(expandableView); targetScroll = Math.max(0, Math.min(targetScroll, getScrollRange())); // Only apply the scroll if we're scrolling the view upwards, or the view is so far up // that it is not visible anymore. int mOwnScrollY = getOwnScrollY(); if (mOwnScrollY < targetScroll || outOfViewScroll < mOwnScrollY) { setOwnScrollY(mOwnScrollY); } } }