mirror of
https://github.com/ultrasonic/ultrasonic
synced 2025-02-27 08:57:44 +01:00
Merge branch 'tzugen-leaks' into develop
This commit is contained in:
commit
2a6c9baa3d
@ -45,6 +45,7 @@ complexity:
|
||||
thresholdInFiles: 20
|
||||
thresholdInClasses: 20
|
||||
thresholdInInterfaces: 20
|
||||
thresholdInObjects: 30
|
||||
LabeledExpression:
|
||||
active: false
|
||||
|
||||
|
@ -451,13 +451,6 @@
|
||||
column="9"/>
|
||||
</issue>
|
||||
|
||||
<issue
|
||||
id="ObsoleteSdkInt"
|
||||
message="This folder configuration (`v14`) is unnecessary; `minSdkVersion` is 14. Merge all the resources in this folder into `drawable-xhdpi`.">
|
||||
<location
|
||||
file="src/main/res/drawable-xhdpi-v14"/>
|
||||
</issue>
|
||||
|
||||
<issue
|
||||
id="StaticFieldLeak"
|
||||
message="This `AsyncTask` class should be static or leaks might occur (org.moire.ultrasonic.service.DownloadQueueSerializer.SerializeTask)"
|
||||
@ -480,17 +473,6 @@
|
||||
column="19"/>
|
||||
</issue>
|
||||
|
||||
<issue
|
||||
id="StaticFieldLeak"
|
||||
message="Do not place Android context classes in static fields; this is a memory leak"
|
||||
errorLine1=" private static Context context;"
|
||||
errorLine2=" ~~~~~~">
|
||||
<location
|
||||
file="src/main/java/org/moire/ultrasonic/view/UpdateView.java"
|
||||
line="29"
|
||||
column="10"/>
|
||||
</issue>
|
||||
|
||||
<issue
|
||||
id="UseCompoundDrawables"
|
||||
message="This tag and its children can be replaced by one `<TextView/>` and a compound drawable"
|
||||
|
@ -3,7 +3,6 @@ package org.moire.ultrasonic.view;
|
||||
import android.content.Context;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import timber.log.Timber;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.AbsListView;
|
||||
import android.widget.LinearLayout;
|
||||
@ -14,6 +13,8 @@ import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.WeakHashMap;
|
||||
|
||||
import timber.log.Timber;
|
||||
|
||||
/**
|
||||
* A View that is periodically refreshed
|
||||
* @deprecated
|
||||
@ -26,12 +27,10 @@ public class UpdateView extends LinearLayout
|
||||
private static Handler backgroundHandler;
|
||||
private static Handler uiHandler;
|
||||
private static Runnable updateRunnable;
|
||||
private static Context context;
|
||||
|
||||
public UpdateView(Context context)
|
||||
{
|
||||
super(context);
|
||||
UpdateView.context = context;
|
||||
|
||||
setLayoutParams(new AbsListView.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
|
||||
INSTANCES.put(this, null);
|
||||
|
@ -1,9 +1,13 @@
|
||||
package org.moire.ultrasonic.imageloader
|
||||
|
||||
import android.app.ActivityManager
|
||||
import android.content.Context
|
||||
import android.content.pm.ApplicationInfo
|
||||
import android.text.TextUtils
|
||||
import android.view.View
|
||||
import android.widget.ImageView
|
||||
import androidx.core.content.ContextCompat
|
||||
import com.squareup.picasso.LruCache
|
||||
import com.squareup.picasso.Picasso
|
||||
import com.squareup.picasso.RequestCreator
|
||||
import java.io.File
|
||||
@ -35,6 +39,7 @@ class ImageLoader(
|
||||
private val picasso = Picasso.Builder(context)
|
||||
.addRequestHandler(CoverArtRequestHandler(apiClient))
|
||||
.addRequestHandler(AvatarRequestHandler(apiClient))
|
||||
.memoryCache(LruCache(calculateMemoryCacheSize(context)))
|
||||
.build().apply {
|
||||
setIndicatorsEnabled(BuildConfig.DEBUG)
|
||||
}
|
||||
@ -179,6 +184,18 @@ class ImageLoader(
|
||||
return requested
|
||||
}
|
||||
}
|
||||
|
||||
private fun calculateMemoryCacheSize(context: Context): Int {
|
||||
val am = ContextCompat.getSystemService(
|
||||
context,
|
||||
ActivityManager::class.java
|
||||
)
|
||||
val largeHeap = context.applicationInfo.flags and ApplicationInfo.FLAG_LARGE_HEAP != 0
|
||||
val memoryClass = if (largeHeap) am!!.largeMemoryClass else am!!.memoryClass
|
||||
// Target 25% of the available heap.
|
||||
@Suppress("MagicNumber")
|
||||
return (1024L * 1024L * memoryClass / 4).toInt()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -708,7 +708,7 @@ open class RESTMusicService(
|
||||
// By registering a callback we ensure this info is saved in the database as well
|
||||
subsonicAPIClient.onProtocolChange = {
|
||||
Timber.i("Server minimum API version set to %s", it)
|
||||
activeServerProvider.setMinimumApiVersion(it.toString())
|
||||
activeServerProvider.setMinimumApiVersion(it.restApiVersion)
|
||||
}
|
||||
}
|
||||
|
||||
|
Before Width: | Height: | Size: 889 B After Width: | Height: | Size: 889 B |
Loading…
x
Reference in New Issue
Block a user