Skip to content

Commit

Permalink
Minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jahirfiquitiva committed May 26, 2020
1 parent c08a3c1 commit 0483202
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,9 @@ class IconsAdapter(
holder.bind(icons[position], animate, onClick)

override fun getItemCount(): Int = icons.size

override fun onViewRecycled(holder: IconViewHolder) {
super.onViewRecycled(holder)
if (!animate) holder.unbind()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ import android.os.Build
import android.view.View
import androidx.appcompat.widget.AppCompatImageView
import androidx.core.view.setPadding
import coil.annotation.ExperimentalCoilApi
import coil.api.load
import coil.transition.Transition
import com.afollestad.sectionedrecyclerview.SectionedViewHolder
import dev.jahir.blueprint.R
import dev.jahir.blueprint.data.models.Icon
Expand Down Expand Up @@ -39,7 +37,10 @@ class IconViewHolder(itemView: View) : SectionedViewHolder(itemView) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) isContextClickable = false
}

@ExperimentalCoilApi
fun unbind() {
iconView?.setImageDrawable(null)
}

private fun setIconDrawable(
icon: Icon,
animate: Boolean,
Expand All @@ -59,12 +60,7 @@ class IconViewHolder(itemView: View) : SectionedViewHolder(itemView) {
.setStartDelay(ICON_ANIMATION_DELAY)
.setDuration(ICON_ANIMATION_DURATION)
.start()
} else {
iconView?.load(iconDrawable) {
transition(Transition.NONE)
crossfade(false)
}
}
} else iconView?.load(iconDrawable)
}
iconView?.setPadding(if (isAdaptive) 10.dpToPx else 6.dpToPx)
itemView.setOnClickListener { onClick?.invoke(icon, iconDrawable) }
Expand Down

0 comments on commit 0483202

Please sign in to comment.