Skip to content

Commit aeba48e

Browse files
committed
2 parents f689ded + 555d977 commit aeba48e

10 files changed

Lines changed: 38 additions & 9 deletions

File tree

app/src/main/java/com/lagradost/cloudstream3/syncproviders/SyncApi.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ interface SyncAPI : OAuth2API {
5151
override var quality: SearchQuality? = null,
5252
override var posterHeaders: Map<String, String>? = null,
5353
override var id: Int? = null,
54+
override var score: Score? = null,
5455
) : SearchResponse
5556

5657
abstract class AbstractSyncStatus {
@@ -163,7 +164,7 @@ interface SyncAPI : OAuth2API {
163164
val releaseDate: Date?,
164165
override var id: Int? = null,
165166
val plot : String? = null,
166-
val rating: Score? = null,
167+
override var score: Score? = null,
167168
val tags: List<String>? = null
168169
) : SearchResponse
169170
}

app/src/main/java/com/lagradost/cloudstream3/ui/result/ResultViewModel2.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2655,7 +2655,7 @@ class ResultViewModel2 : ViewModel() {
26552655
).apply {
26562656
if (searchResponse is SyncAPI.LibraryItem) {
26572657
this.plot = searchResponse.plot
2658-
this.score = Score.from100(searchResponse.personalRating) ?: searchResponse.rating
2658+
this.score = Score.from100(searchResponse.personalRating) ?: searchResponse.score
26592659
this.tags = searchResponse.tags
26602660
}
26612661
if (searchResponse is DataStoreHelper.BookmarkedData) {

app/src/main/java/com/lagradost/cloudstream3/ui/search/SearchResultBuilder.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,13 @@ object SearchResultBuilder {
9090
val ratingText = ((card.personalRating ?: 0).toDouble() / 10).toString()
9191
.replace(".0", "")
9292

93+
rating?.text = ratingText
94+
}
95+
} else {
96+
val ratingText = card.score?.toString(10, 1)
97+
val showRating = (ratingText ?: "") != ""
98+
rating?.isVisible = showRating
99+
if(showRating) {
93100
rating?.text = ratingText
94101
}
95102
}

app/src/main/java/com/lagradost/cloudstream3/ui/search/SyncSearchViewModel.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.lagradost.cloudstream3.ui.search
22

3+
import com.lagradost.cloudstream3.Score
34
import com.lagradost.cloudstream3.SearchQuality
45
import com.lagradost.cloudstream3.SearchResponse
56
import com.lagradost.cloudstream3.TvType
@@ -15,5 +16,6 @@ class SyncSearchViewModel {
1516
override var id: Int?,
1617
override var quality: SearchQuality? = null,
1718
override var posterHeaders: Map<String, String>? = null,
19+
override var score: Score? = null,
1820
) : SearchResponse
1921
}

app/src/main/java/com/lagradost/cloudstream3/utils/DataStoreHelper.kt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ object DataStoreHelper {
259259
@JsonProperty("quality") override var quality: SearchQuality?,
260260
@JsonProperty("posterHeaders") override var posterHeaders: Map<String, String>?,
261261
@JsonProperty("plot") open val plot: String? = null,
262-
@JsonProperty("score") open var score: Score? = null,
262+
@JsonProperty("score") override var score: Score? = null,
263263
@JsonProperty("tags") open val tags: List<String>? = null,
264264
) : SearchResponse {
265265
@JsonProperty("rating", access = JsonProperty.Access.WRITE_ONLY)
@@ -326,7 +326,7 @@ object DataStoreHelper {
326326
year?.toYear(),
327327
this.id,
328328
plot = this.plot,
329-
rating = this.score,
329+
score = this.score,
330330
tags = this.tags
331331
)
332332
}
@@ -379,7 +379,7 @@ object DataStoreHelper {
379379
year?.toYear(),
380380
this.id,
381381
plot = this.plot,
382-
rating = this.score,
382+
score = this.score,
383383
tags = this.tags
384384
)
385385
}
@@ -432,7 +432,7 @@ object DataStoreHelper {
432432
year?.toYear(),
433433
this.id,
434434
plot = this.plot,
435-
rating = this.score,
435+
score = this.score,
436436
tags = this.tags
437437
)
438438
}
@@ -452,6 +452,7 @@ object DataStoreHelper {
452452
@JsonProperty("isFromDownload") val isFromDownload: Boolean,
453453
@JsonProperty("quality") override var quality: SearchQuality? = null,
454454
@JsonProperty("posterHeaders") override var posterHeaders: Map<String, String>? = null,
455+
@JsonProperty("score") override var score: Score? = null,
455456
) : SearchResponse
456457

457458
/**

app/src/main/res/drawable/rating_bg_color.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
<solid android:color="?attr/colorPrimary"/>
44
<corners android:radius="@dimen/rounded_image_radius"/>
55
<!-- <stroke android:color="@color/subColor" android:width="2dp"/>-->
6-
</shape>
6+
</shape>

app/src/main/res/layout/home_result_grid.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,12 @@
110110
style="@style/SubButton"
111111
android:layout_gravity="end" />
112112

113+
<TextView
114+
android:id="@+id/text_rating"
115+
style="@style/RatingButton"
116+
android:layout_gravity="end"
117+
tools:text="7.7" />
118+
113119
<TextView
114120
android:id="@+id/text_flag"
115121
style="@style/SearchBox"

app/src/main/res/layout/home_result_grid_expanded.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,12 @@
109109
style="@style/SubButton"
110110
android:layout_gravity="end" />
111111

112+
<TextView
113+
android:id="@+id/text_rating"
114+
style="@style/RatingButton"
115+
android:layout_gravity="end"
116+
tools:text="7.7" />
117+
112118
<TextView
113119
android:id="@+id/text_flag"
114120
style="@style/SearchBox"

app/src/main/res/values/styles.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@
159159
<item name="android:background">@drawable/rating_bg_color</item>
160160
<item name="drawableTint">?attr/colorOnPrimary</item>
161161
<item name="android:textColor">?attr/colorOnPrimary</item>
162-
<item name="drawableStartCompat">@drawable/ic_baseline_star_24</item>
162+
<!--<item name="drawableStartCompat">@drawable/ic_baseline_star_24</item>-->
163163
</style>
164164

165165
<style name="TypeButton" parent="@style/SearchBox">

library/src/commonMain/kotlin/com/lagradost/cloudstream3/MainAPI.kt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1191,6 +1191,7 @@ interface SearchResponse {
11911191
var posterHeaders: Map<String, String>?
11921192
var id: Int?
11931193
var quality: SearchQuality?
1194+
var score: Score?
11941195
}
11951196

11961197
fun MainAPI.newTorrentSearchResponse(
@@ -1348,6 +1349,7 @@ constructor(
13481349
override var id: Int? = null,
13491350
override var quality: SearchQuality? = null,
13501351
override var posterHeaders: Map<String, String>? = null,
1352+
override var score: Score? = null,
13511353
) : SearchResponse
13521354

13531355
fun AnimeSearchResponse.addDubStatus(status: DubStatus, episodes: Int? = null) {
@@ -1407,6 +1409,7 @@ constructor(
14071409
override var id: Int? = null,
14081410
override var quality: SearchQuality? = null,
14091411
override var posterHeaders: Map<String, String>? = null,
1412+
override var score: Score? = null,
14101413
) : SearchResponse
14111414

14121415
/** Data class of [SearchResponse] interface for Movies.
@@ -1424,7 +1427,8 @@ constructor(
14241427
var year: Int? = null,
14251428
override var id: Int? = null,
14261429
override var quality: SearchQuality? = null,
1427-
override var posterHeaders: Map<String, String>? = null
1430+
override var posterHeaders: Map<String, String>? = null,
1431+
override var score: Score? = null,
14281432
) : SearchResponse
14291433

14301434
/** Data class of [SearchResponse] interface for Live streams.
@@ -1443,6 +1447,7 @@ constructor(
14431447
override var quality: SearchQuality? = null,
14441448
override var posterHeaders: Map<String, String>? = null,
14451449
var lang: String? = null,
1450+
override var score: Score? = null,
14461451
) : SearchResponse
14471452

14481453
/** Data class of [SearchResponse] interface for Tv series.
@@ -1462,6 +1467,7 @@ constructor(
14621467
override var id: Int? = null,
14631468
override var quality: SearchQuality? = null,
14641469
override var posterHeaders: Map<String, String>? = null,
1470+
override var score: Score? = null,
14651471
) : SearchResponse
14661472

14671473
/** Data class of Trailer data.

0 commit comments

Comments
 (0)