diff options
-rw-r--r-- | core/src/main/kotlin/ca/allanwang/kau/xml/Changelog.kt | 16 | ||||
-rw-r--r-- | core/src/main/res/layout/kau_changelog_content.xml | 2 |
2 files changed, 7 insertions, 11 deletions
diff --git a/core/src/main/kotlin/ca/allanwang/kau/xml/Changelog.kt b/core/src/main/kotlin/ca/allanwang/kau/xml/Changelog.kt index 2e66a97..9adcbf4 100644 --- a/core/src/main/kotlin/ca/allanwang/kau/xml/Changelog.kt +++ b/core/src/main/kotlin/ca/allanwang/kau/xml/Changelog.kt @@ -21,7 +21,6 @@ import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import android.widget.TextView -import androidx.annotation.ColorInt import androidx.annotation.LayoutRes import androidx.annotation.XmlRes import androidx.recyclerview.widget.RecyclerView @@ -41,13 +40,13 @@ import org.xmlpull.v1.XmlPullParser * * Easy changelog loader */ -fun Context.showChangelog(@XmlRes xmlRes: Int, @ColorInt textColor: Int? = null, customize: MaterialDialog.() -> Unit = {}) { - ctxCoroutine.launch { - val items = withContext(Dispatchers.Default) { parse(this@showChangelog, xmlRes) } +fun Context.showChangelog(@XmlRes xmlRes: Int, customize: MaterialDialog.() -> Unit = {}) { + ctxCoroutine.launch(Dispatchers.Main) { + val items = withContext(Dispatchers.IO) { parse(this@showChangelog, xmlRes) } materialDialog { title(R.string.kau_changelog) positiveButton(R.string.kau_great) - customListAdapter(ChangelogAdapter(items, textColor), null) + customListAdapter(ChangelogAdapter(items), null) customize() } } @@ -57,7 +56,7 @@ fun Context.showChangelog(@XmlRes xmlRes: Int, @ColorInt textColor: Int? = null, * Internals of the changelog dialog * Contains an mainAdapter for each item, as well as the tags to parse */ -internal class ChangelogAdapter(val items: List<Pair<String, ChangelogType>>, @ColorInt val textColor: Int? = null) : +internal class ChangelogAdapter(val items: List<Pair<String, ChangelogType>>) : RecyclerView.Adapter<ChangelogAdapter.ChangelogVH>() { override fun onCreateViewHolder(parent: ViewGroup, viewType: Int) = ChangelogVH( @@ -67,10 +66,6 @@ internal class ChangelogAdapter(val items: List<Pair<String, ChangelogType>>, @C override fun onBindViewHolder(holder: ChangelogVH, position: Int) { holder.text.text = items[position].first - if (textColor != null) { - holder.text.setTextColor(textColor) - holder.bullet?.setTextColor(textColor) - } } override fun getItemId(position: Int) = position.toLong() @@ -81,7 +76,6 @@ internal class ChangelogAdapter(val items: List<Pair<String, ChangelogType>>, @C internal class ChangelogVH(itemView: View) : RecyclerView.ViewHolder(itemView) { val text: TextView = itemView.findViewById(R.id.kau_changelog_text) - val bullet: TextView? = itemView.findViewById(R.id.kau_changelog_bullet) } } diff --git a/core/src/main/res/layout/kau_changelog_content.xml b/core/src/main/res/layout/kau_changelog_content.xml index ab94956..1fea88d 100644 --- a/core/src/main/res/layout/kau_changelog_content.xml +++ b/core/src/main/res/layout/kau_changelog_content.xml @@ -10,6 +10,7 @@ <!--padding bottom is 14sp * 0.6--> <TextView + android:textColor="?android:textColorSecondary" android:id="@+id/kau_changelog_bullet" android:layout_width="wrap_content" android:layout_height="wrap_content" @@ -19,6 +20,7 @@ android:textAppearance="@style/TextAppearance.AppCompat.Small" /> <TextView + android:textColor="?android:textColorPrimary" android:id="@+id/kau_changelog_text" android:layout_width="match_parent" android:layout_height="wrap_content" |