Skip to content

Commit

Permalink
fix demo transition bug
Browse files Browse the repository at this point in the history
  • Loading branch information
iielse committed Nov 27, 2021
1 parent e6c6343 commit 361a615
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.github.iielse.imageviewer.demo.business
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import com.github.iielse.imageviewer.demo.core.BasePagedAdapter
import com.github.iielse.imageviewer.demo.core.viewer.ViewerTransitionHelper
import com.github.iielse.imageviewer.demo.data.MyData

class TestDataAdapter : BasePagedAdapter() {
Expand All @@ -19,4 +20,12 @@ class TestDataAdapter : BasePagedAdapter() {
is TestDataViewHolder -> item?.data<MyData>()?.let { holder.bind(it, position) }
}
}

override fun onViewAttachedToWindow(holder: RecyclerView.ViewHolder) {
super.onViewAttachedToWindow(holder)
if (holder is TestDataViewHolder) {
val photoId = (holder.itemView.tag as? MyData?)?.id ?: return
ViewerTransitionHelper.put(photoId, holder.binding.imageView)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class TestDataViewHolder(
binding.imageView.scaleType = if (pos == 19) ImageView.ScaleType.FIT_XY else ImageView.ScaleType.CENTER_CROP

Glide.with(binding.imageView).load(item.url).into(binding.imageView)
ViewerTransitionHelper.put(item.id, binding.imageView)

}
}

0 comments on commit 361a615

Please sign in to comment.