forked from recloudstream/cloudstream
fixed major memory leak caused by glide
This commit is contained in:
parent
d581c4b627
commit
5e8e8c35e9
3 changed files with 21 additions and 11 deletions
|
@ -36,7 +36,7 @@ android {
|
||||||
targetSdkVersion 30
|
targetSdkVersion 30
|
||||||
|
|
||||||
versionCode 48
|
versionCode 48
|
||||||
versionName "2.10.29"
|
versionName "2.10.30"
|
||||||
|
|
||||||
resValue "string", "app_version",
|
resValue "string", "app_version",
|
||||||
"${defaultConfig.versionName}${versionNameSuffix ?: ""}"
|
"${defaultConfig.versionName}${versionNameSuffix ?: ""}"
|
||||||
|
@ -99,10 +99,10 @@ dependencies {
|
||||||
implementation 'androidx.appcompat:appcompat:1.4.2'
|
implementation 'androidx.appcompat:appcompat:1.4.2'
|
||||||
implementation 'com.google.android.material:material:1.5.0' // dont change this to 1.6.0 it looks ugly af
|
implementation 'com.google.android.material:material:1.5.0' // dont change this to 1.6.0 it looks ugly af
|
||||||
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
|
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
|
||||||
implementation 'androidx.navigation:navigation-fragment-ktx:2.5.0-rc01'
|
implementation 'androidx.navigation:navigation-fragment-ktx:2.5.0'
|
||||||
implementation 'androidx.navigation:navigation-ui-ktx:2.5.0-rc01'
|
implementation 'androidx.navigation:navigation-ui-ktx:2.5.0'
|
||||||
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.4.1'
|
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.5.0'
|
||||||
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.4.1'
|
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.0'
|
||||||
testImplementation 'junit:junit:4.13.2'
|
testImplementation 'junit:junit:4.13.2'
|
||||||
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
|
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
|
||||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
|
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
|
||||||
|
|
|
@ -2,12 +2,14 @@ package com.lagradost.cloudstream3.animeproviders
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty
|
import com.fasterxml.jackson.annotation.JsonProperty
|
||||||
import com.lagradost.cloudstream3.*
|
import com.lagradost.cloudstream3.*
|
||||||
import org.jsoup.Jsoup
|
|
||||||
import java.util.*
|
|
||||||
import com.lagradost.cloudstream3.mvvm.logError
|
import com.lagradost.cloudstream3.mvvm.logError
|
||||||
import com.lagradost.cloudstream3.mvvm.safeApiCall
|
import com.lagradost.cloudstream3.mvvm.safeApiCall
|
||||||
import com.lagradost.cloudstream3.utils.*
|
|
||||||
import com.lagradost.cloudstream3.utils.AppUtils.parseJson
|
import com.lagradost.cloudstream3.utils.AppUtils.parseJson
|
||||||
|
import com.lagradost.cloudstream3.utils.ExtractorLink
|
||||||
|
import com.lagradost.cloudstream3.utils.M3u8Helper
|
||||||
|
import com.lagradost.cloudstream3.utils.Qualities
|
||||||
|
import com.lagradost.cloudstream3.utils.loadExtractor
|
||||||
|
import org.jsoup.Jsoup
|
||||||
|
|
||||||
class GomunimeProvider : MainAPI() {
|
class GomunimeProvider : MainAPI() {
|
||||||
override var mainUrl = "https://185.231.223.76"
|
override var mainUrl = "https://185.231.223.76"
|
||||||
|
|
|
@ -34,6 +34,7 @@ import androidx.fragment.app.Fragment
|
||||||
import androidx.fragment.app.FragmentActivity
|
import androidx.fragment.app.FragmentActivity
|
||||||
import androidx.navigation.fragment.NavHostFragment
|
import androidx.navigation.fragment.NavHostFragment
|
||||||
import androidx.preference.PreferenceManager
|
import androidx.preference.PreferenceManager
|
||||||
|
import com.bumptech.glide.load.engine.DiskCacheStrategy
|
||||||
import com.bumptech.glide.load.model.GlideUrl
|
import com.bumptech.glide.load.model.GlideUrl
|
||||||
import com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions
|
import com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions
|
||||||
import com.lagradost.cloudstream3.R
|
import com.lagradost.cloudstream3.R
|
||||||
|
@ -156,16 +157,20 @@ object UIHelper {
|
||||||
errorImageDrawable: Int? = null
|
errorImageDrawable: Int? = null
|
||||||
): Boolean {
|
): Boolean {
|
||||||
if (this == null || url.isNullOrBlank()) return false
|
if (this == null || url.isNullOrBlank()) return false
|
||||||
|
|
||||||
return try {
|
return try {
|
||||||
val builder = GlideApp.with(this.context)
|
val builder = GlideApp.with(this)
|
||||||
.load(GlideUrl(url) { headers ?: emptyMap() }).transition(
|
.load(GlideUrl(url) { headers ?: emptyMap() }).transition(
|
||||||
DrawableTransitionOptions.withCrossFade()
|
DrawableTransitionOptions.withCrossFade()
|
||||||
)
|
)
|
||||||
|
.skipMemoryCache(true)
|
||||||
|
.diskCacheStrategy(DiskCacheStrategy.ALL)
|
||||||
|
|
||||||
if (errorImageDrawable != null)
|
val res = if (errorImageDrawable != null)
|
||||||
builder.error(errorImageDrawable).into(this)
|
builder.error(errorImageDrawable).into(this)
|
||||||
else
|
else
|
||||||
builder.into(this)
|
builder.into(this)
|
||||||
|
res.clearOnDetach()
|
||||||
|
|
||||||
true
|
true
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
|
@ -182,13 +187,16 @@ object UIHelper {
|
||||||
) {
|
) {
|
||||||
if (this == null || url.isNullOrBlank()) return
|
if (this == null || url.isNullOrBlank()) return
|
||||||
try {
|
try {
|
||||||
GlideApp.with(this.context)
|
val res = GlideApp.with(this)
|
||||||
.load(GlideUrl(url) { headers ?: emptyMap() })
|
.load(GlideUrl(url) { headers ?: emptyMap() })
|
||||||
.apply(bitmapTransform(BlurTransformation(radius, sample)))
|
.apply(bitmapTransform(BlurTransformation(radius, sample)))
|
||||||
.transition(
|
.transition(
|
||||||
DrawableTransitionOptions.withCrossFade()
|
DrawableTransitionOptions.withCrossFade()
|
||||||
)
|
)
|
||||||
|
.skipMemoryCache(true)
|
||||||
|
.diskCacheStrategy(DiskCacheStrategy.ALL)
|
||||||
.into(this)
|
.into(this)
|
||||||
|
res.clearOnDetach()
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
logError(e)
|
logError(e)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue