PullController.java 文件源码

java
阅读 41 收藏 0 点赞 0 评论 0

项目:android_ui 作者:
/**
 * Performs configuration of this controller from the given <var>attrs</var>.
 *
 * @param context      Context used to obtain values for the given attributes.
 * @param attrs        Set of attributes with values to be used to set up this controller.
 * @param defStyleAttr An attribute which contains a reference to a default style resource, for
 *                     the view attached to this controller, within a theme of the given context.
 * @param defStyleRes  Resource id of the default style for the view attached to this controller.
 * @return {@code True} if some setting of this controller has been changed, {@code false} otherwise.
 */
@SuppressWarnings("ResourceType")
public boolean setUpFromAttrs(@NonNull Context context, AttributeSet attrs, @AttrRes int defStyleAttr, @StyleRes int defStyleRes) {
    final TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.Ui_PullController, defStyleAttr, defStyleRes);
    if (typedArray != null) {
        this.ensurePullHelper();
        final int n = typedArray.getIndexCount();
        for (int i = 0; i < n; i++) {
            final int index = typedArray.getIndex(i);
            if (index == R.styleable.Ui_PullController_uiPullMode) {
                setPullMode(typedArray.getInteger(index, mPullHelper.getPullMode()));
            } else if (index == R.styleable.Ui_PullController_uiPullMinVelocity) {
                setPullMinVelocity(typedArray.getFloat(index, getPullMinVelocity()));
            } else if (index == R.styleable.Ui_PullController_uiPullDistanceFraction) {
                setPullDistanceFraction(typedArray.getFloat(index, getPullDistanceFraction()));
            } else if (index == R.styleable.Ui_PullController_uiPullDistance) {
                setPullDistance(typedArray.getDimensionPixelSize(index, (int) getPullDistance()));
            } else if (index == R.styleable.Ui_PullController_uiPullCollapseDuration) {
                setPullCollapseDuration(typedArray.getInt(index, (int) mAnimations.pullCollapseDuration));
            } else if (index == R.styleable.Ui_PullController_uiPullCollapseDelay) {
                setPullCollapseDelay(typedArray.getInt(index, (int) mAnimations.pullCollapseDelay));
            }
        }
        typedArray.recycle();
        return n > 0;
    }
    return false;
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号