share dialog crash fixed

This commit is contained in:
Bnyro 2022-06-14 14:40:16 +02:00
parent 3260bd6b7a
commit a8f90405a9
2 changed files with 5 additions and 3 deletions

View File

@ -207,7 +207,7 @@ class MainActivity : AppCompatActivity() {
val bundle = Bundle() val bundle = Bundle()
bundle.putString("videoId", watch) bundle.putString("videoId", watch)
// for time stamped links // for time stamped links
if (data.query?.contains("t=")!!) { if (data.query != null && data.query?.contains("t=")!!) {
val timeStamp = data.query.toString().split("t=")[1] val timeStamp = data.query.toString().split("t=")[1]
bundle.putLong("timeStamp", timeStamp.toLong()) bundle.putLong("timeStamp", timeStamp.toLong())
} }
@ -227,7 +227,7 @@ class MainActivity : AppCompatActivity() {
var bundle = Bundle() var bundle = Bundle()
bundle.putString("videoId", watch.replace("v=", "")) bundle.putString("videoId", watch.replace("v=", ""))
// for time stamped links // for time stamped links
if (data.query?.contains("t=")!!) { if (data.query != null && data.query?.contains("t=")!!) {
val timeStamp = data.query.toString().split("t=")[1] val timeStamp = data.query.toString().split("t=")[1]
bundle.putLong("timeStamp", timeStamp.toLong()) bundle.putLong("timeStamp", timeStamp.toLong())
} }
@ -237,7 +237,7 @@ class MainActivity : AppCompatActivity() {
var bundle = Bundle() var bundle = Bundle()
bundle.putString("videoId", watch) bundle.putString("videoId", watch)
// for time stamped links // for time stamped links
if (data.query?.contains("t=")!!) { if (data.query != null && data.query?.contains("t=")!!) {
val timeStamp = data.query.toString().split("t=")[1] val timeStamp = data.query.toString().split("t=")[1]
bundle.putLong("timeStamp", timeStamp.toLong()) bundle.putLong("timeStamp", timeStamp.toLong())
} }

View File

@ -36,6 +36,7 @@ class DescriptionAdapter(
lateinit var bitmap: Bitmap lateinit var bitmap: Bitmap
val thread = Thread { val thread = Thread {
try { try {
// try to parse the thumbnailUrl to a Bitmap
val inputStream = URL(thumbnailUrl).openStream() val inputStream = URL(thumbnailUrl).openStream()
bitmap = BitmapFactory.decodeStream(inputStream) bitmap = BitmapFactory.decodeStream(inputStream)
} catch (ex: java.lang.Exception) { } catch (ex: java.lang.Exception) {
@ -44,6 +45,7 @@ class DescriptionAdapter(
} }
thread.start() thread.start()
thread.join() thread.join()
// return bitmap if initialized
return try { return try {
bitmap bitmap
} catch (e: Exception) { } catch (e: Exception) {