fix: Voice artists not showing media
This commit is contained in:
parent
79337b5e7f
commit
e5cb7c7fdf
9 changed files with 131 additions and 119 deletions
4
.github/workflows/beta.yml
vendored
4
.github/workflows/beta.yml
vendored
|
@ -117,9 +117,11 @@ jobs:
|
||||||
|
|
||||||
#Telegram
|
#Telegram
|
||||||
curl -F "chat_id=${{ secrets.TELEGRAM_CHANNEL_ID }}" \
|
curl -F "chat_id=${{ secrets.TELEGRAM_CHANNEL_ID }}" \
|
||||||
-F "document=@app/build/outputs/apk/google/alpha/app-google-armeabi-v7a-alpha.apk" \
|
|
||||||
-F "caption=Alpha-Build: ${VERSION}: ${commit_messages}" \
|
-F "caption=Alpha-Build: ${VERSION}: ${commit_messages}" \
|
||||||
https://api.telegram.org/bot${{ secrets.TELEGRAM_BOT_TOKEN }}/sendDocument
|
https://api.telegram.org/bot${{ secrets.TELEGRAM_BOT_TOKEN }}/sendDocument
|
||||||
|
curl -F "chat_id=${{ secrets.TELEGRAM_CHANNEL_ID }}" \
|
||||||
|
-F "document=@app/build/outputs/apk/google/alpha/app-google-armeabi-v7a-alpha.apk" \
|
||||||
|
https://api.telegram.org/bot${{ secrets.TELEGRAM_BOT_TOKEN }}/sendDocument
|
||||||
curl -F "chat_id=${{ secrets.TELEGRAM_CHANNEL_ID }}" \
|
curl -F "chat_id=${{ secrets.TELEGRAM_CHANNEL_ID }}" \
|
||||||
-F "document=@app/build/outputs/apk/google/alpha/app-google-arm64-v8a-alpha.apk" \
|
-F "document=@app/build/outputs/apk/google/alpha/app-google-arm64-v8a-alpha.apk" \
|
||||||
https://api.telegram.org/bot${{ secrets.TELEGRAM_BOT_TOKEN }}/sendDocument
|
https://api.telegram.org/bot${{ secrets.TELEGRAM_BOT_TOKEN }}/sendDocument
|
||||||
|
|
|
@ -1421,47 +1421,6 @@ Page(page:$page,perPage:50) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}""".replace("\n", " ").replace(""" """, "")
|
|
||||||
|
|
||||||
var hasNextPage = true
|
|
||||||
val yearMedia = mutableMapOf<String, ArrayList<Media>>()
|
|
||||||
var page = 0
|
|
||||||
|
|
||||||
while (hasNextPage) {
|
|
||||||
page++
|
|
||||||
hasNextPage = executeQuery<Query.Author>(
|
|
||||||
query(page),
|
|
||||||
force = true
|
|
||||||
)?.data?.author?.staffMedia?.let {
|
|
||||||
it.edges?.forEach { i ->
|
|
||||||
i.node?.apply {
|
|
||||||
val status = status.toString()
|
|
||||||
val year = startDate?.year?.toString() ?: "TBA"
|
|
||||||
val title = if (status != "CANCELLED") year else status
|
|
||||||
if (!yearMedia.containsKey(title))
|
|
||||||
yearMedia[title] = arrayListOf()
|
|
||||||
val media = Media(this)
|
|
||||||
media.relation = i.staffRole
|
|
||||||
yearMedia[title]?.add(media)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
it.pageInfo?.hasNextPage == true
|
|
||||||
} ?: false
|
|
||||||
}
|
|
||||||
|
|
||||||
if (yearMedia.contains("CANCELLED")) {
|
|
||||||
val a = yearMedia["CANCELLED"]!!
|
|
||||||
yearMedia.remove("CANCELLED")
|
|
||||||
yearMedia["CANCELLED"] = a
|
|
||||||
}
|
|
||||||
author.yearMedia = yearMedia
|
|
||||||
return author
|
|
||||||
}
|
|
||||||
suspend fun getVoiceActorsDetails(author: Author): Author {
|
|
||||||
fun query(page: Int = 0) = """ {
|
|
||||||
Staff(id:${author.id}) {
|
|
||||||
id
|
|
||||||
characters(page: $page,sort:FAVOURITES_DESC) {
|
characters(page: $page,sort:FAVOURITES_DESC) {
|
||||||
pageInfo{
|
pageInfo{
|
||||||
hasNextPage
|
hasNextPage
|
||||||
|
@ -1480,28 +1439,48 @@ Page(page:$page,perPage:50) {
|
||||||
large
|
large
|
||||||
medium
|
medium
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}""".replace("\n", " ").replace(""" """, "")
|
}""".replace("\n", " ").replace(""" """, "")
|
||||||
|
|
||||||
var hasNextPage = true
|
var hasNextPage = true
|
||||||
|
val yearMedia = mutableMapOf<String, ArrayList<Media>>()
|
||||||
var page = 0
|
var page = 0
|
||||||
val characters = arrayListOf<Character>()
|
val characters = arrayListOf<Character>()
|
||||||
while (hasNextPage) {
|
while (hasNextPage) {
|
||||||
page++
|
page++
|
||||||
hasNextPage = executeQuery<Query.Author>(
|
val query = executeQuery<Query.Author>(query(page), force = true
|
||||||
query(page),
|
)?.data?.author
|
||||||
force = true
|
hasNextPage = query?.staffMedia?.let {
|
||||||
)?.data?.author?.characters?.let {
|
it.edges?.forEach { i ->
|
||||||
it.nodes?.forEach { i ->
|
i.node?.apply {
|
||||||
characters.add(Character(i.id, i.name?.userPreferred, i.image?.large, i.image?.medium, "", false))
|
val status = status.toString()
|
||||||
|
val year = startDate?.year?.toString() ?: "TBA"
|
||||||
|
val title = if (status != "CANCELLED") year else status
|
||||||
|
if (!yearMedia.containsKey(title))
|
||||||
|
yearMedia[title] = arrayListOf()
|
||||||
|
val media = Media(this)
|
||||||
|
media.relation = i.staffRole
|
||||||
|
yearMedia[title]?.add(media)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
it.pageInfo?.hasNextPage == true
|
it.pageInfo?.hasNextPage == true
|
||||||
} ?: false
|
} ?: false
|
||||||
|
query?.characters?.let {
|
||||||
|
it.nodes?.forEach { i ->
|
||||||
|
characters.add(Character(i.id, i.name?.userPreferred, i.image?.large, i.image?.medium, "", false))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (yearMedia.contains("CANCELLED")) {
|
||||||
|
val a = yearMedia["CANCELLED"]!!
|
||||||
|
yearMedia.remove("CANCELLED")
|
||||||
|
yearMedia["CANCELLED"] = a
|
||||||
}
|
}
|
||||||
author.character = characters
|
author.character = characters
|
||||||
|
author.yearMedia = yearMedia
|
||||||
return author
|
return author
|
||||||
}
|
}
|
||||||
suspend fun toggleFollow(id: Int): Query.ToggleFollow? {
|
suspend fun toggleFollow(id: Int): Query.ToggleFollow? {
|
||||||
|
|
|
@ -334,7 +334,7 @@ class Query {
|
||||||
@SerialName("volumesRead") var volumesRead: Int,
|
@SerialName("volumesRead") var volumesRead: Int,
|
||||||
): java.io.Serializable
|
): java.io.Serializable
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class UserFavourites(
|
data class UserFavourites(
|
||||||
@SerialName("anime")
|
@SerialName("anime")
|
||||||
val anime: UserMediaFavouritesCollection,
|
val anime: UserMediaFavouritesCollection,
|
||||||
|
|
|
@ -12,6 +12,7 @@ import androidx.lifecycle.MutableLiveData
|
||||||
import androidx.lifecycle.lifecycleScope
|
import androidx.lifecycle.lifecycleScope
|
||||||
import androidx.recyclerview.widget.ConcatAdapter
|
import androidx.recyclerview.widget.ConcatAdapter
|
||||||
import androidx.recyclerview.widget.GridLayoutManager
|
import androidx.recyclerview.widget.GridLayoutManager
|
||||||
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import ani.dantotsu.EmptyAdapter
|
import ani.dantotsu.EmptyAdapter
|
||||||
import ani.dantotsu.R
|
import ani.dantotsu.R
|
||||||
import ani.dantotsu.Refresh
|
import ani.dantotsu.Refresh
|
||||||
|
@ -55,58 +56,51 @@ class AuthorActivity : AppCompatActivity() {
|
||||||
binding.studioClose.setOnClickListener {
|
binding.studioClose.setOnClickListener {
|
||||||
onBackPressedDispatcher.onBackPressed()
|
onBackPressedDispatcher.onBackPressed()
|
||||||
}
|
}
|
||||||
isVoiceArtist = intent.getBooleanExtra("isVoiceArtist", false)
|
model.getAuthor().observe(this) {
|
||||||
if (isVoiceArtist) {
|
if (it != null) {
|
||||||
model.getVoiceActor().observe(this) {
|
author = it
|
||||||
if (it != null) {
|
loaded = true
|
||||||
author = it
|
binding.studioProgressBar.visibility = View.GONE
|
||||||
loaded = true
|
binding.studioRecycler.visibility = View.VISIBLE
|
||||||
binding.studioProgressBar.visibility = View.GONE
|
if (author!!.yearMedia.isNullOrEmpty()) {
|
||||||
binding.studioRecycler.visibility = View.VISIBLE
|
binding.studioRecycler.visibility = View.GONE
|
||||||
binding.studioRecycler.adapter = CharacterAdapter(author!!.character ?: arrayListOf())
|
|
||||||
binding.studioRecycler.layoutManager = GridLayoutManager(
|
|
||||||
this,
|
|
||||||
(screenWidth / 120f).toInt()
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
val titlePosition = arrayListOf<Int>()
|
||||||
}else{
|
val concatAdapter = ConcatAdapter()
|
||||||
model.getAuthor().observe(this) {
|
val map = author!!.yearMedia ?: return@observe
|
||||||
if (it != null) {
|
val keys = map.keys.toTypedArray()
|
||||||
author = it
|
var pos = 0
|
||||||
loaded = true
|
|
||||||
binding.studioProgressBar.visibility = View.GONE
|
|
||||||
binding.studioRecycler.visibility = View.VISIBLE
|
|
||||||
|
|
||||||
val titlePosition = arrayListOf<Int>()
|
val gridSize = (screenWidth / 124f).toInt()
|
||||||
val concatAdapter = ConcatAdapter()
|
val gridLayoutManager = GridLayoutManager(this, gridSize)
|
||||||
val map = author!!.yearMedia ?: return@observe
|
gridLayoutManager.spanSizeLookup = object : GridLayoutManager.SpanSizeLookup() {
|
||||||
val keys = map.keys.toTypedArray()
|
override fun getSpanSize(position: Int): Int {
|
||||||
var pos = 0
|
return when (position in titlePosition) {
|
||||||
|
true -> gridSize
|
||||||
val gridSize = (screenWidth / 124f).toInt()
|
else -> 1
|
||||||
val gridLayoutManager = GridLayoutManager(this, gridSize)
|
|
||||||
gridLayoutManager.spanSizeLookup = object : GridLayoutManager.SpanSizeLookup() {
|
|
||||||
override fun getSpanSize(position: Int): Int {
|
|
||||||
return when (position in titlePosition) {
|
|
||||||
true -> gridSize
|
|
||||||
else -> 1
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (i in keys.indices) {
|
}
|
||||||
val medias = map[keys[i]]!!
|
for (i in keys.indices) {
|
||||||
val empty = if (medias.size >= 4) medias.size % 4 else 4 - medias.size
|
val medias = map[keys[i]]!!
|
||||||
titlePosition.add(pos)
|
val empty = if (medias.size >= 4) medias.size % 4 else 4 - medias.size
|
||||||
pos += (empty + medias.size + 1)
|
titlePosition.add(pos)
|
||||||
|
pos += (empty + medias.size + 1)
|
||||||
|
|
||||||
concatAdapter.addAdapter(TitleAdapter("${keys[i]} (${medias.size})"))
|
concatAdapter.addAdapter(TitleAdapter("${keys[i]} (${medias.size})"))
|
||||||
concatAdapter.addAdapter(MediaAdaptor(0, medias, this, true))
|
concatAdapter.addAdapter(MediaAdaptor(0, medias, this, true))
|
||||||
concatAdapter.addAdapter(EmptyAdapter(empty))
|
concatAdapter.addAdapter(EmptyAdapter(empty))
|
||||||
}
|
}
|
||||||
|
binding.studioRecycler.adapter = concatAdapter
|
||||||
|
binding.studioRecycler.layoutManager = gridLayoutManager
|
||||||
|
|
||||||
binding.studioRecycler.adapter = concatAdapter
|
binding.charactersRecycler.visibility = View.VISIBLE
|
||||||
binding.studioRecycler.layoutManager = gridLayoutManager
|
binding.charactersText.visibility = View.VISIBLE
|
||||||
|
binding.charactersRecycler.adapter = CharacterAdapter(author!!.character ?: arrayListOf())
|
||||||
|
binding.charactersRecycler.layoutManager = LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false)
|
||||||
|
if (author!!.character.isNullOrEmpty()) {
|
||||||
|
binding.charactersRecycler.visibility = View.GONE
|
||||||
|
binding.charactersText.visibility = View.GONE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -115,7 +109,7 @@ class AuthorActivity : AppCompatActivity() {
|
||||||
if (it) {
|
if (it) {
|
||||||
scope.launch {
|
scope.launch {
|
||||||
if (author != null)
|
if (author != null)
|
||||||
withContext(Dispatchers.IO) { if (isVoiceArtist) model.loadVoiceActor(author!!) else model.loadAuthor(author!!)}
|
withContext(Dispatchers.IO) { model.loadAuthor(author!!)}
|
||||||
live.postValue(false)
|
live.postValue(false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,6 @@ import java.io.Serializable
|
||||||
|
|
||||||
class AuthorAdapter(
|
class AuthorAdapter(
|
||||||
private val authorList: ArrayList<Author>,
|
private val authorList: ArrayList<Author>,
|
||||||
private val isVA: Boolean = false,
|
|
||||||
) : RecyclerView.Adapter<AuthorAdapter.AuthorViewHolder>() {
|
) : RecyclerView.Adapter<AuthorAdapter.AuthorViewHolder>() {
|
||||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): AuthorViewHolder {
|
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): AuthorViewHolder {
|
||||||
val binding =
|
val binding =
|
||||||
|
@ -44,7 +43,7 @@ class AuthorAdapter(
|
||||||
Intent(
|
Intent(
|
||||||
itemView.context,
|
itemView.context,
|
||||||
AuthorActivity::class.java
|
AuthorActivity::class.java
|
||||||
).putExtra("author", author as Serializable).putExtra("isVoiceArtist", isVA),
|
).putExtra("author", author as Serializable),
|
||||||
ActivityOptionsCompat.makeSceneTransitionAnimation(
|
ActivityOptionsCompat.makeSceneTransitionAnimation(
|
||||||
itemView.context as Activity,
|
itemView.context as Activity,
|
||||||
Pair.create(
|
Pair.create(
|
||||||
|
|
|
@ -38,7 +38,7 @@ class CharacterDetailsAdapter(private val character: Character, private val acti
|
||||||
val markWon = Markwon.builder(activity).usePlugin(SoftBreakAddsNewLinePlugin.create())
|
val markWon = Markwon.builder(activity).usePlugin(SoftBreakAddsNewLinePlugin.create())
|
||||||
.usePlugin(SpoilerPlugin()).build()
|
.usePlugin(SpoilerPlugin()).build()
|
||||||
markWon.setMarkdown(binding.characterDesc, desc.replace("~!", "||").replace("!~", "||"))
|
markWon.setMarkdown(binding.characterDesc, desc.replace("~!", "||").replace("!~", "||"))
|
||||||
binding.voiceActorRecycler.adapter = AuthorAdapter(character.voiceActor ?: arrayListOf(), true)
|
binding.voiceActorRecycler.adapter = AuthorAdapter(character.voiceActor ?: arrayListOf())
|
||||||
binding.voiceActorRecycler.layoutManager = LinearLayoutManager(
|
binding.voiceActorRecycler.layoutManager = LinearLayoutManager(
|
||||||
activity, LinearLayoutManager.HORIZONTAL, false
|
activity, LinearLayoutManager.HORIZONTAL, false
|
||||||
)
|
)
|
||||||
|
|
|
@ -26,11 +26,7 @@ class OtherDetailsViewModel : ViewModel() {
|
||||||
suspend fun loadAuthor(m: Author) {
|
suspend fun loadAuthor(m: Author) {
|
||||||
if (author.value == null) author.postValue(Anilist.query.getAuthorDetails(m))
|
if (author.value == null) author.postValue(Anilist.query.getAuthorDetails(m))
|
||||||
}
|
}
|
||||||
private val voiceActor: MutableLiveData<Author> = MutableLiveData(null)
|
|
||||||
fun getVoiceActor(): LiveData<Author> = voiceActor
|
|
||||||
suspend fun loadVoiceActor(m: Author) {
|
|
||||||
if (voiceActor.value == null) voiceActor.postValue(Anilist.query.getVoiceActorsDetails(m))
|
|
||||||
}
|
|
||||||
private val calendar: MutableLiveData<Map<String, MutableList<Media>>> = MutableLiveData(null)
|
private val calendar: MutableLiveData<Map<String, MutableList<Media>>> = MutableLiveData(null)
|
||||||
fun getCalendar(): LiveData<Map<String, MutableList<Media>>> = calendar
|
fun getCalendar(): LiveData<Map<String, MutableList<Media>>> = calendar
|
||||||
suspend fun loadCalendar() {
|
suspend fun loadCalendar() {
|
||||||
|
|
|
@ -27,6 +27,61 @@
|
||||||
|
|
||||||
</com.google.android.material.appbar.AppBarLayout>
|
</com.google.android.material.appbar.AppBarLayout>
|
||||||
|
|
||||||
|
<androidx.core.widget.NestedScrollView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="64dp"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/charactersText"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="8dp"
|
||||||
|
android:layout_marginEnd="32dp"
|
||||||
|
android:fontFamily="@font/poppins_bold"
|
||||||
|
android:padding="8dp"
|
||||||
|
android:text="@string/characters"
|
||||||
|
android:textSize="18sp"
|
||||||
|
android:visibility="gone"
|
||||||
|
tools:visibility="visible" />
|
||||||
|
|
||||||
|
<ani.dantotsu.FadingEdgeRecyclerView
|
||||||
|
android:id="@+id/charactersRecycler"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:clipToPadding="false"
|
||||||
|
android:nestedScrollingEnabled="true"
|
||||||
|
android:paddingStart="20dp"
|
||||||
|
android:paddingEnd="20dp"
|
||||||
|
android:requiresFadingEdge="horizontal"
|
||||||
|
tools:itemCount="4"
|
||||||
|
tools:layoutManager="androidx.recyclerview.widget.GridLayoutManager"
|
||||||
|
tools:listitem="@layout/item_media_compact"
|
||||||
|
tools:orientation="horizontal" />
|
||||||
|
|
||||||
|
|
||||||
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
|
android:id="@+id/studioRecycler"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:clipToPadding="false"
|
||||||
|
android:nestedScrollingEnabled="false"
|
||||||
|
android:paddingTop="16dp"
|
||||||
|
android:visibility="gone"
|
||||||
|
app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior"
|
||||||
|
tools:itemCount="4"
|
||||||
|
tools:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
|
||||||
|
tools:listitem="@layout/item_media_compact"
|
||||||
|
tools:orientation="vertical"
|
||||||
|
tools:visibility="visible" />
|
||||||
|
</LinearLayout>
|
||||||
|
</androidx.core.widget.NestedScrollView>
|
||||||
|
|
||||||
<ProgressBar
|
<ProgressBar
|
||||||
android:id="@+id/studioProgressBar"
|
android:id="@+id/studioProgressBar"
|
||||||
style="?android:attr/progressBarStyle"
|
style="?android:attr/progressBarStyle"
|
||||||
|
@ -36,20 +91,6 @@
|
||||||
app:layout_behavior="@string/appbar_scrolling_view_behavior"
|
app:layout_behavior="@string/appbar_scrolling_view_behavior"
|
||||||
tools:visibility="gone" />
|
tools:visibility="gone" />
|
||||||
|
|
||||||
<androidx.recyclerview.widget.RecyclerView
|
|
||||||
android:id="@+id/studioRecycler"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:clipToPadding="false"
|
|
||||||
android:paddingTop="16dp"
|
|
||||||
android:visibility="gone"
|
|
||||||
app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior"
|
|
||||||
tools:itemCount="4"
|
|
||||||
tools:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
|
|
||||||
tools:listitem="@layout/item_media_compact"
|
|
||||||
tools:orientation="vertical"
|
|
||||||
tools:visibility="visible" />
|
|
||||||
|
|
||||||
<androidx.cardview.widget.CardView
|
<androidx.cardview.widget.CardView
|
||||||
android:id="@+id/studioClose"
|
android:id="@+id/studioClose"
|
||||||
android:layout_width="32dp"
|
android:layout_width="32dp"
|
||||||
|
|
|
@ -887,4 +887,5 @@ Non quae tempore quo provident laudantium qui illo dolor vel quia dolor et exerc
|
||||||
<string name="ban">Ban</string>
|
<string name="ban">Ban</string>
|
||||||
<string name="voice_actors">Voice Actors</string>
|
<string name="voice_actors">Voice Actors</string>
|
||||||
<string name="download_permission_required">Permission is required to download</string>
|
<string name="download_permission_required">Permission is required to download</string>
|
||||||
|
<string name="media">Media</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue