feat(social): filter activity only with in 3days
This commit is contained in:
parent
133354a22d
commit
90b9b7bef3
7 changed files with 40 additions and 30 deletions
|
@ -6,7 +6,6 @@ import ani.dantotsu.checkGenreTime
|
||||||
import ani.dantotsu.checkId
|
import ani.dantotsu.checkId
|
||||||
import ani.dantotsu.connections.anilist.Anilist.authorRoles
|
import ani.dantotsu.connections.anilist.Anilist.authorRoles
|
||||||
import ani.dantotsu.connections.anilist.Anilist.executeQuery
|
import ani.dantotsu.connections.anilist.Anilist.executeQuery
|
||||||
import ani.dantotsu.connections.anilist.api.Activity
|
|
||||||
import ani.dantotsu.connections.anilist.api.FeedResponse
|
import ani.dantotsu.connections.anilist.api.FeedResponse
|
||||||
import ani.dantotsu.connections.anilist.api.FuzzyDate
|
import ani.dantotsu.connections.anilist.api.FuzzyDate
|
||||||
import ani.dantotsu.connections.anilist.api.NotificationResponse
|
import ani.dantotsu.connections.anilist.api.NotificationResponse
|
||||||
|
@ -1651,14 +1650,12 @@ Page(page:$page,perPage:50) {
|
||||||
}""".trimIndent()
|
}""".trimIndent()
|
||||||
val list = mutableListOf<User>()
|
val list = mutableListOf<User>()
|
||||||
val threeDaysAgo = Calendar.getInstance().apply {
|
val threeDaysAgo = Calendar.getInstance().apply {
|
||||||
add(Calendar.DAY_OF_MONTH, -10)
|
add(Calendar.DAY_OF_MONTH, -3)
|
||||||
}.timeInMillis
|
}.timeInMillis
|
||||||
executeQuery<Social>(query(), force = true)?.data?.let { data ->
|
executeQuery<Social>(query(), force = true)?.data?.let { data ->
|
||||||
val activities = listOf(data.page1.activities, data.page2.activities).flatten()
|
val activities = listOf(data.page1.activities, data.page2.activities).flatten()
|
||||||
|
|
||||||
.sortedByDescending { it.createdAt }
|
.sortedByDescending { it.createdAt }
|
||||||
.filter { it.createdAt < threeDaysAgo }
|
.filter { it.createdAt * 1000L > threeDaysAgo }
|
||||||
|
|
||||||
val anilistActivities = mutableListOf<User>()
|
val anilistActivities = mutableListOf<User>()
|
||||||
val groupedActivities = activities.groupBy { it.userId }
|
val groupedActivities = activities.groupBy { it.userId }
|
||||||
|
|
||||||
|
|
|
@ -42,6 +42,7 @@ import ani.dantotsu.setSlideIn
|
||||||
import ani.dantotsu.setSlideUp
|
import ani.dantotsu.setSlideUp
|
||||||
import ani.dantotsu.settings.SettingsDialogFragment
|
import ani.dantotsu.settings.SettingsDialogFragment
|
||||||
import ani.dantotsu.settings.saving.PrefManager
|
import ani.dantotsu.settings.saving.PrefManager
|
||||||
|
import ani.dantotsu.settings.saving.PrefManager.asLiveBool
|
||||||
import ani.dantotsu.settings.saving.PrefName
|
import ani.dantotsu.settings.saving.PrefName
|
||||||
import ani.dantotsu.snackString
|
import ani.dantotsu.snackString
|
||||||
import ani.dantotsu.statusBarHeight
|
import ani.dantotsu.statusBarHeight
|
||||||
|
@ -56,7 +57,6 @@ import kotlin.math.min
|
||||||
class HomeFragment : Fragment() {
|
class HomeFragment : Fragment() {
|
||||||
private var _binding: FragmentHomeBinding? = null
|
private var _binding: FragmentHomeBinding? = null
|
||||||
private val binding get() = _binding!!
|
private val binding get() = _binding!!
|
||||||
|
|
||||||
override fun onCreateView(
|
override fun onCreateView(
|
||||||
inflater: LayoutInflater,
|
inflater: LayoutInflater,
|
||||||
container: ViewGroup?,
|
container: ViewGroup?,
|
||||||
|
@ -322,7 +322,12 @@ class HomeFragment : Fragment() {
|
||||||
binding.homeUserStatusRecyclerView.visibility = View.GONE
|
binding.homeUserStatusRecyclerView.visibility = View.GONE
|
||||||
if (it != null) {
|
if (it != null) {
|
||||||
if (it.isNotEmpty()) {
|
if (it.isNotEmpty()) {
|
||||||
|
PrefManager.getLiveVal(PrefName.RefreshStatus, false).apply {
|
||||||
|
asLiveBool()
|
||||||
|
observe(viewLifecycleOwner) { _ ->
|
||||||
binding.homeUserStatusRecyclerView.adapter = UserStatusAdapter(it)
|
binding.homeUserStatusRecyclerView.adapter = UserStatusAdapter(it)
|
||||||
|
}
|
||||||
|
}
|
||||||
binding.homeUserStatusRecyclerView.layoutManager = LinearLayoutManager(
|
binding.homeUserStatusRecyclerView.layoutManager = LinearLayoutManager(
|
||||||
requireContext(),
|
requireContext(),
|
||||||
LinearLayoutManager.HORIZONTAL,
|
LinearLayoutManager.HORIZONTAL,
|
||||||
|
|
|
@ -58,9 +58,8 @@ class CircleView(context: Context, attrs: AttributeSet?) : View(context, attrs)
|
||||||
setColor(0)
|
setColor(0)
|
||||||
} else {
|
} else {
|
||||||
val effectiveAngle = totalAngle / parts
|
val effectiveAngle = totalAngle / parts
|
||||||
|
|
||||||
for (i in 0 until parts) {
|
for (i in 0 until parts) {
|
||||||
val startAngle = i * (effectiveAngle + gapAngle)
|
val startAngle = i * (effectiveAngle + gapAngle) -90f
|
||||||
path.reset()
|
path.reset()
|
||||||
path.addArc(
|
path.addArc(
|
||||||
centerX - radius,
|
centerX - radius,
|
||||||
|
|
|
@ -106,7 +106,6 @@ constructor(
|
||||||
|
|
||||||
leftTouchPanel.setOnTouchListener(this)
|
leftTouchPanel.setOnTouchListener(this)
|
||||||
rightTouchPanel.setOnTouchListener(this)
|
rightTouchPanel.setOnTouchListener(this)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -469,6 +468,20 @@ constructor(
|
||||||
activityLikeCount.text = story.likeCount.toString()
|
activityLikeCount.text = story.likeCount.toString()
|
||||||
activityLike.setColorFilter(if (story.isLiked == true) likeColor else notLikeColor)
|
activityLike.setColorFilter(if (story.isLiked == true) likeColor else notLikeColor)
|
||||||
activityLikeContainer.setOnClickListener {
|
activityLikeContainer.setOnClickListener {
|
||||||
|
like()
|
||||||
|
}
|
||||||
|
activityLikeContainer.setOnLongClickListener {
|
||||||
|
UsersDialogFragment().apply {
|
||||||
|
userList(userList)
|
||||||
|
show(activ.supportFragmentManager, "dialog")
|
||||||
|
}
|
||||||
|
true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fun like(){
|
||||||
|
val story = activityList[storyIndex - 1]
|
||||||
|
val likeColor = ContextCompat.getColor(context, R.color.yt_red)
|
||||||
|
val notLikeColor = ContextCompat.getColor(context, R.color.bg_opp)
|
||||||
val scope = CoroutineScope(Dispatchers.IO + SupervisorJob())
|
val scope = CoroutineScope(Dispatchers.IO + SupervisorJob())
|
||||||
scope.launch {
|
scope.launch {
|
||||||
val res = Anilist.query.toggleLike(story.id, "ACTIVITY")
|
val res = Anilist.query.toggleLike(story.id, "ACTIVITY")
|
||||||
|
@ -489,12 +502,4 @@ constructor(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
activityLikeContainer.setOnLongClickListener {
|
|
||||||
UsersDialogFragment().apply {
|
|
||||||
userList(userList)
|
|
||||||
show(activ.supportFragmentManager, "dialog")
|
|
||||||
}
|
|
||||||
true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -5,8 +5,10 @@ import android.view.LayoutInflater
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
|
import ani.dantotsu.R
|
||||||
import ani.dantotsu.connections.anilist.Anilist
|
import ani.dantotsu.connections.anilist.Anilist
|
||||||
import ani.dantotsu.databinding.ItemUserStatusBinding
|
import ani.dantotsu.databinding.ItemUserStatusBinding
|
||||||
|
import ani.dantotsu.getAppString
|
||||||
import ani.dantotsu.loadImage
|
import ani.dantotsu.loadImage
|
||||||
import ani.dantotsu.profile.ProfileActivity
|
import ani.dantotsu.profile.ProfileActivity
|
||||||
import ani.dantotsu.profile.User
|
import ani.dantotsu.profile.User
|
||||||
|
@ -59,7 +61,7 @@ class UserStatusAdapter(private val user: ArrayList<User>) :
|
||||||
setAnimation(b.root.context, b.root)
|
setAnimation(b.root.context, b.root)
|
||||||
val user = user[position]
|
val user = user[position]
|
||||||
b.profileUserAvatar.loadImage(user.pfp)
|
b.profileUserAvatar.loadImage(user.pfp)
|
||||||
b.profileUserName.text = if (Anilist.userid == user.id) "You" else user.name
|
b.profileUserName.text = if (Anilist.userid == user.id) getAppString(R.string.your_story) else user.name
|
||||||
|
|
||||||
val watchedActivity =
|
val watchedActivity =
|
||||||
PrefManager.getCustomVal<Set<Int>>("${user.id}_activities", setOf())
|
PrefManager.getCustomVal<Set<Int>>("${user.id}_activities", setOf())
|
||||||
|
|
|
@ -187,6 +187,7 @@ enum class PrefName(val data: Pref) { //TODO: Split this into multiple files
|
||||||
CommentNotificationStore(Pref(Location.Irrelevant, List::class, listOf<CommentStore>())),
|
CommentNotificationStore(Pref(Location.Irrelevant, List::class, listOf<CommentStore>())),
|
||||||
UnreadCommentNotifications(Pref(Location.Irrelevant, Int::class, 0)),
|
UnreadCommentNotifications(Pref(Location.Irrelevant, Int::class, 0)),
|
||||||
DownloadsDir(Pref(Location.Irrelevant, String::class, "")),
|
DownloadsDir(Pref(Location.Irrelevant, String::class, "")),
|
||||||
|
RefreshStatus(Pref(Location.Irrelevant, Boolean::class, false)),
|
||||||
|
|
||||||
//Protected
|
//Protected
|
||||||
DiscordToken(Pref(Location.Protected, String::class, "")),
|
DiscordToken(Pref(Location.Protected, String::class, "")),
|
||||||
|
|
|
@ -964,4 +964,5 @@ Non quae tempore quo provident laudantium qui illo dolor vel quia dolor et exerc
|
||||||
<string name="avatar">%1$s\ [Avatar]</string>
|
<string name="avatar">%1$s\ [Avatar]</string>
|
||||||
<string name="cover">%1$s\ [Cover]</string>
|
<string name="cover">%1$s\ [Cover]</string>
|
||||||
<string name="banner">%1$s\ [Banner]</string>
|
<string name="banner">%1$s\ [Banner]</string>
|
||||||
|
<string name="your_story">Your Story</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue