feat: optimize activity page

This commit is contained in:
aayush262
2024-05-26 21:43:12 +05:30
parent f3f0daf7e7
commit 2de8ffd367
8 changed files with 206 additions and 212 deletions

View File

@@ -15,6 +15,7 @@ import ani.dantotsu.initActivity
import ani.dantotsu.navBarHeight
import ani.dantotsu.statusBarHeight
import ani.dantotsu.themes.ThemeManager
import ani.dantotsu.profile.notification.NotificationFragment.Companion.NotificationType
import nl.joery.animatedbottombar.AnimatedBottomBar
class NotificationActivity : AppCompatActivity() {
@@ -84,11 +85,11 @@ class NotificationActivity : AppCompatActivity() {
override fun getItemCount(): Int = 4
override fun createFragment(position: Int): Fragment = when (position) {
0 -> NotificationFragment(if (id != -1) "getOne" else "media", id)
1 -> NotificationFragment("user")
2 -> NotificationFragment("subscription")
3 -> NotificationFragment("comment")
else -> NotificationFragment("media")
0 -> NotificationFragment(if (id != -1) NotificationType.ONE else NotificationType.MEDIA, id)
1 -> NotificationFragment(NotificationType.USER)
2 -> NotificationFragment(NotificationType.SUBSCRIPTION)
3 -> NotificationFragment(NotificationType.COMMENT)
else -> NotificationFragment(NotificationType.MEDIA)
}
}
}

View File

@@ -11,6 +11,7 @@ import androidx.fragment.app.Fragment
import androidx.lifecycle.lifecycleScope
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import androidx.webkit.internal.ApiFeature.N
import ani.dantotsu.R
import ani.dantotsu.connections.anilist.Anilist
import ani.dantotsu.connections.anilist.api.Notification
@@ -28,7 +29,10 @@ import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
class NotificationFragment(val type: String, private val getID: Int = -1) : Fragment() {
class NotificationFragment(
val type: NotificationType,
val getID: Int = -1
) : Fragment() {
private lateinit var binding: FragmentNotificationsBinding
private var adapter: GroupieAdapter = GroupieAdapter()
private var currentPage = 1
@@ -233,6 +237,10 @@ class NotificationFragment(val type: String, private val getID: Int = -1) : Frag
enum class NotificationClickType {
USER, MEDIA, ACTIVITY, COMMENT, UNDEFINED
}
enum class NotificationType {
MEDIA, USER, SUBSCRIPTION, COMMENT, ONE
}
}
}