mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-13 22:00:30 +05:30
open links fixed
This commit is contained in:
parent
b34170bf08
commit
8712aa4efe
@ -12,9 +12,13 @@ class RouterActivity : AppCompatActivity() {
|
|||||||
val TAG = "RouterActivity"
|
val TAG = "RouterActivity"
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
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
|
// 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 {
|
} else {
|
||||||
// start app as normal if URI not in host list
|
// start app as normal if URI not in host list
|
||||||
ThemeHelper().restartMainActivity(this)
|
ThemeHelper().restartMainActivity(this)
|
||||||
@ -30,16 +34,13 @@ class RouterActivity : AppCompatActivity() {
|
|||||||
return hostsList.contains(intentDataHost)
|
return hostsList.contains(intentDataHost)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun handleSendText(intent: Intent) {
|
private fun handleSendText(uri: Uri) {
|
||||||
intent.getStringExtra(Intent.EXTRA_TEXT)?.let {
|
Log.i(TAG, uri.toString())
|
||||||
Log.i(TAG, it)
|
val pm: PackageManager = this.packageManager
|
||||||
val pm: PackageManager = this.packageManager
|
val intent = pm.getLaunchIntentForPackage(this.packageName)
|
||||||
// startIntent(this, MainActivity::class.java doesn't work for the activity aliases needed for the logo switch option
|
intent?.flags = Intent.FLAG_ACTIVITY_CLEAR_TASK
|
||||||
val intent = pm.getLaunchIntentForPackage(this.packageName)
|
intent?.data = uri
|
||||||
intent?.flags = Intent.FLAG_ACTIVITY_CLEAR_TASK
|
this.startActivity(intent)
|
||||||
intent?.data = Uri.parse(it)
|
this.finishAndRemoveTask()
|
||||||
this.startActivity(intent)
|
|
||||||
this.finishAndRemoveTask()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.github.libretube.adapters
|
package com.github.libretube.adapters
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
@ -35,17 +36,18 @@ class CommentsAdapter(
|
|||||||
private var repliesPage = CommentsPage()
|
private var repliesPage = CommentsPage()
|
||||||
|
|
||||||
fun updateItems(newItems: List<Comment>) {
|
fun updateItems(newItems: List<Comment>) {
|
||||||
var commentsSize = comments.size
|
val commentsSize = comments.size
|
||||||
comments.addAll(newItems)
|
comments.addAll(newItems)
|
||||||
notifyItemRangeInserted(commentsSize, newItems.size)
|
notifyItemRangeInserted(commentsSize, newItems.size)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): CommentsViewHolder {
|
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): CommentsViewHolder {
|
||||||
var commentsView =
|
val commentsView =
|
||||||
LayoutInflater.from(parent.context).inflate(R.layout.comments_row, parent, false)
|
LayoutInflater.from(parent.context).inflate(R.layout.comments_row, parent, false)
|
||||||
return CommentsViewHolder(commentsView)
|
return CommentsViewHolder(commentsView)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressLint("SetTextI18n")
|
||||||
override fun onBindViewHolder(holder: CommentsViewHolder, position: Int) {
|
override fun onBindViewHolder(holder: CommentsViewHolder, position: Int) {
|
||||||
holder.v.findViewById<TextView>(R.id.comment_infos).text =
|
holder.v.findViewById<TextView>(R.id.comment_infos).text =
|
||||||
comments[position].author.toString() +
|
comments[position].author.toString() +
|
||||||
@ -103,10 +105,10 @@ class CommentsAdapter(
|
|||||||
|
|
||||||
private fun fetchReplies(nextpage: String, repliesAdapter: RepliesAdapter) {
|
private fun fetchReplies(nextpage: String, repliesAdapter: RepliesAdapter) {
|
||||||
CoroutineScope(Dispatchers.Main).launch {
|
CoroutineScope(Dispatchers.Main).launch {
|
||||||
if (!isLoading && nextpage != null) {
|
if (!isLoading) {
|
||||||
isLoading = true
|
isLoading = true
|
||||||
try {
|
try {
|
||||||
repliesPage = RetrofitInstance.api.getCommentsNextPage(videoId!!, nextpage!!)
|
repliesPage = RetrofitInstance.api.getCommentsNextPage(videoId, nextpage)
|
||||||
} catch (e: IOException) {
|
} catch (e: IOException) {
|
||||||
println(e)
|
println(e)
|
||||||
Log.e(TAG, "IOException, you might not have internet connection")
|
Log.e(TAG, "IOException, you might not have internet connection")
|
||||||
|
@ -4,7 +4,6 @@ import android.app.Dialog
|
|||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import androidx.core.content.ContentProviderCompat.requireContext
|
|
||||||
import androidx.fragment.app.DialogFragment
|
import androidx.fragment.app.DialogFragment
|
||||||
import com.github.libretube.R
|
import com.github.libretube.R
|
||||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||||
|
Loading…
Reference in New Issue
Block a user