kHRYSTAL / CircleRecyclerView

the library is a loop RecyclerView(expression), can show some effects when display
714 stars 100 forks source link

第一次没有默认选中 #1

Closed huyanghu closed 7 years ago

huyanghu commented 8 years ago

第一次不滑动 ,点击中间的view 没有响应

huyanghu commented 8 years ago

还行不行的,第一次不滑动,点击中间的view还是没有响应,你测试一下吧.

huyanghu commented 8 years ago

还有就是不循环滚动,起始的view,终止的view都无法滚动到中间位置

kHRYSTAL commented 8 years ago

huyanghu commented 8 years ago

横向的第一次不滑动 ,点击中间的view 没有响应

kHRYSTAL commented 8 years ago

The emulator display well I thought maybe when onLayout() called the centerItem was in center, and distance is zero, it's can not called onScrollStateChanged(state)

so I update these:

 @Override
    protected void onLayout(boolean changed, int l, int t, int r, int b) {
        super.onLayout(changed, l, t, r, b);
        if (mNeedLoop) {
            scrollToPosition(DEFAULT_SELECTION);
            if (isFirstOnLayout) {
                mCurrentCenterChildView = findViewAtCenter();
                smoothScrollToView(mCurrentCenterChildView);
            }
        } else if (!mNeedLoop && mNeedCenterForce) {
            if (isFirstOnLayout) {
                LinearLayoutManager layoutManager = (LinearLayoutManager) getLayoutManager();
                if (layoutManager.canScrollHorizontally())
                    setPadding(getWidth() / 2, 0, getWidth() / 2, 0);
                else if (layoutManager.canScrollVertically())
                    setPadding(0, getHeight() / 2, 0, getHeight() / 2);
                setClipToPadding(false);
                setClipChildren(false);
                isFirstOnLayout = false;
                mCurrentCenterChildView = findViewAtCenter();
                smoothScrollToView(mCurrentCenterChildView);
            }
        }
        if (isFirstOnLayout) {
            isFirstOnLayout = false;
            if (mCenterItemClickListener != null && mCurrentCenterChildView != null)
                mCurrentCenterChildView.setOnClickListener(new OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        mCenterItemClickListener.onCenterItemClick(v);
                    }
                });
        }
    }

you can try again, thanks for reply :-)

huyanghu commented 8 years ago

横竖都一样,第一次不滑动,点击是不响应的, 只有轻轻的滑动一点就有响应了,

huyanghu commented 8 years ago

noloopButCenterForce 选项,第一次点击有响应是,你打开的时候,它上下滑动了一下,你自己观察就能看出来,

kHRYSTAL commented 8 years ago

@huyanghu I use real phone find this problem, onLayout() not work at first time and test real phone are flymeOS 5.1.17a(note2) and 1+(A1001) 1+ not work but flyme works well so and thought it is os problem , I delete that judgement in onLayout() and scrollToView is cause by smoothScrollBy(x, y) , this method is necessary

thanks for reply :-)