Implement click functionality on cast names to initiate a Google search (#1465)

This commit is contained in:
Bilal Aslam
2025-01-16 04:02:46 +05:00
committed by GitHub
parent 63a8b2d938
commit c35cdb7da9

View File

@ -1,5 +1,7 @@
package com.lagradost.cloudstream3.ui.result package com.lagradost.cloudstream3.ui.result
import android.app.SearchManager
import android.content.Intent
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
@ -10,6 +12,8 @@ import com.lagradost.cloudstream3.ActorData
import com.lagradost.cloudstream3.ActorRole import com.lagradost.cloudstream3.ActorRole
import com.lagradost.cloudstream3.R import com.lagradost.cloudstream3.R
import com.lagradost.cloudstream3.databinding.CastItemBinding import com.lagradost.cloudstream3.databinding.CastItemBinding
import com.lagradost.cloudstream3.ui.settings.Globals.PHONE
import com.lagradost.cloudstream3.ui.settings.Globals.isLayout
import com.lagradost.cloudstream3.utils.ImageLoader.loadImage import com.lagradost.cloudstream3.utils.ImageLoader.loadImage
class ActorAdaptor( class ActorAdaptor(
@ -101,6 +105,21 @@ class ActorAdaptor(
callback(position) callback(position)
} }
itemView.setOnLongClickListener {
if (isLayout(PHONE)) {
Intent(Intent.ACTION_WEB_SEARCH).apply {
putExtra(SearchManager.QUERY, actor.actor.name)
}.also { intent ->
itemView.context.packageManager?.let { pm ->
if (intent.resolveActivity(pm) != null) {
itemView.context.startActivity(intent)
}
}
}
}
true
}
binding.apply { binding.apply {
actorImage.loadImage(mainImg) actorImage.loadImage(mainImg)