diff --git a/app/src/main/java/com/github/libretube/RouterActivity.kt b/app/src/main/java/com/github/libretube/RouterActivity.kt index be955d57a..1292422a3 100644 --- a/app/src/main/java/com/github/libretube/RouterActivity.kt +++ b/app/src/main/java/com/github/libretube/RouterActivity.kt @@ -12,9 +12,13 @@ class RouterActivity : AppCompatActivity() { val TAG = "RouterActivity" override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) - if (checkHost(intent)) { + if (intent.getStringExtra(Intent.EXTRA_TEXT) != null && checkHost(intent)) { // start the main activity using the given URI as data if the host is known - handleSendText(intent) + val uri = Uri.parse(intent.getStringExtra(Intent.EXTRA_TEXT)!!) + handleSendText(uri) + } else if (intent.data != null) { + val uri = intent.data + handleSendText(uri!!) } else { // start app as normal if URI not in host list ThemeHelper().restartMainActivity(this) @@ -30,16 +34,13 @@ class RouterActivity : AppCompatActivity() { return hostsList.contains(intentDataHost) } - private fun handleSendText(intent: Intent) { - intent.getStringExtra(Intent.EXTRA_TEXT)?.let { - Log.i(TAG, it) - val pm: PackageManager = this.packageManager - // startIntent(this, MainActivity::class.java doesn't work for the activity aliases needed for the logo switch option - val intent = pm.getLaunchIntentForPackage(this.packageName) - intent?.flags = Intent.FLAG_ACTIVITY_CLEAR_TASK - intent?.data = Uri.parse(it) - this.startActivity(intent) - this.finishAndRemoveTask() - } + private fun handleSendText(uri: Uri) { + Log.i(TAG, uri.toString()) + val pm: PackageManager = this.packageManager + val intent = pm.getLaunchIntentForPackage(this.packageName) + intent?.flags = Intent.FLAG_ACTIVITY_CLEAR_TASK + intent?.data = uri + this.startActivity(intent) + this.finishAndRemoveTask() } } diff --git a/app/src/main/java/com/github/libretube/adapters/CommentsAdapter.kt b/app/src/main/java/com/github/libretube/adapters/CommentsAdapter.kt index 3176cad6e..7740c7e58 100644 --- a/app/src/main/java/com/github/libretube/adapters/CommentsAdapter.kt +++ b/app/src/main/java/com/github/libretube/adapters/CommentsAdapter.kt @@ -1,5 +1,6 @@ package com.github.libretube.adapters +import android.annotation.SuppressLint import android.util.Log import android.view.LayoutInflater import android.view.View @@ -35,17 +36,18 @@ class CommentsAdapter( private var repliesPage = CommentsPage() fun updateItems(newItems: List) { - var commentsSize = comments.size + val commentsSize = comments.size comments.addAll(newItems) notifyItemRangeInserted(commentsSize, newItems.size) } override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): CommentsViewHolder { - var commentsView = + val commentsView = LayoutInflater.from(parent.context).inflate(R.layout.comments_row, parent, false) return CommentsViewHolder(commentsView) } + @SuppressLint("SetTextI18n") override fun onBindViewHolder(holder: CommentsViewHolder, position: Int) { holder.v.findViewById(R.id.comment_infos).text = comments[position].author.toString() + @@ -103,10 +105,10 @@ class CommentsAdapter( private fun fetchReplies(nextpage: String, repliesAdapter: RepliesAdapter) { CoroutineScope(Dispatchers.Main).launch { - if (!isLoading && nextpage != null) { + if (!isLoading) { isLoading = true try { - repliesPage = RetrofitInstance.api.getCommentsNextPage(videoId!!, nextpage!!) + repliesPage = RetrofitInstance.api.getCommentsNextPage(videoId, nextpage) } catch (e: IOException) { println(e) Log.e(TAG, "IOException, you might not have internet connection") diff --git a/app/src/main/java/com/github/libretube/dialogs/UpdateDialog.kt b/app/src/main/java/com/github/libretube/dialogs/UpdateDialog.kt index 2ca40e58f..62beaf79c 100644 --- a/app/src/main/java/com/github/libretube/dialogs/UpdateDialog.kt +++ b/app/src/main/java/com/github/libretube/dialogs/UpdateDialog.kt @@ -4,7 +4,6 @@ import android.app.Dialog import android.content.Intent import android.net.Uri import android.os.Bundle -import androidx.core.content.ContentProviderCompat.requireContext import androidx.fragment.app.DialogFragment import com.github.libretube.R import com.google.android.material.dialog.MaterialAlertDialogBuilder