feat: remove other tabs when opening page from notification
This commit is contained in:
parent
f205463a51
commit
5a78d68f67
2 changed files with 27 additions and 25 deletions
|
@ -3,6 +3,7 @@ package ani.dantotsu.profile.notification
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
|
import androidx.core.view.isVisible
|
||||||
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
|
||||||
|
@ -36,18 +37,17 @@ class NotificationActivity : AppCompatActivity() {
|
||||||
binding.root.updateLayoutParams<ViewGroup.MarginLayoutParams> {
|
binding.root.updateLayoutParams<ViewGroup.MarginLayoutParams> {
|
||||||
bottomMargin = navBarHeight
|
bottomMargin = navBarHeight
|
||||||
}
|
}
|
||||||
val mediaTab = navBar.createTab(R.drawable.ic_round_movie_filter_24, "Media")
|
val tabs = listOf(
|
||||||
val userTab = navBar.createTab(R.drawable.ic_round_person_24, "User")
|
Pair(R.drawable.ic_round_movie_filter_24, "Media"),
|
||||||
val subscriptionTab = navBar.createTab(R.drawable.ic_round_notifications_active_24, "Subscriptions")
|
Pair(R.drawable.ic_round_person_24, "User"),
|
||||||
val commentTab = navBar.createTab(R.drawable.ic_round_comment_24, "Comments")
|
Pair(R.drawable.ic_round_notifications_active_24, "Subs"),
|
||||||
navBar.addTab(mediaTab)
|
Pair(R.drawable.ic_round_comment_24, "Comments")
|
||||||
navBar.addTab(userTab)
|
)
|
||||||
navBar.addTab(subscriptionTab)
|
tabs.forEach { (icon, title) -> navBar.addTab(navBar.createTab(icon, title)) }
|
||||||
navBar.addTab(commentTab)
|
|
||||||
binding.notificationBack.setOnClickListener {
|
binding.notificationBack.setOnClickListener { onBackPressedDispatcher.onBackPressed() }
|
||||||
onBackPressedDispatcher.onBackPressed()
|
|
||||||
}
|
|
||||||
val getOne = intent.getIntExtra("activityId", -1)
|
val getOne = intent.getIntExtra("activityId", -1)
|
||||||
|
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.setOffscreenPageLimit(4)
|
||||||
binding.notificationViewPager.setCurrentItem(selected, false)
|
binding.notificationViewPager.setCurrentItem(selected, false)
|
||||||
|
@ -72,17 +72,17 @@ class NotificationActivity : AppCompatActivity() {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
|
super.onResume()
|
||||||
if (this::navBar.isInitialized) {
|
if (this::navBar.isInitialized) {
|
||||||
navBar.selectTabAt(selected)
|
navBar.selectTabAt(selected)
|
||||||
}
|
}
|
||||||
super.onResume()
|
|
||||||
}
|
}
|
||||||
private class ViewPagerAdapter(
|
private class ViewPagerAdapter(
|
||||||
fragmentManager: FragmentManager,
|
fragmentManager: FragmentManager,
|
||||||
lifecycle: Lifecycle,
|
lifecycle: Lifecycle,
|
||||||
val id: Int = -1
|
val id: Int = -1
|
||||||
) : FragmentStateAdapter(fragmentManager, lifecycle) {
|
) : FragmentStateAdapter(fragmentManager, lifecycle) {
|
||||||
override fun getItemCount(): Int = 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(if (id != -1) NotificationType.ONE else NotificationType.MEDIA, id)
|
0 -> NotificationFragment(if (id != -1) NotificationType.ONE else NotificationType.MEDIA, id)
|
||||||
|
|
|
@ -1,13 +1,12 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout 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"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/listProgressBar"
|
android:id="@+id/notificationProgressBar"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
|
@ -23,26 +22,29 @@
|
||||||
android:id="@+id/listFrameLayout"
|
android:id="@+id/listFrameLayout"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:orientation="vertical"
|
android:gravity="center_horizontal"
|
||||||
android:gravity="center_horizontal">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/emptyTextView"
|
android:id="@+id/emptyTextView"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
|
android:fontFamily="@font/poppins_semi_bold"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:visibility="gone"
|
android:visibility="gone" />
|
||||||
android:fontFamily="@font/poppins_semi_bold" />
|
|
||||||
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
||||||
android:id="@+id/followSwipeRefresh"
|
android:id="@+id/notificationSwipeRefresh"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="0dp"
|
android:layout_height="0dp"
|
||||||
android:layout_weight="1"
|
|
||||||
android:layout_marginStart="12dp"
|
android:layout_marginStart="12dp"
|
||||||
android:layout_marginEnd="12dp"
|
android:layout_marginEnd="12dp"
|
||||||
|
android:layout_weight="1"
|
||||||
android:clipChildren="false"
|
android:clipChildren="false"
|
||||||
android:clipToPadding="false">
|
android:clipToPadding="false">
|
||||||
|
|
||||||
<ani.dantotsu.FadingEdgeRecyclerView
|
<ani.dantotsu.FadingEdgeRecyclerView
|
||||||
android:id="@+id/listRecyclerView"
|
android:id="@+id/notificationRecyclerView"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:nestedScrollingEnabled="true"
|
android:nestedScrollingEnabled="true"
|
||||||
|
@ -52,12 +54,12 @@
|
||||||
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
|
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
|
||||||
|
|
||||||
<ProgressBar
|
<ProgressBar
|
||||||
android:id="@+id/followRefresh"
|
android:id="@+id/notificationRefresh"
|
||||||
style="?android:attr/progressBarStyle"
|
style="?android:attr/progressBarStyle"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_horizontal"
|
||||||
android:layout_marginBottom="32dp"
|
android:layout_marginBottom="32dp"
|
||||||
android:visibility="gone"
|
android:visibility="gone" />
|
||||||
android:layout_gravity="center_horizontal" />
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
Loading…
Add table
Add a link
Reference in a new issue