Merge pull request #324 from Bnyro/fix

description formatting fix
This commit is contained in:
Bnyro 2022-05-29 12:36:52 +02:00 committed by GitHub
commit 308982fde2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 8 deletions

View File

@ -19,6 +19,7 @@ import com.github.libretube.adapters.ChannelAdapter
import com.github.libretube.obj.Subscribe
import com.google.android.material.button.MaterialButton
import com.squareup.picasso.Picasso
import org.chromium.base.ThreadUtils.runOnUiThread
import java.io.IOException
import retrofit2.HttpException
@ -206,10 +207,11 @@ class ChannelFragment : Fragment() {
response.subscriberCount.formatShort()
)
val channelDescription = view.findViewById<TextView>(R.id.channel_description)
if (response.description?.trim() == "")
if (response.description?.trim() == "") {
channelDescription.visibility = View.GONE
else
} else {
channelDescription.text = response.description?.trim()
}
val bannerImage = view.findViewById<ImageView>(R.id.channel_banner)
val channelImage = view.findViewById<ImageView>(R.id.channel_image)
Picasso.get().load(response.bannerUrl).into(bannerImage)

View File

@ -69,12 +69,13 @@ import com.google.android.exoplayer2.util.RepeatModeUtil
import com.google.android.material.button.MaterialButton
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import com.squareup.picasso.Picasso
import org.chromium.base.ThreadUtils.runOnUiThread
import org.chromium.net.CronetEngine
import retrofit2.HttpException
import java.io.IOException
import java.net.URLEncoder
import java.util.concurrent.Executors
import kotlin.math.abs
import org.chromium.net.CronetEngine
import retrofit2.HttpException
var isFullScreen = false
@ -654,13 +655,20 @@ class PlayerFragment : Fragment() {
response.relatedStreams!!,
childFragmentManager
)
val description = response.description!!
view.findViewById<TextView>(R.id.player_description).text =
// detect whether the description is html formatted
if (description.contains("<") && description.contains(">")) {
if (SDK_INT >= Build.VERSION_CODES.N) {
Html.fromHtml(response.description, Html.FROM_HTML_MODE_COMPACT).trim()
Html.fromHtml(description, Html.FROM_HTML_MODE_COMPACT)
.trim()
} else {
Html.fromHtml(response.description).trim()
Html.fromHtml(description).trim()
}
} else {
description
}
view.findViewById<TextView>(R.id.player_views_info).text =
response.views.formatShort() + " views • " + response.uploadDate
view.findViewById<TextView>(R.id.textLike).text = response.likes.formatShort()

View File

@ -96,6 +96,7 @@
android:layout_marginStart="10dp"
android:layout_marginEnd="10dp"
android:layout_marginBottom="15dp"
android:autoLink="web"
android:text="" />
<RelativeLayout