mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-14 22:30:30 +05:30
Merge pull request #3953 from Bnyro/master
Fix crash when opening description while chapter updates
This commit is contained in:
commit
d27e5fae0d
@ -16,7 +16,7 @@ fun Long?.formatShort(): String {
|
||||
val units = arrayOf("", "K", "M", "B", "T")
|
||||
for (i in units.size downTo 1) {
|
||||
val step = 1000.0.pow(i.toDouble())
|
||||
if (value > step) return String.format("%3.0f%s", value / step, units[i]).trim()
|
||||
if (value > step) return "%3.0f%s".format(value / step, units[i]).trim()
|
||||
}
|
||||
value.toString()
|
||||
}
|
||||
|
@ -133,7 +133,7 @@ object ThemeHelper {
|
||||
*/
|
||||
fun getStyledAppName(context: Context): Spanned {
|
||||
val colorPrimary = getThemeColor(context, androidx.appcompat.R.attr.colorPrimaryDark)
|
||||
val hexColor = String.format("#%06X", (0xFFFFFF and colorPrimary))
|
||||
val hexColor = "#%06X".format(0xFFFFFF and colorPrimary)
|
||||
return "Libre<span style='color:$hexColor';>Tube</span>"
|
||||
.parseAsHtml(HtmlCompat.FROM_HTML_MODE_COMPACT)
|
||||
}
|
||||
|
@ -53,7 +53,5 @@ class ChaptersAdapter(
|
||||
notifyItemChanged(newPosition)
|
||||
}
|
||||
|
||||
override fun getItemCount(): Int {
|
||||
return chapters.size
|
||||
}
|
||||
override fun getItemCount() = chapters.size
|
||||
}
|
||||
|
@ -563,7 +563,7 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions {
|
||||
streams.views.formatShort()
|
||||
} else {
|
||||
// show exact view count
|
||||
String.format("%,d", streams.views)
|
||||
"%,d".format(streams.views)
|
||||
}
|
||||
val viewInfo = getString(R.string.normal_views, views, localizeDate(streams))
|
||||
if (binding.descLinLayout.isVisible) {
|
||||
@ -586,9 +586,8 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions {
|
||||
if (this::chapters.isInitialized && chapters.isNotEmpty()) {
|
||||
val chapterIndex = getCurrentChapterIndex() ?: return
|
||||
// scroll to the current chapter in the chapterRecView in the description
|
||||
val layoutManager = binding.chaptersRecView.layoutManager as LinearLayoutManager
|
||||
layoutManager.scrollToPositionWithOffset(chapterIndex, 0)
|
||||
// set selected
|
||||
binding.chaptersRecView.scrollToPosition(chapterIndex)
|
||||
// set selected item, that should be highlighted
|
||||
val chaptersAdapter = binding.chaptersRecView.adapter as ChaptersAdapter
|
||||
chaptersAdapter.updateSelectedPosition(chapterIndex)
|
||||
}
|
||||
|
@ -6,6 +6,7 @@
|
||||
android:layout_height="match_parent"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:backgroundTint="@android:color/transparent"
|
||||
android:layout_marginHorizontal="1dp"
|
||||
app:strokeWidth="0dp">
|
||||
|
||||
<LinearLayout
|
||||
@ -13,7 +14,7 @@
|
||||
android:layout_width="100dp"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:paddingHorizontal="5dp">
|
||||
android:padding="5dp">
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
|
Loading…
Reference in New Issue
Block a user