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


Java ScrollUtils.addOnGlobalLayoutListener方法代码示例

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


在下文中一共展示了ScrollUtils.addOnGlobalLayoutListener方法的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: 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

示例4: 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

示例5: 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

示例6: 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

示例7: onCreate

import com.github.ksoichiro.android.observablescrollview.ScrollUtils; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    final ObservableListView scrollable = (ObservableListView) findViewById(R.id.scrollable);
    ScrollUtils.addOnGlobalLayoutListener(scrollable, new Runnable() {
        @Override
        public void run() {
            int count = scrollable.getAdapter().getCount() - 1;
            int position = count == 0 ? 1 : count > 0 ? count : 0;
            scrollable.smoothScrollToPosition(position);
            scrollable.setSelection(position);
        }
    });
}
 
开发者ID:LeMinhAn,项目名称:AndroidObservableScrollView-master,代码行数:15,代码来源:ListViewScrollFromBottomActivity.java

示例8: 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

示例9: onCreate

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

    mFlexibleSpaceImageHeight = getResources().getDimensionPixelSize(R.dimen.flexible_space_image_height);
    mActionBarSize = getActionBarSize();

    // Even when the top gap has began to change, header bar still can move
    // within mIntersectionHeight.
    mIntersectionHeight = getResources().getDimensionPixelSize(R.dimen.intersection_height);

    mImage = findViewById(R.id.image);
    mHeader = findViewById(R.id.header);
    mHeaderBar = findViewById(R.id.header_bar);
    mHeaderBackground = findViewById(R.id.header_background);
    mListBackgroundView = findViewById(R.id.list_background);

    final S scrollable = createScrollable();

    ((TextView) findViewById(R.id.title)).setText(getTitle());
    setTitle(null);

    ScrollUtils.addOnGlobalLayoutListener((View) scrollable, new Runnable() {
        @Override
        public void run() {
            mReady = true;
            updateViews(scrollable.getCurrentScrollY(), false);
        }
    });
}
 
开发者ID:LeMinhAn,项目名称:AndroidObservableScrollView-master,代码行数:32,代码来源:FillGapBaseActivity.java

示例10: onCreate

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

    mPagerAdapter = new NavigationAdapter(getSupportFragmentManager());
    mPager = (ViewPager) findViewById(R.id.pager);
    mPager.setAdapter(mPagerAdapter);
    mFlexibleSpaceHeight = getResources().getDimensionPixelSize(R.dimen.flexible_space_image_height);
    mTabHeight = getResources().getDimensionPixelSize(R.dimen.tab_height);

    TextView titleView = (TextView) findViewById(R.id.title);
    titleView.setText(R.string.title_activity_flexiblespacewithimagewithviewpagertab);

    mSlidingTabLayout = (SlidingTabLayout) findViewById(R.id.sliding_tabs);
    mSlidingTabLayout.setCustomTabView(R.layout.tab_indicator, android.R.id.text1);
    mSlidingTabLayout.setSelectedIndicatorColors(getResources().getColor(R.color.accent));
    mSlidingTabLayout.setDistributeEvenly(true);
    mSlidingTabLayout.setViewPager(mPager);

    // Initialize the first Fragment's state when layout is completed.
    ScrollUtils.addOnGlobalLayoutListener(mSlidingTabLayout, new Runnable() {
        @Override
        public void run() {
            translateTab(0, false);
        }
    });
}
 
开发者ID:LeMinhAn,项目名称:AndroidObservableScrollView-master,代码行数:29,代码来源:FlexibleSpaceWithImageWithViewPagerTabActivity.java

示例11: 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_gridview, container, false);

    Activity parentActivity = getActivity();
    final ObservableGridView gridView = (ObservableGridView) view.findViewById(R.id.scroll);
    setDummyDataWithHeader(gridView, inflater.inflate(R.layout.padding, gridView, false));

    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(gridView, new Runnable() {
                @Override
                public void run() {
                    // scrollTo() doesn't work, should use setSelection()
                    gridView.setSelection(initialPosition);
                }
            });
        }

        // TouchInterceptionViewGroup should be a parent view other than ViewPager.
        // This is a workaround for the issue #117:
        // https://github.com/ksoichiro/Android-ObservableScrollView/issues/117
        gridView.setTouchInterceptionViewGroup((ViewGroup) parentActivity.findViewById(R.id.root));

        gridView.setScrollViewCallbacks((ObservableScrollViewCallbacks) parentActivity);
    }
    return view;
}
 
开发者ID:LeMinhAn,项目名称:AndroidObservableScrollView-master,代码行数:32,代码来源:ViewPagerTabGridViewFragment.java

示例12: 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_recyclerview, container, false);

    Activity parentActivity = getActivity();
    final ObservableRecyclerView recyclerView = (ObservableRecyclerView) view.findViewById(R.id.scroll);
    recyclerView.setLayoutManager(new LinearLayoutManager(parentActivity));
    recyclerView.setHasFixedSize(false);
    View headerView = LayoutInflater.from(parentActivity).inflate(R.layout.padding, null);
    setDummyDataWithHeader(recyclerView, headerView);

    if (parentActivity instanceof ObservableScrollViewCallbacks) {
        // Scroll to the specified offset after layout
        Bundle args = getArguments();
        if (args != null && args.containsKey(ARG_INITIAL_POSITION)) {
            final int initialPosition = args.getInt(ARG_INITIAL_POSITION, 0);
            ScrollUtils.addOnGlobalLayoutListener(recyclerView, new Runnable() {
                @Override
                public void run() {
                    recyclerView.scrollVerticallyToPosition(initialPosition);
                }
            });
        }

        // TouchInterceptionViewGroup should be a parent view other than ViewPager.
        // This is a workaround for the issue #117:
        // https://github.com/ksoichiro/Android-ObservableScrollView/issues/117
        recyclerView.setTouchInterceptionViewGroup((ViewGroup) parentActivity.findViewById(R.id.root));

        recyclerView.setScrollViewCallbacks((ObservableScrollViewCallbacks) parentActivity);
    }
    return view;
}
 
开发者ID:LeMinhAn,项目名称:AndroidObservableScrollView-master,代码行数:34,代码来源:ViewPagerTabRecyclerViewFragment.java

示例13: 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, listView, false));

    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);
                }
            });
        }

        // TouchInterceptionViewGroup should be a parent view other than ViewPager.
        // This is a workaround for the issue #117:
        // https://github.com/ksoichiro/Android-ObservableScrollView/issues/117
        listView.setTouchInterceptionViewGroup((ViewGroup) parentActivity.findViewById(R.id.root));

        listView.setScrollViewCallbacks((ObservableScrollViewCallbacks) parentActivity);
    }
    return view;
}
 
开发者ID:LeMinhAn,项目名称:AndroidObservableScrollView-master,代码行数:32,代码来源:ViewPagerTabListViewFragment.java

示例14: 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_flexiblespacewithimagerecyclerview, container, false);

    final ObservableRecyclerView recyclerView = (ObservableRecyclerView) view.findViewById(R.id.scroll);
    recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
    recyclerView.setHasFixedSize(false);
    final View headerView = LayoutInflater.from(getActivity()).inflate(R.layout.recycler_header, null);
    final int flexibleSpaceImageHeight = getResources().getDimensionPixelSize(R.dimen.flexible_space_image_height);
    headerView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, flexibleSpaceImageHeight));
    setDummyDataWithHeader(recyclerView, headerView);

    // TouchInterceptionViewGroup should be a parent view other than ViewPager.
    // This is a workaround for the issue #117:
    // https://github.com/ksoichiro/Android-ObservableScrollView/issues/117
    recyclerView.setTouchInterceptionViewGroup((ViewGroup) view.findViewById(R.id.fragment_root));

    // 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(recyclerView, new Runnable() {
            @Override
            public void run() {
                int offset = scrollY % flexibleSpaceImageHeight;
                RecyclerView.LayoutManager lm = recyclerView.getLayoutManager();
                if (lm != null && lm instanceof LinearLayoutManager) {
                    ((LinearLayoutManager) lm).scrollToPositionWithOffset(0, -offset);
                }
            }
        });
        updateFlexibleSpace(scrollY, view);
    } else {
        updateFlexibleSpace(0, view);
    }

    recyclerView.setScrollViewCallbacks(this);

    return view;
}
 
开发者ID:LeMinhAn,项目名称:AndroidObservableScrollView-master,代码行数:41,代码来源:FlexibleSpaceWithImageRecyclerViewFragment.java

示例15: 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_flexiblespacewithimagescrollview, container, false);

    final ObservableScrollView scrollView = (ObservableScrollView) view.findViewById(R.id.scroll);
    // TouchInterceptionViewGroup should be a parent view other than ViewPager.
    // This is a workaround for the issue #117:
    // https://github.com/ksoichiro/Android-ObservableScrollView/issues/117
    scrollView.setTouchInterceptionViewGroup((ViewGroup) view.findViewById(R.id.fragment_root));

    // 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);
            }
        });
        updateFlexibleSpace(scrollY, view);
    } else {
        updateFlexibleSpace(0, view);
    }

    scrollView.setScrollViewCallbacks(this);

    return view;
}
 
开发者ID:LeMinhAn,项目名称:AndroidObservableScrollView-master,代码行数:30,代码来源:FlexibleSpaceWithImageScrollViewFragment.java


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