This commit is contained in:
LagradOst 2021-06-26 19:03:22 +02:00
parent 4cfb7c38c0
commit f0df8ec391
7 changed files with 165 additions and 44 deletions

View File

@ -5,19 +5,22 @@ import android.content.Context
import android.content.Intent
import android.net.Uri
import android.os.Bundle
import android.text.Spannable
import android.text.SpannableString
import android.text.SpannableStringBuilder
import android.view.LayoutInflater
import android.view.View
import android.view.View.GONE
import android.view.View.VISIBLE
import android.view.ViewGroup
import android.widget.FrameLayout
import android.widget.Toast
import androidx.appcompat.app.AlertDialog
import androidx.appcompat.app.AppCompatActivity
import androidx.coordinatorlayout.widget.CoordinatorLayout
import androidx.core.content.ContextCompat
import androidx.core.text.color
import androidx.core.widget.NestedScrollView
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentActivity
import androidx.lifecycle.ViewModelProvider
import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.RecyclerView
@ -35,7 +38,6 @@ import com.lagradost.cloudstream3.UIHelper.fixPaddingStatusbar
import com.lagradost.cloudstream3.UIHelper.getStatusBarHeight
import com.lagradost.cloudstream3.UIHelper.isCastApiAvailable
import com.lagradost.cloudstream3.UIHelper.popCurrentPage
import com.lagradost.cloudstream3.UIHelper.popupMenu
import com.lagradost.cloudstream3.UIHelper.popupMenuNoIcons
import com.lagradost.cloudstream3.mvvm.Resource
import com.lagradost.cloudstream3.mvvm.observe
@ -246,10 +248,10 @@ class ResultFragment : Fragment() {
getApiFromName(apiName).instantLinkLoading
} else false
var dialog : AlertDialog? = null
var dialog: AlertDialog? = null
val currentLoad = currentLoadingCount
if(!skipLoading) {
if (!skipLoading) {
val builder = AlertDialog.Builder(requireContext(), R.style.AlertDialogCustomTransparent)
val customLayout = layoutInflater.inflate(R.layout.dialog_loading, null)
builder.setView(customLayout)
@ -384,11 +386,36 @@ class ResultFragment : Fragment() {
startActivity(Intent.createChooser(i, d.name))
}
if (d.year != null) {
result_year.visibility = VISIBLE
result_year.text = d.year.toString()
val metadataInfoArray = ArrayList<Pair<String, String>>()
if (d is AnimeLoadResponse) {
val status = when (d.showStatus) {
null -> null
ShowStatus.Ongoing -> "Ongoing"
ShowStatus.Completed -> "Completed"
}
if (status != null) {
metadataInfoArray.add(Pair("Status", status))
}
}
if (d.year != null) metadataInfoArray.add(Pair("Year", d.year.toString()))
val rating = d.rating
if (rating != null) metadataInfoArray.add(Pair("Rating",
"%.2f/10.0".format(rating.toFloat() / 10f).replace(",", ".")))
val duration = d.duration
if (duration != null) metadataInfoArray.add(Pair("Duration", duration))
if (metadataInfoArray.size > 0) {
result_metadata.visibility = VISIBLE
val text = SpannableStringBuilder()
val grayColor = ContextCompat.getColor(requireContext(), R.color.grayTextColor)
val textColor = ContextCompat.getColor(requireContext(), R.color.textColor)
for (meta in metadataInfoArray) {
text.color(grayColor) { append("${meta.first}: ") }
.color(textColor) { append("${meta.second}\n") }
}
result_metadata.text = text
} else {
result_year.visibility = GONE
result_metadata.visibility = GONE
}
if (d.posterUrl != null) {
@ -481,7 +508,7 @@ activity?.startActivityForResult(vlcIntent, REQUEST_CODE)
result_tag.removeAllViews()
result_tag_holder.visibility = GONE
result_status.visibility = GONE
// result_status.visibility = GONE
val tags = d.tags
if (tags == null) {
@ -528,12 +555,6 @@ activity?.startActivityForResult(vlcIntent, REQUEST_CODE)
when (d) {
is AnimeLoadResponse -> {
result_status.visibility = VISIBLE
result_status.text = when (d.showStatus) {
null -> ""
ShowStatus.Ongoing -> "Ongoing"
ShowStatus.Completed -> "Completed"
}
// val preferEnglish = true
//val titleName = (if (preferEnglish) d.engName else d.japName) ?: d.name

View File

@ -0,0 +1,25 @@
<vector
xmlns:android="http://schemas.android.com/apk/res/android"
android:name="vector"
android:width="842dp"
android:height="842dp"
android:viewportWidth="842"
android:viewportHeight="842">
<!--70% https://stackoverflow.com/questions/11285961/how-to-make-a-background-20-transparent-on-android -->
<path
android:name="path"
android:pathData="M 421.44 17.5 C 336.15 17.5 253.011 44.513 184.01 94.646 C 115.009 144.778 63.626 215.5 37.27 296.616 C 10.914 377.732 10.914 465.148 37.27 546.264 C 63.626 627.38 115.009 698.102 184.01 748.234 C 253.011 798.367 336.15 825.38 421.44 825.38 C 506.73 825.38 589.869 798.367 658.87 748.234 C 727.871 698.102 779.254 627.38 805.61 546.264 C 831.966 465.148 831.966 377.732 805.61 296.616 C 779.254 215.5 727.871 144.778 658.87 94.646 C 589.869 44.513 506.73 17.5 421.44 17.5 Z"
android:fillColor="#B3000000"
android:strokeWidth="1"/>
<path
android:name="path_1"
android:pathData="M 421.44 17.5 C 336.15 17.5 253.011 44.513 184.01 94.646 C 115.009 144.778 63.626 215.5 37.27 296.616 C 10.914 377.732 10.914 465.148 37.27 546.264 C 63.626 627.38 115.009 698.102 184.01 748.234 C 253.011 798.367 336.15 825.38 421.44 825.38 C 506.73 825.38 589.869 798.367 658.87 748.234 C 727.871 698.102 779.254 627.38 805.61 546.264 C 831.966 465.148 831.966 377.732 805.61 296.616 C 779.254 215.5 727.871 144.778 658.87 94.646 C 589.869 44.513 506.73 17.5 421.44 17.5 Z"
android:strokeColor="#ffffff"
android:strokeWidth="35"
android:strokeMiterLimit="10"/>
<path
android:name="path_2"
android:pathData="M 598.91 419.24 L 333.91 266.24 L 333.91 572.24 L 598.91 419.24 Z"
android:fillColor="#ffffff"
android:strokeWidth="1"/>
</vector>

View File

@ -63,7 +63,8 @@
<FrameLayout
android:visibility="gone"
tools:visibility="visible"
android:id="@+id/result_finish_loading" android:layout_width="match_parent"
android:id="@+id/result_finish_loading"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.google.android.material.appbar.AppBarLayout
android:visibility="gone"
@ -82,8 +83,11 @@
</com.google.android.material.appbar.MaterialToolbar>
</com.google.android.material.appbar.AppBarLayout>
<FrameLayout android:layout_width="match_parent" android:id="@+id/result_poster_blur_holder"
android:layout_height="180dp">
<FrameLayout
android:alpha="0"
android:layout_width="match_parent"
android:id="@+id/result_poster_blur_holder"
android:layout_height="180dp">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
@ -103,8 +107,8 @@
android:layout_height="wrap_content">
<LinearLayout
android:orientation="vertical"
android:layout_marginStart="10dp"
android:layout_marginEnd="10dp"
android:layout_marginStart="@dimen/result_padding"
android:layout_marginEnd="@dimen/result_padding"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!--
@ -116,7 +120,7 @@
</ImageView>
</LinearLayout>-->
<LinearLayout
android:layout_marginTop="10dp"
android:layout_marginTop="@dimen/result_padding"
android:orientation="horizontal" android:layout_width="match_parent"
android:layout_height="wrap_content">
@ -145,33 +149,33 @@
tools:text="The Perfect Run The Perfect Run The Perfect Run"
android:id="@+id/result_title"
android:textSize="20sp"
android:textStyle="bold"
android:textStyle="normal"
android:textColor="?attr/textColor" android:layout_width="wrap_content"
android:layout_height="wrap_content">
</TextView>
<TextView
android:id="@+id/result_year"
android:id="@+id/result_metadata"
tools:text="2021\nda"
android:paddingTop="3sp"
android:lineSpacingExtra="3sp"
android:textStyle="normal"
android:textSize="15sp"
android:textColor="?attr/textColor" android:layout_width="wrap_content"
android:layout_height="wrap_content">
</TextView>
<!--<TextView
android:id="@+id/result_rating"
tools:text="2021"
android:textStyle="bold"
android:textStyle="normal"
android:textSize="15sp"
android:textColor="?attr/textColor" android:layout_width="wrap_content"
android:layout_height="wrap_content">
</TextView>
<TextView
android:id="@+id/result_status"
tools:text="Finished"
android:textSize="15sp"
android:textColor="?attr/textColor" android:layout_width="wrap_content"
android:layout_height="wrap_content">
</TextView>
</TextView>-->
</LinearLayout>
</LinearLayout>
<GridLayout android:layout_width="match_parent" android:layout_height="50dp">
<GridLayout
android:layout_width="match_parent"
android:layout_height="50dp">
<com.google.android.material.button.MaterialButton
android:visibility="visible"
android:layout_gravity="center_vertical"
@ -353,7 +357,7 @@
android:focusable="true"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_margin="10dp"
android:layout_margin="@dimen/result_padding"
android:layout_gravity="end"
android:tint="?attr/white"
android:src="@drawable/ic_baseline_clear_24"

View File

@ -34,7 +34,6 @@
android:layout_height="match_parent">
</View>
</LinearLayout>
<GridLayout android:layout_width="match_parent" android:layout_height="match_parent">
<ImageView
android:layout_marginStart="10dp"
@ -61,6 +60,4 @@
android:src="@drawable/ic_baseline_more_vert_24"
android:contentDescription="@string/episode_more_options_descript"/>
</GridLayout>
</androidx.cardview.widget.CardView>

View File

@ -0,0 +1,71 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.cardview.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
app:cardCornerRadius="@dimen/roundedImageRadius"
app:cardBackgroundColor="?attr/itemBackground"
android:id="@+id/episode_holder"
android:foreground="?android:attr/selectableItemBackgroundBorderless"
android:layout_marginBottom="5dp"
>
<LinearLayout
android:padding="10dp"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout android:layout_width="match_parent" android:orientation="horizontal"
android:layout_height="wrap_content">
<FrameLayout
android:layout_width="126dp"
android:layout_height="72dp"
>
<ImageView
android:id="@+id/episode_poster"
tools:src="@drawable/example_poster"
android:scaleType="centerCrop"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:contentDescription="@string/episode_poster">
</ImageView>
<ImageView tools:src="@drawable/play_button"
android:layout_gravity="center"
android:layout_width="36dp"
android:layout_height="36dp"
android:contentDescription="@string/play_episode">
</ImageView>
<androidx.core.widget.ContentLoadingProgressBar
android:id="@+id/episode_progress"
style="@android:style/Widget.Material.ProgressBar.Horizontal"
android:layout_width="match_parent"
tools:progress="50"
android:layout_gravity="bottom"
android:layout_height="5dp">
</androidx.core.widget.ContentLoadingProgressBar>
</FrameLayout>
<LinearLayout android:layout_marginStart="10dp" android:orientation="vertical"
android:layout_gravity="center" android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView android:id="@+id/episode_text" tools:text="1. Jobless" android:textColor="?attr/textColor"
android:layout_width="wrap_content" android:layout_height="wrap_content">
</TextView>
<TextView android:id="@+id/episode_rating"
tools:text="8.8"
android:textColor="?attr/grayTextColor"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</TextView>
</LinearLayout>
</LinearLayout>
<TextView
android:paddingTop="2.5dp"
android:id="@+id/episode_descript"
android:textColor="?attr/grayTextColor"
tools:text="Jon and Daenerys arrive in Winterfell and are met with skepticism. Sam learns about the fate of his family. Cersei gives Euron the reward he aims for. Theon follows his heart. "
android:layout_width="match_parent" android:layout_height="wrap_content">
</TextView>
</LinearLayout>
</androidx.cardview.widget.CardView>

View File

@ -2,7 +2,8 @@
<!-- Default screen margins, per the Android Design guidelines. -->
<dimen name="activity_horizontal_margin">16dp</dimen>
<dimen name="activity_vertical_margin">16dp</dimen>
<dimen name="roundedImageRadius">1dp</dimen>
<dimen name="roundedImageRadius">5dp</dimen>
<dimen name="navbarHeight">0dp</dimen>
<dimen name="card_corner_radius">2dp</dimen>
<dimen name="result_padding">15dp</dimen>
</resources>

View File

@ -34,4 +34,6 @@
<string name="pick_source">Pick Source</string>
<string name="reload_error">Retry connection…</string>
<string name="result_go_back">Go Back</string>
<string name="episode_poster">Episode Poster</string>
<string name="play_episode">Play Episode</string>
</resources>