diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/PortraitPhotosAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/PortraitPhotosAdapter.kt index 983ea00a2..aa4666cbf 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/PortraitPhotosAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/PortraitPhotosAdapter.kt @@ -15,7 +15,7 @@ import com.simplemobiletools.gallery.pro.R import kotlinx.android.synthetic.main.portrait_photo_item.view.* import java.util.* -class PortraitPhotosAdapter(val context: Context, val photos: ArrayList, val sideElementWidth: Int, val itemClick: (Int) -> Unit) : +class PortraitPhotosAdapter(val context: Context, val photos: ArrayList, val sideElementWidth: Int, val itemClick: (Int, Int) -> Unit) : RecyclerView.Adapter() { private var currentSelection = photos.firstOrNull { it.contains("cover", true) } ?: photos.firstOrNull { it.isNotEmpty() } @@ -60,6 +60,14 @@ class PortraitPhotosAdapter(val context: Context, val photos: ArrayList, .transition(DrawableTransitionOptions.withCrossFade()) .apply(options) .into(portrait_photo_item_thumbnail) + + if (photo.isNotEmpty()) { + setOnClickListener { + itemClick(position, x.toInt()) + } + } else { + setOnClickListener(null) + } } return itemView } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/fragments/PhotoFragment.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/fragments/PhotoFragment.kt index ffc8d4a2a..c1401fe21 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/fragments/PhotoFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/fragments/PhotoFragment.kt @@ -458,7 +458,7 @@ class PhotoFragment : ViewPagerFragment() { val files = File(mMedium.parentPath).listFiles()?.toMutableList() as? ArrayList if (files != null) { val screenWidth = context!!.realScreenSize.x - val itemWidth = context!!.resources.getDimension(R.dimen.portrait_photos_stripe_height) + context!!.resources.getDimension(R.dimen.one_dp) + val itemWidth = context!!.resources.getDimension(R.dimen.portrait_photos_stripe_height).toInt() + context!!.resources.getDimension(R.dimen.one_dp).toInt() val sideWidth = screenWidth / 2 - itemWidth / 2 val fakeItemsCnt = ceil(sideWidth / itemWidth.toDouble()).toInt() @@ -480,8 +480,10 @@ class PhotoFragment : ViewPagerFragment() { curWidth += itemWidth } - val sideElementWidth = curWidth.toInt() - screenWidth - val adapter = PortraitPhotosAdapter(context!!, paths, sideElementWidth) { + val sideElementWidth = curWidth - screenWidth + val adapter = PortraitPhotosAdapter(context!!, paths, sideElementWidth) { position, x -> + mView.photo_portrait_stripe.smoothScrollBy((x + itemWidth / 2) - screenWidth / 2, 0) + } mView.photo_portrait_stripe.adapter = adapter