add portrait photos on a stripe

This commit is contained in:
tibbi 2019-10-02 11:46:09 +02:00
parent f1a4e21d94
commit 3ed598c2fd
4 changed files with 87 additions and 1 deletions

View File

@ -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<String>, val itemClick: (Int) -> Unit) : RecyclerView.Adapter<PortraitPhotosAdapter.ViewHolder>() {
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
}
}
}

View File

@ -41,6 +41,7 @@ import com.simplemobiletools.commons.helpers.ensureBackgroundThread
import com.simplemobiletools.gallery.pro.R import com.simplemobiletools.gallery.pro.R
import com.simplemobiletools.gallery.pro.activities.PanoramaPhotoActivity import com.simplemobiletools.gallery.pro.activities.PanoramaPhotoActivity
import com.simplemobiletools.gallery.pro.activities.PhotoActivity 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.extensions.*
import com.simplemobiletools.gallery.pro.helpers.* import com.simplemobiletools.gallery.pro.helpers.*
import com.simplemobiletools.gallery.pro.models.Medium 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.layoutParams as RelativeLayout.LayoutParams).bottomMargin = bottomMargin
mView.photo_portrait_stripe_wrapper.beVisible() mView.photo_portrait_stripe_wrapper.beVisible()
val files = File(mMedium.parentPath).listFiles()?.toMutableList() as? ArrayList<File>
if (files != null) {
val paths = files.map { it.absolutePath }.toMutableList() as ArrayList<String>
val adapter = PortraitPhotosAdapter(context!!, paths) {
}
mView.photo_portrait_stripe.adapter = adapter
}
} }
private fun openPanorama() { private fun openPanorama() {

View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/portrait_photo_item_holder"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="1dp"
android:layout_marginEnd="1dp">
<ImageView
android:id="@+id/portrait_photo_item_thumbnail"
android:layout_width="@dimen/portrait_photos_stripe_height"
android:layout_height="@dimen/portrait_photos_stripe_height"
android:background="@drawable/stroke_background"
android:contentDescription="@null"
android:padding="1dp" />
</RelativeLayout>

View File

@ -19,7 +19,7 @@
<dimen name="bottom_filters_height">90dp</dimen> <dimen name="bottom_filters_height">90dp</dimen>
<dimen name="bottom_filters_height_with_margin">98dp</dimen> <dimen name="bottom_filters_height_with_margin">98dp</dimen>
<dimen name="bottom_editor_actions_shadow_height">180dp</dimen> <dimen name="bottom_editor_actions_shadow_height">180dp</dimen>
<dimen name="portrait_photos_stripe_height">60dp</dimen> <dimen name="portrait_photos_stripe_height">48dp</dimen>
<dimen name="default_status_action_height">86dp</dimen> <dimen name="default_status_action_height">86dp</dimen>
<dimen name="widget_initial_size">110dp</dimen> <dimen name="widget_initial_size">110dp</dimen>
<dimen name="full_brush_size">40dp</dimen> <dimen name="full_brush_size">40dp</dimen>