本文整理汇总了Java中android.support.v4.view.ViewCompat.isAttachedToWindow方法的典型用法代码示例。如果您正苦于以下问题:Java ViewCompat.isAttachedToWindow方法的具体用法?Java ViewCompat.isAttachedToWindow怎么用?Java ViewCompat.isAttachedToWindow使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.support.v4.view.ViewCompat
的用法示例。
在下文中一共展示了ViewCompat.isAttachedToWindow方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: shouldInheritContext
import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
private boolean shouldInheritContext(ViewParent parent) {
if (parent == null) {
// The initial parent is null so just return false
return false;
}
final View windowDecor = mAppCompatActivity.getWindow().getDecorView();
while (true) {
if (parent == null) {
// Bingo. We've hit a view which has a null parent before being terminated from
// the loop. This is (most probably) because it's the root view in an inflation
// call, therefore we should inherit. This works as the inflated layout is only
// added to the hierarchy at the end of the inflate() call.
return true;
} else if (parent == windowDecor || !(parent instanceof View)
|| ViewCompat.isAttachedToWindow((View) parent)) {
// We have either hit the window's decor view, a parent which isn't a View
// (i.e. ViewRootImpl), or an attached view, so we know that the original parent
// is currently added to the view hierarchy. This means that it has not be
// inflated in the current inflate() call and we should not inherit the context.
return false;
}
parent = parent.getParent();
}
}
示例2: openMenu
import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
public void openMenu() {
if (!ViewCompat.isAttachedToWindow(this))
return;
requestFocus();
boolean showMenu = true;
if (menuListener != null) {
newNavigationMenu();
showMenu = menuListener.onPrepareMenu(navigationMenu);
}
if (showMenu) {
addMenuItems();
fab.setSelected(true);
} else {
fab.setSelected(false);
}
}
示例3: reset
import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
/**
* Changes the view the tracker should observe.
* @param view The new View to observe. Set to {@code null} to completely stop observing.
*/
public void reset(@Nullable View view) {
// Unregister the listeners for the current view.
if (mView != null) {
mView.removeOnAttachStateChangeListener(this);
if (ViewCompat.isAttachedToWindow(mView)) {
mView.getViewTreeObserver().removeOnPreDrawListener(this);
}
}
// Register the listeners for the new view.
mView = view;
if (mView != null) {
// Listen to onPreDraw only if view is potentially visible (attached to the window).
mView.addOnAttachStateChangeListener(this);
if (ViewCompat.isAttachedToWindow(mView)) {
mView.getViewTreeObserver().addOnPreDrawListener(this);
}
}
}
示例4: fromNormalToEditing
import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
private void fromNormalToEditing() {
if (mDisplayMode == DisplayMode.SCREEN_TOOLBAR) {
setCurrentState(SearchViewState.EDITING);
openSearchInternal(true);
} else if (mDisplayMode == DisplayMode.APPBAR_MENUITEM) {
setCurrentState(SearchViewState.EDITING);
if (ViewCompat.isAttachedToWindow(this))
revealFromMenuItem();
else {
getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
getViewTreeObserver().removeGlobalOnLayoutListener(this);
} else {
getViewTreeObserver().removeOnGlobalLayoutListener(this);
}
revealFromMenuItem();
}
});
}
}
mHomeButton.animateState(mHomeButtonOpenIconState);
}
示例5: animateVisibility
import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
@UiThread private static void animateVisibility(@Nullable final View view, final boolean show, int visibility, int duration) {
if (view == null) {
return;
}
if (!ViewCompat.isAttachedToWindow(view)) {
view.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
@Override public boolean onPreDraw() {
view.getViewTreeObserver().removeOnPreDrawListener(this);
animateSafeVisibility(show, view, visibility, duration);
return true;
}
});
} else {
animateSafeVisibility(show, view, visibility, duration);
}
}
示例6: setState
import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
public final void setState(final int state) {
if (state == mState) {
return;
}
if (mViewRef == null) {
// The view is not laid out yet; modify mState and let onLayoutChild handle it later
if (state == STATE_COLLAPSED || state == STATE_EXPANDED ||
(mHideable && state == STATE_HIDDEN)) {
mState = state;
}
return;
}
final V child = mViewRef.get();
if (child == null) {
return;
}
// Start the animation; wait until a pending layout if there is one.
ViewParent parent = child.getParent();
if (parent != null && parent.isLayoutRequested() && ViewCompat.isAttachedToWindow(child)) {
child.post(new Runnable() {
@Override
public void run() {
startSettlingAnimation(child, state);
}
});
} else {
startSettlingAnimation(child, state);
}
}
示例7: closeMenu
import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
public void closeMenu() {
if (!ViewCompat.isAttachedToWindow(this))
return;
if (isMenuOpen()) {
fab.setSelected(false);
removeFabMenuItems();
if (menuListener != null) {
menuListener.onMenuClosed();
}
}
}
示例8: hide
import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
public void hide() {
if (!ViewCompat.isAttachedToWindow(this))
return;
if (isMenuOpen()) {
closeMenu();
}
fab.hide();
}
示例9: show
import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
public void show() {
if (!ViewCompat.isAttachedToWindow(this))
return;
fab.show();
}
示例10: update
import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
@Override
public void update(long bytesRead, long contentLength, boolean done) {
if (ViewCompat.isAttachedToWindow(itemView)) {
}
}
示例11: isVisibleToUser
import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
private boolean isVisibleToUser(View view) {
return ViewCompat.isAttachedToWindow(view) && view.getGlobalVisibleRect(this.mVisibleRect);
}
示例12: show
import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
public void show() {
if (!ViewCompat.isAttachedToWindow(this))
return;
setVisibility(View.VISIBLE);
fab.show();
}