fix(notifications): extra padding
This commit is contained in:
parent
6f685a4388
commit
d488d11573
3 changed files with 46 additions and 89 deletions
|
@ -43,30 +43,14 @@ class ActivityFragment : Fragment() {
|
||||||
|
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
type = arguments?.getSerializableCompat<ActivityType>("type") as ActivityType
|
arguments?.let {
|
||||||
userId = arguments?.getInt("userId")
|
type = it.getSerializableCompat<ActivityType>("type") as ActivityType
|
||||||
activityId = arguments?.getInt("activityId")
|
userId = it.getInt("userId")
|
||||||
|
activityId = it.getInt("activityId")
|
||||||
|
}
|
||||||
binding.titleBar.visibility = if (type == ActivityType.OTHER_USER) View.VISIBLE else View.GONE
|
binding.titleBar.visibility = if (type == ActivityType.OTHER_USER) View.VISIBLE else View.GONE
|
||||||
binding.titleText.text = if (userId == Anilist.userid) getString(R.string.create_new_activity) else getString(R.string.write_a_message)
|
binding.titleText.text = if (userId == Anilist.userid) getString(R.string.create_new_activity) else getString(R.string.write_a_message)
|
||||||
binding.titleImage.setOnClickListener {
|
binding.titleImage.setOnClickListener{handleTitleImageClick() }
|
||||||
if(userId == Anilist.userid) {
|
|
||||||
ContextCompat.startActivity(
|
|
||||||
requireContext(),
|
|
||||||
Intent(context, ActivityMarkdownCreator::class.java)
|
|
||||||
.putExtra("type", "activity"),
|
|
||||||
null
|
|
||||||
)
|
|
||||||
} else{
|
|
||||||
ContextCompat.startActivity(
|
|
||||||
requireContext(),
|
|
||||||
Intent(context, ActivityMarkdownCreator::class.java)
|
|
||||||
.putExtra("type", "message")
|
|
||||||
.putExtra("userId", userId),
|
|
||||||
|
|
||||||
null
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
binding.listRecyclerView.adapter = adapter
|
binding.listRecyclerView.adapter = adapter
|
||||||
binding.listRecyclerView.layoutManager = LinearLayoutManager(context)
|
binding.listRecyclerView.layoutManager = LinearLayoutManager(context)
|
||||||
binding.listProgressBar.isVisible = true
|
binding.listProgressBar.isVisible = true
|
||||||
|
@ -104,7 +88,13 @@ class ActivityFragment : Fragment() {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
private fun handleTitleImageClick() {
|
||||||
|
val intent = Intent(context, ActivityMarkdownCreator::class.java).apply {
|
||||||
|
putExtra("type", if (userId == Anilist.userid) "activity" else "message")
|
||||||
|
putExtra("userId", userId)
|
||||||
|
}
|
||||||
|
ContextCompat.startActivity(requireContext(), intent, null)
|
||||||
|
}
|
||||||
|
|
||||||
private suspend fun getList() {
|
private suspend fun getList() {
|
||||||
val list = when (type) {
|
val list = when (type) {
|
||||||
|
@ -141,35 +131,23 @@ class ActivityFragment : Fragment() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun onActivityClick(id: Int, type: String) {
|
private fun onActivityClick(id: Int, type: String) {
|
||||||
when (type) {
|
val intent = when (type) {
|
||||||
"USER" -> {
|
"USER" -> Intent(requireContext(), ProfileActivity::class.java).putExtra("userId", id)
|
||||||
ContextCompat.startActivity(
|
"MEDIA" -> Intent(requireContext(), MediaDetailsActivity::class.java).putExtra("mediaId", id)
|
||||||
requireContext(), Intent(requireContext(), ProfileActivity::class.java)
|
else -> return
|
||||||
.putExtra("userId", id), null
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
"MEDIA" -> {
|
|
||||||
ContextCompat.startActivity(
|
|
||||||
requireContext(), Intent(requireContext(), MediaDetailsActivity::class.java)
|
|
||||||
.putExtra("mediaId", id), null
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
ContextCompat.startActivity(requireContext(), intent, null)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
super.onResume()
|
super.onResume()
|
||||||
if (this::binding.isInitialized) {
|
if (this::binding.isInitialized) {
|
||||||
binding.root.requestLayout()
|
binding.root.requestLayout()
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
enum class ActivityType {
|
enum class ActivityType { GLOBAL, USER, OTHER_USER, ONE }
|
||||||
GLOBAL, USER, OTHER_USER, ONE
|
|
||||||
}
|
|
||||||
|
|
||||||
fun newInstance(type: ActivityType, userId: Int? = null, activityId: Int? = null): ActivityFragment {
|
fun newInstance(type: ActivityType, userId: Int? = null, activityId: Int? = null): ActivityFragment {
|
||||||
return ActivityFragment().apply {
|
return ActivityFragment().apply {
|
||||||
|
|
|
@ -20,7 +20,7 @@ import ani.dantotsu.profile.notification.NotificationFragment.Companion.Notifica
|
||||||
import nl.joery.animatedbottombar.AnimatedBottomBar
|
import nl.joery.animatedbottombar.AnimatedBottomBar
|
||||||
|
|
||||||
class NotificationActivity : AppCompatActivity() {
|
class NotificationActivity : AppCompatActivity() {
|
||||||
private lateinit var binding: ActivityNotificationBinding
|
lateinit var binding: ActivityNotificationBinding
|
||||||
private var selected: Int = 0
|
private var selected: Int = 0
|
||||||
lateinit var navBar: AnimatedBottomBar
|
lateinit var navBar: AnimatedBottomBar
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
@ -38,8 +38,8 @@ class NotificationActivity : AppCompatActivity() {
|
||||||
bottomMargin = navBarHeight
|
bottomMargin = navBarHeight
|
||||||
}
|
}
|
||||||
val tabs = listOf(
|
val tabs = listOf(
|
||||||
Pair(R.drawable.ic_round_movie_filter_24, "Media"),
|
|
||||||
Pair(R.drawable.ic_round_person_24, "User"),
|
Pair(R.drawable.ic_round_person_24, "User"),
|
||||||
|
Pair(R.drawable.ic_round_movie_filter_24, "Media"),
|
||||||
Pair(R.drawable.ic_round_notifications_active_24, "Subs"),
|
Pair(R.drawable.ic_round_notifications_active_24, "Subs"),
|
||||||
Pair(R.drawable.ic_round_comment_24, "Comments")
|
Pair(R.drawable.ic_round_comment_24, "Comments")
|
||||||
)
|
)
|
||||||
|
@ -49,7 +49,6 @@ class NotificationActivity : AppCompatActivity() {
|
||||||
val getOne = intent.getIntExtra("activityId", -1)
|
val getOne = intent.getIntExtra("activityId", -1)
|
||||||
if (getOne != -1) navBar.isVisible = false
|
if (getOne != -1) navBar.isVisible = false
|
||||||
binding.notificationViewPager.adapter = ViewPagerAdapter(supportFragmentManager, lifecycle, getOne)
|
binding.notificationViewPager.adapter = ViewPagerAdapter(supportFragmentManager, lifecycle, getOne)
|
||||||
binding.notificationViewPager.setOffscreenPageLimit(4)
|
|
||||||
binding.notificationViewPager.setCurrentItem(selected, false)
|
binding.notificationViewPager.setCurrentItem(selected, false)
|
||||||
navBar.selectTabAt(selected)
|
navBar.selectTabAt(selected)
|
||||||
navBar.setOnTabSelectListener(object : AnimatedBottomBar.OnTabSelectListener {
|
navBar.setOnTabSelectListener(object : AnimatedBottomBar.OnTabSelectListener {
|
||||||
|
@ -84,8 +83,8 @@ class NotificationActivity : AppCompatActivity() {
|
||||||
override fun getItemCount(): Int = if (id != -1) 1 else 4
|
override fun getItemCount(): Int = if (id != -1) 1 else 4
|
||||||
|
|
||||||
override fun createFragment(position: Int): Fragment = when (position) {
|
override fun createFragment(position: Int): Fragment = when (position) {
|
||||||
0 -> NotificationFragment.newInstance(if (id != -1) NotificationType.ONE else NotificationType.MEDIA, id)
|
0 -> NotificationFragment.newInstance(NotificationType.USER)
|
||||||
1 -> NotificationFragment.newInstance(NotificationType.USER)
|
1 -> NotificationFragment.newInstance(if (id != -1) NotificationType.ONE else NotificationType.MEDIA, id)
|
||||||
2 -> NotificationFragment.newInstance(NotificationType.SUBSCRIPTION)
|
2 -> NotificationFragment.newInstance(NotificationType.SUBSCRIPTION)
|
||||||
3 -> NotificationFragment.newInstance(NotificationType.COMMENT)
|
3 -> NotificationFragment.newInstance(NotificationType.COMMENT)
|
||||||
else -> NotificationFragment.newInstance(NotificationType.MEDIA)
|
else -> NotificationFragment.newInstance(NotificationType.MEDIA)
|
||||||
|
|
|
@ -46,8 +46,10 @@ class NotificationFragment : Fragment() {
|
||||||
|
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
type = arguments?.getSerializableCompat<NotificationType>("type") as NotificationType
|
arguments?.let {
|
||||||
getID = arguments?.getInt("id") ?: -1
|
getID = it.getInt("id")
|
||||||
|
type = it.getSerializableCompat<NotificationType>("type") as NotificationType
|
||||||
|
}
|
||||||
binding.notificationRecyclerView.adapter = adapter
|
binding.notificationRecyclerView.adapter = adapter
|
||||||
binding.notificationRecyclerView.layoutManager = LinearLayoutManager(context)
|
binding.notificationRecyclerView.layoutManager = LinearLayoutManager(context)
|
||||||
binding.notificationProgressBar.isVisible = true
|
binding.notificationProgressBar.isVisible = true
|
||||||
|
@ -158,47 +160,31 @@ class NotificationFragment : Fragment() {
|
||||||
!binding.notificationRecyclerView.canScrollVertically(1)
|
!binding.notificationRecyclerView.canScrollVertically(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun onClick(
|
fun onClick(id: Int, optional: Int?, type: NotificationClickType) {
|
||||||
id: Int,
|
val intent = when (type) {
|
||||||
optional: Int?,
|
NotificationClickType.USER -> Intent(requireContext(), ProfileActivity::class.java).apply {
|
||||||
type: NotificationClickType
|
putExtra("userId", id)
|
||||||
) {
|
|
||||||
when (type) {
|
|
||||||
NotificationClickType.USER -> {
|
|
||||||
ContextCompat.startActivity(
|
|
||||||
requireContext(), Intent(requireContext(), ProfileActivity::class.java)
|
|
||||||
.putExtra("userId", id), null
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NotificationClickType.MEDIA -> {
|
NotificationClickType.MEDIA -> Intent(requireContext(), MediaDetailsActivity::class.java).apply {
|
||||||
ContextCompat.startActivity(
|
putExtra("mediaId", id)
|
||||||
requireContext(), Intent(requireContext(), MediaDetailsActivity::class.java)
|
|
||||||
.putExtra("mediaId", id), null
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NotificationClickType.ACTIVITY -> {
|
NotificationClickType.ACTIVITY -> Intent(requireContext(), FeedActivity::class.java).apply {
|
||||||
ContextCompat.startActivity(
|
putExtra("activityId", id)
|
||||||
requireContext(), Intent(requireContext(), FeedActivity::class.java)
|
|
||||||
.putExtra("activityId", id), null
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NotificationClickType.COMMENT -> {
|
NotificationClickType.COMMENT -> Intent(requireContext(), MediaDetailsActivity::class.java).apply {
|
||||||
ContextCompat.startActivity(
|
putExtra("FRAGMENT_TO_LOAD", "COMMENTS")
|
||||||
requireContext(), Intent(requireContext(), MediaDetailsActivity::class.java)
|
putExtra("mediaId", id)
|
||||||
.putExtra("FRAGMENT_TO_LOAD", "COMMENTS")
|
putExtra("commentId", optional ?: -1)
|
||||||
.putExtra("mediaId", id)
|
|
||||||
.putExtra("commentId", optional ?: -1),
|
|
||||||
null
|
|
||||||
)
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NotificationClickType.UNDEFINED -> {
|
NotificationClickType.UNDEFINED -> null
|
||||||
// Do nothing
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
intent?.let {
|
||||||
|
ContextCompat.startActivity(requireContext(), it, null)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -206,18 +192,12 @@ class NotificationFragment : Fragment() {
|
||||||
super.onResume()
|
super.onResume()
|
||||||
if (this::binding.isInitialized) {
|
if (this::binding.isInitialized) {
|
||||||
binding.root.requestLayout()
|
binding.root.requestLayout()
|
||||||
binding.root.setBaseline((activity as NotificationActivity).navBar)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
enum class NotificationClickType {
|
enum class NotificationClickType { USER, MEDIA, ACTIVITY, COMMENT, UNDEFINED }
|
||||||
USER, MEDIA, ACTIVITY, COMMENT, UNDEFINED
|
enum class NotificationType { MEDIA, USER, SUBSCRIPTION, COMMENT, ONE }
|
||||||
}
|
|
||||||
|
|
||||||
enum class NotificationType {
|
|
||||||
MEDIA, USER, SUBSCRIPTION, COMMENT, ONE
|
|
||||||
}
|
|
||||||
|
|
||||||
fun newInstance(type: NotificationType, id: Int = -1): NotificationFragment {
|
fun newInstance(type: NotificationType, id: Int = -1): NotificationFragment {
|
||||||
return NotificationFragment().apply {
|
return NotificationFragment().apply {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue