Skip to content

Commit

Permalink
Allow setting a custom placeholder while icons load
Browse files Browse the repository at this point in the history
  • Loading branch information
jahirfiquitiva committed Apr 6, 2019
1 parent 2cf6ec1 commit 0371e88
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 4 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions app/src/main/res/values/blueprint_configs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@
-->
<bool name="enable_colored_cards">false</bool>

<!--
Show a custom image as placeholder while loading icons
Use drawable name without extensions
-->
<string name="icons_placeholder" translatable="false"></string>

<!--
1. Set the max amount of apps to request.
2. Limit requests to 1 every X minutes.
Expand Down
16 changes: 15 additions & 1 deletion app/src/main/res/values/frames_configs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,24 @@
-->
<bool name="show_bottom_sheet">true</bool>

<!--
Show a custom image as placeholder while loading wallpapers or collections
Use drawable name without extensions
-->
<string name="walls_placeholder" translatable="false"></string>
<string name="collections_placeholder" translatable="false"></string>

<!--
Enable immediate download
When set to false, users must wait 3 hours after installing the app to be able to download
any wallpapers
-->
<bool name="immediate_download">false</bool>

<!-- These are your donation items. Only put their ids here -->
<string-array name="donation_items">
<item>coffee</item>
<item>pizza</item>
<item>burger</item>
</string-array>
</resources>
</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ import jahirfiquitiva.libs.blueprint.models.Icon
import jahirfiquitiva.libs.frames.helpers.glide.FramesGlideListener
import jahirfiquitiva.libs.kext.extensions.bind
import jahirfiquitiva.libs.kext.extensions.clearChildrenAnimations
import jahirfiquitiva.libs.kext.extensions.drawable
import jahirfiquitiva.libs.kext.extensions.string

class IconViewHolder(itemView: View) : RecyclerView.ViewHolder(
itemView) {
Expand All @@ -51,7 +53,11 @@ class IconViewHolder(itemView: View) : RecyclerView.ViewHolder(
if (!animate) options.dontAnimate()

man.load(item.icon)
.apply(options)
.apply(
options
.placeholder(
context.drawable(context.string(R.string.icons_placeholder)))
.error(context.drawable(context.string(R.string.icons_placeholder))))
.listener(object : FramesGlideListener<Drawable>() {
override fun onLoadSucceed(
resource: Drawable,
Expand Down Expand Up @@ -103,4 +109,4 @@ class IconViewHolder(itemView: View) : RecyclerView.ViewHolder(
fun unbind() {
icon?.setImageDrawable(null)
}
}
}
8 changes: 7 additions & 1 deletion library/src/main/res/values/blueprint_configs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@
-->
<bool name="enable_colored_cards">false</bool>

<!--
Show a custom image as placeholder while loading icons
Use drawable name without extensions
-->
<string name="icons_placeholder" translatable="false"></string>

<!--
1. Set the max amount of apps to request.
2. Limit requests to 1 every X minutes.
Expand All @@ -91,4 +97,4 @@

<!-- Host must also be filled in first. An app API key from Arctic Request Manager. -->
<string name="arctic_backend_api_key"></string>
</resources>
</resources>

0 comments on commit 0371e88

Please sign in to comment.