Skip to content

Commit

Permalink
Merge pull request #4 from GetStream/fix/scaletype
Browse files Browse the repository at this point in the history
Check if the photo attacher is initialized on setting the scale type
  • Loading branch information
skydoves authored Feb 21, 2024
2 parents 92b1415 + f6062fa commit 0dbe3e0
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
4 changes: 2 additions & 2 deletions photoview/src/main/kotlin/io/getstream/photoview/PhotoView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public class PhotoView @JvmOverloads constructor(
*
* @return the attacher.
*/
private lateinit var attacher: PhotoViewAttacher
private lateinit var attacher: PhotoViewAttacher // Don't remove lateinit
private var pendingScaleType: ScaleType? = null

init {
Expand Down Expand Up @@ -76,7 +76,7 @@ public class PhotoView @JvmOverloads constructor(
}

override fun setScaleType(scaleType: ScaleType) {
if (drawable == null) {
if (drawable == null || !::attacher.isInitialized) {
pendingScaleType = scaleType
} else {
attacher.scaleType = scaleType
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ class LauncherActivity : AppCompatActivity() {
"Simple Sample",
"ViewPager Sample",
"Rotation Sample",
"Picasso Sample",
"Coil Sample",
"Glide Sample",
"Activity Transition Sample",
Expand Down

0 comments on commit 0dbe3e0

Please sign in to comment.