Skip to content

Commit c2caea8

Browse files
committed
center 1 photo
1 parent d902a16 commit c2caea8

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

PowerFileExplorer/src/main/java/com/veinhorn/scrollgalleryview/ScrollGalleryView.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ public void onPageSelected(int pagerPos) {
329329
final int measuredWidth = getMeasuredWidth();
330330
final int mid = (measuredWidth - thumbnailSize) / 2;
331331
Log.d(TAG, "onPageSelected pagerPos " + pagerPos + ", mediaPos " + mediaPos + ", mid " + mid + ", childCount " + childCount);
332-
if ((mediaPos) <= childCount / 2 || sizeMediaFiles == 1) {
332+
if ((mediaPos) <= mid / thumbnailSize || sizeMediaFiles == 1) {
333333
thumbnailsRecyclerView.setPadding(Math.max(mid - (mediaPos) * thumbnailSize, 0), 0, 0, 0);
334334
} else if ((sizeMediaFiles - 1 - (mediaPos)) <= childCount / 2) {
335335
thumbnailsRecyclerView.setPadding(0, 0, Math.max(mid - (sizeMediaFiles - 1 - (mediaPos)) * thumbnailSize, 0), 0);
@@ -558,9 +558,9 @@ private void initializeViewPager() {
558558
viewPager.setAdapter(imageViewPagerAdapter);
559559
thumbnailRecyclerAdapter = new ThumbnailAdapter(mContext, mListOfMedia, thumbnailOnClickListener, thumbnailSize);//mimes, parentPath,
560560
thumbnailsRecyclerView.setAdapter(thumbnailRecyclerAdapter);
561-
//if (sizeMediaFiles == 1) {
562-
// thumbnailsRecyclerView.setPadding((getMeasuredWidth() - thumbnailSize) / 2, 0, 0, 0);
563-
//}
561+
if (sizeMediaFiles == 1) {
562+
thumbnailsRecyclerView.setPadding((getMeasuredWidth() - thumbnailSize) / 2, 0, 0, 0);
563+
}
564564
}
565565

566566
public void setCurrentItem(final int newPagerPos, boolean smoothScroll) {

0 commit comments

Comments
 (0)