Fix crashing, loading albums
This commit is contained in:
parent
397f42a54a
commit
d7ab358e60
59 changed files with 370 additions and 405 deletions
27
appthemehelper/src/main/java/code/name/monkey/appthemehelper/common/prefs/supportv7/ATEPreferenceCategory.kt
Executable file → Normal file
27
appthemehelper/src/main/java/code/name/monkey/appthemehelper/common/prefs/supportv7/ATEPreferenceCategory.kt
Executable file → Normal file
|
@ -19,23 +19,26 @@ import android.util.AttributeSet
|
|||
import android.widget.TextView
|
||||
import androidx.preference.PreferenceCategory
|
||||
import androidx.preference.PreferenceViewHolder
|
||||
import code.name.monkey.appthemehelper.R
|
||||
import code.name.monkey.appthemehelper.ThemeStore
|
||||
|
||||
class ATEPreferenceCategory @JvmOverloads constructor(
|
||||
context: Context,
|
||||
attrs: AttributeSet? = null,
|
||||
defStyleAttr: Int = 0,
|
||||
defStyleRes: Int = 0
|
||||
context: Context?,
|
||||
attrs: AttributeSet?,
|
||||
defStyleAttr: Int = -1,
|
||||
defStyleRes: Int = -1
|
||||
) : PreferenceCategory(context, attrs, defStyleAttr, defStyleRes) {
|
||||
|
||||
init {
|
||||
layoutResource = R.layout.ate_preference_category
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: PreferenceViewHolder) {
|
||||
super.onBindViewHolder(holder)
|
||||
val mTitle = holder.itemView as TextView
|
||||
mTitle.setTextColor(ThemeStore.accentColor(context))
|
||||
val mTitle = holder.itemView.findViewById<TextView>(android.R.id.title)
|
||||
mTitle.setTextColor(ThemeStore.accentColor(holder.itemView.context))
|
||||
/*mTitle.textSize = dip2px(context, 4f)
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
mTitle.setTextAppearance(R.style.TextAppearance_MaterialComponents_Overline)
|
||||
}*/
|
||||
}
|
||||
|
||||
fun dip2px(context: Context, dpVale: Float): Float {
|
||||
val scale = context.resources.displayMetrics.density
|
||||
return (dpVale * scale + 0.5f)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,50 +0,0 @@
|
|||
package code.name.monkey.appthemehelper.util
|
||||
|
||||
/**
|
||||
* @author Aidan Follestad (afollestad)
|
||||
*/
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.Typeface
|
||||
import androidx.collection.SimpleArrayMap
|
||||
|
||||
/*
|
||||
Each call to Typeface.createFromAsset will load a new instance of the typeface into memory,
|
||||
and this memory is not consistently get garbage collected
|
||||
http://code.google.com/p/android/issues/detail?id=9904
|
||||
(It states released but even on Lollipop you can see the typefaces accumulate even after
|
||||
multiple GC passes)
|
||||
|
||||
You can detect this by running:
|
||||
adb shell dumpsys meminfo com.your.packagenage
|
||||
|
||||
You will see output like:
|
||||
|
||||
Asset Allocations
|
||||
zip:/data/app/com.your.packagenage-1.apk:/assets/Roboto-Medium.ttf: 125K
|
||||
zip:/data/app/com.your.packagenage-1.apk:/assets/Roboto-Medium.ttf: 125K
|
||||
zip:/data/app/com.your.packagenage-1.apk:/assets/Roboto-Medium.ttf: 125K
|
||||
zip:/data/app/com.your.packagenage-1.apk:/assets/Roboto-Regular.ttf: 123K
|
||||
zip:/data/app/com.your.packagenage-1.apk:/assets/Roboto-Medium.ttf: 125K
|
||||
|
||||
*/
|
||||
object TypefaceHelper {
|
||||
|
||||
private val cache = SimpleArrayMap<String, Typeface>()
|
||||
|
||||
operator fun get(c: Context, name: String): Typeface? {
|
||||
synchronized(cache) {
|
||||
if (!cache.containsKey(name)) {
|
||||
try {
|
||||
val t = Typeface.createFromAsset(c.assets, name)
|
||||
cache.put(name, t)
|
||||
return t
|
||||
} catch (e: RuntimeException) {
|
||||
return null
|
||||
}
|
||||
|
||||
}
|
||||
return cache.get(name)
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,15 +1,11 @@
|
|||
package code.name.monkey.appthemehelper.util
|
||||
|
||||
import android.graphics.drawable.ColorDrawable
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.graphics.drawable.TransitionDrawable
|
||||
import android.view.View
|
||||
import android.view.ViewTreeObserver
|
||||
import androidx.annotation.ColorInt
|
||||
|
||||
|
||||
object ViewUtil {
|
||||
|
||||
fun removeOnGlobalLayoutListener(v: View, listener: ViewTreeObserver.OnGlobalLayoutListener) {
|
||||
v.viewTreeObserver.removeOnGlobalLayoutListener(listener)
|
||||
}
|
||||
|
@ -17,23 +13,4 @@ object ViewUtil {
|
|||
fun setBackgroundCompat(view: View, drawable: Drawable?) {
|
||||
view.background = drawable
|
||||
}
|
||||
|
||||
fun setBackgroundTransition(view: View, newDrawable: Drawable): TransitionDrawable {
|
||||
val transition = DrawableUtil.createTransitionDrawable(view.background, newDrawable)
|
||||
setBackgroundCompat(view, transition)
|
||||
return transition
|
||||
}
|
||||
|
||||
fun setBackgroundColorTransition(view: View, @ColorInt newColor: Int): TransitionDrawable {
|
||||
val oldColor = view.background
|
||||
|
||||
val start = oldColor ?: ColorDrawable(view.solidColor)
|
||||
val end = ColorDrawable(newColor)
|
||||
|
||||
val transition = DrawableUtil.createTransitionDrawable(start, end)
|
||||
|
||||
setBackgroundCompat(view, transition)
|
||||
|
||||
return transition
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,7 +34,6 @@
|
|||
|
||||
<code.name.monkey.appthemehelper.common.views.ATEPrimaryTextView
|
||||
android:id="@android:id/title"
|
||||
style="@style/TextViewSubtitle1"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentStart="true"
|
||||
|
@ -53,7 +52,6 @@
|
|||
android:layout_alignLeft="@android:id/title"
|
||||
android:layout_marginTop="2dp"
|
||||
android:maxLines="4"
|
||||
android:textAppearance="@style/TextViewBody2"
|
||||
tools:text="Summary" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
|
|
@ -54,7 +54,6 @@
|
|||
android:layout_alignLeft="@android:id/title"
|
||||
android:layout_marginTop="2dp"
|
||||
android:maxLines="4"
|
||||
android:textAppearance="@style/TextViewBody2"
|
||||
tools:text="I have one solution for you.you can change font size for specific preference by managing layout file." />
|
||||
|
||||
</RelativeLayout>
|
||||
|
|
|
@ -29,7 +29,6 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_vertical"
|
||||
android:textAppearance="@style/TextViewSubtitle1"
|
||||
android:textColor="#000000" />
|
||||
|
||||
<code.name.monkey.appthemehelper.common.views.ATESecondaryTextView
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue