From 6d97ac1b8246068294c3f243089ef0c09a0ebaca Mon Sep 17 00:00:00 2001 From: LagradOst <11805592+LagradOst@users.noreply.github.com> Date: Sun, 3 Apr 2022 20:34:51 +0200 Subject: [PATCH] voiceactors and fixed flowlayout --- .../syncproviders/providers/AniListApi.kt | 12 ++++++++++++ .../cloudstream3/widget/FlowLayout.kt | 18 ++++++++++++------ 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/com/lagradost/cloudstream3/syncproviders/providers/AniListApi.kt b/app/src/main/java/com/lagradost/cloudstream3/syncproviders/providers/AniListApi.kt index 89a939f5..eb7bebdc 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/syncproviders/providers/AniListApi.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/syncproviders/providers/AniListApi.kt @@ -343,6 +343,18 @@ class AniListApi(index: Int) : AccountManager(index), SyncAPI { characters(sort: ROLE page: 1 perPage: 20) { edges { role + voiceActors { + name { + userPreferred + full + native + } + age + image { + large + medium + } + } node { name { userPreferred diff --git a/app/src/main/java/com/lagradost/cloudstream3/widget/FlowLayout.kt b/app/src/main/java/com/lagradost/cloudstream3/widget/FlowLayout.kt index c4ecf5e2..e05f5b7a 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/widget/FlowLayout.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/widget/FlowLayout.kt @@ -8,7 +8,7 @@ import com.lagradost.cloudstream3.R import kotlin.math.max class FlowLayout : ViewGroup { - var itemSpacing : Int = 0 + var itemSpacing: Int = 0 constructor(context: Context?) : super(context) @@ -36,7 +36,7 @@ class FlowLayout : ViewGroup { val childHeight = child.measuredHeight //check if child can be placed in the current row, else go to next line - if (currentChildHookPointx + childWidth > realWidth) { + if (currentChildHookPointx + childWidth > realWidth && i + 1 < childCount) { //new line currentWidth = max(currentWidth, currentChildHookPointx) @@ -44,7 +44,8 @@ class FlowLayout : ViewGroup { currentChildHookPointx = 0 currentChildHookPointy += childHeight } - val nextChildHookPointx = currentChildHookPointx + childWidth + if(childWidth == 0) 0 else itemSpacing + val nextChildHookPointx = + currentChildHookPointx + childWidth + if (childWidth == 0) 0 else itemSpacing val nextChildHookPointy = currentChildHookPointy currentHeight = max(currentHeight, currentChildHookPointy + childHeight) val lp = child.layoutParams as LayoutParams @@ -54,8 +55,10 @@ class FlowLayout : ViewGroup { currentChildHookPointy = nextChildHookPointy } currentWidth = max(currentChildHookPointx, currentWidth) - setMeasuredDimension(resolveSize(currentWidth, widthMeasureSpec), - resolveSize(currentHeight, heightMeasureSpec)) + setMeasuredDimension( + resolveSize(currentWidth, widthMeasureSpec), + resolveSize(currentHeight, heightMeasureSpec) + ) } override fun onLayout(b: Boolean, left: Int, top: Int, right: Int, bottom: Int) { @@ -73,7 +76,10 @@ class FlowLayout : ViewGroup { } override fun generateDefaultLayoutParams(): LayoutParams { - return LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT) + return LayoutParams( + ViewGroup.LayoutParams.WRAP_CONTENT, + ViewGroup.LayoutParams.WRAP_CONTENT + ) } override fun generateLayoutParams(p: ViewGroup.LayoutParams): LayoutParams {