replace fresco with coil

This commit is contained in:
Phillip Thelen 2021-06-07 16:09:57 +02:00
parent b15bc38c0a
commit a381458a28
78 changed files with 249 additions and 537 deletions

View file

@ -61,13 +61,11 @@ dependencies {
implementation 'androidx.appcompat:appcompat:1.3.0'
implementation 'com.google.android.material:material:1.3.0'
implementation 'androidx.recyclerview:recyclerview:1.2.0'
implementation 'androidx.legacy:legacy-preference-v14:1.0.0'
// Markdown
implementation "io.noties.markwon:core:4.6.2"
implementation "io.noties.markwon:ext-strikethrough:4.6.2"
implementation "io.noties.markwon:image:4.6.2"
implementation "io.noties.markwon:recycler:4.6.2"
implementation "io.noties.markwon:html:4.6.2"
//Eventbus
implementation 'org.greenrobot:eventbus:3.2.0'
// IAP Handling / Verification
@ -86,13 +84,9 @@ dependencies {
//Analytics
implementation 'com.amplitude:android-sdk:2.30.0'
// Fresco Image Management Library
implementation('com.facebook.fresco:fresco:2.4.0') {
exclude module: 'bolts-android'
}
implementation('com.facebook.fresco:animated-gif:2.4.0') {
exclude module: 'bolts-android'
}
// Image Management Library
implementation("io.coil-kt:coil:1.2.2")
implementation("io.coil-kt:coil-gif:1.2.2")
//Tests
testImplementation 'junit:junit:4.12'
testImplementation 'androidx.test:core:1.3.0'
@ -124,8 +118,8 @@ dependencies {
implementation 'androidx.navigation:navigation-ui-ktx:2.3.5'
implementation "androidx.paging:paging-runtime-ktx:3.0.0"
implementation 'com.plattysoft.leonids:LeonidsLib:1.3.2'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.3'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.4.3'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.0'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.0'
implementation 'com.willowtreeapps:signinwithapplebutton:0.3'
@ -149,7 +143,7 @@ android {
buildConfigField "String", "TESTING_LEVEL", "\"production\""
resConfigs "en", "bg", "de", "en-rGB", "es", "fr", "hr-rHR", "in", "it", "iw", "ja", "ko", "lt", "nl", "pl", "pt-rBR", "pt-rPT", "ru", "tr", "zh", "zh-rTW"
versionCode 2960
versionCode 2962
versionName "3.3"
}

View file

@ -1,7 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
@ -23,11 +22,10 @@
<FrameLayout
android:layout_width="match_parent"
android:layout_height="66dp">
<com.facebook.drawee.view.SimpleDraweeView
<ImageView
android:id="@+id/achievement_icon"
android:layout_width="64dp"
android:layout_height="56dp"
app:actualImageScaleType="fitCenter"
android:layout_gravity="center"/>
</FrameLayout>
<TextView

View file

@ -9,11 +9,10 @@
<RelativeLayout
android:layout_width="100dp"
android:layout_height="86dp">
<com.facebook.drawee.view.SimpleDraweeView
<ImageView
android:id="@+id/achievement_icon"
android:layout_width="64dp"
android:layout_height="56dp"
app:actualImageScaleType="fitCenter"
android:layout_centerInParent="true"/>
<TextView
android:id="@+id/achievement_count_label"

View file

@ -2,7 +2,6 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
xmlns:fresco="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
@ -86,13 +85,12 @@
android:textIsSelectable="true"
tools:text="Blurb" />
<com.facebook.drawee.view.SimpleDraweeView
<ImageView
android:id="@+id/profile_image"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="5dp"
android:minHeight="200dp"
fresco:actualImageScaleType="fitCenter"
android:visibility="gone"/>
<LinearLayout
android:layout_width="match_parent"
@ -352,11 +350,10 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:text="#" />
<com.facebook.drawee.view.SimpleDraweeView
<ImageView
android:id="@+id/current_pet_drawee"
android:layout_width="40dp"
android:layout_height="40dp"
fresco:actualImageScaleType="centerCrop"/>
android:layout_height="40dp"/>
</TableRow>
<TableRow android:layout_height="wrap_content"
@ -372,11 +369,10 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:text="#" />
<com.facebook.drawee.view.SimpleDraweeView
<ImageView
android:id="@+id/current_mount_drawee"
android:layout_width="40dp"
android:layout_height="40dp"
fresco:actualImageScaleType="centerCrop"/>
android:layout_height="40dp"/>
</TableRow>
</TableLayout>
</LinearLayout>

View file

@ -14,7 +14,7 @@
android:gravity="center"
android:layout_marginTop="8dp"
style="@style/CardTitle"/>
<com.facebook.drawee.view.SimpleDraweeView
<ImageView
android:id="@+id/imageView"
android:layout_width="match_parent"
android:layout_height="180dp"

View file

@ -4,11 +4,10 @@
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.facebook.drawee.view.SimpleDraweeView
<ImageView
android:id="@+id/icon_view"
android:layout_width="52dp"
android:layout_height="56dp"
app:actualImageScaleType="fitCenter"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:layout_marginStart="30dp"/>

View file

@ -8,13 +8,11 @@
android:background="@drawable/layout_rounded_bg_window"
android:orientation="vertical"
android:layout_gravity="center">
<com.facebook.drawee.view.SimpleDraweeView
<ImageView
android:id="@+id/imageView"
android:layout_width="76dp"
android:layout_height="76dp"
android:layout_gravity="start"
app:roundedCornerRadius="6dp"
app:roundingBorderWidth="6dp"
android:scaleType="fitEnd" />
<FrameLayout
android:id="@+id/buy_button"

View file

@ -8,12 +8,11 @@
android:background="@drawable/layout_rounded_bg_window"
android:orientation="vertical"
android:layout_gravity="center">
<com.facebook.drawee.view.SimpleDraweeView
<ImageView
android:id="@+id/imageView"
android:layout_width="60dp"
android:layout_height="76dp"
android:layout_gravity="start"
app:roundedCornerRadius="6dp"
android:scaleType="fitEnd" />
<FrameLayout
android:id="@+id/buy_button"

View file

@ -16,11 +16,10 @@
android:layout_width="41dp"
android:layout_height="wrap_content"
android:src="@drawable/sparkles_left" />
<com.facebook.drawee.view.SimpleDraweeView
<ImageView
android:id="@+id/icon_view"
android:layout_width="52dp"
android:layout_height="56dp"
app:actualImageScaleType="fitCenter"
android:layout_marginStart="20dp"
android:layout_marginEnd="20dp" />
<ImageView

View file

@ -46,7 +46,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"/>
<com.habitrpg.android.habitica.ui.views.WrapContentDraweeView
<ImageView
android:id="@+id/imageView"
android:layout_width="match_parent"
android:layout_height="wrap_content"

View file

@ -15,7 +15,7 @@
android:layout_height="80dp"
android:background="@drawable/layout_rounded_bg_window"
android:layout_marginEnd="@dimen/spacing_large">
<com.facebook.drawee.view.SimpleDraweeView
<ImageView
android:id="@+id/egg_view"
android:layout_width="@dimen/gear_image_size"
android:layout_height="@dimen/gear_image_size"
@ -25,7 +25,7 @@
android:layout_width="80dp"
android:layout_height="80dp"
android:background="@drawable/layout_rounded_bg_window">
<com.facebook.drawee.view.SimpleDraweeView
<ImageView
android:id="@+id/hatchingPotion_view"
android:layout_width="@dimen/gear_image_size"
android:layout_height="@dimen/gear_image_size"

View file

@ -5,7 +5,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_horizontal">
<com.facebook.drawee.view.SimpleDraweeView
<ImageView
android:layout_width="60dp"
android:layout_height="60dp"
android:id="@+id/imageView"

View file

@ -5,11 +5,10 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal">
<com.facebook.drawee.view.SimpleDraweeView
<ImageView
android:id="@+id/icon_view"
android:layout_height="@dimen/shopitem_image_size"
android:layout_width="@dimen/shopitem_image_size"
app:actualImageScaleType="fitCenter" />
android:layout_width="@dimen/shopitem_image_size" />
<TextView
android:id="@+id/title_view"
android:layout_width="match_parent"

View file

@ -21,7 +21,7 @@
android:background="@drawable/layout_rounded_bg_window"
android:layout_centerVertical="true"
android:layout_alignParentStart="true">
<com.facebook.drawee.view.SimpleDraweeView
<ImageView
android:id="@+id/egg_view"
android:layout_width="@dimen/gear_image_size"
android:layout_height="@dimen/gear_image_size"
@ -46,7 +46,7 @@
android:background="@drawable/layout_rounded_bg_window"
android:layout_marginEnd="13dp"
android:layout_marginStart="@dimen/spacing_small">
<com.facebook.drawee.view.SimpleDraweeView
<ImageView
android:id="@+id/pet_view"
android:layout_width="@dimen/gear_image_size"
android:layout_height="@dimen/gear_image_size"
@ -63,7 +63,7 @@
android:background="@drawable/layout_rounded_bg_window"
android:layout_centerVertical="true"
android:layout_alignParentStart="true">
<com.facebook.drawee.view.SimpleDraweeView
<ImageView
android:id="@+id/hatchingPotion_view"
android:layout_width="@dimen/gear_image_size"
android:layout_height="@dimen/gear_image_size"

View file

@ -10,7 +10,7 @@
tools:parentTag="LinearLayout"
tools:orientation="vertical">
<com.facebook.drawee.view.SimpleDraweeView
<ImageView
android:id="@+id/imageView"
android:layout_width="@dimen/shopitem_image_size"
android:layout_height="@dimen/shopitem_image_size" />

View file

@ -11,7 +11,7 @@
tools:parentTag="LinearLayout"
tools:orientation="vertical">
<com.facebook.drawee.view.SimpleDraweeView
<ImageView
android:id="@+id/imageView"
android:layout_width="@dimen/shopitem_image_size"
android:layout_height="@dimen/shopitem_image_size" />

View file

@ -10,7 +10,7 @@
tools:parentTag="LinearLayout"
tools:orientation="vertical">
<com.facebook.drawee.view.SimpleDraweeView
<ImageView
android:id="@+id/imageView"
android:layout_width="@dimen/shopitem_image_size"
android:layout_height="@dimen/shopitem_image_size" />

View file

@ -3,7 +3,7 @@
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.facebook.drawee.view.SimpleDraweeView
<ImageView
android:layout_width="@dimen/avatar_width"
android:layout_height="@dimen/avatar_height"
android:id="@+id/imageView"

View file

@ -12,7 +12,7 @@
tools:background="?attr/colorContentBackground"
tools:orientation="vertical">
<com.facebook.drawee.view.SimpleDraweeView
<ImageView
android:id="@+id/imageView"
android:layout_width="@dimen/shopitem_image_size"
android:layout_height="@dimen/shopitem_image_size" />

View file

@ -25,7 +25,7 @@
android:layout_height="wrap_content"
android:layout_gravity="center"
android:src="@drawable/sparkles_left" />
<com.facebook.drawee.view.SimpleDraweeView
<ImageView
android:id="@+id/achievement_view"
android:layout_width="48dp"
android:layout_height="52dp"

View file

@ -11,7 +11,7 @@
android:layout_height="70dp"
android:layout_gravity="center_horizontal"
android:background="@drawable/layout_rounded_bg_content">
<com.facebook.drawee.view.SimpleDraweeView
<ImageView
android:id="@+id/icon_view"
android:layout_width="@dimen/gear_image_size"
android:layout_height="@dimen/gear_image_size"

View file

@ -65,7 +65,7 @@
android:gravity="center_vertical"
android:layout_marginBottom="@dimen/spacing_medium"
android:visibility="gone">
<com.facebook.drawee.view.SimpleDraweeView
<ImageView
android:id="@+id/quest_scroll_image_view"
android:layout_width="@dimen/gear_image_size"
android:layout_height="@dimen/gear_image_size" />
@ -101,7 +101,7 @@
android:background="@drawable/layout_rounded_bg_window"
android:padding="@dimen/spacing_medium"
android:layout_marginBottom="@dimen/spacing_medium">
<com.habitrpg.android.habitica.ui.views.WrapContentDraweeView
<ImageView
android:id="@+id/quest_image_view"
android:layout_width="@dimen/quest_image_width"
android:layout_height="wrap_content"

View file

@ -17,7 +17,7 @@
android:paddingTop="12dp"
android:paddingBottom="12dp"
>
<com.facebook.drawee.view.SimpleDraweeView
<ImageView
android:id="@+id/quest_scroll_image_view"
android:layout_width="63dp"
android:layout_height="63dp"

View file

@ -187,7 +187,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<com.facebook.drawee.view.SimpleDraweeView
<ImageView
android:id="@+id/sub_benefits_mystery_item_icon"
android:layout_width="68dp"
android:layout_height="68dp"

View file

@ -13,11 +13,10 @@
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_marginEnd="@dimen/row_padding">
<com.facebook.drawee.view.SimpleDraweeView
<ImageView
android:layout_width="@dimen/gear_image_size"
android:layout_height="@dimen/gear_image_size"
android:id="@+id/gear_image"
app:actualImageScaleType="fitCenter"/>
android:id="@+id/gear_image"/>
</FrameLayout>
<LinearLayout

View file

@ -8,11 +8,10 @@
android:clickable="true"
android:focusable="true"
tools:parentTag="android.widget.LinearLayout">
<com.facebook.drawee.view.SimpleDraweeView
<ImageView
android:id="@+id/imageView"
android:layout_width="@dimen/gear_image_size"
android:layout_height="@dimen/gear_image_size"
actualImageScaleType="fitCenter"
android:layout_marginEnd="@dimen/row_padding"/>
<LinearLayout
android:layout_width="match_parent"

View file

@ -6,11 +6,10 @@
android:layout_height="wrap_content"
style="@style/RowWrapper"
android:clickable="true">
<com.facebook.drawee.view.SimpleDraweeView
<ImageView
android:id="@+id/imageView"
android:layout_width="@dimen/gear_image_size"
android:layout_height="@dimen/gear_image_size"
bind:actualImageScaleType="fitCenter"
android:layout_marginEnd="@dimen/row_padding"/>
<LinearLayout
android:layout_width="match_parent"

View file

@ -19,12 +19,11 @@
android:layout_width="68dp"
android:layout_height="66dp"
android:layout_gravity="center">
<com.facebook.drawee.view.SimpleDraweeView
<ImageView
android:id="@+id/imageView"
android:layout_width="68dp"
android:layout_height="68dp"
android:layout_gravity="center"
app:actualImageScaleType="fitCenter"
/>
</FrameLayout>

View file

@ -10,7 +10,7 @@
android:layout_width="match_parent"
android:layout_height="@dimen/shop_height" />
<com.facebook.drawee.view.SimpleDraweeView
<ImageView
android:id="@+id/sceneView"
android:layout_width="375dp"
android:layout_height="@dimen/shop_scene_height" />

View file

@ -7,12 +7,11 @@
android:background="@drawable/layout_rounded_bg_window"
android:orientation="vertical"
android:padding="8dp">
<com.facebook.drawee.view.SimpleDraweeView
<ImageView
android:id="@+id/imageView"
android:layout_width="68dp"
android:layout_height="68dp"
android:layout_gravity="center"
app:actualImageScaleType="fitCenter"/>
android:layout_gravity="center"/>
<ProgressBar
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="match_parent"
@ -28,13 +27,13 @@
android:layout_width="86dp"
android:layout_height="68dp"
android:layout_gravity="center">
<com.facebook.drawee.view.SimpleDraweeView
<ImageView
android:id="@+id/hatchingPotion_view"
android:layout_width="72dp"
android:layout_height="72dp"
android:layout_alignParentTop="true"
android:layout_alignParentEnd="true" />
<com.facebook.drawee.view.SimpleDraweeView
<ImageView
android:id="@+id/egg_view"
android:layout_width="72dp"
android:layout_height="72dp"

View file

@ -2,6 +2,6 @@
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="@dimen/pet_image_width" android:layout_height="@dimen/pet_image_height"
android:layout_gravity="center">
<com.facebook.drawee.view.SimpleDraweeView android:id="@+id/pet_imageview"
<ImageView android:id="@+id/pet_imageview"
android:layout_width="90dp" android:layout_height="90dp" android:layout_gravity="center" android:scaleType="center" />
</FrameLayout>

View file

@ -18,12 +18,11 @@
android:layout_width="68dp"
android:layout_height="58dp"
android:layout_gravity="center">
<com.facebook.drawee.view.SimpleDraweeView
<ImageView
android:id="@+id/imageView"
android:layout_width="68dp"
android:layout_height="68dp"
android:layout_gravity="center"
app:actualImageScaleType="fitCenter"
/>
</FrameLayout>
<TextView

View file

@ -10,11 +10,10 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal">
<com.facebook.drawee.view.SimpleDraweeView
<ImageView
android:id="@+id/achievement_drawee"
android:layout_width="64dp"
android:layout_height="56dp"
app:actualImageScaleType="fitCenter"
android:layout_marginEnd="3dp" />
<TextView
android:id="@+id/achievement_count_label"

View file

@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<TableRow xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:fresco="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content">
@ -31,10 +30,9 @@
</LinearLayout>
<com.facebook.drawee.view.SimpleDraweeView
<ImageView
android:id="@+id/gear_drawee"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_margin="5dp"
fresco:actualImageScaleType="centerCrop"/>
android:layout_margin="5dp"/>
</TableRow>

View file

@ -8,7 +8,7 @@
android:gravity="center_vertical"
android:orientation="horizontal">
<com.facebook.drawee.view.SimpleDraweeView
<ImageView
android:id="@+id/icon_view"
android:layout_width="40dp"
android:layout_height="wrap_content"

View file

@ -6,7 +6,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clipChildren="true">
<com.habitrpg.android.habitica.ui.views.WrapContentDraweeView
<ImageView
android:id="@+id/bossArtView"
android:layout_width="wrap_content"
android:layout_height="120dp"

View file

@ -47,7 +47,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clipChildren="true">
<com.habitrpg.android.habitica.ui.views.WrapContentDraweeView
<ImageView
android:id="@+id/questImageView"
android:layout_width="219dp"
android:layout_height="wrap_content"
@ -56,7 +56,7 @@
android:paddingStart="@dimen/spacing_large"
android:paddingEnd="@dimen/spacing_large"
android:layout_gravity="center_horizontal" />
<com.habitrpg.android.habitica.ui.views.WrapContentDraweeView
<ImageView
android:id="@+id/questFlourishesImageView"
android:layout_width="310dp"
android:layout_height="219dp"

View file

@ -2,18 +2,16 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="@drawable/layout_rounded_bg_window"
android:gravity="center_vertical"
android:layout_marginBottom="4dp">
<com.facebook.drawee.view.SimpleDraweeView
<ImageView
android:id="@+id/imageView"
android:layout_width="@dimen/shopitem_image_size"
android:layout_height="@dimen/shopitem_image_size"
android:layout_marginEnd="8dp"
android:scaleType="center"
app:actualImageScaleType="fitCenter"/>
android:scaleType="center"/>
<TextView
android:id="@+id/titleTextView"

View file

@ -14,7 +14,7 @@
android:orientation="vertical"
android:background="@drawable/layout_rounded_bg_shopitem"
android:layout_centerInParent="true">
<com.facebook.drawee.view.SimpleDraweeView
<ImageView
android:id="@+id/imageView"
android:layout_width="@dimen/shopitem_image_size"
android:layout_height="@dimen/shopitem_image_size"

View file

@ -16,7 +16,7 @@
android:layout_marginTop="4dp"
android:layout_marginBottom="4dp">
<com.facebook.drawee.view.SimpleDraweeView
<ImageView
android:id="@+id/skill_image"
android:layout_width="40dp"
android:layout_height="40dp"

View file

@ -9,14 +9,20 @@ import android.content.pm.PackageManager
import android.content.res.Resources
import android.database.DatabaseErrorHandler
import android.database.sqlite.SQLiteDatabase
import android.os.Build.VERSION.SDK_INT
import android.util.Log
import androidx.appcompat.app.AppCompatDelegate
import androidx.core.content.edit
import androidx.preference.PreferenceManager
import coil.Coil
import coil.ImageLoader
import coil.annotation.ExperimentalCoilApi
import coil.decode.GifDecoder
import coil.decode.ImageDecoderDecoder
import coil.transition.CrossfadeTransition
import coil.util.DebugLogger
import com.amplitude.api.Amplitude
import com.amplitude.api.Identify
import com.facebook.drawee.backends.pipeline.Fresco
import com.facebook.imagepipeline.core.ImagePipelineConfig
import com.google.firebase.analytics.FirebaseAnalytics
import com.google.firebase.installations.FirebaseInstallations
import com.google.firebase.remoteconfig.FirebaseRemoteConfig
@ -67,6 +73,7 @@ abstract class HabiticaBaseApplication : Application() {
var checkout: Checkout? = null
private set
@OptIn(ExperimentalCoilApi::class)
override fun onCreate() {
super.onCreate()
setupRealm()
@ -90,10 +97,19 @@ abstract class HabiticaBaseApplication : Application() {
}
}
val config = ImagePipelineConfig.newBuilder(this)
.setDownsampleEnabled(true)
.build()
Fresco.initialize(this, config)
var builder = ImageLoader.Builder(this)
.transition(CrossfadeTransition())
.componentRegistry {
if (SDK_INT >= 28) {
add(ImageDecoderDecoder(this@HabiticaBaseApplication))
} else {
add(GifDecoder())
}
}
if (BuildConfig.DEBUG) {
builder = builder.logger(DebugLogger())
}
Coil.setImageLoader(builder.build())
RxErrorHandler.init(analyticsManager)

View file

@ -8,7 +8,6 @@ import com.habitrpg.android.habitica.helpers.AppConfigManager
import com.habitrpg.android.habitica.helpers.RxErrorHandler
import com.habitrpg.android.habitica.interactors.ScoreTaskLocallyInteractor
import com.habitrpg.android.habitica.models.BaseMainObject
import com.habitrpg.android.habitica.models.BaseObject
import com.habitrpg.android.habitica.models.responses.BulkTaskScoringData
import com.habitrpg.android.habitica.models.responses.TaskDirection
import com.habitrpg.android.habitica.models.responses.TaskDirectionData

View file

@ -1,8 +1,5 @@
package com.habitrpg.android.habitica.helpers
import com.facebook.imagepipeline.request.BasePostprocessor
import com.habitrpg.android.habitica.helpers.postProcessors.InvertPostProcessor
import com.habitrpg.android.habitica.ui.AvatarView
import java.util.*
class AprilFoolsHandler {
@ -20,13 +17,13 @@ class AprilFoolsHandler {
}
private fun invertFools() {
AvatarView.postProcessors[AvatarView.LayerType.PET] = {
/*AvatarView.postProcessors[AvatarView.LayerType.PET] = {
if (Date().after(eventEnd)) {
null
} else {
InvertPostProcessor()
}
}
}*/
}
}
}

View file

@ -1,37 +1,2 @@
package com.habitrpg.android.habitica.helpers.postProcessors
import android.graphics.*
import com.facebook.cache.common.CacheKey
import com.facebook.cache.common.SimpleCacheKey
import com.facebook.imagepipeline.request.BasePostprocessor
class InvertPostProcessor: BasePostprocessor() {
override fun getName(): String {
return "invertPostProcessor"
}
override fun process(bitmap: Bitmap) {
val canvas = Canvas(bitmap)
val paint = Paint()
val matrixInvert = ColorMatrix()
matrixInvert.set(floatArrayOf(
-1.0f, 0.0f, 0.0f, 0.0f, 255.0f,
0.0f, -1.0f, 0.0f, 0.0f, 255.0f,
0.0f, 0.0f, -1.0f, 0.0f, 255.0f,
0.0f, 0.0f, 0.0f, 1.0f, 0.0f
))
val filter = ColorMatrixColorFilter(matrixInvert)
paint.colorFilter = filter
canvas.drawBitmap(bitmap, 0f, 0f, paint)
}
override fun getPostprocessorCacheKey(): CacheKey {
return SimpleCacheKey("0")
}
}

View file

@ -22,17 +22,4 @@ open class OwnedItem : RealmObject(), BaseMainObject, OwnedObject {
var itemType: String? = null
var numberOwned = 0
override fun equals(other: Any?): Boolean {
return if (other is OwnedItem) {
userID == other.userID && key == other.key && itemType == other.itemType
} else super.equals(other)
}
override fun hashCode(): Int {
var result = userID?.hashCode() ?: 0
result = 31 * result + (key?.hashCode() ?: 0)
result = 31 * result + (itemType?.hashCode() ?: 0)
return result
}
}

View file

@ -12,17 +12,4 @@ open class OwnedMount : RealmObject(), OwnedObject {
var owned = false
override fun equals(other: Any?): Boolean {
return if (other is OwnedMount) {
userID == other.userID && key == other.key
} else super.equals(other)
}
override fun hashCode(): Int {
var result = userID?.hashCode() ?: 0
result = 31 * result + (key?.hashCode() ?: 0)
result = 31 * result + owned.hashCode()
return result
}
}

View file

@ -10,16 +10,4 @@ open class OwnedPet : RealmObject(), OwnedObject {
override var userID: String? = null
override var key: String? = null
var trained = 0
override fun equals(other: Any?): Boolean {
return if (other is OwnedPet) {
userID == other.userID && key == other.key
} else super.equals(other)
}
override fun hashCode(): Int {
var result = userID?.hashCode() ?: 0
result = 31 * result + (key?.hashCode() ?: 0)
return result
}
}

View file

@ -2,22 +2,16 @@ package com.habitrpg.android.habitica.ui
import android.content.Context
import android.graphics.*
import android.graphics.drawable.Animatable
import android.graphics.drawable.Drawable
import android.net.Uri
import android.text.TextUtils
import android.util.AttributeSet
import android.util.Log
import android.view.View
import com.facebook.drawee.backends.pipeline.Fresco
import com.facebook.drawee.controller.BaseControllerListener
import com.facebook.drawee.generic.GenericDraweeHierarchy
import com.facebook.drawee.generic.GenericDraweeHierarchyBuilder
import com.facebook.drawee.view.DraweeHolder
import com.facebook.drawee.view.MultiDraweeHolder
import com.facebook.imagepipeline.image.ImageInfo
import com.facebook.imagepipeline.request.BasePostprocessor
import com.facebook.imagepipeline.request.ImageRequestBuilder
import android.widget.FrameLayout
import android.widget.ImageView
import coil.imageLoader
import coil.load
import coil.request.ImageRequest
import coil.target.ViewTarget
import com.habitrpg.android.habitica.BuildConfig
import com.habitrpg.android.habitica.R
import com.habitrpg.android.habitica.helpers.AppConfigManager
@ -27,7 +21,7 @@ import io.reactivex.rxjava3.functions.Consumer
import java.util.*
import java.util.concurrent.atomic.AtomicInteger
class AvatarView : View {
class AvatarView : FrameLayout {
private var showBackground = true
private var showMount = true
@ -36,8 +30,7 @@ class AvatarView : View {
private var hasBackground: Boolean = false
private var hasMount: Boolean = false
private var hasPet: Boolean = false
private var isOrphan: Boolean = false
private val multiDraweeHolder = MultiDraweeHolder<GenericDraweeHierarchy>()
private val imageViewHolder = mutableListOf<ImageView>()
private var avatar: Avatar? = null
private var avatarRectF: RectF? = null
private val avatarMatrix = Matrix()
@ -93,11 +86,9 @@ class AvatarView : View {
}
constructor(context: Context, showBackground: Boolean, showMount: Boolean, showPet: Boolean) : super(context) {
this.showBackground = showBackground
this.showMount = showMount
this.showPet = showPet
isOrphan = true
}
private fun init(attrs: AttributeSet?, defStyle: Int) {
@ -113,10 +104,12 @@ class AvatarView : View {
} finally {
a.recycle()
}
setWillNotDraw(false)
}
private fun showLayers(layerMap: Map<LayerType, String>) {
if (multiDraweeHolder.size() > 0) return
if (imageViewHolder.isNotEmpty()) return
var i = 0
currentLayers = layerMap
@ -126,46 +119,32 @@ class AvatarView : View {
for ((layerKey, layerName) in layerMap) {
val layerNumber = i++
val hierarchy = GenericDraweeHierarchyBuilder(resources)
.setFadeDuration(0)
.build()
val draweeHolder = DraweeHolder.create(hierarchy, context)
draweeHolder.topLevelDrawable?.callback = this
multiDraweeHolder.add(draweeHolder)
val uri = Uri.parse(IMAGE_URI_ROOT + DataBindingUtils.getFullFilename(layerName, null))
var request = ImageRequestBuilder.newBuilderWithSource(uri)
postProcessors[layerKey]?.let {
request = request.setPostprocessor(it())
val imageView = if (imageViewHolder.size <= layerNumber) {
val newImageView = ImageView(context)
newImageView.scaleType = ImageView.ScaleType.MATRIX
addView(newImageView)
imageViewHolder.add(newImageView)
newImageView
} else {
imageViewHolder[layerNumber]
}
val controller = Fresco.newDraweeControllerBuilder()
.setImageRequest(request.build())
.setControllerListener(object : BaseControllerListener<ImageInfo>() {
override fun onFinalImageSet(
id: String?,
imageInfo: ImageInfo?,
anim: Animatable?) {
if (imageInfo != null) {
if (multiDraweeHolder.size() > layerNumber) {
multiDraweeHolder.get(layerNumber).topLevelDrawable?.bounds = getLayerBounds(layerKey, layerName, imageInfo)
}
onLayerComplete()
}
}
override fun onFailure(id: String?, throwable: Throwable?) {
Log.e(TAG, "Error loading layer: $layerName", throwable)
onLayerComplete()
}
})
.setAutoPlayAnimations(!isOrphan)
.build()
draweeHolder.controller = controller
imageView.load(DataBindingUtils.BASE_IMAGE_URL + DataBindingUtils.getFullFilename(layerName)) {
allowHardware(false)
target({}, {
onLayerComplete()
}, {
val bounds = getLayerBounds(layerKey, layerName, it)
imageView.load(it)
imageView.imageMatrix = avatarMatrix
val layoutParams = imageView.layoutParams as? FrameLayout.LayoutParams
layoutParams?.topMargin = bounds.top
layoutParams?.marginStart = bounds.left
imageView.layoutParams = layoutParams
onLayerComplete()
})
}
}
if (isOrphan) multiDraweeHolder.onAttach()
}
private fun getLayerMap(avatar: Avatar, resetHasAttributes: Boolean): Map<LayerType, String> {
@ -322,9 +301,9 @@ class AvatarView : View {
return layerMap
}
private fun getLayerBounds(layerType: LayerType, layerName: String, layerImageInfo: ImageInfo): Rect {
private fun getLayerBounds(layerType: LayerType, layerName: String, drawable: Drawable): Rect {
var offset: PointF? = null
val bounds = Rect(0, 0, layerImageInfo.width, layerImageInfo.height)
val bounds = Rect(0, 0, drawable.intrinsicWidth, drawable.intrinsicHeight)
val boundsF = RectF(bounds)
// lookup layer specific offset
@ -367,7 +346,7 @@ class AvatarView : View {
// compact hero box
offset = PointF(0.0f, 18.0f)
}
LayerType.PET -> offset = PointF(0f, (FULL_HERO_RECT.height() - layerImageInfo.height).toFloat())
LayerType.PET -> offset = PointF(0f, (FULL_HERO_RECT.height() - bounds.height()).toFloat())
}
}
@ -403,7 +382,7 @@ class AvatarView : View {
fun onAvatarImageReady(consumer: Consumer<Bitmap?>) {
avatarImageConsumer = consumer
if (multiDraweeHolder.size() > 0 && numberLayersInProcess.get() == 0) {
if (imageViewHolder.size > 0 && numberLayersInProcess.get() == 0) {
avatarImageConsumer?.accept(avatarImage)
} else {
initAvatarRectMatrix()
@ -420,39 +399,28 @@ class AvatarView : View {
val equals = currentLayers != null && currentLayers == newLayerMap
if (!equals || postProcessors.isNotEmpty()) {
multiDraweeHolder.clear()
if (!equals) {
imageViewHolder.clear()
numberLayersInProcess.set(0)
}
}
invalidate()
}
private fun initAvatarRectMatrix() {
if (avatarRectF == null) {
val srcRect = originalRect
if (isOrphan) {
avatarRectF = RectF(srcRect)
// change scale to not be 1:1
// a quick fix as fresco AnimatedDrawable/ScaleTypeDrawable
// will not translate matrix properly
avatarMatrix.setScale(1.2f, 1.2f)
avatarMatrix.mapRect(avatarRectF)
} else {
// full hero box when showMount and showPet is enabled (140w * 147h)
// compact hero box when only showBackground is enabled (114w * 114h)
// hero only box when all show settings disabled (90w * 90h)
avatarRectF = RectF(0f, 0f, width.toFloat(), height.toFloat())
avatarMatrix.setRectToRect(RectF(srcRect), avatarRectF, Matrix.ScaleToFit.START) // TODO support other ScaleToFit
avatarRectF = RectF(srcRect)
avatarMatrix.mapRect(avatarRectF)
}
// full hero box when showMount and showPet is enabled (140w * 147h)
// compact hero box when only showBackground is enabled (114w * 114h)
// hero only box when all show settings disabled (90w * 90h)
avatarRectF = RectF(0f, 0f, width.toFloat(), height.toFloat())
avatarMatrix.setRectToRect(RectF(srcRect), avatarRectF, Matrix.ScaleToFit.START) // TODO support other ScaleToFit
avatarRectF = RectF(srcRect)
avatarMatrix.mapRect(avatarRectF)
}
}
override fun onDraw(canvas: Canvas) {
override fun onDraw(canvas: Canvas?) {
super.onDraw(canvas)
initAvatarRectMatrix()
@ -461,37 +429,9 @@ class AvatarView : View {
if (avatar?.isValid() != true) return
// request image layers if not yet processed
if (multiDraweeHolder.size() == 0) {
if (imageViewHolder.size == 0) {
showLayers(layerMap)
}
// manually call onAttach/onDetach if view is without parent as they will never be called otherwise
if (isOrphan) multiDraweeHolder.onAttach()
multiDraweeHolder.draw(canvas)
}
override fun onDetachedFromWindow() {
super.onDetachedFromWindow()
multiDraweeHolder.onDetach()
}
override fun onStartTemporaryDetach() {
super.onStartTemporaryDetach()
multiDraweeHolder.onDetach()
}
override fun onAttachedToWindow() {
super.onAttachedToWindow()
multiDraweeHolder.onAttach()
}
override fun onFinishTemporaryDetach() {
super.onFinishTemporaryDetach()
multiDraweeHolder.onAttach()
}
override fun verifyDrawable(who: Drawable): Boolean {
return multiDraweeHolder.verifyDrawable(who) || super.verifyDrawable(who)
}
override fun invalidateDrawable(drawable: Drawable) {
@ -526,12 +466,11 @@ class AvatarView : View {
}
companion object {
const val IMAGE_URI_ROOT = "https://habitica-assets.s3.amazonaws.com/mobileApp/images/"
private const val TAG = "AvatarView"
private val FULL_HERO_RECT = Rect(0, 0, 140, 147)
private val COMPACT_HERO_RECT = Rect(0, 0, 114, 114)
private val HERO_ONLY_RECT = Rect(0, 0, 90, 90)
val postProcessors: MutableMap<LayerType, (() -> BasePostprocessor?)> = mutableMapOf()
//val postProcessors: MutableMap<LayerType, (() -> BasePostprocessor?)> = mutableMapOf()
}
}

View file

@ -46,7 +46,6 @@ class AvatarWithBarsViewModel(private val context: Context, private val binding:
}
}
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
fun updateData(user: Avatar) {
userObject = user
@ -65,7 +64,8 @@ class AvatarWithBarsViewModel(private val context: Context, private val binding:
if (!user.hasClass()) {
setUserLevel(context, binding.lvlTv, stats.lvl)
} else {
setUserLevelWithClass(context, binding.lvlTv, stats.lvl, userClass.capitalize(Locale.getDefault()), stats.habitClass)
setUserLevelWithClass(context, binding.lvlTv, stats.lvl,
userClass.replaceFirstChar { if (it.isLowerCase()) it.titlecase(Locale.getDefault()) else it.toString() }, stats.habitClass)
}
setHpBarData(stats.hp?.toFloat() ?: 0.toFloat(), stats.maxHealth ?: 0)

View file

@ -9,14 +9,13 @@ import android.widget.ImageView
import android.widget.LinearLayout
import android.widget.TextView
import com.facebook.drawee.view.SimpleDraweeView
import com.habitrpg.android.habitica.R
import com.habitrpg.android.habitica.ui.helpers.DataBindingUtils
import com.habitrpg.android.habitica.ui.views.HabiticaIconsHelper
class ItemDetailDialog(context: Context) : AlertDialog(context) {
private val itemImageView: SimpleDraweeView
private val itemImageView: ImageView
private val contentTextView: TextView
private val priceTextView: TextView
private val currencyImageView: ImageView
@ -28,7 +27,7 @@ class ItemDetailDialog(context: Context) : AlertDialog(context) {
contentViewLayout.orientation = LinearLayout.VERTICAL
// Gear Image
itemImageView = SimpleDraweeView(context)
itemImageView = ImageView(context)
val gearImageLayoutParams = LinearLayout.LayoutParams(
LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT)

View file

@ -4,16 +4,10 @@ import android.content.Context
import android.graphics.Typeface
import android.os.Bundle
import android.view.*
import android.widget.ProgressBar
import android.widget.TableLayout
import android.widget.TableRow
import android.widget.TextView
import android.widget.*
import androidx.core.content.ContextCompat
import androidx.core.os.bundleOf
import com.facebook.drawee.backends.pipeline.Fresco
import com.facebook.drawee.controller.BaseControllerListener
import com.facebook.drawee.view.SimpleDraweeView
import com.facebook.imagepipeline.image.ImageInfo
import coil.load
import com.habitrpg.android.habitica.R
import com.habitrpg.android.habitica.components.UserComponent
import com.habitrpg.android.habitica.data.ApiClient
@ -31,7 +25,6 @@ import com.habitrpg.android.habitica.models.inventory.Equipment
import com.habitrpg.android.habitica.models.members.Member
import com.habitrpg.android.habitica.models.user.Outfit
import com.habitrpg.android.habitica.models.user.Stats
import com.habitrpg.android.habitica.ui.AvatarView
import com.habitrpg.android.habitica.ui.AvatarWithBarsViewModel
import com.habitrpg.android.habitica.ui.adapter.social.AchievementProfileAdapter
import com.habitrpg.android.habitica.ui.helpers.loadImage
@ -202,14 +195,7 @@ class FullProfileActivity : BaseActivity() {
if (imageUrl == null || imageUrl.isEmpty()) {
binding.profileImage.visibility = View.GONE
} else {
binding.profileImage.controller = Fresco.newDraweeControllerBuilder()
.setUri(imageUrl)
.setControllerListener(object : BaseControllerListener<ImageInfo>() {
override fun onFailure(id: String?, throwable: Throwable?) {
binding.profileImage.visibility = View.GONE
}
})
.build()
binding.profileImage.load(imageUrl)
}
val blurbText = profile.blurb
@ -240,8 +226,8 @@ class FullProfileActivity : BaseActivity() {
binding.petsFoundCount.text = user.petsFoundCount.toString()
binding.mountsTamedCount.text = user.mountsTamedCount.toString()
binding.currentPetDrawee.loadImage("Pet-" + user.currentPet)
binding.currentMountDrawee.loadImage("Mount_Icon_" + user.currentMount)
if (user.currentPet?.isNotBlank() == true) binding.currentPetDrawee.loadImage("Pet-" + user.currentPet)
if (user.currentMount?.isNotBlank() == true) binding.currentMountDrawee.loadImage("Mount_Icon_" + user.currentMount)
}
// endregion
@ -314,16 +300,9 @@ class FullProfileActivity : BaseActivity() {
private fun addEquipmentRow(table: TableLayout, gearKey: String?, text: String?, stats: String?) {
val gearRow = layoutInflater.inflate(R.layout.profile_gear_tablerow, table, false) as? TableRow
val draweeView = gearRow?.findViewById<SimpleDraweeView>(R.id.gear_drawee)
val draweeView = gearRow?.findViewById<ImageView>(R.id.gear_drawee)
draweeView?.controller = Fresco.newDraweeControllerBuilder()
.setUri(AvatarView.IMAGE_URI_ROOT + "shop_" + gearKey + ".png")
.setControllerListener(object : BaseControllerListener<ImageInfo>() {
override fun onFailure(id: String?, throwable: Throwable?) {
draweeView?.visibility = View.GONE
}
})
.build()
draweeView?.loadImage("shop_$gearKey")
val keyTextView = gearRow?.findViewById<TextView>(R.id.tableRowTextView1)
keyTextView?.text = text
@ -342,7 +321,10 @@ class FullProfileActivity : BaseActivity() {
private fun addLevelAttributes(user: Member) {
val byLevelStat = min((user.stats?.lvl ?: 0) / 2.0f, 50f)
addAttributeRow(getString(R.string.profile_level), byLevelStat, byLevelStat, byLevelStat, byLevelStat, true, false)
addAttributeRow(getString(R.string.profile_level), byLevelStat, byLevelStat, byLevelStat, byLevelStat,
roundDown = true,
isSummary = false
)
}
private fun loadItemDataByOutfit(outfit: Outfit?): Flowable<out List<Equipment>> {
@ -393,7 +375,10 @@ class FullProfileActivity : BaseActivity() {
private fun addNormalAddBuffAttributes(stats: Stats) {
val buffs = stats.buffs
addAttributeRow(getString(R.string.profile_allocated), stats.strength?.toFloat() ?: 0f, stats.intelligence?.toFloat() ?: 0f, stats.constitution?.toFloat() ?: 0f, stats.per?.toFloat() ?: 0f, true, false)
addAttributeRow(getString(R.string.profile_allocated), stats.strength?.toFloat() ?: 0f, stats.intelligence?.toFloat() ?: 0f, stats.constitution?.toFloat() ?: 0f, stats.per?.toFloat() ?: 0f,
roundDown = true,
isSummary = false
)
addAttributeRow(getString(R.string.buffs), buffs?.str
?: 0f, buffs?._int ?: 0f, buffs?.con ?: 0f, buffs?.per ?: 0f, roundDown = true, isSummary = false)

View file

@ -15,6 +15,7 @@ import android.os.Bundle
import android.util.Log
import android.view.*
import android.widget.FrameLayout
import android.widget.ImageView
import android.widget.TextView
import androidx.appcompat.app.ActionBarDrawerToggle
import androidx.core.content.FileProvider
@ -25,7 +26,6 @@ import androidx.lifecycle.ViewModelProvider
import androidx.navigation.NavDestination
import androidx.navigation.findNavController
import androidx.navigation.fragment.NavHostFragment
import com.facebook.drawee.view.SimpleDraweeView
import com.google.firebase.analytics.FirebaseAnalytics
import com.google.firebase.perf.FirebasePerformance
import com.habitrpg.android.habitica.HabiticaBaseApplication
@ -514,7 +514,7 @@ open class MainActivity : BaseActivity(), TutorialView.OnTutorialReaction {
HabiticaSnackbar.showSnackbar(snackbarContainer, feedResponse.message, SnackbarDisplayType.NORMAL)
if (feedResponse.value == -1) {
val mountWrapper = View.inflate(this, R.layout.pet_imageview, null) as? FrameLayout
val mountImageView = mountWrapper?.findViewById(R.id.pet_imageview) as? SimpleDraweeView
val mountImageView = mountWrapper?.findViewById(R.id.pet_imageview) as? ImageView
DataBindingUtils.loadImage(mountImageView, "Mount_Icon_" + event.usingPet.key)
val dialog = HabiticaAlertDialog(this@MainActivity)
@ -756,7 +756,7 @@ open class MainActivity : BaseActivity(), TutorialView.OnTutorialReaction {
val factory = LayoutInflater.from(this)
val view = factory.inflate(R.layout.dialog_login_incentive, null)
val imageView = view.findViewById(R.id.imageView) as? SimpleDraweeView
val imageView = view.findViewById(R.id.imageView) as? ImageView
var imageKey = notificationData?.rewardKey?.get(0)
if (imageKey?.contains("armor") == true) {
imageKey = "slim_$imageKey"
@ -860,7 +860,7 @@ open class MainActivity : BaseActivity(), TutorialView.OnTutorialReaction {
fun hatchPet(potion: HatchingPotion, egg: Egg) {
compositeSubscription.add(this.inventoryRepository.hatchPet(egg, potion) {
val petWrapper = View.inflate(this, R.layout.pet_imageview, null) as? FrameLayout
val petImageView = petWrapper?.findViewById(R.id.pet_imageview) as? SimpleDraweeView
val petImageView = petWrapper?.findViewById(R.id.pet_imageview) as? ImageView
DataBindingUtils.loadImage(petImageView, "stable_Pet-" + egg.key + "-" + potion.key)
val potionName = potion.text

View file

@ -2,9 +2,9 @@ package com.habitrpg.android.habitica.ui.adapter
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import com.facebook.drawee.view.SimpleDraweeView
import com.habitrpg.android.habitica.R
import com.habitrpg.android.habitica.databinding.AchievementChallengeItemBinding
import com.habitrpg.android.habitica.databinding.AchievementQuestItemBinding
@ -72,7 +72,7 @@ class AchievementsAdapter: RecyclerView.Adapter<RecyclerView.ViewHolder>() {
private var achievement: Achievement? = null
private val achievementContainer: ViewGroup?
private val achievementIconView: SimpleDraweeView
private val achievementIconView: ImageView
private val achievementCountView: TextView
private val achievementTitleView: TextView
private val achievementDescriptionView: TextView?

View file

@ -8,7 +8,6 @@ import android.widget.LinearLayout
import android.widget.TextView
import androidx.core.content.ContextCompat
import androidx.core.os.bundleOf
import com.facebook.drawee.view.SimpleDraweeView
import com.habitrpg.android.habitica.R
import com.habitrpg.android.habitica.databinding.CustomizationGridItemBinding
import com.habitrpg.android.habitica.helpers.MainNavigationController
@ -118,7 +117,7 @@ class CustomizationEquipmentRecyclerViewAdapter : androidx.recyclerview.widget.R
if (equipment?.owned != true && (equipment?.value ?: 0.0) > 0.0) {
val dialogContent = LayoutInflater.from(itemView.context).inflate(R.layout.dialog_purchase_customization, null) as LinearLayout
val imageView = dialogContent.findViewById<SimpleDraweeView>(R.id.imageView)
val imageView = dialogContent.findViewById<ImageView>(R.id.imageView)
DataBindingUtils.loadImage(imageView, "shop_" + this.equipment?.key)
val priceLabel = dialogContent.findViewById<TextView>(R.id.priceLabel)

View file

@ -10,7 +10,7 @@ import android.widget.LinearLayout
import android.widget.TextView
import androidx.core.content.ContextCompat
import androidx.core.os.bundleOf
import com.facebook.drawee.view.SimpleDraweeView
import coil.load
import com.habitrpg.android.habitica.R
import com.habitrpg.android.habitica.databinding.CustomizationGridItemBinding
import com.habitrpg.android.habitica.databinding.CustomizationSectionHeaderBinding
@ -149,7 +149,7 @@ class CustomizationRecyclerViewAdapter() : androidx.recyclerview.widget.Recycler
this.customization = customization
if (customization.type == "background" && customization.identifier == "") {
binding.imageView.setActualImageResource(R.drawable.no_background)
binding.imageView.load(R.drawable.no_background)
} else {
DataBindingUtils.loadImage(binding.imageView, customization.getIconName(userSize, hairColor))
}
@ -193,7 +193,7 @@ class CustomizationRecyclerViewAdapter() : androidx.recyclerview.widget.Recycler
} else {
val dialogContent = LayoutInflater.from(itemView.context).inflate(R.layout.dialog_purchase_customization, null) as LinearLayout
val imageView = dialogContent.findViewById<SimpleDraweeView>(R.id.imageView)
val imageView = dialogContent.findViewById<ImageView>(R.id.imageView)
DataBindingUtils.loadImage(imageView, customization?.getImageName(userSize, hairColor))
val priceLabel = dialogContent.findViewById<TextView>(R.id.priceLabel)

View file

@ -2,11 +2,11 @@ package com.habitrpg.android.habitica.ui.adapter.inventory
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import android.widget.TextView
import androidx.core.content.ContextCompat
import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.facebook.drawee.view.SimpleDraweeView
import com.habitrpg.android.habitica.R
import com.habitrpg.android.habitica.databinding.ShopHeaderBinding
import com.habitrpg.android.habitica.extensions.inflate
@ -182,7 +182,7 @@ class StableRecyclerAdapter : RecyclerView.Adapter<RecyclerView.ViewHolder>() {
internal inner class StableViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView), View.OnClickListener {
private var animal: Animal? = null
private val imageView: SimpleDraweeView = itemView.findViewById(R.id.imageView)
private val imageView: ImageView = itemView.findViewById(R.id.imageView)
private val titleView: TextView = itemView.findViewById(R.id.titleTextView)
private val ownedTextView: TextView = itemView.findViewById(R.id.ownedTextView)

View file

@ -1,25 +1,16 @@
package com.habitrpg.android.habitica.ui.adapter.social
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import com.facebook.drawee.backends.pipeline.Fresco
import com.facebook.drawee.controller.BaseControllerListener
import com.facebook.imagepipeline.image.ImageInfo
import com.habitrpg.android.habitica.R
import com.habitrpg.android.habitica.databinding.ProfileAchievementItemBinding
import com.habitrpg.android.habitica.extensions.addOkButton
import com.habitrpg.android.habitica.extensions.fromHtml
import com.habitrpg.android.habitica.extensions.inflate
import com.habitrpg.android.habitica.models.Achievement
import com.habitrpg.android.habitica.ui.AvatarView
import com.habitrpg.android.habitica.ui.activities.MainActivity
import com.habitrpg.android.habitica.ui.helpers.loadImage
import com.habitrpg.android.habitica.ui.viewHolders.SectionViewHolder
import com.habitrpg.android.habitica.ui.views.dialogs.AchievementDetailDialog
import com.habitrpg.android.habitica.ui.views.dialogs.HabiticaAlertDialog
class AchievementProfileAdapter : RecyclerView.Adapter<RecyclerView.ViewHolder>() {
@ -71,14 +62,7 @@ class AchievementProfileAdapter : RecyclerView.Adapter<RecyclerView.ViewHolder>(
}
fun bind(item: Achievement) {
val iconUrl = AvatarView.IMAGE_URI_ROOT + (if (!item.earned) "achievement-unearned" else item.icon) + "2x.png"
binding.achievementDrawee.controller = Fresco.newDraweeControllerBuilder()
.setUri(iconUrl)
.setControllerListener(object : BaseControllerListener<ImageInfo>() {
override fun onFailure(id: String?, throwable: Throwable?) { /* no-on */ }
})
.build()
binding.achievementDrawee.loadImage((if (!item.earned) "achievement-unearned" else item.icon) + "2x.png")
this.achievement = item
binding.achievementText.text = item.title

View file

@ -122,8 +122,9 @@ class AboutFragment : BaseMainFragment<FragmentAboutBinding>() {
}
private fun doTheThing() {
context?.let { FirebaseAnalytics.getInstance(it).logEvent("found_easter_egg", null) }
DataBindingUtils.loadImage("Pet-Sabretooth-Base") {bitmap ->
val context = context ?: return
FirebaseAnalytics.getInstance(context).logEvent("found_easter_egg", null)
DataBindingUtils.loadImage(context,"Pet-Sabretooth-Base") {bitmap ->
activity?.runOnUiThread {
activity?.let {
ParticleSystem(it, 50, bitmap, 3000)
@ -135,7 +136,7 @@ class AboutFragment : BaseMainFragment<FragmentAboutBinding>() {
}
}
}
DataBindingUtils.loadImage("Pet-Sabretooth-Golden") {bitmap ->
DataBindingUtils.loadImage(context,"Pet-Sabretooth-Golden") {bitmap ->
activity?.runOnUiThread {
activity?.let {
ParticleSystem(it, 50, bitmap, 3000)
@ -147,7 +148,7 @@ class AboutFragment : BaseMainFragment<FragmentAboutBinding>() {
}
}
}
DataBindingUtils.loadImage("Pet-Sabretooth-Red") {bitmap ->
DataBindingUtils.loadImage(context, "Pet-Sabretooth-Red") {bitmap ->
activity?.runOnUiThread {
activity?.let {
ParticleSystem(it, 50, bitmap, 3000)

View file

@ -14,6 +14,7 @@ import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.activity.result.contract.ActivityResultContracts
import androidx.core.graphics.drawable.toBitmap
import androidx.core.os.bundleOf
import com.google.firebase.analytics.FirebaseAnalytics
import com.habitrpg.android.habitica.R
@ -105,19 +106,16 @@ class NoPartyFragmentFragment : BaseMainFragment<FragmentNoPartyBinding>() {
}
context?.let { context ->
DataBindingUtils.loadImage("timeTravelersShop_background_fall") {bitmap ->
DataBindingUtils.loadImage(context, "timeTravelersShop_background_fall") { drawable ->
val bitmap = drawable.toBitmap()
val aspectRatio = bitmap.width / bitmap.height.toFloat()
val height = context.resources.getDimension(R.dimen.shop_height).toInt()
val width = (height * aspectRatio).roundToInt()
val drawable = BitmapDrawable(context.resources, Bitmap.createScaledBitmap(bitmap, width, height, false))
drawable.tileModeX = Shader.TileMode.REPEAT
Observable.just(drawable)
.observeOn(AndroidSchedulers.mainThread())
.subscribe({
if (binding?.noPartyBackground != null) {
binding?.noPartyBackground?.background = it
}
}, RxErrorHandler.handleEmptyError())
val bitmapDrawable = BitmapDrawable(context.resources, Bitmap.createScaledBitmap(bitmap, width, height, false))
bitmapDrawable.tileModeX = Shader.TileMode.REPEAT
if (binding?.noPartyBackground != null) {
binding?.noPartyBackground?.background = bitmapDrawable
}
}
}

View file

@ -1,26 +1,18 @@
package com.habitrpg.android.habitica.ui.helpers
import android.content.Context
import android.graphics.Bitmap
import android.graphics.PorterDuff
import android.graphics.drawable.Animatable
import android.graphics.drawable.Drawable
import android.view.View
import android.view.ViewGroup
import android.view.animation.Animation
import android.view.animation.Transformation
import android.widget.ImageView
import android.widget.LinearLayout
import androidx.core.content.res.ResourcesCompat
import androidx.core.net.toUri
import com.facebook.common.executors.CallerThreadExecutor
import com.facebook.common.references.CloseableReference
import com.facebook.datasource.DataSource
import com.facebook.drawee.backends.pipeline.Fresco
import com.facebook.drawee.controller.BaseControllerListener
import com.facebook.drawee.interfaces.DraweeController
import com.facebook.drawee.view.SimpleDraweeView
import com.facebook.imagepipeline.datasource.BaseBitmapDataSubscriber
import com.facebook.imagepipeline.image.CloseableImage
import com.facebook.imagepipeline.image.ImageInfo
import com.facebook.imagepipeline.request.ImageRequestBuilder
import coil.imageLoader
import coil.load
import coil.request.ImageRequest
import com.habitrpg.android.habitica.R
import com.habitrpg.android.habitica.extensions.setTintWith
import com.habitrpg.android.habitica.helpers.AppConfigManager
@ -28,67 +20,42 @@ import java.util.*
import kotlin.collections.HashMap
fun SimpleDraweeView.loadImage(imageName: String, imageFormat: String? = null) {
fun ImageView.loadImage(imageName: String?, imageFormat: String? = null) {
DataBindingUtils.loadImage(this, imageName, imageFormat)
}
object DataBindingUtils {
fun loadImage(view: SimpleDraweeView?, imageName: String) {
fun loadImage(view: ImageView?, imageName: String) {
loadImage(view, imageName, null)
}
fun loadImage(view: SimpleDraweeView?, imageName: String?, imageFormat: String? = null) {
fun loadImage(view: ImageView?, imageName: String?, imageFormat: String? = null) {
if (view != null && imageName != null && view.visibility == View.VISIBLE) {
val fullname = getFullFilename(imageName, imageFormat)
if (view.tag == fullname) {
return
}
view.tag = fullname
val builder = Fresco.newDraweeControllerBuilder()
.setUri("https://habitica-assets.s3.amazonaws.com/mobileApp/images/$fullname")
.setControllerListener(object : BaseControllerListener<ImageInfo>() {
override fun onFinalImageSet(id: String?, imageInfo: ImageInfo?, animatable: Animatable?) {
if (imageInfo != null && view.layoutParams.height == ViewGroup.LayoutParams.WRAP_CONTENT) {
view.aspectRatio = imageInfo.width.toFloat() / imageInfo.height
}
super.onFinalImageSet(id, imageInfo, animatable)
}
})
.setAutoPlayAnimations(true)
.setOldController(view.controller)
val controller: DraweeController = builder.build()
view.controller = controller
view.load(BASE_IMAGE_URL + fullname)
}
}
fun loadImage(imageName: String, imageResult: (Bitmap) -> Unit) {
loadImage(imageName, null, imageResult)
fun loadImage(context: Context, imageName: String, imageResult: (Drawable) -> Unit) {
loadImage(context, imageName, null, imageResult)
}
fun loadImage(imageName: String, imageFormat: String?, imageResult: (Bitmap) -> Unit) {
val imageRequest = ImageRequestBuilder
.newBuilderWithSource("https://habitica-assets.s3.amazonaws.com/mobileApp/images/${getFullFilename(imageName, imageFormat)}".toUri())
.build()
val imagePipeline = Fresco.getImagePipeline()
val dataSource = imagePipeline.fetchDecodedImage(imageRequest, this)
dataSource.subscribe(object : BaseBitmapDataSubscriber() {
public override fun onNewResultImpl(bitmap: Bitmap?) {
if (dataSource.isFinished && bitmap != null) {
imageResult(bitmap)
dataSource.close()
}
fun loadImage(context: Context, imageName: String, imageFormat: String?, imageResult: (Drawable) -> Unit) {
val request = ImageRequest.Builder(context)
.data(BASE_IMAGE_URL + getFullFilename(imageName, imageFormat))
.target {
imageResult(it)
}
override fun onFailureImpl(dataSource: DataSource<CloseableReference<CloseableImage>>) {
dataSource.close()
}
}, CallerThreadExecutor.getInstance())
.build()
context.imageLoader.enqueue(request)
}
fun getFullFilename(imageName: String, imageFormat: String?): String {
fun getFullFilename(imageName: String, imageFormat: String? = null): String {
val name = when {
spriteSubstitutions.containsKey(imageName) -> spriteSubstitutions[imageName]
FILENAME_MAP.containsKey(imageName) -> FILENAME_MAP[imageName]
@ -126,6 +93,7 @@ object DataBindingUtils {
override fun willChangeBounds(): Boolean = true
}
val BASE_IMAGE_URL = "https://habitica-assets.s3.amazonaws.com/mobileApp/images/"
private val FILEFORMAT_MAP: Map<String, String>
private val FILENAME_MAP: Map<String, String>

View file

@ -4,6 +4,7 @@ import android.content.res.Resources
import android.graphics.drawable.BitmapDrawable
import android.view.View
import android.view.ViewGroup
import androidx.core.graphics.drawable.toBitmap
import com.habitrpg.android.habitica.R
import com.habitrpg.android.habitica.databinding.MountOverviewItemBinding
import com.habitrpg.android.habitica.extensions.inflate
@ -41,13 +42,9 @@ class MountViewHolder(parent: ViewGroup, private val equipEvents: PublishSubject
binding.imageView.alpha = 0.2f
}
binding.imageView.background = null
DataBindingUtils.loadImage(imageName) {
val drawable = BitmapDrawable(itemView.context.resources, if (owned) it else it.extractAlpha())
Observable.just(drawable)
.observeOn(AndroidSchedulers.mainThread())
.subscribe({
binding.imageView.background = drawable
}, RxErrorHandler.handleEmptyError())
DataBindingUtils.loadImage(itemView.context, imageName) {
val drawable = if (owned) it else BitmapDrawable(itemView.context.resources, it.toBitmap().extractAlpha())
binding.imageView.background = drawable
}
}

View file

@ -4,6 +4,7 @@ import android.graphics.PorterDuff
import android.graphics.drawable.BitmapDrawable
import android.view.View
import android.view.ViewGroup
import androidx.core.graphics.drawable.toBitmap
import com.habitrpg.android.habitica.R
import com.habitrpg.android.habitica.databinding.PetDetailItemBinding
import com.habitrpg.android.habitica.events.commands.FeedCommand
@ -98,14 +99,10 @@ class PetViewHolder(parent: ViewGroup, private val equipEvents: PublishSubject<S
binding.trainedProgressBar.progressBackgroundTintMode = PorterDuff.Mode.SRC_OVER
}
binding.imageView.background = null
DataBindingUtils.loadImage(imageName) {
DataBindingUtils.loadImage(itemView.context, imageName) {
val resources = itemView.context.resources ?: return@loadImage
val drawable = BitmapDrawable(resources, if (trained == 0) it.extractAlpha() else it)
Observable.just(drawable)
.observeOn(AndroidSchedulers.mainThread())
.subscribe({
binding.imageView.background = drawable
}, RxErrorHandler.handleEmptyError())
val drawable = if (trained == 0) BitmapDrawable(resources, it.toBitmap().extractAlpha()) else it
binding.imageView.background = drawable
}
}

View file

@ -7,6 +7,7 @@ import android.graphics.drawable.BitmapDrawable
import android.util.AttributeSet
import android.widget.FrameLayout
import android.widget.ImageView
import androidx.core.graphics.drawable.toBitmap
import com.habitrpg.android.habitica.R
import com.habitrpg.android.habitica.databinding.NpcBannerBinding
import com.habitrpg.android.habitica.extensions.layoutInflater
@ -41,11 +42,11 @@ class NPCBannerView(context: Context, attrs: AttributeSet?) : FrameLayout(contex
binding.backgroundView.scaleType = ImageView.ScaleType.FIT_START
DataBindingUtils.loadImage(identifier + "_background" + shopSpriteSuffix) {
val aspectRatio = it.width / it.height.toFloat()
DataBindingUtils.loadImage(context, identifier + "_background" + shopSpriteSuffix) {
val aspectRatio = it.intrinsicWidth / it.intrinsicHeight.toFloat()
val height = context.resources.getDimension(R.dimen.shop_height).toInt()
val width = (height * aspectRatio).roundToInt()
val drawable = BitmapDrawable(context.resources, Bitmap.createScaledBitmap(it, width, height, false))
val drawable = BitmapDrawable(context.resources, Bitmap.createScaledBitmap(it.toBitmap(), width, height, false))
drawable.tileModeX = Shader.TileMode.REPEAT
Observable.just(drawable)
.observeOn(AndroidSchedulers.mainThread())

View file

@ -1,41 +0,0 @@
package com.habitrpg.android.habitica.ui.views
import android.content.Context
import android.graphics.drawable.Animatable
import android.net.Uri
import android.util.AttributeSet
import com.facebook.drawee.backends.pipeline.PipelineDraweeControllerBuilder
import com.facebook.drawee.controller.BaseControllerListener
import com.facebook.drawee.view.SimpleDraweeView
import com.facebook.imagepipeline.image.ImageInfo
//https://stackoverflow.com/questions/33955510/facebook-fresco-using-wrap-content
class WrapContentDraweeView : SimpleDraweeView {
// we set a listener and update the view's aspect ratio depending on the loaded image
private val listener = object : BaseControllerListener<ImageInfo>() {
override fun onIntermediateImageSet(id: String?, imageInfo: ImageInfo?) {
}
override fun onFinalImageSet(id: String?, imageInfo: ImageInfo?, animatable: Animatable?) {
}
}
constructor(context: Context) : super(context)
constructor(context: Context, attrs: AttributeSet) : super(context, attrs)
constructor(context: Context, attrs: AttributeSet, defStyle: Int) : super(context, attrs, defStyle)
override fun setImageURI(uri: Uri, callerContext: Any?) {
val controller = (controllerBuilder as PipelineDraweeControllerBuilder)
.setControllerListener(listener)
.setCallerContext(callerContext)
.setUri(uri)
.setAutoPlayAnimations(true)
.setOldController(controller)
.build()
setController(controller)
}
}

View file

@ -2,8 +2,8 @@ package com.habitrpg.android.habitica.ui.views.dialogs
import android.content.Context
import android.view.LayoutInflater
import android.widget.ImageView
import android.widget.TextView
import com.facebook.drawee.view.SimpleDraweeView
import com.habitrpg.android.habitica.R
import com.habitrpg.android.habitica.extensions.addCloseButton
import com.habitrpg.android.habitica.extensions.fromHtml
@ -12,7 +12,7 @@ import com.habitrpg.android.habitica.ui.helpers.DataBindingUtils
class AchievementDetailDialog(val achievement: Achievement, context: Context): HabiticaAlertDialog(context) {
private var iconView: SimpleDraweeView?
private var iconView: ImageView?
private var descriptionView: TextView?
init {

View file

@ -2,15 +2,15 @@ package com.habitrpg.android.habitica.ui.views.dialogs
import android.content.Context
import android.view.LayoutInflater
import com.facebook.drawee.view.SimpleDraweeView
import android.widget.ImageView
import com.habitrpg.android.habitica.R
import com.habitrpg.android.habitica.helpers.MainNavigationController
import com.habitrpg.android.habitica.ui.helpers.DataBindingUtils
class FirstDropDialog(context: Context) : HabiticaAlertDialog(context) {
private var eggView: SimpleDraweeView?
private var hatchingPotionView: SimpleDraweeView?
private var eggView: ImageView?
private var hatchingPotionView: ImageView?
init {
val inflater = context.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as? LayoutInflater

View file

@ -5,6 +5,7 @@ import android.graphics.drawable.BitmapDrawable
import android.view.LayoutInflater
import android.view.View
import android.widget.LinearLayout
import androidx.core.graphics.drawable.toBitmap
import com.habitrpg.android.habitica.R
import com.habitrpg.android.habitica.databinding.DialogPetSuggestHatchBinding
import com.habitrpg.android.habitica.helpers.RxErrorHandler
@ -143,9 +144,9 @@ class PetSuggestHatchDialog(context: Context) : HabiticaAlertDialog(context) {
val imageName = "stable_Pet-${pet.animal}-${pet.color}"
DataBindingUtils.loadImage(imageName) {
DataBindingUtils.loadImage(context, imageName) {
val resources = context.resources ?: return@loadImage
val drawable = BitmapDrawable(resources, if (hasMount) it else it.extractAlpha())
val drawable = if (hasMount) it else BitmapDrawable(resources, it.toBitmap().extractAlpha())
Observable.just(drawable)
.observeOn(AndroidSchedulers.mainThread())
.subscribe({

View file

@ -9,7 +9,6 @@ import android.view.ViewGroup
import android.widget.ImageView
import android.widget.LinearLayout
import android.widget.TextView
import com.facebook.drawee.view.SimpleDraweeView
import com.habitrpg.android.habitica.R
import com.habitrpg.android.habitica.databinding.DialogCompletedQuestContentBinding
import com.habitrpg.android.habitica.extensions.fromHtml
@ -87,7 +86,7 @@ class QuestCompletedDialogContent : LinearLayout {
private fun addRewardsRow(inflater: LayoutInflater?, item: QuestDropItem, containerView: ViewGroup?) {
val view = inflater?.inflate(R.layout.row_quest_reward, containerView, false) as? ViewGroup
val imageView = view?.findViewById(R.id.imageView) as? SimpleDraweeView
val imageView = view?.findViewById(R.id.imageView) as? ImageView
val titleTextView = view?.findViewById(R.id.titleTextView) as? TextView
DataBindingUtils.loadImage(imageView, item.imageName)
if (item.count > 1) {

View file

@ -5,7 +5,6 @@ import android.view.LayoutInflater
import android.view.View
import android.widget.ImageView
import android.widget.TextView
import com.facebook.drawee.view.SimpleDraweeView
import com.habitrpg.android.habitica.R
import com.habitrpg.android.habitica.extensions.fromHtml
import com.habitrpg.android.habitica.models.notifications.ChallengeWonData
@ -13,7 +12,7 @@ import com.habitrpg.android.habitica.ui.helpers.DataBindingUtils
class WonChallengeDialog(context: Context) : HabiticaAlertDialog(context) {
fun configure(data: ChallengeWonData?) {
val imageView = additionalContentView?.findViewById<SimpleDraweeView>(R.id.achievement_view)
val imageView = additionalContentView?.findViewById<ImageView>(R.id.achievement_view)
DataBindingUtils.loadImage(imageView, "achievement-karaoke-2x")
if (data?.name != null) {

View file

@ -1,14 +1,14 @@
package com.habitrpg.android.habitica.ui.views.shops
import android.content.Context
import android.widget.ImageView
import android.widget.TextView
import com.facebook.drawee.view.SimpleDraweeView
import com.habitrpg.android.habitica.databinding.DialogPurchaseContentItemBinding
import com.habitrpg.android.habitica.extensions.layoutInflater
class PurchaseDialogBaseContent(context: Context) : PurchaseDialogContent(context) {
val binding = DialogPurchaseContentItemBinding.inflate(context.layoutInflater, this)
override val imageView: SimpleDraweeView
override val imageView: ImageView
get() = binding.imageView
override val titleTextView: TextView
get() = binding.titleTextView

View file

@ -3,21 +3,22 @@ package com.habitrpg.android.habitica.ui.views.shops
import android.content.Context
import android.util.AttributeSet
import android.view.Gravity
import android.widget.ImageView
import android.widget.LinearLayout
import android.widget.TextView
import com.facebook.drawee.backends.pipeline.Fresco
import com.facebook.drawee.view.SimpleDraweeView
import coil.load
import com.habitrpg.android.habitica.extensions.dpToPx
import com.habitrpg.android.habitica.extensions.fromHtml
import com.habitrpg.android.habitica.models.inventory.QuestContent
import com.habitrpg.android.habitica.models.shops.ShopItem
import com.habitrpg.android.habitica.ui.helpers.DataBindingUtils
import com.habitrpg.android.habitica.ui.helpers.loadImage
abstract class PurchaseDialogContent @JvmOverloads constructor(
context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0
) : LinearLayout(context, attrs, defStyleAttr) {
abstract val imageView: SimpleDraweeView
abstract val imageView: ImageView
abstract val titleTextView: TextView
init {
@ -27,23 +28,19 @@ abstract class PurchaseDialogContent @JvmOverloads constructor(
open fun setItem(item: ShopItem) {
if (item.path?.contains("timeTravelBackgrounds") == true) {
val controller = Fresco.newDraweeControllerBuilder()
.setUri("https://habitica-assets.s3.amazonaws.com/mobileApp/images/${item.imageName?.replace("icon_", "")}.gif")
.setAutoPlayAnimations(true)
.build()
imageView.controller = controller
imageView.load("${DataBindingUtils.BASE_IMAGE_URL}${item.imageName?.replace("icon_", "")}.gif")
val params = imageView.layoutParams
params.height = 147.dpToPx(context)
params.width = 140.dpToPx(context)
imageView.layoutParams = params
} else {
DataBindingUtils.loadImage(imageView, item.imageName)
imageView.loadImage(item.imageName)
}
titleTextView.text = item.text
}
open fun setQuestContentItem(questContent: QuestContent) {
DataBindingUtils.loadImage(imageView, "inventory_quest_scroll_" + questContent.key)
imageView.loadImage("inventory_quest_scroll_" + questContent.key)
titleTextView.setText(questContent.text.fromHtml(), TextView.BufferType.SPANNABLE)
}
}

View file

@ -1,9 +1,9 @@
package com.habitrpg.android.habitica.ui.views.shops
import android.content.Context
import android.widget.ImageView
import android.widget.TextView
import androidx.core.content.ContextCompat
import com.facebook.drawee.view.SimpleDraweeView
import com.habitrpg.android.habitica.R
import com.habitrpg.android.habitica.databinding.DialogPurchaseContentGearBinding
import com.habitrpg.android.habitica.extensions.layoutInflater
@ -12,7 +12,7 @@ import com.habitrpg.android.habitica.models.shops.ShopItem
internal class PurchaseDialogGearContent(context: Context) : PurchaseDialogContent(context) {
val binding = DialogPurchaseContentGearBinding.inflate(context.layoutInflater, this)
override val imageView: SimpleDraweeView
override val imageView: ImageView
get() = binding.imageView
override val titleTextView: TextView
get() = binding.titleTextView

View file

@ -1,8 +1,8 @@
package com.habitrpg.android.habitica.ui.views.shops
import android.content.Context
import android.widget.ImageView
import android.widget.TextView
import com.facebook.drawee.view.SimpleDraweeView
import com.habitrpg.android.habitica.databinding.DialogPurchaseGemsBinding
import com.habitrpg.android.habitica.extensions.asDrawable
import com.habitrpg.android.habitica.extensions.layoutInflater
@ -11,7 +11,7 @@ import com.habitrpg.android.habitica.ui.views.HabiticaIconsHelper
internal class PurchaseDialogGemsContent(context: Context) : PurchaseDialogContent(context) {
internal val binding = DialogPurchaseGemsBinding.inflate(context.layoutInflater, this)
override val imageView: SimpleDraweeView
override val imageView: ImageView
get() = binding.imageView
override val titleTextView: TextView
get() = binding.titleTextView

View file

@ -1,15 +1,15 @@
package com.habitrpg.android.habitica.ui.views.shops
import android.content.Context
import android.widget.ImageView
import android.widget.TextView
import com.facebook.drawee.view.SimpleDraweeView
import com.habitrpg.android.habitica.databinding.DialogPurchaseContentItemBinding
import com.habitrpg.android.habitica.extensions.layoutInflater
import com.habitrpg.android.habitica.models.shops.ShopItem
class PurchaseDialogItemContent(context: Context) : PurchaseDialogContent(context) {
private val binding = DialogPurchaseContentItemBinding.inflate(context.layoutInflater, this)
override val imageView: SimpleDraweeView
override val imageView: ImageView
get() = binding.imageView
override val titleTextView: TextView
get() = binding.titleTextView

View file

@ -7,7 +7,6 @@ import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import android.widget.TextView
import com.facebook.drawee.view.SimpleDraweeView
import com.habitrpg.android.habitica.R
import com.habitrpg.android.habitica.databinding.DialogPurchaseContentQuestBinding
import com.habitrpg.android.habitica.extensions.layoutInflater
@ -18,7 +17,7 @@ import com.habitrpg.android.habitica.ui.views.HabiticaIconsHelper
class PurchaseDialogQuestContent(context: Context) : PurchaseDialogContent(context) {
private val binding = DialogPurchaseContentQuestBinding.inflate(context.layoutInflater, this)
override val imageView: SimpleDraweeView
override val imageView: ImageView
get() = binding.imageView
override val titleTextView: TextView
get() = binding.titleTextView
@ -88,7 +87,7 @@ class PurchaseDialogQuestContent(context: Context) : PurchaseDialogContent(conte
private fun addRewardsRow(inflater: LayoutInflater?, item: QuestDropItem, containerView: ViewGroup?) {
val view = inflater?.inflate(R.layout.row_quest_reward, containerView, false) as? ViewGroup
val imageView = view?.findViewById(R.id.imageView) as? SimpleDraweeView
val imageView = view?.findViewById(R.id.imageView) as? ImageView
val titleTextView = view?.findViewById(R.id.titleTextView) as? TextView
DataBindingUtils.loadImage(imageView, item.imageName)
if (item.count > 1) {

View file

@ -6,10 +6,10 @@ import android.graphics.RectF
import android.util.AttributeSet
import android.view.LayoutInflater
import android.view.View
import android.widget.ImageView
import android.widget.LinearLayout
import android.widget.TextView
import androidx.core.content.ContextCompat
import com.facebook.drawee.view.SimpleDraweeView
import com.habitrpg.android.habitica.R
import com.habitrpg.android.habitica.databinding.QuestProgressOldBinding
import com.habitrpg.android.habitica.extensions.layoutInflater
@ -88,7 +88,7 @@ class OldQuestProgressView : LinearLayout {
for (collect in progress.collect ?: emptyList<QuestProgressCollect>()) {
val contentCollect = quest.getCollectWithKey(collect.key) ?: continue
val view = inflater.inflate(R.layout.quest_collect, binding.collectionContainer, false)
val iconView = view.findViewById(R.id.icon_view) as? SimpleDraweeView
val iconView = view.findViewById(R.id.icon_view) as? ImageView
val nameView = view.findViewById(R.id.name_view) as? TextView
val valueView = view.findViewById(R.id.value_view) as? ValueBar
DataBindingUtils.loadImage(iconView, "quest_" + quest.key + "_" + collect.key)

View file

@ -16,7 +16,7 @@ import android.widget.TextView
import androidx.appcompat.app.AlertDialog
import androidx.core.content.ContextCompat
import androidx.core.content.edit
import com.facebook.drawee.view.SimpleDraweeView
import androidx.core.graphics.drawable.toBitmap
import com.habitrpg.android.habitica.R
import com.habitrpg.android.habitica.databinding.QuestProgressBinding
import com.habitrpg.android.habitica.extensions.layoutInflater
@ -181,10 +181,11 @@ class QuestProgressView : LinearLayout {
progress?.rageStrikes?.sortedByDescending { it.wasHit }?.forEach { strike ->
val iconView = ImageView(context)
if (strike.wasHit) {
DataBindingUtils.loadImage("rage_strike_${strike.key}") {
DataBindingUtils.loadImage(context,"rage_strike_${strike.key}") {
Observable.just(it)
.observeOn(AndroidSchedulers.mainThread())
.subscribe({ bitmap ->
.subscribe({ drawable ->
val bitmap = drawable.toBitmap()
val displayDensity = resources.displayMetrics.density
val width = bitmap.width * displayDensity
val height = bitmap.height * displayDensity
@ -250,7 +251,7 @@ class QuestProgressView : LinearLayout {
for (collect in collection) {
val contentCollect = quest.getCollectWithKey(collect.key) ?: continue
val view = inflater.inflate(R.layout.quest_collect, binding.collectionContainer, false)
val iconView: SimpleDraweeView = view.findViewById(R.id.icon_view)
val iconView: ImageView = view.findViewById(R.id.icon_view)
val nameView: TextView = view.findViewById(R.id.name_view)
val valueView: ValueBar = view.findViewById(R.id.value_view)
DataBindingUtils.loadImage(iconView, "quest_" + quest.key + "_" + collect.key)

View file

@ -1,20 +0,0 @@
{
"version": 1,
"artifactType": {
"type": "APK",
"kind": "Directory"
},
"applicationId": "com.habitrpg.android.habitica",
"variantName": "staffRelease",
"elements": [
{
"type": "SINGLE",
"filters": [],
"properties": [],
"versionCode": 2509,
"versionName": "2509",
"enabled": true,
"outputFile": "Habitica-staff-release.apk"
}
]
}