Skip to content

Commit 9a880f7

Browse files
committed
Added BlurHash support
1 parent 531d005 commit 9a880f7

8 files changed

Lines changed: 506 additions & 196 deletions

File tree

.idea/misc.xml

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/src/main/java/com/goodayapps/avatarview/MainActivity.kt

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import coil.decode.ImageDecoderDecoder
1414
import coil.decode.SvgDecoder
1515
import coil.load
1616
import coil.request.CachePolicy
17+
import coil.util.DebugLogger
1718
import com.goodayapps.widget.AvatarDrawable
1819
import com.goodayapps.widget.AvatarView
1920
import kotlinx.android.synthetic.main.activity_main.*
@@ -27,7 +28,13 @@ class MainActivity : AppCompatActivity() {
2728
initViews()
2829

2930
// avatar111.load("https://media4.giphy.com/media/f8hd7QP9LT31Rk2NG1/giphy.gif")
30-
avatar111.load("https://comunitee.b-cdn.net/staging/avatars/users/hlHkulpffffqQr3NWcVKxI6GbSB3/65E808E7-3098-45CE-B0D6-E50B12912751_1640027738.jpeg")
31+
// avatar111.load("https://data.whicdn.com/images/337953887/original.gif"){
32+
// placeholder(R.drawable.ic_circle)
33+
//// crossfade(false)
34+
// error(R.drawable.ic_circle)
35+
// }
36+
37+
avatar111.blurHash = "UBIEhD?d01D%0MbcIVWA0gIpV[f69zSO-o%2"
3138
}
3239

3340
private fun initViews() {
@@ -130,7 +137,7 @@ class MainActivity : AppCompatActivity() {
130137

131138
private fun initCoil(context: Context): ImageLoader {
132139
val builder = ImageLoader.Builder(context)
133-
.memoryCachePolicy(CachePolicy.ENABLED)
140+
.memoryCachePolicy(CachePolicy.DISABLED)
134141
.crossfade(true)
135142
.componentRegistry {
136143
if (Build.VERSION.SDK_INT >= 28) {
@@ -141,6 +148,10 @@ class MainActivity : AppCompatActivity() {
141148
add(SvgDecoder(context))
142149
}
143150

151+
if (BuildConfig.DEBUG) {
152+
builder.logger(DebugLogger())
153+
}
154+
144155
val imageLoader = builder.build()
145156

146157
Coil.setImageLoader(imageLoader)
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<shape xmlns:android="http://schemas.android.com/apk/res/android"
3+
android:innerRadius="0dp"
4+
android:shape="oval"
5+
android:useLevel="false">
6+
<size android:height="24dp" android:width="24dp"/>
7+
<solid android:color="@color/colorPrimaryDark" />
8+
</shape>

app/src/main/res/layout/activity_main.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@
4545
app:avBorderColorSecondary="#FF9D00"
4646
app:avBorderGradientAngle="135"
4747
app:avBorderWidth="5dp"
48-
app:iconDrawableScale=".3"
48+
app:iconDrawableScale="1"
4949
app:placeholderText="OMG" />
50-
50+
<!--
5151
<com.goodayapps.widget.AvatarView
5252
style="@style/AvatarStyleHelper"
5353
android:layout_width="@dimen/avatar_size"
@@ -108,7 +108,7 @@
108108
app:avBorderColor="@color/colorAccent"
109109
app:avBorderWidth="5dp"
110110
app:iconDrawableScale=".7"
111-
app:placeholderText="AV" />
111+
app:placeholderText="AV" />-->
112112
</GridLayout>
113113

114114
<LinearLayout

avatar-view/build.gradle

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,11 @@ project.afterEvaluate {
5353
}
5454

5555
dependencies {
56-
implementation fileTree(dir: "libs", include: ["*.jar"])
57-
implementation 'androidx.core:core-ktx:1.7.0'
58-
implementation 'androidx.appcompat:appcompat:1.4.0'
56+
api 'androidx.core:core-ktx:1.7.0'
57+
api 'androidx.appcompat:appcompat:1.4.1'
58+
59+
//Coroutines
60+
api 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.2'
61+
api 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.2'
62+
5963
}

0 commit comments

Comments
 (0)