forked from recloudstream/cloudstream
made movie download nice
This commit is contained in:
parent
765aa7c5af
commit
aa146c7b98
5 changed files with 242 additions and 42 deletions
|
@ -177,13 +177,14 @@ class AllAnimeProvider : MainAPI() {
|
||||||
Pair(Actor(name, img), role)
|
Pair(Actor(name, img), role)
|
||||||
}
|
}
|
||||||
|
|
||||||
val recommendations = soup.select("#suggesction > div > div.p > .swipercard")?.mapNotNull {
|
// bruh, they use graphql
|
||||||
val recTitle = it?.selectFirst(".showname > a") ?: return@mapNotNull null
|
//val recommendations = soup.select("#suggesction > div > div.p > .swipercard")?.mapNotNull {
|
||||||
val recName = recTitle.text() ?: return@mapNotNull null
|
// val recTitle = it?.selectFirst(".showname > a") ?: return@mapNotNull null
|
||||||
val href = fixUrlNull(recTitle.attr("href")) ?: return@mapNotNull null
|
// val recName = recTitle.text() ?: return@mapNotNull null
|
||||||
val img = it.selectFirst(".image > img").attr("src") ?: return@mapNotNull null
|
// val href = fixUrlNull(recTitle.attr("href")) ?: return@mapNotNull null
|
||||||
AnimeSearchResponse(recName, href, this.name, TvType.Anime, img)
|
// val img = it.selectFirst(".image > img").attr("src") ?: return@mapNotNull null
|
||||||
}
|
// AnimeSearchResponse(recName, href, this.name, TvType.Anime, img)
|
||||||
|
//}
|
||||||
|
|
||||||
return newAnimeLoadResponse(title, url, TvType.Anime) {
|
return newAnimeLoadResponse(title, url, TvType.Anime) {
|
||||||
posterUrl = poster
|
posterUrl = poster
|
||||||
|
@ -192,7 +193,7 @@ class AllAnimeProvider : MainAPI() {
|
||||||
addEpisodes(DubStatus.Subbed, episodes.first)
|
addEpisodes(DubStatus.Subbed, episodes.first)
|
||||||
addEpisodes(DubStatus.Dubbed, episodes.second)
|
addEpisodes(DubStatus.Dubbed, episodes.second)
|
||||||
addActors(characters)
|
addActors(characters)
|
||||||
this.recommendations = recommendations
|
//this.recommendations = recommendations
|
||||||
|
|
||||||
showStatus = getStatus(showData.status.toString())
|
showStatus = getStatus(showData.status.toString())
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,8 @@ import android.view.View
|
||||||
import android.view.animation.DecelerateInterpolator
|
import android.view.animation.DecelerateInterpolator
|
||||||
import android.widget.ImageView
|
import android.widget.ImageView
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
|
import androidx.core.view.isGone
|
||||||
|
import androidx.core.view.isVisible
|
||||||
import androidx.core.widget.ContentLoadingProgressBar
|
import androidx.core.widget.ContentLoadingProgressBar
|
||||||
import com.google.android.material.button.MaterialButton
|
import com.google.android.material.button.MaterialButton
|
||||||
import com.lagradost.cloudstream3.R
|
import com.lagradost.cloudstream3.R
|
||||||
|
@ -28,7 +30,8 @@ class EasyDownloadButton : IDisposable {
|
||||||
}
|
}
|
||||||
|
|
||||||
private var downloadProgressEventListener: ((Triple<Int, Long, Long>) -> Unit)? = null
|
private var downloadProgressEventListener: ((Triple<Int, Long, Long>) -> Unit)? = null
|
||||||
private var downloadStatusEventListener: ((Pair<Int, VideoDownloadManager.DownloadType>) -> Unit)? = null
|
private var downloadStatusEventListener: ((Pair<Int, VideoDownloadManager.DownloadType>) -> Unit)? =
|
||||||
|
null
|
||||||
|
|
||||||
fun setUpMaterialButton(
|
fun setUpMaterialButton(
|
||||||
setupCurrentBytes: Long?,
|
setupCurrentBytes: Long?,
|
||||||
|
@ -39,10 +42,47 @@ class EasyDownloadButton : IDisposable {
|
||||||
data: IMinimumData,
|
data: IMinimumData,
|
||||||
clickCallback: (DownloadClickEvent) -> Unit,
|
clickCallback: (DownloadClickEvent) -> Unit,
|
||||||
) {
|
) {
|
||||||
setUpDownloadButton(setupCurrentBytes, setupTotalBytes, progressBar, textView, data, downloadButton, {
|
setUpDownloadButton(
|
||||||
|
setupCurrentBytes,
|
||||||
|
setupTotalBytes,
|
||||||
|
progressBar,
|
||||||
|
textView,
|
||||||
|
data,
|
||||||
|
downloadButton,
|
||||||
|
{
|
||||||
downloadButton.setIconResource(it.first)
|
downloadButton.setIconResource(it.first)
|
||||||
downloadButton.text = it.second
|
downloadButton.text = it.second
|
||||||
}, clickCallback)
|
},
|
||||||
|
clickCallback
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun setUpMoreButton(
|
||||||
|
setupCurrentBytes: Long?,
|
||||||
|
setupTotalBytes: Long?,
|
||||||
|
progressBar: ContentLoadingProgressBar,
|
||||||
|
downloadImage: ImageView,
|
||||||
|
textView: TextView?,
|
||||||
|
textViewProgress: TextView?,
|
||||||
|
clickableView: View,
|
||||||
|
isTextPercentage: Boolean,
|
||||||
|
data: IMinimumData,
|
||||||
|
clickCallback: (DownloadClickEvent) -> Unit,
|
||||||
|
) {
|
||||||
|
setUpDownloadButton(
|
||||||
|
setupCurrentBytes,
|
||||||
|
setupTotalBytes,
|
||||||
|
progressBar,
|
||||||
|
textViewProgress,
|
||||||
|
data,
|
||||||
|
clickableView,
|
||||||
|
{ (image, text) ->
|
||||||
|
downloadImage.isVisible = textViewProgress?.isGone ?: true
|
||||||
|
downloadImage.setImageResource(image)
|
||||||
|
textView?.text = text
|
||||||
|
},
|
||||||
|
clickCallback, isTextPercentage
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setUpButton(
|
fun setUpButton(
|
||||||
|
@ -54,9 +94,18 @@ class EasyDownloadButton : IDisposable {
|
||||||
data: IMinimumData,
|
data: IMinimumData,
|
||||||
clickCallback: (DownloadClickEvent) -> Unit,
|
clickCallback: (DownloadClickEvent) -> Unit,
|
||||||
) {
|
) {
|
||||||
setUpDownloadButton(setupCurrentBytes, setupTotalBytes, progressBar, textView, data, downloadImage, {
|
setUpDownloadButton(
|
||||||
|
setupCurrentBytes,
|
||||||
|
setupTotalBytes,
|
||||||
|
progressBar,
|
||||||
|
textView,
|
||||||
|
data,
|
||||||
|
downloadImage,
|
||||||
|
{
|
||||||
downloadImage.setImageResource(it.first)
|
downloadImage.setImageResource(it.first)
|
||||||
}, clickCallback)
|
},
|
||||||
|
clickCallback
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setUpDownloadButton(
|
private fun setUpDownloadButton(
|
||||||
|
@ -68,11 +117,12 @@ class EasyDownloadButton : IDisposable {
|
||||||
downloadView: View,
|
downloadView: View,
|
||||||
downloadImageChangeCallback: (Pair<Int, String>) -> Unit,
|
downloadImageChangeCallback: (Pair<Int, String>) -> Unit,
|
||||||
clickCallback: (DownloadClickEvent) -> Unit,
|
clickCallback: (DownloadClickEvent) -> Unit,
|
||||||
|
isTextPercentage: Boolean = false
|
||||||
) {
|
) {
|
||||||
var lastState: VideoDownloadManager.DownloadType? = null
|
var lastState: VideoDownloadManager.DownloadType? = null
|
||||||
var currentBytes = setupCurrentBytes ?: 0
|
var currentBytes = setupCurrentBytes ?: 0
|
||||||
var totalBytes = setupTotalBytes ?: 0
|
var totalBytes = setupTotalBytes ?: 0
|
||||||
var needImageUpdate = false
|
var needImageUpdate = true
|
||||||
|
|
||||||
fun changeDownloadImage(state: VideoDownloadManager.DownloadType) {
|
fun changeDownloadImage(state: VideoDownloadManager.DownloadType) {
|
||||||
lastState = state
|
lastState = state
|
||||||
|
@ -92,7 +142,12 @@ class EasyDownloadButton : IDisposable {
|
||||||
} else {
|
} else {
|
||||||
Pair(R.drawable.netflix_download, R.string.download)
|
Pair(R.drawable.netflix_download, R.string.download)
|
||||||
}
|
}
|
||||||
downloadImageChangeCallback.invoke(Pair(img.first, downloadView.context.getString(img.second)))
|
downloadImageChangeCallback.invoke(
|
||||||
|
Pair(
|
||||||
|
img.first,
|
||||||
|
downloadView.context.getString(img.second)
|
||||||
|
)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun fixDownloadedBytes(setCurrentBytes: Long, setTotalBytes: Long, animate: Boolean) {
|
fun fixDownloadedBytes(setCurrentBytes: Long, setTotalBytes: Long, animate: Boolean) {
|
||||||
|
@ -113,7 +168,9 @@ class EasyDownloadButton : IDisposable {
|
||||||
val totalMbString = "%.1f".format(setTotalBytes / 1000000f)
|
val totalMbString = "%.1f".format(setTotalBytes / 1000000f)
|
||||||
|
|
||||||
textView?.text =
|
textView?.text =
|
||||||
textView?.context?.getString(R.string.download_size_format)?.format(currentMbString, totalMbString)
|
if (isTextPercentage) "%d%%".format(setCurrentBytes * 100L / setTotalBytes) else
|
||||||
|
textView?.context?.getString(R.string.download_size_format)
|
||||||
|
?.format(currentMbString, totalMbString)
|
||||||
|
|
||||||
progressBar.let { bar ->
|
progressBar.let { bar ->
|
||||||
bar.max = (setTotalBytes / 1000).toInt()
|
bar.max = (setTotalBytes / 1000).toInt()
|
||||||
|
@ -144,12 +201,14 @@ class EasyDownloadButton : IDisposable {
|
||||||
if (downloadData.second != currentBytes || downloadData.third != totalBytes) { // TO PREVENT WASTING UI TIME
|
if (downloadData.second != currentBytes || downloadData.third != totalBytes) { // TO PREVENT WASTING UI TIME
|
||||||
Coroutines.runOnMainThread {
|
Coroutines.runOnMainThread {
|
||||||
fixDownloadedBytes(downloadData.second, downloadData.third, true)
|
fixDownloadedBytes(downloadData.second, downloadData.third, true)
|
||||||
|
changeDownloadImage(VideoDownloadManager.getDownloadState(data.id))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
downloadStatusEventListener = { downloadData: Pair<Int, VideoDownloadManager.DownloadType> ->
|
downloadStatusEventListener =
|
||||||
|
{ downloadData: Pair<Int, VideoDownloadManager.DownloadType> ->
|
||||||
if (data.id == downloadData.first) {
|
if (data.id == downloadData.first) {
|
||||||
if (lastState != downloadData.second || needImageUpdate) { // TO PREVENT WASTING UI TIME
|
if (lastState != downloadData.second || needImageUpdate) { // TO PREVENT WASTING UI TIME
|
||||||
Coroutines.runOnMainThread {
|
Coroutines.runOnMainThread {
|
||||||
|
|
|
@ -486,7 +486,7 @@ class ResultFragment : Fragment(), PanelsChildGestureRegionObserver.GestureRegio
|
||||||
setFormatText(result_meta_duration, R.string.duration_format, duration)
|
setFormatText(result_meta_duration, R.string.duration_format, duration)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setShow(showStatus : ShowStatus?) {
|
private fun setShow(showStatus: ShowStatus?) {
|
||||||
val status = when (showStatus) {
|
val status = when (showStatus) {
|
||||||
null -> null
|
null -> null
|
||||||
ShowStatus.Ongoing -> R.string.status_ongoing
|
ShowStatus.Ongoing -> R.string.status_ongoing
|
||||||
|
@ -1439,12 +1439,15 @@ class ResultFragment : Fragment(), PanelsChildGestureRegionObserver.GestureRegio
|
||||||
)
|
)
|
||||||
downloadButton?.dispose()
|
downloadButton?.dispose()
|
||||||
downloadButton = EasyDownloadButton()
|
downloadButton = EasyDownloadButton()
|
||||||
downloadButton?.setUpMaterialButton(
|
downloadButton?.setUpMoreButton(
|
||||||
file?.fileLength,
|
file?.fileLength,
|
||||||
file?.totalBytes,
|
file?.totalBytes,
|
||||||
result_movie_progress_downloaded,
|
result_movie_progress_downloaded,
|
||||||
|
result_movie_download_icon,
|
||||||
|
result_movie_download_text,
|
||||||
|
result_movie_download_text_precentage,
|
||||||
result_download_movie,
|
result_download_movie,
|
||||||
result_movie_text_progress,
|
true,
|
||||||
VideoDownloadHelper.DownloadEpisodeCached(
|
VideoDownloadHelper.DownloadEpisodeCached(
|
||||||
d.name,
|
d.name,
|
||||||
d.posterUrl,
|
d.posterUrl,
|
||||||
|
@ -1491,6 +1494,59 @@ class ResultFragment : Fragment(), PanelsChildGestureRegionObserver.GestureRegio
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*downloadButton?.setUpMaterialButton(
|
||||||
|
file?.fileLength,
|
||||||
|
file?.totalBytes,
|
||||||
|
result_movie_progress_downloaded,
|
||||||
|
result_download_movie,
|
||||||
|
null, //result_movie_text_progress
|
||||||
|
VideoDownloadHelper.DownloadEpisodeCached(
|
||||||
|
d.name,
|
||||||
|
d.posterUrl,
|
||||||
|
0,
|
||||||
|
null,
|
||||||
|
localId,
|
||||||
|
localId,
|
||||||
|
d.rating,
|
||||||
|
d.plot,
|
||||||
|
System.currentTimeMillis(),
|
||||||
|
)
|
||||||
|
) { downloadClickEvent ->
|
||||||
|
if (downloadClickEvent.action == DOWNLOAD_ACTION_DOWNLOAD) {
|
||||||
|
currentEpisodes?.firstOrNull()?.let { episode ->
|
||||||
|
handleAction(
|
||||||
|
EpisodeClickEvent(
|
||||||
|
ACTION_DOWNLOAD_EPISODE,
|
||||||
|
ResultEpisode(
|
||||||
|
d.name,
|
||||||
|
d.name,
|
||||||
|
null,
|
||||||
|
0,
|
||||||
|
null,
|
||||||
|
episode.data,
|
||||||
|
d.apiName,
|
||||||
|
localId,
|
||||||
|
0,
|
||||||
|
0L,
|
||||||
|
0L,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
d.type,
|
||||||
|
localId,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
handleDownloadClick(
|
||||||
|
activity,
|
||||||
|
currentHeaderName,
|
||||||
|
downloadClickEvent
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}*/
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
lateFixDownloadButton(false)
|
lateFixDownloadButton(false)
|
||||||
|
|
|
@ -6,6 +6,6 @@
|
||||||
android:thickness="2dp"
|
android:thickness="2dp"
|
||||||
android:useLevel="false">
|
android:useLevel="false">
|
||||||
|
|
||||||
<solid android:color="#CCC" />
|
<solid android:color="?attr/white" />
|
||||||
|
|
||||||
</shape>
|
</shape>
|
|
@ -471,7 +471,7 @@
|
||||||
style="@style/WhiteButton" />
|
style="@style/WhiteButton" />
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
tools:visibility="gone"
|
tools:visibility="visible"
|
||||||
android:layout_marginTop="5dp"
|
android:layout_marginTop="5dp"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:id="@+id/result_movie_parent"
|
android:id="@+id/result_movie_parent"
|
||||||
|
@ -493,7 +493,8 @@
|
||||||
app:icon="@drawable/ic_baseline_play_arrow_24"
|
app:icon="@drawable/ic_baseline_play_arrow_24"
|
||||||
android:layout_width="match_parent" />
|
android:layout_width="match_parent" />
|
||||||
|
|
||||||
<com.google.android.material.button.MaterialButton
|
|
||||||
|
<!--<com.google.android.material.button.MaterialButton
|
||||||
android:nextFocusUp="@id/result_play_movie"
|
android:nextFocusUp="@id/result_play_movie"
|
||||||
android:nextFocusDown="@id/result_season_button"
|
android:nextFocusDown="@id/result_season_button"
|
||||||
android:layout_marginBottom="10dp"
|
android:layout_marginBottom="10dp"
|
||||||
|
@ -507,11 +508,94 @@
|
||||||
tools:text="Downloading"
|
tools:text="Downloading"
|
||||||
tools:icon="@drawable/netflix_download"
|
tools:icon="@drawable/netflix_download"
|
||||||
|
|
||||||
|
android:clickable="true"
|
||||||
|
android:focusable="true"
|
||||||
|
android:layout_width="match_parent" />-->
|
||||||
|
|
||||||
|
<FrameLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
|
<com.google.android.material.button.MaterialButton
|
||||||
|
android:nextFocusUp="@id/result_play_movie"
|
||||||
|
android:nextFocusDown="@id/result_season_button"
|
||||||
|
|
||||||
|
android:id="@+id/result_download_movie"
|
||||||
|
style="@style/BlackButton"
|
||||||
|
android:layout_marginStart="0dp"
|
||||||
|
android:layout_marginEnd="0dp"
|
||||||
|
android:visibility="visible"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
|
||||||
android:clickable="true"
|
android:clickable="true"
|
||||||
android:focusable="true"
|
android:focusable="true"
|
||||||
android:layout_width="match_parent" />
|
android:layout_width="match_parent" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:gravity="center"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
<androidx.core.widget.ContentLoadingProgressBar
|
<androidx.core.widget.ContentLoadingProgressBar
|
||||||
|
android:id="@+id/result_movie_progress_downloaded"
|
||||||
|
android:layout_width="25dp"
|
||||||
|
android:layout_height="25dp"
|
||||||
|
android:indeterminate="false"
|
||||||
|
android:progressDrawable="@drawable/circular_progress_bar_filled"
|
||||||
|
android:background="@drawable/circle_shape"
|
||||||
|
style="?android:attr/progressBarStyleHorizontal"
|
||||||
|
android:max="100"
|
||||||
|
android:layout_margin="5dp"
|
||||||
|
android:paddingEnd="5dp"
|
||||||
|
android:paddingStart="5dp"
|
||||||
|
android:layout_gravity="end|center_vertical"
|
||||||
|
android:progress="30"
|
||||||
|
android:visibility="visible" />
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/result_movie_download_icon"
|
||||||
|
app:tint="?attr/white"
|
||||||
|
android:visibility="visible"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:layout_width="30dp"
|
||||||
|
android:background="?selectableItemBackgroundBorderless"
|
||||||
|
android:src="@drawable/ic_baseline_play_arrow_24"
|
||||||
|
android:contentDescription="@string/download" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/result_movie_download_text"
|
||||||
|
android:letterSpacing="0.09"
|
||||||
|
android:textColor="?attr/textColor"
|
||||||
|
android:textSize="15sp"
|
||||||
|
android:textStyle="bold"
|
||||||
|
android:gravity="center"
|
||||||
|
android:textAllCaps="false"
|
||||||
|
tools:text="Downloading"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="match_parent" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:visibility="gone"
|
||||||
|
android:id="@+id/result_movie_download_text_precentage"
|
||||||
|
android:letterSpacing="0.09"
|
||||||
|
android:paddingStart="5dp"
|
||||||
|
android:paddingEnd="5dp"
|
||||||
|
android:textColor="?attr/textColor"
|
||||||
|
android:textSize="15sp"
|
||||||
|
android:textStyle="bold"
|
||||||
|
android:gravity="center"
|
||||||
|
android:textAllCaps="false"
|
||||||
|
tools:text="68%"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="match_parent" />
|
||||||
|
</LinearLayout>
|
||||||
|
</FrameLayout>
|
||||||
|
|
||||||
|
|
||||||
|
<!--<androidx.core.widget.ContentLoadingProgressBar
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="20dp"
|
android:layout_height="20dp"
|
||||||
tools:progress="50"
|
tools:progress="50"
|
||||||
|
@ -524,15 +608,15 @@
|
||||||
android:progress="0"
|
android:progress="0"
|
||||||
android:visibility="gone"
|
android:visibility="gone"
|
||||||
tools:visibility="visible" />
|
tools:visibility="visible" />
|
||||||
|
-->
|
||||||
<TextView
|
<!-- <TextView
|
||||||
android:id="@+id/result_movie_text_progress"
|
android:id="@+id/result_movie_text_progress"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical"
|
||||||
tools:text="128MB / 237MB"
|
tools:text="128MB / 237MB"
|
||||||
android:textColor="?attr/grayTextColor"
|
android:textColor="?attr/grayTextColor"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="match_parent" />
|
android:layout_height="match_parent" />-->
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
|
|
Loading…
Reference in a new issue