WTF: rebel pls fix it
This commit is contained in:
parent
36c64951c7
commit
8da0092561
8 changed files with 170 additions and 16 deletions
|
@ -110,6 +110,10 @@
|
||||||
android:name=".profile.ProfileActivity"
|
android:name=".profile.ProfileActivity"
|
||||||
android:windowSoftInputMode="adjustResize|stateHidden"
|
android:windowSoftInputMode="adjustResize|stateHidden"
|
||||||
android:parentActivityName=".MainActivity" />
|
android:parentActivityName=".MainActivity" />
|
||||||
|
<activity
|
||||||
|
android:name=".profile.FollowActivity"
|
||||||
|
android:windowSoftInputMode="adjustResize|stateHidden"
|
||||||
|
android:parentActivityName=".MainActivity" />
|
||||||
<activity
|
<activity
|
||||||
android:name=".others.imagesearch.ImageSearchActivity"
|
android:name=".others.imagesearch.ImageSearchActivity"
|
||||||
android:parentActivityName=".MainActivity" />
|
android:parentActivityName=".MainActivity" />
|
||||||
|
|
|
@ -1254,6 +1254,7 @@ Page(page:$page,perPage:50) {
|
||||||
show = true
|
show = true
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
suspend fun userFavMedia(anime: Boolean, id: Int): ArrayList<Media> {
|
suspend fun userFavMedia(anime: Boolean, id: Int): ArrayList<Media> {
|
||||||
var hasNextPage = true
|
var hasNextPage = true
|
||||||
var page = 0
|
var page = 0
|
||||||
|
@ -1280,6 +1281,9 @@ Page(page:$page,perPage:50) {
|
||||||
private fun userFavMediaQuery(anime: Boolean, page: Int, id: Int): String {
|
private fun userFavMediaQuery(anime: Boolean, page: Int, id: Int): String {
|
||||||
return """User(id:${id}){id favourites{${if (anime) "anime" else "manga"}(page:$page){pageInfo{hasNextPage}edges{favouriteOrder node{id idMal isAdult mediaListEntry{ progress private score(format:POINT_100) status } chapters isFavourite format episodes nextAiringEpisode{episode}meanScore isFavourite format startDate{year month day} title{english romaji userPreferred}type status(version:2)bannerImage coverImage{large}}}}}}"""
|
return """User(id:${id}){id favourites{${if (anime) "anime" else "manga"}(page:$page){pageInfo{hasNextPage}edges{favouriteOrder node{id idMal isAdult mediaListEntry{ progress private score(format:POINT_100) status } chapters isFavourite format episodes nextAiringEpisode{episode}meanScore isFavourite format startDate{year month day} title{english romaji userPreferred}type status(version:2)bannerImage coverImage{large}}}}}}"""
|
||||||
}
|
}
|
||||||
|
suspend fun userFollowing(id: Int): Query.Following?{
|
||||||
|
return executeQuery<Query.Following>("""{Following:Page {following(userId:${id},sort:[USERNAME]){id name avatar{large medium}bannerImage}}}""", force = true)
|
||||||
|
}
|
||||||
private suspend fun userBannerImage(type: String,id: Int?): String? {
|
private suspend fun userBannerImage(type: String,id: Int?): String? {
|
||||||
val response =
|
val response =
|
||||||
executeQuery<Query.MediaListCollection>("""{ MediaListCollection(userId: ${id}, type: $type, chunk:1,perChunk:25, sort: [SCORE_DESC,UPDATED_TIME_DESC]) { lists { entries{ media { id bannerImage } } } } } """)
|
executeQuery<Query.MediaListCollection>("""{ MediaListCollection(userId: ${id}, type: $type, chunk:1,perChunk:25, sort: [SCORE_DESC,UPDATED_TIME_DESC]) { lists { entries{ media { id bannerImage } } } } } """)
|
||||||
|
|
|
@ -199,7 +199,17 @@ class Query {
|
||||||
val user: UserProfile?
|
val user: UserProfile?
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@Serializable
|
||||||
|
data class Following(
|
||||||
|
@SerialName("data")
|
||||||
|
val data: Data
|
||||||
|
) {
|
||||||
|
@Serializable
|
||||||
|
data class Data(
|
||||||
|
@SerialName("following")
|
||||||
|
val following: ani.dantotsu.connections.anilist.api.User?
|
||||||
|
)
|
||||||
|
}
|
||||||
@Serializable
|
@Serializable
|
||||||
data class UserProfile(
|
data class UserProfile(
|
||||||
@SerialName("id")
|
@SerialName("id")
|
||||||
|
|
32
app/src/main/java/ani/dantotsu/profile/FollowActivity.kt
Normal file
32
app/src/main/java/ani/dantotsu/profile/FollowActivity.kt
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
package ani.dantotsu.profile
|
||||||
|
|
||||||
|
import android.os.Bundle
|
||||||
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
|
import androidx.lifecycle.lifecycleScope
|
||||||
|
import ani.dantotsu.connections.anilist.Anilist
|
||||||
|
import ani.dantotsu.databinding.ActivityFollowBinding
|
||||||
|
import ani.dantotsu.initActivity
|
||||||
|
import ani.dantotsu.themes.ThemeManager
|
||||||
|
import kotlinx.coroutines.Dispatchers
|
||||||
|
import kotlinx.coroutines.launch
|
||||||
|
import kotlinx.coroutines.withContext
|
||||||
|
|
||||||
|
|
||||||
|
class FollowActivity : AppCompatActivity(){
|
||||||
|
private lateinit var binding: ActivityFollowBinding
|
||||||
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
super.onCreate(savedInstanceState)
|
||||||
|
ThemeManager(this).applyTheme()
|
||||||
|
initActivity(this)
|
||||||
|
binding = ActivityFollowBinding.inflate(layoutInflater)
|
||||||
|
setContentView(binding.root)
|
||||||
|
binding.listTitle.text = intent.getStringExtra("title")
|
||||||
|
lifecycleScope.launch(Dispatchers.IO) {
|
||||||
|
val respond = Anilist.query.userFollowing(intent.getIntExtra("userId", 0))
|
||||||
|
val user = respond?.data?.following
|
||||||
|
withContext(Dispatchers.Main) {
|
||||||
|
user?.id
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,10 +1,12 @@
|
||||||
package ani.dantotsu.profile
|
package ani.dantotsu.profile
|
||||||
|
|
||||||
import android.annotation.SuppressLint
|
import android.annotation.SuppressLint
|
||||||
|
import android.content.Intent
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
|
import androidx.core.content.ContextCompat
|
||||||
import androidx.core.view.updateLayoutParams
|
import androidx.core.view.updateLayoutParams
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import androidx.fragment.app.FragmentManager
|
import androidx.fragment.app.FragmentManager
|
||||||
|
@ -98,14 +100,15 @@ class ProfileActivity : AppCompatActivity() {
|
||||||
}
|
}
|
||||||
binding.profileProgressBar.visibility = View.GONE
|
binding.profileProgressBar.visibility = View.GONE
|
||||||
binding.profileTopContainer.visibility = View.VISIBLE
|
binding.profileTopContainer.visibility = View.VISIBLE
|
||||||
binding.profileBannerImage.loadImage(user.bannerImage)
|
|
||||||
binding.profileBannerImage.setOnLongClickListener {
|
binding.temp.setOnClickListener {
|
||||||
ImageViewDialog.newInstance(
|
ContextCompat.startActivity(
|
||||||
this@ProfileActivity,
|
this@ProfileActivity, Intent(this@ProfileActivity, FollowActivity::class.java)
|
||||||
"${user.name}'s [Banner]",
|
.putExtra("title", "Following")
|
||||||
user.bannerImage
|
.putExtra("userId", user.id), null
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.profileUserAvatar.loadImage(user.avatar?.medium)
|
binding.profileUserAvatar.loadImage(user.avatar?.medium)
|
||||||
binding.profileUserAvatar.setOnLongClickListener {
|
binding.profileUserAvatar.setOnLongClickListener {
|
||||||
ImageViewDialog.newInstance(
|
ImageViewDialog.newInstance(
|
||||||
|
@ -114,6 +117,7 @@ class ProfileActivity : AppCompatActivity() {
|
||||||
user.avatar?.medium
|
user.avatar?.medium
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.profileUserName.text = "${user.name} $userLevel"
|
binding.profileUserName.text = "${user.name} $userLevel"
|
||||||
if (!(PrefManager.getVal(PrefName.BannerAnimations) as Boolean)) binding.profileBannerImage.pause()
|
if (!(PrefManager.getVal(PrefName.BannerAnimations) as Boolean)) binding.profileBannerImage.pause()
|
||||||
binding.profileBannerImage.loadImage(user.bannerImage)
|
binding.profileBannerImage.loadImage(user.bannerImage)
|
||||||
|
@ -125,14 +129,7 @@ class ProfileActivity : AppCompatActivity() {
|
||||||
user.bannerImage
|
user.bannerImage
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
binding.profileUserAvatar.loadImage(user.avatar?.medium)
|
|
||||||
binding.profileUserAvatar.setOnLongClickListener {
|
|
||||||
ImageViewDialog.newInstance(
|
|
||||||
this@ProfileActivity,
|
|
||||||
user.name + " [Avatar]",
|
|
||||||
user.avatar?.medium
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
38
app/src/main/res/layout/activity_follow.xml
Normal file
38
app/src/main/res/layout/activity_follow.xml
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:orientation="vertical">
|
||||||
|
<ProgressBar
|
||||||
|
android:id="@+id/listProgressBar"
|
||||||
|
style="?android:attr/progressBarStyle"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:visibility="gone"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/listTitle"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="48dp"
|
||||||
|
android:layout_marginStart="32dp"
|
||||||
|
android:ellipsize="end"
|
||||||
|
android:fontFamily="@font/poppins_bold"
|
||||||
|
android:gravity="center|start"
|
||||||
|
android:singleLine="true"
|
||||||
|
android:textAppearance="@style/TextAppearance.Widget.AppCompat.Toolbar.Title"
|
||||||
|
android:textColor="?attr/colorOnBackground"
|
||||||
|
android:textSize="16sp"
|
||||||
|
tools:text="xyz" />
|
||||||
|
|
||||||
|
|
||||||
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
|
android:id="@+id/listRecyclerView"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginEnd="16dp"
|
||||||
|
android:layout_marginStart="16dp"
|
||||||
|
tools:listitem="@layout/item_follow"/>
|
||||||
|
</LinearLayout>
|
|
@ -102,7 +102,21 @@
|
||||||
app:cornerRadius="8dp"
|
app:cornerRadius="8dp"
|
||||||
app:strokeColor="?attr/colorPrimaryContainer"
|
app:strokeColor="?attr/colorPrimaryContainer"
|
||||||
tools:ignore="SpeakableTextPresentCheck" />
|
tools:ignore="SpeakableTextPresentCheck" />
|
||||||
|
<Button
|
||||||
|
android:id="@+id/temp"
|
||||||
|
style="@style/Widget.Material3.Button.OutlinedButton"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:enabled="true"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:fontFamily="@font/poppins_bold"
|
||||||
|
android:textColor="@color/bg_opp"
|
||||||
|
android:text="temp"
|
||||||
|
android:textSize="14sp"
|
||||||
|
android:backgroundTint="?attr/colorPrimaryContainer"
|
||||||
|
app:cornerRadius="8dp"
|
||||||
|
app:strokeColor="?attr/colorPrimaryContainer"
|
||||||
|
tools:ignore="SpeakableTextPresentCheck" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<androidx.viewpager2.widget.ViewPager2
|
<androidx.viewpager2.widget.ViewPager2
|
||||||
|
|
55
app/src/main/res/layout/item_follow.xml
Normal file
55
app/src/main/res/layout/item_follow.xml
Normal file
|
@ -0,0 +1,55 @@
|
||||||
|
<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="80dp"
|
||||||
|
app:cardCornerRadius="16dp"
|
||||||
|
android:layout_marginBottom="16dp">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/followBanner"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
tools:ignore="ContentDescription,ImageContrastCheck" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="80dp"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<androidx.cardview.widget.CardView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="10dp"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
app:cardCornerRadius="32dp">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/followProfile"
|
||||||
|
|
||||||
|
android:layout_width="64dp"
|
||||||
|
android:layout_height="64dp"
|
||||||
|
tools:ignore="ContentDescription,ImageContrastCheck"
|
||||||
|
tools:srcCompat="@tools:sample/avatars" />
|
||||||
|
</androidx.cardview.widget.CardView>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/followName"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:paddingStart="10dp"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:fontFamily="@font/poppins_bold"
|
||||||
|
android:textColor="?attr/colorSecondary"
|
||||||
|
tools:text="Username"
|
||||||
|
tools:ignore="RtlSymmetry" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
<View
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_gravity="bottom"
|
||||||
|
android:layout_height="4dp"
|
||||||
|
android:layout_marginStart="-16dp"
|
||||||
|
android:layout_marginEnd="-16dp"
|
||||||
|
android:background="?android:attr/listDivider" />
|
||||||
|
</androidx.cardview.widget.CardView>
|
Loading…
Add table
Add a link
Reference in a new issue