mirror of
https://github.com/recloudstream/cloudstream.git
synced 2024-08-15 01:53:11 +00:00
Tenshi recommendations + bug fixes
This commit is contained in:
parent
4120f8b865
commit
5053dff3f2
10 changed files with 57 additions and 37 deletions
|
@ -43,6 +43,7 @@ import com.lagradost.cloudstream3.utils.DataStore.removeKey
|
||||||
import com.lagradost.cloudstream3.utils.DataStoreHelper.setViewPos
|
import com.lagradost.cloudstream3.utils.DataStoreHelper.setViewPos
|
||||||
import com.lagradost.cloudstream3.utils.InAppUpdater.Companion.runAutoUpdate
|
import com.lagradost.cloudstream3.utils.InAppUpdater.Companion.runAutoUpdate
|
||||||
import com.lagradost.cloudstream3.utils.UIHelper.checkWrite
|
import com.lagradost.cloudstream3.utils.UIHelper.checkWrite
|
||||||
|
import com.lagradost.cloudstream3.utils.UIHelper.colorFromAttribute
|
||||||
import com.lagradost.cloudstream3.utils.UIHelper.getResourceColor
|
import com.lagradost.cloudstream3.utils.UIHelper.getResourceColor
|
||||||
import com.lagradost.cloudstream3.utils.UIHelper.hideKeyboard
|
import com.lagradost.cloudstream3.utils.UIHelper.hideKeyboard
|
||||||
import com.lagradost.cloudstream3.utils.UIHelper.navigate
|
import com.lagradost.cloudstream3.utils.UIHelper.navigate
|
||||||
|
@ -195,6 +196,8 @@ class MainActivity : AppCompatActivity(), ColorPickerDialogListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onBackPressed() {
|
override fun onBackPressed() {
|
||||||
|
this.window?.navigationBarColor =
|
||||||
|
this.colorFromAttribute(R.attr.primaryGrayBackground)
|
||||||
this.updateLocale()
|
this.updateLocale()
|
||||||
backEvent.invoke(true)
|
backEvent.invoke(true)
|
||||||
super.onBackPressed()
|
super.onBackPressed()
|
||||||
|
|
|
@ -12,7 +12,6 @@ import org.jsoup.nodes.Document
|
||||||
import java.net.URI
|
import java.net.URI
|
||||||
import java.text.SimpleDateFormat
|
import java.text.SimpleDateFormat
|
||||||
import java.util.*
|
import java.util.*
|
||||||
import kotlin.collections.ArrayList
|
|
||||||
|
|
||||||
class TenshiProvider : MainAPI() {
|
class TenshiProvider : MainAPI() {
|
||||||
companion object {
|
companion object {
|
||||||
|
@ -256,10 +255,18 @@ class TenshiProvider : MainAPI() {
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
val similarAnime = document.select("ul.anime-loop > li > a")?.mapNotNull { element ->
|
||||||
|
val href = element.attr("href") ?: return@mapNotNull null
|
||||||
|
val title =
|
||||||
|
element.selectFirst("> .overlay > .thumb-title")?.text() ?: return@mapNotNull null
|
||||||
|
val img = element.selectFirst("> img")?.attr("src")
|
||||||
|
AnimeSearchResponse(title, href, this.name, TvType.Anime, img)
|
||||||
|
}
|
||||||
|
|
||||||
val type = document.selectFirst("a[href*=\"$mainUrl/type/\"]")?.text()?.trim()
|
val type = document.selectFirst("a[href*=\"$mainUrl/type/\"]")?.text()?.trim()
|
||||||
|
|
||||||
return newAnimeLoadResponse(canonicalTitle, url, getType(type ?: "")) {
|
return newAnimeLoadResponse(canonicalTitle, url, getType(type ?: "")) {
|
||||||
|
recommendations = similarAnime
|
||||||
posterUrl = document.selectFirst("img.cover-image")?.attr("src")
|
posterUrl = document.selectFirst("img.cover-image")?.attr("src")
|
||||||
plot = document.selectFirst(".entry-description > .card-body")?.text()?.trim()
|
plot = document.selectFirst(".entry-description > .card-body")?.text()?.trim()
|
||||||
tags =
|
tags =
|
||||||
|
|
|
@ -115,7 +115,7 @@ class HomeFragment : Fragment() {
|
||||||
// Span settings
|
// Span settings
|
||||||
recycle.spanCount = currentSpan
|
recycle.spanCount = currentSpan
|
||||||
|
|
||||||
recycle.adapter = SearchAdapter(item.list, recycle) { callback ->
|
recycle.adapter = SearchAdapter(item.list.toMutableList(), recycle) { callback ->
|
||||||
handleSearchClickCallback(this, callback)
|
handleSearchClickCallback(this, callback)
|
||||||
if (callback.action == SEARCH_ACTION_LOAD || callback.action == SEARCH_ACTION_PLAY_FILE) {
|
if (callback.action == SEARCH_ACTION_LOAD || callback.action == SEARCH_ACTION_PLAY_FILE) {
|
||||||
bottomSheetDialogBuilder.dismissSafe(this)
|
bottomSheetDialogBuilder.dismissSafe(this)
|
||||||
|
|
|
@ -152,10 +152,7 @@ class QuickSearchFragment(var isMainApis: Boolean = false) : Fragment() {
|
||||||
is Resource.Success -> {
|
is Resource.Success -> {
|
||||||
it.value.let { data ->
|
it.value.let { data ->
|
||||||
if (data.isNotEmpty()) {
|
if (data.isNotEmpty()) {
|
||||||
(search_autofit_results?.adapter as SearchAdapter?)?.apply {
|
(search_autofit_results?.adapter as SearchAdapter?)?.updateList(data)
|
||||||
cardList = data.toList()
|
|
||||||
notifyDataSetChanged()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
searchExitIcon.alpha = 1f
|
searchExitIcon.alpha = 1f
|
||||||
|
|
|
@ -392,10 +392,6 @@ class ResultFragment : Fragment(), PanelsChildGestureRegionObserver.GestureRegio
|
||||||
downloadButton?.dispose()
|
downloadButton?.dispose()
|
||||||
updateUIListener = null
|
updateUIListener = null
|
||||||
super.onDestroy()
|
super.onDestroy()
|
||||||
activity?.let {
|
|
||||||
it.window?.navigationBarColor =
|
|
||||||
it.colorFromAttribute(R.attr.primaryGrayBackground)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
|
@ -499,18 +495,16 @@ class ResultFragment : Fragment(), PanelsChildGestureRegionObserver.GestureRegio
|
||||||
result_recommendations?.isGone = isInvalid
|
result_recommendations?.isGone = isInvalid
|
||||||
result_recommendations_btt?.isGone = isInvalid
|
result_recommendations_btt?.isGone = isInvalid
|
||||||
result_recommendations_btt?.setOnClickListener {
|
result_recommendations_btt?.setOnClickListener {
|
||||||
if(result_overlapping_panels?.getSelectedPanel()?.ordinal == 1) {
|
if (result_overlapping_panels?.getSelectedPanel()?.ordinal == 1) {
|
||||||
result_overlapping_panels?.openEndPanel()
|
result_overlapping_panels?.openEndPanel()
|
||||||
} else {
|
} else {
|
||||||
result_overlapping_panels?.closePanels()
|
result_overlapping_panels?.closePanels()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
result_overlapping_panels?.setEndPanelLockState(if (isInvalid) OverlappingPanelsLayout.LockState.CLOSE else OverlappingPanelsLayout.LockState.UNLOCKED)
|
result_overlapping_panels?.setEndPanelLockState(if (isInvalid) OverlappingPanelsLayout.LockState.CLOSE else OverlappingPanelsLayout.LockState.UNLOCKED)
|
||||||
|
result_recommendations.post {
|
||||||
rec?.let { list ->
|
rec?.let { list ->
|
||||||
(result_recommendations?.adapter as SearchAdapter?)?.apply {
|
(result_recommendations?.adapter as SearchAdapter?)?.updateList(list)
|
||||||
cardList = list
|
|
||||||
notifyDataSetChanged()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -540,13 +534,12 @@ class ResultFragment : Fragment(), PanelsChildGestureRegionObserver.GestureRegio
|
||||||
|
|
||||||
private fun updateUI() {
|
private fun updateUI() {
|
||||||
viewModel.reloadEpisodes()
|
viewModel.reloadEpisodes()
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("SetTextI18n")
|
@SuppressLint("SetTextI18n")
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
|
||||||
fixGrid()
|
fixGrid()
|
||||||
result_recommendations?.spanCount = 3
|
result_recommendations?.spanCount = 3
|
||||||
result_overlapping_panels?.setStartPanelLockState(OverlappingPanelsLayout.LockState.CLOSE)
|
result_overlapping_panels?.setStartPanelLockState(OverlappingPanelsLayout.LockState.CLOSE)
|
||||||
|
@ -955,7 +948,6 @@ class ResultFragment : Fragment(), PanelsChildGestureRegionObserver.GestureRegio
|
||||||
viewModel.loadEpisode(episodeClick.data, false)
|
viewModel.loadEpisode(episodeClick.data, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ACTION_DOWNLOAD_MIRROR -> {
|
ACTION_DOWNLOAD_MIRROR -> {
|
||||||
acquireSingleExtractorLink(
|
acquireSingleExtractorLink(
|
||||||
sortUrls(
|
sortUrls(
|
||||||
|
|
|
@ -5,6 +5,7 @@ import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import android.widget.FrameLayout
|
import android.widget.FrameLayout
|
||||||
import android.widget.ImageView
|
import android.widget.ImageView
|
||||||
|
import androidx.recyclerview.widget.DiffUtil
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import com.lagradost.cloudstream3.SearchResponse
|
import com.lagradost.cloudstream3.SearchResponse
|
||||||
import com.lagradost.cloudstream3.ui.AutofitRecyclerView
|
import com.lagradost.cloudstream3.ui.AutofitRecyclerView
|
||||||
|
@ -22,7 +23,7 @@ const val SEARCH_ACTION_FOCUSED = 4
|
||||||
class SearchClickCallback(val action: Int, val view: View, val position : Int, val card: SearchResponse)
|
class SearchClickCallback(val action: Int, val view: View, val position : Int, val card: SearchResponse)
|
||||||
|
|
||||||
class SearchAdapter(
|
class SearchAdapter(
|
||||||
var cardList: List<SearchResponse>,
|
private val cardList: MutableList<SearchResponse>,
|
||||||
private val resView: AutofitRecyclerView,
|
private val resView: AutofitRecyclerView,
|
||||||
private val clickCallback: (SearchClickCallback) -> Unit,
|
private val clickCallback: (SearchClickCallback) -> Unit,
|
||||||
) : RecyclerView.Adapter<RecyclerView.ViewHolder>() {
|
) : RecyclerView.Adapter<RecyclerView.ViewHolder>() {
|
||||||
|
@ -48,6 +49,17 @@ class SearchAdapter(
|
||||||
return cardList.size
|
return cardList.size
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun updateList(newList: List<SearchResponse>) {
|
||||||
|
val diffResult = DiffUtil.calculateDiff(
|
||||||
|
SearchResponseDiffCallback(this.cardList, newList)
|
||||||
|
)
|
||||||
|
|
||||||
|
cardList.clear()
|
||||||
|
cardList.addAll(newList)
|
||||||
|
|
||||||
|
diffResult.dispatchUpdatesTo(this)
|
||||||
|
}
|
||||||
|
|
||||||
class CardViewHolder
|
class CardViewHolder
|
||||||
constructor(
|
constructor(
|
||||||
itemView: View,
|
itemView: View,
|
||||||
|
@ -74,3 +86,16 @@ class SearchAdapter(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class SearchResponseDiffCallback(private val oldList: List<SearchResponse>, private val newList: List<SearchResponse>) :
|
||||||
|
DiffUtil.Callback() {
|
||||||
|
override fun areItemsTheSame(oldItemPosition: Int, newItemPosition: Int) =
|
||||||
|
oldList[oldItemPosition].name == newList[newItemPosition].name
|
||||||
|
|
||||||
|
override fun getOldListSize() = oldList.size
|
||||||
|
|
||||||
|
override fun getNewListSize() = newList.size
|
||||||
|
|
||||||
|
override fun areContentsTheSame(oldItemPosition: Int, newItemPosition: Int) =
|
||||||
|
oldList[oldItemPosition] == newList[newItemPosition]
|
||||||
|
}
|
|
@ -346,10 +346,7 @@ class SearchFragment : Fragment() {
|
||||||
is Resource.Success -> {
|
is Resource.Success -> {
|
||||||
it.value.let { data ->
|
it.value.let { data ->
|
||||||
if (data.isNotEmpty()) {
|
if (data.isNotEmpty()) {
|
||||||
(search_autofit_results?.adapter as SearchAdapter?)?.apply {
|
(search_autofit_results?.adapter as SearchAdapter?)?.updateList(data)
|
||||||
cardList = data.toList()
|
|
||||||
notifyDataSetChanged()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
searchExitIcon.alpha = 1f
|
searchExitIcon.alpha = 1f
|
||||||
|
|
|
@ -5,6 +5,7 @@ import android.widget.ImageView
|
||||||
import android.widget.ProgressBar
|
import android.widget.ProgressBar
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
import androidx.cardview.widget.CardView
|
import androidx.cardview.widget.CardView
|
||||||
|
import androidx.core.view.isVisible
|
||||||
import com.lagradost.cloudstream3.*
|
import com.lagradost.cloudstream3.*
|
||||||
import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.isTvSettings
|
import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.isTvSettings
|
||||||
import com.lagradost.cloudstream3.utils.AppUtils.getNameFull
|
import com.lagradost.cloudstream3.utils.AppUtils.getNameFull
|
||||||
|
@ -40,17 +41,15 @@ object SearchResultBuilder {
|
||||||
|
|
||||||
// Do logic
|
// Do logic
|
||||||
|
|
||||||
bar?.visibility = View.GONE
|
bar?.isVisible = false
|
||||||
playImg?.visibility = View.GONE
|
playImg?.isVisible = false
|
||||||
textIsDub?.visibility = View.GONE
|
textIsDub?.isVisible = false
|
||||||
textIsSub?.visibility = View.GONE
|
textIsSub?.isVisible = false
|
||||||
|
|
||||||
cardText?.text = card.name
|
cardText?.text = card.name
|
||||||
|
|
||||||
//imageTextProvider.text = card.apiName
|
cardView.isVisible = true
|
||||||
if (!card.posterUrl.isNullOrEmpty()) {
|
if (!cardView.setImage(card.posterUrl)) {
|
||||||
cardView.setImage(card.posterUrl)
|
|
||||||
} else {
|
|
||||||
cardView.setImageResource(R.drawable.default_cover)
|
cardView.setImageResource(R.drawable.default_cover)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -119,16 +119,18 @@ object UIHelper {
|
||||||
return color
|
return color
|
||||||
}
|
}
|
||||||
|
|
||||||
fun ImageView?.setImage(url: String?) {
|
fun ImageView?.setImage(url: String?) : Boolean {
|
||||||
if (this == null || url.isNullOrBlank()) return
|
if (this == null || url.isNullOrBlank()) return false
|
||||||
try {
|
return try {
|
||||||
GlideApp.with(this.context)
|
GlideApp.with(this.context)
|
||||||
.load(GlideUrl(url)).transition(
|
.load(GlideUrl(url)).transition(
|
||||||
DrawableTransitionOptions.withCrossFade()
|
DrawableTransitionOptions.withCrossFade()
|
||||||
)
|
)
|
||||||
.into(this)
|
.into(this)
|
||||||
|
true
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
logError(e)
|
logError(e)
|
||||||
|
false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,12 +15,10 @@
|
||||||
app:shimmer_highlight_alpha="0.3"
|
app:shimmer_highlight_alpha="0.3"
|
||||||
app:shimmer_duration="@integer/loading_time"
|
app:shimmer_duration="@integer/loading_time"
|
||||||
app:shimmer_auto_start="true"
|
app:shimmer_auto_start="true"
|
||||||
android:paddingTop="40dp"
|
|
||||||
android:id="@+id/result_loading"
|
android:id="@+id/result_loading"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_gravity="center"
|
android:layout_gravity="center"
|
||||||
android:layout_marginTop="15dp"
|
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
|
|
Loading…
Reference in a new issue