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


Java ScrollUtils类代码示例

本文整理汇总了Java中com.github.ksoichiro.android.observablescrollview.ScrollUtils的典型用法代码示例。如果您正苦于以下问题:Java ScrollUtils类的具体用法?Java ScrollUtils怎么用?Java ScrollUtils使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ScrollUtils类属于com.github.ksoichiro.android.observablescrollview包,在下文中一共展示了ScrollUtils类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: initSlide

import com.github.ksoichiro.android.observablescrollview.ScrollUtils; //导入依赖的package包/类
private void initSlide() {
    ScrollUtils.addOnGlobalLayoutListener(rvDetailEvents, new Runnable() {
        @Override
        public void run() {
            mLayoutFinished = true;
            updateScroll(rvDetailEvents.getCurrentScrollY());
        }
    });
    rvDetailEvents.setScrollViewCallbacks(new ObservableScrollViewCallbacks() {
        @Override
        public void onScrollChanged(int scrollY, boolean firstScroll, boolean dragging) {
            if (!mLayoutFinished) return;
            updateScroll(scrollY);
        }

        @Override
        public void onDownMotionEvent() {

        }

        @Override
        public void onUpOrCancelMotionEvent(ScrollState scrollState) {
        }
    });
}
 
开发者ID:Sherchen,项目名称:AnimationsDemo,代码行数:26,代码来源:DetailEventsFragment.java

示例2: getHeights

import com.github.ksoichiro.android.observablescrollview.ScrollUtils; //导入依赖的package包/类
private void getHeights() {
    ScrollUtils.addOnGlobalLayoutListener(touchInterceptionFrameLayout, new Runnable() {
        @Override
        public void run() {
            scrollViewFullHeight = touchInterceptionFrameLayout.getHeight();
        }
    });
    if (scrollView instanceof View) {
        ScrollUtils.addOnGlobalLayoutListener(((View) scrollView), new Runnable() {
            @Override
            public void run() {
                scrollViewHeight = ((View) scrollView).getHeight();

            }
        });
    }
    if (shouldStayViews != null && shouldStayViews.length > 0 && scrollViewCanScrollHeight == 0) {
        ScrollUtils.addOnGlobalLayoutListener(shouldStayViews[0], new Runnable() {
            @Override
            public void run() {
                scrollViewCanScrollHeight = shouldStayViews[0].getHeight();

            }
        });
    }
}
 
开发者ID:Grasea,项目名称:Grandroid2,代码行数:27,代码来源:SimpleObservableScrollHandler.java

示例3: onScrollChanged

import com.github.ksoichiro.android.observablescrollview.ScrollUtils; //导入依赖的package包/类
@Override
public void onScrollChanged(int scrollY, boolean firstScroll, boolean dragging) {
    if (mDragging) {
        int toolbarHeight = mToolbarView.getHeight();
        if (mFirstScroll) {
            mFirstScroll = false;
            float currentHeaderTranslationY = ViewHelper.getTranslationY(mHeaderView);
            if (-toolbarHeight < currentHeaderTranslationY) {
                mBaseTranslationY = scrollY;
            }
        }
        float headerTranslationY = ScrollUtils.getFloat(-(scrollY - mBaseTranslationY), -toolbarHeight, 0);
        ViewPropertyAnimator.animate(mHeaderView).cancel();
        ViewHelper.setTranslationY(mHeaderView, headerTranslationY);
    }
}
 
开发者ID:LeMinhAn,项目名称:AndroidObservableScrollView-master,代码行数:17,代码来源:StickyHeaderWebViewActivity.java

示例4: onScrollChanged

import com.github.ksoichiro.android.observablescrollview.ScrollUtils; //导入依赖的package包/类
@Override
public void onScrollChanged(int scrollY, boolean firstScroll, boolean dragging) {
    // Translate overlay and image
    float flexibleRange = mFlexibleSpaceImageHeight - mActionBarSize;
    int minOverlayTransitionY = mActionBarSize - mOverlayView.getHeight();
    ViewHelper.setTranslationY(mOverlayView, ScrollUtils.getFloat(-scrollY, minOverlayTransitionY, 0));
    ViewHelper.setTranslationY(mImageView, ScrollUtils.getFloat(-scrollY / 2, minOverlayTransitionY, 0));

    // Translate list background
    ViewHelper.setTranslationY(mRecyclerViewBackground, Math.max(0, -scrollY + mFlexibleSpaceImageHeight));

    // Change alpha of overlay
    ViewHelper.setAlpha(mOverlayView, ScrollUtils.getFloat((float) scrollY / flexibleRange, 0, 1));

    // Scale title text
    float scale = 1 + ScrollUtils.getFloat((flexibleRange - scrollY) / flexibleRange, 0, MAX_TEXT_SCALE_DELTA);
    setPivotXToTitle();
    ViewHelper.setPivotY(mTitleView, 0);
    ViewHelper.setScaleX(mTitleView, scale);
    ViewHelper.setScaleY(mTitleView, scale);

    // Translate title text
    int maxTitleTranslationY = (int) (mFlexibleSpaceImageHeight - mTitleView.getHeight() * scale);
    int titleTranslationY = maxTitleTranslationY - scrollY;
    ViewHelper.setTranslationY(mTitleView, titleTranslationY);
}
 
开发者ID:LeMinhAn,项目名称:AndroidObservableScrollView-master,代码行数:27,代码来源:FlexibleSpaceWithImageRecyclerViewActivity.java

示例5: updateFlexibleSpace

import com.github.ksoichiro.android.observablescrollview.ScrollUtils; //导入依赖的package包/类
private void updateFlexibleSpace(float translationY) {
    ViewHelper.setTranslationY(mInterceptionLayout, translationY);
    int minOverlayTransitionY = getActionBarSize() - mOverlayView.getHeight();
    ViewHelper.setTranslationY(mImageView, ScrollUtils.getFloat(-translationY / 2, minOverlayTransitionY, 0));

    // Change alpha of overlay
    float flexibleRange = mFlexibleSpaceHeight - getActionBarSize();
    ViewHelper.setAlpha(mOverlayView, ScrollUtils.getFloat(-translationY / flexibleRange, 0, 1));

    // Scale title text
    float scale = 1 + ScrollUtils.getFloat((flexibleRange + translationY - mTabHeight) / flexibleRange, 0, MAX_TEXT_SCALE_DELTA);
    setPivotXToTitle();
    ViewHelper.setPivotY(mTitleView, 0);
    ViewHelper.setScaleX(mTitleView, scale);
    ViewHelper.setScaleY(mTitleView, scale);
}
 
开发者ID:LeMinhAn,项目名称:AndroidObservableScrollView-master,代码行数:17,代码来源:FlexibleSpaceWithImageWithViewPagerTab2Activity.java

示例6: updateFlexibleSpaceText

import com.github.ksoichiro.android.observablescrollview.ScrollUtils; //导入依赖的package包/类
private void updateFlexibleSpaceText(final int scrollY) {
    ViewHelper.setTranslationY(mFlexibleSpaceView, -scrollY);
    int adjustedScrollY = (int) ScrollUtils.getFloat(scrollY, 0, mFlexibleSpaceHeight);

    // Special logic for WebView.
    adjustTopMargin(mWebViewContainer, adjustedScrollY <= mFlexibleSpaceHeight ? 0 : mFlexibleSpaceHeight + getActionBarSize());

    float maxScale = (float) (mFlexibleSpaceHeight - mToolbarView.getHeight()) / mToolbarView.getHeight();
    float scale = maxScale * ((float) mFlexibleSpaceHeight - adjustedScrollY) / mFlexibleSpaceHeight;

    ViewHelper.setPivotX(mTitleView, 0);
    ViewHelper.setPivotY(mTitleView, 0);
    ViewHelper.setScaleX(mTitleView, 1 + scale);
    ViewHelper.setScaleY(mTitleView, 1 + scale);
    int maxTitleTranslationY = mToolbarView.getHeight() + mFlexibleSpaceHeight - (int) (mTitleView.getHeight() * (1 + scale));
    int titleTranslationY = (int) (maxTitleTranslationY * ((float) mFlexibleSpaceHeight - adjustedScrollY) / mFlexibleSpaceHeight);
    ViewHelper.setTranslationY(mTitleView, titleTranslationY);
}
 
开发者ID:LeMinhAn,项目名称:AndroidObservableScrollView-master,代码行数:19,代码来源:FlexibleSpaceToolbarWebViewActivity.java

示例7: onCreate

import com.github.ksoichiro.android.observablescrollview.ScrollUtils; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_parallaxtoolbarscrollview);

    setSupportActionBar((Toolbar) findViewById(R.id.toolbar));

    mImageView = findViewById(R.id.image);
    mToolbarView = findViewById(R.id.toolbar);
    mToolbarView.setBackgroundColor(ScrollUtils.getColorWithAlpha(0, getResources().getColor(R.color.primary)));

    mScrollView = (ObservableScrollView) findViewById(R.id.scroll);
    mScrollView.setScrollViewCallbacks(this);

    mParallaxImageHeight = getResources().getDimensionPixelSize(R.dimen.parallax_image_height);
}
 
开发者ID:LeMinhAn,项目名称:AndroidObservableScrollView-master,代码行数:17,代码来源:ParallaxToolbarScrollViewActivity.java

示例8: onCreateView

import com.github.ksoichiro.android.observablescrollview.ScrollUtils; //导入依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_listview, container, false);

    Activity parentActivity = getActivity();
    final ObservableListView listView = (ObservableListView) view.findViewById(R.id.scroll);
    UiTestUtils.setDummyDataWithHeader(getActivity(), listView, inflater.inflate(R.layout.padding, null));

    if (parentActivity instanceof ObservableScrollViewCallbacks) {
        // Scroll to the specified position after layout
        Bundle args = getArguments();
        if (args != null && args.containsKey(ARG_INITIAL_POSITION)) {
            final int initialPosition = args.getInt(ARG_INITIAL_POSITION, 0);
            ScrollUtils.addOnGlobalLayoutListener(listView, new Runnable() {
                @Override
                public void run() {
                    // scrollTo() doesn't work, should use setSelection()
                    listView.setSelection(initialPosition);
                }
            });
        }
        listView.setScrollViewCallbacks((ObservableScrollViewCallbacks) parentActivity);
    }
    return view;
}
 
开发者ID:LeMinhAn,项目名称:AndroidObservableScrollView-master,代码行数:26,代码来源:ViewPagerTabListViewFragment.java

示例9: onCreateView

import com.github.ksoichiro.android.observablescrollview.ScrollUtils; //导入依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_scrollview, container, false);

    final ObservableScrollView scrollView = (ObservableScrollView) view.findViewById(R.id.scroll);
    Activity parentActivity = getActivity();
    if (parentActivity instanceof ObservableScrollViewCallbacks) {
        // Scroll to the specified offset after layout
        Bundle args = getArguments();
        if (args != null && args.containsKey(ARG_SCROLL_Y)) {
            final int scrollY = args.getInt(ARG_SCROLL_Y, 0);
            ScrollUtils.addOnGlobalLayoutListener(scrollView, new Runnable() {
                @Override
                public void run() {
                    scrollView.scrollTo(0, scrollY);
                }
            });
        }
        scrollView.setScrollViewCallbacks((ObservableScrollViewCallbacks) parentActivity);
    }
    return view;
}
 
开发者ID:LeMinhAn,项目名称:AndroidObservableScrollView-master,代码行数:23,代码来源:ViewPagerTabScrollViewFragment.java

示例10: onCreateView

import com.github.ksoichiro.android.observablescrollview.ScrollUtils; //导入依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_listview, container, false);

    Activity parentActivity = getActivity();
    final ObservableListView listView = (ObservableListView) view.findViewById(R.id.scroll);
    setDummyDataWithHeader(listView, inflater.inflate(R.layout.padding, null));

    if (parentActivity instanceof ObservableScrollViewCallbacks) {
        // Scroll to the specified position after layout
        Bundle args = getArguments();
        if (args != null && args.containsKey(ARG_INITIAL_POSITION)) {
            final int initialPosition = args.getInt(ARG_INITIAL_POSITION, 0);
            ScrollUtils.addOnGlobalLayoutListener(listView, new Runnable() {
                @Override
                public void run() {
                    // scrollTo() doesn't work, should use setSelection()
                    listView.setSelection(initialPosition);
                }
            });
        }
        listView.setScrollViewCallbacks((ObservableScrollViewCallbacks) parentActivity);
    }
    return view;
}
 
开发者ID:brucetoo,项目名称:Android-ObservableScrollView,代码行数:26,代码来源:ViewPagerTabListViewFragment.java

示例11: onMoveMotionEvent

import com.github.ksoichiro.android.observablescrollview.ScrollUtils; //导入依赖的package包/类
public void onMoveMotionEvent(MotionEvent ev, float diffX, float diffY) {
    float translationY = ScrollUtils.getFloat(ViewHelper.getTranslationY(touchInterceptionFrameLayout) + diffY, -scrollViewCanScrollHeight, 0);

    ViewHelper.setTranslationY(touchInterceptionFrameLayout, translationY);
    if (shouldStayViews != null && shouldStayViews.length > 0) {
        for (View v : shouldStayViews) {
            ViewHelper.setTranslationY(v, -translationY);
        }
    }
    requestRootLayout(translationY);
    onViewResize(translationY);
}
 
开发者ID:Grasea,项目名称:Grandroid2,代码行数:13,代码来源:SimpleObservableScrollHandler.java

示例12: onMoveMotionEvent

import com.github.ksoichiro.android.observablescrollview.ScrollUtils; //导入依赖的package包/类
@Override
public void onMoveMotionEvent(MotionEvent ev, float diffX, float diffY) {
    float translationY = ScrollUtils.getFloat(ViewHelper.getTranslationY(mInterceptionLayout) + diffY, -mToolbarView.getHeight(), 0);
    ViewHelper.setTranslationY(mInterceptionLayout, translationY);
    if (translationY < 0) {
        FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) mInterceptionLayout.getLayoutParams();
        lp.height = (int) (-translationY + getScreenHeight());
        mInterceptionLayout.requestLayout();
    }
}
 
开发者ID:LeMinhAn,项目名称:AndroidObservableScrollView-master,代码行数:11,代码来源:ViewPagerTab2Activity.java

示例13: onCreate

import com.github.ksoichiro.android.observablescrollview.ScrollUtils; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_stickyheaderrecyclerview);

    setSupportActionBar((Toolbar) findViewById(R.id.toolbar));

    mHeaderView = findViewById(R.id.header);
    ViewCompat.setElevation(mHeaderView, getResources().getDimension(R.dimen.toolbar_elevation));
    mToolbarView = findViewById(R.id.toolbar);

    mRecyclerView = (ObservableRecyclerView) findViewById(R.id.recycler);
    mRecyclerView.setScrollViewCallbacks(this);
    mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
    mRecyclerView.setHasFixedSize(false);
    View headerView = LayoutInflater.from(this).inflate(R.layout.recycler_header, null);
    setDummyDataWithHeader(mRecyclerView, headerView);

    ScrollUtils.addOnGlobalLayoutListener(mRecyclerView, new Runnable() {
        @Override
        public void run() {
            int count = mRecyclerView.getAdapter().getItemCount() - 1;
            int position = count == 0 ? 1 : count > 0 ? count : 0;
            mRecyclerView.scrollToPosition(position);
        }
    });
}
 
开发者ID:LeMinhAn,项目名称:AndroidObservableScrollView-master,代码行数:28,代码来源:ScrollFromBottomRecyclerViewActivity.java

示例14: onScrollChanged

import com.github.ksoichiro.android.observablescrollview.ScrollUtils; //导入依赖的package包/类
@Override
public void onScrollChanged(int scrollY, boolean firstScroll, boolean dragging) {
    int toolbarHeight = mToolbarView.getHeight();
    if (dragging || scrollY < toolbarHeight) {
        if (firstScroll) {
            float currentHeaderTranslationY = ViewHelper.getTranslationY(mHeaderView);
            if (-toolbarHeight < currentHeaderTranslationY && toolbarHeight < scrollY) {
                mBaseTranslationY = scrollY;
            }
        }
        float headerTranslationY = ScrollUtils.getFloat(-(scrollY - mBaseTranslationY), -toolbarHeight, 0);
        ViewPropertyAnimator.animate(mHeaderView).cancel();
        ViewHelper.setTranslationY(mHeaderView, headerTranslationY);
    }
}
 
开发者ID:LeMinhAn,项目名称:AndroidObservableScrollView-master,代码行数:16,代码来源:ScrollFromBottomRecyclerViewActivity.java

示例15: onCreate

import com.github.ksoichiro.android.observablescrollview.ScrollUtils; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_stickyheaderlistview);

    setSupportActionBar((Toolbar) findViewById(R.id.toolbar));

    mHeaderView = findViewById(R.id.header);
    ViewCompat.setElevation(mHeaderView, getResources().getDimension(R.dimen.toolbar_elevation));
    mToolbarView = findViewById(R.id.toolbar);

    mListView = (ObservableListView) findViewById(R.id.list);
    mListView.setScrollViewCallbacks(this);

    LayoutInflater inflater = LayoutInflater.from(this);
    mListView.addHeaderView(inflater.inflate(R.layout.padding, mListView, false)); // toolbar
    mListView.addHeaderView(inflater.inflate(R.layout.padding, mListView, false)); // sticky view
    setDummyData(mListView);

    ScrollUtils.addOnGlobalLayoutListener(mListView, new Runnable() {
        @Override
        public void run() {
            int count = mListView.getAdapter().getCount() - 1;
            int position = count == 0 ? 1 : count > 0 ? count : 0;
            mListView.smoothScrollToPosition(position);
            mListView.setSelection(position);
        }
    });
}
 
开发者ID:LeMinhAn,项目名称:AndroidObservableScrollView-master,代码行数:30,代码来源:ScrollFromBottomListViewActivity.java


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