Skip to content

Commit

Permalink
Minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jahirfiquitiva committed Jun 15, 2020
1 parent 6029df2 commit 006407e
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 11 deletions.
7 changes: 5 additions & 2 deletions library/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@
android:supportsRtl="true"
tools:ignore="GoogleAppIndexingWarning,UnusedAttribute">

<!-- TODO: Delete -->
<activity android:name=".ui.activities.BlueprintActivity" />
<activity
android:name="dev.jahir.frames.ui.activities.MuzeiSettingsActivity"
android:exported="false"
tools:replace="android:exported" />

<activity
android:name="dev.jahir.kuper.ui.activities.KuperActivity"
Expand All @@ -24,6 +26,7 @@

<activity
android:name=".ui.activities.BlueprintKuperActivity"
android:exported="false"
android:label="@string/templates" />

<activity
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ class IconsAdapter(
var onClick: ((Icon, Drawable?) -> Unit)? = null
) : RecyclerView.Adapter<IconViewHolder>() {

init {
setHasStableIds(true)
}

var icons: ArrayList<Icon> = ArrayList()
set(value) {
field.clear()
Expand All @@ -32,4 +36,6 @@ class IconsAdapter(
super.onViewRecycled(holder)
if (!animate) holder.unbind()
}

override fun getItemId(position: Int): Long = icons[position].resId.hashCode().toLong()
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ class IconsCategoriesFragment : BaseFramesFragment<IconsCategory>() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
recyclerView?.layoutManager =
LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false)
LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false).apply {
isItemPrefetchEnabled = true
}
recyclerView?.adapter = iconsCategoriesAdapter
recyclerView?.setHasFixedSize(true)
loadData()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import android.os.Build
import android.view.View
import androidx.appcompat.widget.AppCompatImageView
import androidx.core.view.setPadding
import coil.api.load
import com.afollestad.sectionedrecyclerview.SectionedViewHolder
import dev.jahir.blueprint.R
import dev.jahir.blueprint.data.models.Icon
Expand All @@ -22,10 +21,6 @@ class IconViewHolder(itemView: View) : SectionedViewHolder(itemView) {

fun bind(icon: Icon, animate: Boolean = true, onClick: ((Icon, Drawable?) -> Unit)? = null) {
setIconDrawable(icon, context.preferences.animationsEnabled && animate, onClick)
if (onClick == null) {
iconView?.disableClick()
itemView.disableClick()
}
}

private fun View.disableClick() {
Expand Down Expand Up @@ -53,17 +48,22 @@ class IconViewHolder(itemView: View) : SectionedViewHolder(itemView) {
scaleX = 0F
scaleY = 0F
alpha = 0F
setImageDrawable(iconDrawable)
}
setImageDrawable(iconDrawable)
if (animate) {
animate().scaleX(1F)
.scaleY(1F)
.alpha(1F)
.setStartDelay(ICON_ANIMATION_DELAY)
.setDuration(ICON_ANIMATION_DURATION)
.start()
} else iconView?.load(iconDrawable)
}
}
iconView?.setPadding(if (isAdaptive) 10.dpToPx else 6.dpToPx)
itemView.setOnClickListener { onClick?.invoke(icon, iconDrawable) }
if (onClick == null) {
iconView?.disableClick()
itemView.disableClick()
} else itemView.setOnClickListener { onClick.invoke(icon, iconDrawable) }
}

companion object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class IconsPreviewRecyclerView @JvmOverloads constructor(
init {
isSaveEnabled = true
isNestedScrollingEnabled = false
setHasFixedSize(true)
itemAnimator = DefaultItemAnimator()
layoutManager = LayoutManager(context, context.integer(R.integer.icons_columns_count))
addItemDecoration(
Expand Down

0 comments on commit 006407e

Please sign in to comment.