Skip to content

Commit

Permalink
Add image transition
Browse files Browse the repository at this point in the history
Allow focus on screenshots with dpad
  • Loading branch information
Iamlooker committed Nov 19, 2023
1 parent fd043dc commit 1b7a321
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class AppDetailAdapter(private val callbacks: Callbacks) :
fun onFavouriteClicked()
fun onPreferenceChanged(preference: ProductPreference)
fun onPermissionsClick(group: String?, permissions: List<String>)
fun onScreenshotClick(screenshot: Product.Screenshot)
fun onScreenshotClick(screenshot: Product.Screenshot, parentView: ImageView)
fun onReleaseClick(release: Release)
fun onRequestAddRepository(address: String)
fun onUriClick(uri: Uri, shouldConfirm: Boolean): Boolean
Expand Down Expand Up @@ -1407,7 +1407,9 @@ class AppDetailAdapter(private val callbacks: Callbacks) :
layoutManager =
LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false)
adapter =
ScreenshotsAdapter { callbacks.onScreenshotClick(it) }.apply {
ScreenshotsAdapter { screenshot, view ->
callbacks.onScreenshotClick(screenshot, view)
}.apply {
setScreenshots(item.repository, item.packageName, item.screenshots)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import android.os.Bundle
import android.provider.Settings
import android.view.MenuItem
import android.view.View
import android.widget.ImageView
import androidx.appcompat.app.AlertDialog
import androidx.core.net.toUri
import androidx.core.os.bundleOf
Expand Down Expand Up @@ -431,7 +432,7 @@ class AppDetailFragment() : ScreenFragment(), AppDetailAdapter.Callbacks {
.show(childFragmentManager)
}

override fun onScreenshotClick(screenshot: Product.Screenshot) {
override fun onScreenshotClick(screenshot: Product.Screenshot, parentView: ImageView) {
val product = products
.firstOrNull { (product, _) ->
product.screenshots.find { it === screenshot }?.identifier != null
Expand All @@ -443,6 +444,7 @@ class AppDetailFragment() : ScreenFragment(), AppDetailAdapter.Callbacks {
.Builder(context, screenshots) { view, current ->
view.load(current.url(product.second, viewModel.packageName))
}
.withTransitionFrom(parentView)
.withStartPosition(position)
.show()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ package com.looker.droidify.ui.appDetail
import android.content.Context
import android.graphics.drawable.Drawable
import android.view.Gravity
import android.view.View
import android.view.ViewGroup
import android.widget.FrameLayout
import android.widget.ImageView
import androidx.recyclerview.widget.RecyclerView
import coil.load
import coil.size.Scale
Expand All @@ -23,7 +25,7 @@ import com.looker.droidify.graphics.PaddingDrawable
import com.looker.droidify.utility.extension.ImageUtils.url
import com.looker.droidify.widget.StableRecyclerAdapter

class ScreenshotsAdapter(private val onClick: (Product.Screenshot) -> Unit) :
class ScreenshotsAdapter(private val onClick: (Product.Screenshot, ImageView) -> Unit) :
StableRecyclerAdapter<ScreenshotsAdapter.ViewType, RecyclerView.ViewHolder>() {
enum class ViewType { SCREENSHOT }

Expand Down Expand Up @@ -51,6 +53,7 @@ class ScreenshotsAdapter(private val onClick: (Product.Screenshot) -> Unit) :
with(image) {
shapeAppearanceModel = imageShapeModel
background = context.selectableBackground
isFocusable = true
}
with(itemView as FrameLayout) {
layoutParams = RecyclerView.LayoutParams(
Expand Down Expand Up @@ -88,7 +91,7 @@ class ScreenshotsAdapter(private val onClick: (Product.Screenshot) -> Unit) :
viewType: ViewType
): RecyclerView.ViewHolder {
return ViewHolder(parent.context).apply {
image.setOnClickListener { onClick(items[absoluteAdapterPosition].screenshot) }
image.setOnClickListener { onClick(items[absoluteAdapterPosition].screenshot, it as ImageView) }
}
}

Expand Down

0 comments on commit 1b7a321

Please sign in to comment.