Giter Club home page Giter Club logo

recyclercoverflow's People

Contributors

bluemix avatar chenlittleping 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

recyclercoverflow's Issues

调用smoothScrollPosition滚动指定位置,会出现回滚到原来位置

你好,我用的平板横屏调试demo,出现这个问题。
我debug看了下,
位置0->位置1,正常调用smoothScrollToPosition
位置1->位置2,调用smoothScrollToPosition同时会调用scrollHorizontallyBy,导致mOffsetAll重新计算,导致滚动失败。
我尝试着在scrollHorizontallyBy 和 fixOffsetWhenFinishScroll方法里加个判断,return出去不触发,恢复正常使用。具体原因分析不出来。
我的修改:
` @OverRide
public int scrollHorizontallyBy(int dx, RecyclerView.Recycler recycler,
RecyclerView.State state) {
if (isSmoothScroll){
Log.e("isSmoothScroll" , "return");
return 0;
}
if (mAnimation != null && mAnimation.isRunning()) mAnimation.cancel();
int travel = dx;
if (!mIsLoop) { //非循环模式,限制滚动位置
if (dx + mOffsetAll < 0) {
travel = -mOffsetAll;
} else if (dx + mOffsetAll > getMaxOffset()){
travel = (int) (getMaxOffset() - mOffsetAll);
}
}
mOffsetAll += travel; //累计偏移量
layoutItems(recycler, state, dx > 0 ? SCROLL_TO_LEFT : SCROLL_TO_RIGHT);
return travel;
}
/**
* 修正停止滚动后,Item滚动到中间位置
/
private void fixOffsetWhenFinishScroll() {
if (isSmoothScroll){
Log.e("smoothScroll","return fixOffsetWhenFinishScroll");
return;
}
int scrollN = (int) (mOffsetAll * 1.0f / getIntervalDistance());
float moreDx = (mOffsetAll % getIntervalDistance());
double judgeDistance = getIntervalDistance() * 0.5;
if (Math.abs(moreDx) > judgeDistance) {
if (moreDx > 0) scrollN ++;
else scrollN --;
}
int finalOffset = (int) (scrollN * getIntervalDistance());
startScroll(mOffsetAll, finalOffset);
mSelectPosition = Math.abs(Math.round (finalOffset * 1.0f / getIntervalDistance())) % getItemCount();
}
/
*
* 滚动到指定X轴位置
* @param from X轴方向起始点的偏移量
* @param to X轴方向终点的偏移量
*/
private isSmoothScroll = false;
private void startScroll(int from, int to) {
if (mAnimation != null && mAnimation.isRunning()) {
mAnimation.cancel();
}
final int direction = from < to ? SCROLL_TO_LEFT : SCROLL_TO_RIGHT;
mAnimation = ValueAnimator.ofFloat(from, to);
mAnimation.setDuration(500);
mAnimation.setInterpolator(new DecelerateInterpolator());
mAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@OverRide
public void onAnimationUpdate(ValueAnimator animation) {
mOffsetAll = Math.round((float) animation.getAnimatedValue());
layoutItems(mRecycle, mState, direction);
}
});
mAnimation.addListener(new Animator.AnimatorListener() {
@OverRide
public void onAnimationStart(Animator animation) {
}

        @Override
        public void onAnimationEnd(Animator animation) {
            onSelectedCallBack();
            isSmoothScroll = false;
        }

        @Override
        public void onAnimationCancel(Animator animation) {

        }

        @Override
        public void onAnimationRepeat(Animator animation) {

        }
    });
    mAnimation.start();
}

@OverRide
public void smoothScrollToPosition(RecyclerView recyclerView, RecyclerView.State state, int position) {
// TODO 循环模式暂不支持平滑滚动

    if (mIsLoop) return;
    int finalOffset = calculateOffsetForPosition(position);
    if (mRecycle == null || mState == null) {//如果RecyclerView还没初始化完,先记录下要滚动的位置
        mSelectPosition = position;
    } else {
        startScroll(mOffsetAll, finalOffset);
        isSmoothScroll = true;
    }
}

`

adapter.notifyDataSetChanged()

当删除其中某一张图片时,如果是从后面往前删除后不会默认滑动到它的前张,而且删除最后一张的时候会出现下标越界异常。adapter.notifyDataSetChangerd()后就会出现上述情况

最中间的item被它右边小的item盖住,层次不是在最上面

故障复现:
1)将item间隔因数设置为0.62f, 同时将RecyclerCoverFlow高度设置为140dp,宽度充满. adapteer的item宽高设置为120dp. 这样刚好让屏幕上只显示5个item.
2)故障规律:在滑动RecyclerCoverFlow停止后,如果停止item position正好是5的倍数余1.(是以Demo中position从1开始计算) bug就会复现.
例如每屏item数量为5个, Demo滑动停止后的item position为6, 11 ,16, 21,31,36等等, 最中间的item都会被右边的item (第7,12 , 17, 22, 32,37)所盖住一部分,也就是最中间的item层级不是在最上层.
补充: 将间隔因数设置为0.6f,就不会复现这种问题

屏幕适配方案

需求: 在屏幕上只想显示五个item.
解决方案: 根据自身item的宽和设置item间隔因数,来调整显示在屏幕上面的个数. 设定好只显示五个item.
但是由于屏幕的像素密度不一致的问题. 会导致部分手机上显示不同, 可能会显示七个或是更多.
例如乐视 Le x260手机 1dp = 2.625px. 它比其它手机可能会多显示两个或是更多.

推荐使用张鸿洋的AndroidAutoLayout库.
https://github.com/hongyangAndroid/AndroidAutoLayout
对它的item进行尺寸适配, 所有屏幕基上就长的一样了, 这样下来就可以完美解决了

Fatal Exception: java.lang.NullPointerException

Fatal Exception: java.lang.NullPointerException
Attempt to invoke virtual method 'boolean androidx.recyclerview.widget.RecyclerView$State.isPreLayout()' on a null object reference
recycler.coverflow.CoverFlowLayoutManger.layoutItems (CoverFlowLayoutManger.java:184)
recycler.coverflow.CoverFlowLayoutManger.access$300 (CoverFlowLayoutManger.java:28)
recycler.coverflow.CoverFlowLayoutManger$1.onAnimationUpdate (CoverFlowLayoutManger.java:448)
android.animation.ValueAnimator.animateValue (ValueAnimator.java:1558)
com.android.internal.os.ZygoteInit.main (ZygoteInit.java:950)

how to make indicator with the recycle cover flow

how to make indicator with the recycle cover flow?
i'm tried to add to LinePagerIndicatorDecoration when using addItemDecoration, after casting the layout with CoverFlowLayoutManger, i have a problem when findFirstVisibleItemPosition !!!!

how to make a Dots indicator decoration in the bottom

CoverFlowLayoutManger中mSlectPositon计算存在bug

CoverFlowLayoutManger中mSlectPositon计算存在bug
private void onSelectedCallBack() {
mSelectPosition = Math.round (mOffsetAll / getIntervalDistance());
mSelectPosition = Math.abs(mSelectPosition % getItemCount());
if (mSelectedListener != null && mSelectPosition != mLastSelectPosition) {
mSelectedListener.onItemSelected(mSelectPosition);
}
mLastSelectPosition = mSelectPosition;
}

当mSelectPositon为负数时,会出现位置对不上,比如我有5个条目,当mSelectPosition为-6,Math.abs(mSelectPosition % getItemCount())计算结果为1,但事实对应的条目应该是4,当mSelectPosition为负数时正确的位置计算应该为应为
mSelectPosition = 条目个数和(list.size())+mSelectPosition % getItemCount()

添加灰度后,边缘多了黑色的线

不好意思 大神 又来麻烦你了,我发现加入灰度之后,图片的边框多了黑色的线,看下边的截图
image

希望大神能抽空帮忙看看 怎么解决下

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.