Add some fake paddings to gallery preview
This commit is contained in:
2 files changed
+6
-6
No files matched your search
@@ -61,8 +61,6 @@ import com.hippo.yorozuya.ViewUtils;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Locale;
|
||||
|
||||
import rikka.recyclerview.RecyclerViewKt;
|
||||
|
||||
public class GalleryPreviewsScene extends ToolbarScene {
|
||||
|
||||
public static final String KEY_GALLERY_INFO = "gallery_info";
|
||||
@@ -148,7 +146,7 @@ public class GalleryPreviewsScene extends ToolbarScene {
|
||||
mAdapter = new GalleryPreviewAdapter();
|
||||
mRecyclerView.setAdapter(mAdapter);
|
||||
int columnWidth = resources.getDimensionPixelOffset(Settings.getThumbSizeResId());
|
||||
AutoGridLayoutManager layoutManager = new AutoGridLayoutManager(context, columnWidth);
|
||||
AutoGridLayoutManager layoutManager = new AutoGridLayoutManager(context, columnWidth, LayoutUtils.dp2pix(context, 16));
|
||||
layoutManager.setStrategy(AutoGridLayoutManager.STRATEGY_SUITABLE_SIZE);
|
||||
mRecyclerView.setLayoutManager(layoutManager);
|
||||
mRecyclerView.setClipToPadding(false);
|
||||
|
||||
@@ -32,11 +32,13 @@ public class AutoGridLayoutManager extends GridLayoutManager {
|
||||
private int mColumnSize = -1;
|
||||
private boolean mColumnSizeChanged = true;
|
||||
private int mStrategy;
|
||||
private int fakePadding;
|
||||
|
||||
private List<OnUpdateSpanCountListener> mListeners;
|
||||
|
||||
public AutoGridLayoutManager(Context context, int columnSize) {
|
||||
public AutoGridLayoutManager(Context context, int columnSize, int fakePadding) {
|
||||
super(context, 1);
|
||||
this.fakePadding = fakePadding;
|
||||
setColumnSize(columnSize);
|
||||
}
|
||||
|
||||
@@ -81,9 +83,9 @@ public class AutoGridLayoutManager extends GridLayoutManager {
|
||||
if (mColumnSizeChanged && mColumnSize > 0) {
|
||||
int totalSpace;
|
||||
if (getOrientation() == RecyclerView.VERTICAL) {
|
||||
totalSpace = getWidth() - getPaddingRight() - getPaddingLeft();
|
||||
totalSpace = getWidth() - getPaddingRight() - getPaddingLeft() - fakePadding;
|
||||
} else {
|
||||
totalSpace = getHeight() - getPaddingTop() - getPaddingBottom();
|
||||
totalSpace = getHeight() - getPaddingTop() - getPaddingBottom() - fakePadding;
|
||||
}
|
||||
|
||||
int spanCount;
|
||||
|
||||
Reference in new issue
Block a user