Skip to content
This repository was archived by the owner on Oct 19, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,11 @@ public void onScrolled(RecyclerView recyclerView, final int dx, final int dy) {
// so you should bind it as early as possible

if(ViewCompat.isInLayout(recyclerView) && mComponentRef != null && mComponentRef.get() != null) {
mContentOffsetY = Math.abs(mComponentRef.get().calcContentOffset(recyclerView));
if (RecycleUtil.recyclerVerticalScrollOffset(recyclerView) != 0){
mContentOffsetY = Math.abs(mComponentRef.get().calcContentOffset(recyclerView));
} else {
mContentOffsetY = 0;
}
} else {
mContentOffsetY += dy;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.alibaba.android.bindingx.plugin.weex;

import android.support.annotation.NonNull;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.StaggeredGridLayoutManager;
import android.view.View;

public class RecycleUtil {
public static int recyclerVerticalScrollOffset(@NonNull RecyclerView recyclerView) {
if (recyclerView.getLayoutManager() instanceof LinearLayoutManager) {
LinearLayoutManager manager = (LinearLayoutManager) recyclerView.getLayoutManager();
int position = manager.findFirstVisibleItemPosition();
View firstItemView = manager.findViewByPosition(position);
return firstItemView.getTop();
} else if (recyclerView.getLayoutManager() instanceof StaggeredGridLayoutManager) {
StaggeredGridLayoutManager manager = (StaggeredGridLayoutManager) recyclerView.getLayoutManager();
int[] firstVisibleItems = manager.findFirstVisibleItemPositions(null);
if (firstVisibleItems.length > 0) {
View firstItemView = manager.findViewByPosition(firstVisibleItems[0]);
return firstItemView.getTop();
}
}
return recyclerView.computeVerticalScrollOffset();
}
}