Git Product home page Git Product logo

pager-layoutmanager's People

Contributors

gcssloop avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pager-layoutmanager's Issues

为什onBindViewHolder会被调用多次呢

在初始化加载的时候,比如我设置5分,15个item,第一次加第一页时,还没滑动onBindViewHolder方法就加载被调用12次,从postion = 0 到 11,也就是最后一页没有调用

recyclerview 嵌套在viewPager中如何处理滑动冲突

你好,我有一个顶部TabLayout,下面添加了一个ViewPager,在ViewPager里加载多个Fragment,然后每个Fragment中用recyclerview中添加完这个控件后,然后在滚动每个Fragment里面的recyclerView的时候 ,会触发外层viewpager的滚动事件,导致ViewPager的Fragment的切换,而不是每个Fragment里面recyclerView的一页页切换,我要实现的效果是滑动的时候先每个Fragment里面recyclerView里面一页页切换,切换到recyclerView最后一页的时候,引起viewPager的Fragment切换。怎么实现这个效果呢?

添加完依赖后,报错, 这是什么问题

Error:Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.

java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex

以上报错内容

没有适配ViewPager

没有适配ViewPager,在ViewPager中快速滚动可能没法触发RecyclerView滚动

高概率无法编译

Error:(276, 24) Failed to resolve: com.gcssloop.recyclerview:pagerlayoutmanager:2.3.7,高概率出现

Add a English Readme.MD.

I don't know the language in which readme is written. Please someone suitable write English Readme.MD

从左到右往回快速滑动失效

layoutManager.setPageListener(this); // 设置页面变化监听器
当以上这句代码被注释后,从左到右往回快速滑动,翻页无法触发
我以为,这句代码只是纯粹做页面变化监听,当我不想监听页面变化时,不设置也没问题
但事实上不设置监听器,layoutManager里面的部分逻辑也被跳过了,导致往回快速滑动失效

AutoSize

@OverRide
public void onLayoutChildren(RecyclerView.Recycler recycler, RecyclerView.State state) {

    // 如果是 preLayout 则不重新布局
    if (state.isPreLayout() || !state.didStructureChange()) {
        return;
    }

    if (getItemCount() == 0) {
        removeAndRecycleAllViews(recycler);
        // 页面变化回调
        setPageCount(0);
        setPageIndex(0, false);
        return;
    } else {
        setPageCount(getTotalPageCount());
        setPageIndex(getPageIndexByOffset(), false);
    }

    // 计算页面数量
    int mPageCount = getItemCount() / mOnePageSize;
    if (getItemCount() % mOnePageSize != 0) {
        mPageCount++;
    }

    // 计算可以滚动的最大数值,并对滚动距离进行修正
    if (canScrollHorizontally()) {
        mMaxScrollX = (mPageCount - 1) * getUsableWidth();
        mMaxScrollY = 0;
        if (mOffsetX > mMaxScrollX) {
            mOffsetX = mMaxScrollX;
        }
    } else {
        mMaxScrollX = 0;
        mMaxScrollY = (mPageCount - 1) * getUsableHeight();
        if (mOffsetY > mMaxScrollY) {
            mOffsetY = mMaxScrollY;
        }
    }

    // 接口回调
    // setPageCount(mPageCount);
    // setPageIndex(mCurrentPageIndex, false);

    if (mItemWidth <= 0) {
        mItemWidth = getUsableWidth() / mColumns;
    }
    if (mItemHeight <= 0) {
        mItemHeight = getUsableHeight() / mRows;
    }

    mWidthUsed = getUsableWidth() - mItemWidth;
    mHeightUsed = getUsableHeight() - mItemHeight;

    // 预存储两页的View显示区域
    for (int i = 0; i < mOnePageSize * 2; i++) {
        getItemFrameByPosition(i);
    }

    if (mOffsetX == 0 && mOffsetY == 0) {
        // 预存储View
        for (int i = 0; i < mOnePageSize; i++) {
            if (i >= getItemCount()) break; // 防止数据过少时导致数组越界异常
            View view = recycler.getViewForPosition(i);
            RecyclerView.LayoutParams lp = (RecyclerView.LayoutParams) view.getLayoutParams();
            lp.width = ScreenUtils.getScreenWidth() / mColumns  - (lp.leftMargin + lp.rightMargin) / 2;
            addView(view);
            measureChildWithMargins(view, mWidthUsed, mHeightUsed);
        }
    }

    // 回收和填充布局
    recycleAndFillItems(recycler, state, true);
}

@OverRide
public void onMeasure(RecyclerView.Recycler recycler, RecyclerView.State state, int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(recycler, state, widthMeasureSpec, heightMeasureSpec);
int widthsize = View.MeasureSpec.getSize(widthMeasureSpec); //取出宽度的确切数值
int widthmode = View.MeasureSpec.getMode(widthMeasureSpec); //取出宽度的测量模式

    // 将 wrap_content 转换为 match_parent
    if (widthmode != EXACTLY && widthsize > 0) {
        widthmode = EXACTLY;
    }
    final int heightMode = View.MeasureSpec.getMode(heightMeasureSpec);
    final int heightSize = View.MeasureSpec.getSize(heightMeasureSpec);
    int height = 0;
    //自适应高度
    for (int i = 0; i < getItemCount(); i++) {

        try {
            measureScrapChild(recycler, i,
                    widthMeasureSpec,
                    View.MeasureSpec.makeMeasureSpec(i, View.MeasureSpec.UNSPECIFIED),
                    mMeasuredDimension);
        } catch (IndexOutOfBoundsException e) {
            e.printStackTrace();
        }

        if (i == 0) {
            height = mMeasuredDimension[1];
        }
    }

    switch (heightMode) {
        case EXACTLY:
            height = heightSize;
        case View.MeasureSpec.AT_MOST:
        case View.MeasureSpec.UNSPECIFIED:
    }
    setMeasuredDimension(View.MeasureSpec.makeMeasureSpec(widthsize, widthmode), height - 200);
}

private int[] mMeasuredDimension = new int[2];
private void measureScrapChild(RecyclerView.Recycler recycler, int position, int widthSpec, int heightSpec, int[] measuredDimension) {
    View view = recycler.getViewForPosition(position);
    if (view != null) {
        RecyclerView.LayoutParams p = (RecyclerView.LayoutParams) view.getLayoutParams();
        int childHeightSpec = ViewGroup.getChildMeasureSpec(heightSpec,
                getPaddingTop() + getPaddingBottom(), p.height);
        view.measure(widthSpec, childHeightSpec);
        measuredDimension[0] = view.getMeasuredWidth() + p.leftMargin + p.rightMargin;
        measuredDimension[1] = view.getMeasuredHeight() + p.bottomMargin + p.topMargin;
        recycler.recycleView(view);
    }
}

加载图片错乱

我发现翻页的时候每次都会调用onBindViewHolder() 方法,导致加载图片混乱,怎么能让已经显示的页面,在翻页的时候不调用onBindViewHolder方法

[bug]具体描述如下

慢速滑动的时候,高概率会惯性的继续滑动一点,然后再复位。(用的demo测试的)

Show float number of pages

I need to show 1 row of elements but in this order: the first, and half of the second... or the first, the second and half of the third... but without loses the scale of the element... is possible to do that?
screenshot

notifyItemChanged 失效,无法刷新单条数据

notifyDataSetChanged是有效的,也就是做不到刷新单个item。
如果只是刷新数据,可以使用LiveData实现。但是,如果TextView的宽度是wrapcontent,字符长度变化的时候由于控件没刷新,所以就会出现字符被切掉的问题。

刷新单条item的bug

举个例子,当单击item要改变显示的文字时,此时调用了onLayoutChildren,会导致item显示错乱。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.