当前位置: 首页>>代码示例>>Java>>正文


Java ViewTreeObserver.OnPreDrawListener方法代码示例

本文整理汇总了Java中android.view.ViewTreeObserver.OnPreDrawListener方法的典型用法代码示例。如果您正苦于以下问题:Java ViewTreeObserver.OnPreDrawListener方法的具体用法?Java ViewTreeObserver.OnPreDrawListener怎么用?Java ViewTreeObserver.OnPreDrawListener使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.view.ViewTreeObserver的用法示例。


在下文中一共展示了ViewTreeObserver.OnPreDrawListener方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: execute

import android.view.ViewTreeObserver; //导入方法依赖的package包/类
@Override
protected void execute(@NonNull final ViewGroup container, @NonNull final SceneInfo upper,
    @NonNull final List<SceneInfo> lower, @NonNull final OnCompleteListener listener) {
  this.listener = listener;
  view = getFirstNonLaidOutView(upper, lower);
  if (view != null) {
    onPreDrawListener = new ViewTreeObserver.OnPreDrawListener() {
      @Override
      public boolean onPreDraw() {
        if (view != null && onPreDrawListener != null) {
          view.getViewTreeObserver().removeOnPreDrawListener(onPreDrawListener);
        }
        view = null;
        onPreDrawListener = null;
        animate(container, upper, lower);
        return true;
      }
    };
    view.getViewTreeObserver().addOnPreDrawListener(onPreDrawListener);
  } else {
    animate(container, upper, lower);
  }
}
 
开发者ID:seven332,项目名称:Stage,代码行数:24,代码来源:AnimatorCurtain.java

示例2: addPreDrawListener

import android.view.ViewTreeObserver; //导入方法依赖的package包/类
void addPreDrawListener() {
    if (mPreDrawListener != null) {
        return;
    }
    mPreDrawListener = new ViewTreeObserver.OnPreDrawListener() {
        @Override
        public boolean onPreDraw() {
            final boolean titleOnTwoLines = (mTitle.getLineCount() > 1);
            int bodymaxLines = titleOnTwoLines ? 3 : 5; // MAGICAL
            if (mBody.getMaxLines() != bodymaxLines) {
                mBody.setMaxLines(bodymaxLines);
                return false;
            } else {
                removePreDrawListener();
                return true;
            }
        }
    };
    view.getViewTreeObserver().addOnPreDrawListener(mPreDrawListener);
}
 
开发者ID:archos-sa,项目名称:aos-Video,代码行数:21,代码来源:TvshowDetailsDescriptionPresenter.java

示例3: addPreDrawListener

import android.view.ViewTreeObserver; //导入方法依赖的package包/类
void addPreDrawListener() {
    if (mPreDrawListener != null) {
        return;
    }
    mPreDrawListener = new ViewTreeObserver.OnPreDrawListener() {
        @Override
        public boolean onPreDraw() {
            final boolean titleOnTwoLines = (mTitle.getLineCount() > 1);
            final boolean hasEpisodeLine = (mEpisodeGroup.getVisibility()==View.VISIBLE);
            int bodymaxLines = titleOnTwoLines ? 3 : 5; // MAGICAL
            if (hasEpisodeLine) bodymaxLines-=1; // MAGICAL

            if (mBody.getMaxLines() != bodymaxLines) {
                mBody.setMaxLines(bodymaxLines);
                return false;
            } else {
                removePreDrawListener();
                return true;
            }
        }
    };
    view.getViewTreeObserver().addOnPreDrawListener(mPreDrawListener);
}
 
开发者ID:archos-sa,项目名称:aos-Video,代码行数:24,代码来源:VideoDetailsDescriptionPresenter.java

示例4: setXFraction

import android.view.ViewTreeObserver; //导入方法依赖的package包/类
/**
 * Set the X translation as a fraction of the width of this view. Make sure this method is not
 * stripped out by proguard when using this with {@link android.animation.ObjectAnimator}. You
 * may need to add
 * <code>
 *     -keep @com.android.setupwizardlib.annotations.Keep class *
 * </code>
 * to your proguard configuration if you are seeing mysterious {@link NoSuchMethodError} at
 * runtime.
 */
@Keep
@TargetApi(VERSION_CODES.HONEYCOMB)
public void setXFraction(float fraction) {
    mXFraction = fraction;
    final int width = getWidth();
    if (width != 0) {
        setTranslationX(width * fraction);
    } else {
        // If we haven't done a layout pass yet, wait for one and then set the fraction before
        // the draw occurs using an OnPreDrawListener. Don't call translationX until we know
        // getWidth() has a reliable, non-zero value or else we will see the fragment flicker on
        // screen.
        if (mPreDrawListener == null) {
            mPreDrawListener = new ViewTreeObserver.OnPreDrawListener() {
                @Override
                public boolean onPreDraw() {
                    getViewTreeObserver().removeOnPreDrawListener(mPreDrawListener);
                    setXFraction(mXFraction);
                    return true;
                }
            };
            getViewTreeObserver().addOnPreDrawListener(mPreDrawListener);
        }
    }
}
 
开发者ID:Trumeet,项目名称:SetupWizardLibCompat,代码行数:36,代码来源:TemplateLayout.java

示例5: runJustBeforeBeingDrawn

import android.view.ViewTreeObserver; //导入方法依赖的package包/类
/**
 * Runs the code just before the given view is being drawn so that its size has been already
 * calculated.
 *
 * @param view     View to be drawn.
 * @param runnable Code to run.
 */
private static void runJustBeforeBeingDrawn(final View view, final Runnable runnable) {
    final ViewTreeObserver.OnPreDrawListener onPreDrawListener = new ViewTreeObserver.OnPreDrawListener() {
        @Override
        public boolean onPreDraw() {
            view.getViewTreeObserver().removeOnPreDrawListener(this);
            runnable.run();
            return true;
        }
    };
    view.getViewTreeObserver().addOnPreDrawListener(onPreDrawListener);
}
 
开发者ID:crux-lab,项目名称:sectioned-recycler-view,代码行数:19,代码来源:SectionHeaderLayout.java

示例6: ensurePreDrawListener

import android.view.ViewTreeObserver; //导入方法依赖的package包/类
private void ensurePreDrawListener() {
  if (mPreDrawListener == null) {
          mPreDrawListener = new ViewTreeObserver.OnPreDrawListener() {
          @Override
          public boolean onPreDraw() {
            FloatingActionButtonImpl.this.onPreDraw();
            return true;
          }
        };
  }
}
 
开发者ID:commonsguy,项目名称:cwac-crossport,代码行数:12,代码来源:FloatingActionButtonImpl.java


注:本文中的android.view.ViewTreeObserver.OnPreDrawListener方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。