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 new file mode 100644 index 000000000..a29ffe115 --- /dev/null +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/PortraitPhotosAdapter.kt @@ -0,0 +1,59 @@ +package com.simplemobiletools.gallery.pro.adapters + +import android.content.Context +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import androidx.recyclerview.widget.RecyclerView +import com.bumptech.glide.Glide +import com.bumptech.glide.load.engine.DiskCacheStrategy +import com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions +import com.bumptech.glide.request.RequestOptions +import com.bumptech.glide.signature.ObjectKey +import com.simplemobiletools.commons.extensions.getFileKey +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 itemClick: (Int) -> Unit) : RecyclerView.Adapter() { + + private var currentSelection = photos.first() + private var strokeBackground = context.resources.getDrawable(R.drawable.stroke_background) + + override fun onBindViewHolder(holder: ViewHolder, position: Int) { + holder.bindView(photos[position]) + } + + override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder { + val view = LayoutInflater.from(parent.context).inflate(R.layout.portrait_photo_item, parent, false) + return ViewHolder(view) + } + + override fun getItemCount() = photos.size + + fun getCurrentPhoto() = currentSelection + + inner class ViewHolder(view: View) : RecyclerView.ViewHolder(view) { + fun bindView(photo: String): View { + itemView.apply { + portrait_photo_item_thumbnail.background = if (getCurrentPhoto() == photo) { + strokeBackground + } else { + null + } + + val options = RequestOptions() + .signature(ObjectKey(photo.getFileKey())) + .diskCacheStrategy(DiskCacheStrategy.RESOURCE) + .centerCrop() + + Glide.with(context) + .load(photo) + .transition(DrawableTransitionOptions.withCrossFade()) + .apply(options) + .into(portrait_photo_item_thumbnail) + } + 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 1dca82751..eb44f7d97 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 @@ -41,6 +41,7 @@ import com.simplemobiletools.commons.helpers.ensureBackgroundThread import com.simplemobiletools.gallery.pro.R import com.simplemobiletools.gallery.pro.activities.PanoramaPhotoActivity import com.simplemobiletools.gallery.pro.activities.PhotoActivity +import com.simplemobiletools.gallery.pro.adapters.PortraitPhotosAdapter import com.simplemobiletools.gallery.pro.extensions.* import com.simplemobiletools.gallery.pro.helpers.* import com.simplemobiletools.gallery.pro.models.Medium @@ -452,6 +453,15 @@ class PhotoFragment : ViewPagerFragment() { } (mView.photo_portrait_stripe_wrapper.layoutParams as RelativeLayout.LayoutParams).bottomMargin = bottomMargin mView.photo_portrait_stripe_wrapper.beVisible() + + val files = File(mMedium.parentPath).listFiles()?.toMutableList() as? ArrayList + if (files != null) { + val paths = files.map { it.absolutePath }.toMutableList() as ArrayList + val adapter = PortraitPhotosAdapter(context!!, paths) { + + } + mView.photo_portrait_stripe.adapter = adapter + } } private fun openPanorama() { diff --git a/app/src/main/res/layout/portrait_photo_item.xml b/app/src/main/res/layout/portrait_photo_item.xml new file mode 100644 index 000000000..3e0500cda --- /dev/null +++ b/app/src/main/res/layout/portrait_photo_item.xml @@ -0,0 +1,17 @@ + + + + + + diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml index a0c13e2e8..e7ea8b9e6 100644 --- a/app/src/main/res/values/dimens.xml +++ b/app/src/main/res/values/dimens.xml @@ -19,7 +19,7 @@ 90dp 98dp 180dp - 60dp + 48dp 86dp 110dp 40dp