pref: 首页 Snackbar 不再遮挡底栏
This commit is contained in:
parent
b15e61799e
commit
1185ae7061
|
|
@ -16,7 +16,6 @@ import android.util.Log
|
||||||
import android.view.Menu
|
import android.view.Menu
|
||||||
import android.view.MenuItem
|
import android.view.MenuItem
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.widget.FrameLayout
|
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import androidx.viewpager.widget.ViewPager.OnPageChangeListener
|
import androidx.viewpager.widget.ViewPager.OnPageChangeListener
|
||||||
|
|
@ -46,14 +45,10 @@ import com.huanchengfly.tieba.post.models.MyInfoBean
|
||||||
import com.huanchengfly.tieba.post.services.NotifyJobService
|
import com.huanchengfly.tieba.post.services.NotifyJobService
|
||||||
import com.huanchengfly.tieba.post.utils.*
|
import com.huanchengfly.tieba.post.utils.*
|
||||||
import com.huanchengfly.tieba.post.widgets.MyViewPager
|
import com.huanchengfly.tieba.post.widgets.MyViewPager
|
||||||
import com.huanchengfly.tieba.post.widgets.theme.TintToolbar
|
|
||||||
|
|
||||||
open class MainActivity : BaseActivity(), BottomNavigationView.OnNavigationItemSelectedListener, OnNavigationItemReselectedListener {
|
open class MainActivity : BaseActivity(), BottomNavigationView.OnNavigationItemSelectedListener, OnNavigationItemReselectedListener {
|
||||||
var mAdapter: ViewPagerAdapter = ViewPagerAdapter(supportFragmentManager)
|
var mAdapter: ViewPagerAdapter = ViewPagerAdapter(supportFragmentManager)
|
||||||
|
|
||||||
@BindView(R.id.toolbar)
|
|
||||||
lateinit var mToolbar: TintToolbar
|
|
||||||
|
|
||||||
@BindView(R.id.mViewPager)
|
@BindView(R.id.mViewPager)
|
||||||
lateinit var mViewPager: MyViewPager
|
lateinit var mViewPager: MyViewPager
|
||||||
|
|
||||||
|
|
@ -68,9 +63,6 @@ open class MainActivity : BaseActivity(), BottomNavigationView.OnNavigationItemS
|
||||||
private val newMessageReceiver: BroadcastReceiver = NewMessageReceiver()
|
private val newMessageReceiver: BroadcastReceiver = NewMessageReceiver()
|
||||||
private val accountSwitchReceiver: BroadcastReceiver = AccountSwitchReceiver()
|
private val accountSwitchReceiver: BroadcastReceiver = AccountSwitchReceiver()
|
||||||
|
|
||||||
@BindView(R.id.appbar)
|
|
||||||
lateinit var appbar: FrameLayout
|
|
||||||
|
|
||||||
public override fun onResume() {
|
public override fun onResume() {
|
||||||
val reason = ThemeUtil.getSharedPreferences(this).getString(ThemeUtil.SP_SWITCH_REASON, null)
|
val reason = ThemeUtil.getSharedPreferences(this).getString(ThemeUtil.SP_SWITCH_REASON, null)
|
||||||
val followSystemNight = appPreferences.followSystemNight
|
val followSystemNight = appPreferences.followSystemNight
|
||||||
|
|
@ -131,7 +123,6 @@ open class MainActivity : BaseActivity(), BottomNavigationView.OnNavigationItemS
|
||||||
val hideExploreItemView = menuView!!.getChildAt(if (hideExplore) 1 else 2) as BottomNavigationItemView
|
val hideExploreItemView = menuView!!.getChildAt(if (hideExplore) 1 else 2) as BottomNavigationItemView
|
||||||
val badge = layoutInflater.inflate(R.layout.layout_badge, hideExploreItemView, true)
|
val badge = layoutInflater.inflate(R.layout.layout_badge, hideExploreItemView, true)
|
||||||
badgeTextView = badge.findViewById(R.id.tv_msg_count)
|
badgeTextView = badge.findViewById(R.id.tv_msg_count)
|
||||||
setSupportActionBar(mToolbar)
|
|
||||||
if (hideExplore) {
|
if (hideExplore) {
|
||||||
mBottomNavigationView.menu.removeItem(R.id.navbar_explore)
|
mBottomNavigationView.menu.removeItem(R.id.navbar_explore)
|
||||||
}
|
}
|
||||||
|
|
@ -156,9 +147,7 @@ open class MainActivity : BaseActivity(), BottomNavigationView.OnNavigationItemS
|
||||||
@SuppressLint("RestrictedApi")
|
@SuppressLint("RestrictedApi")
|
||||||
override fun onPageSelected(position: Int) {
|
override fun onPageSelected(position: Int) {
|
||||||
val baseFragment = mAdapter.getItem(position)
|
val baseFragment = mAdapter.getItem(position)
|
||||||
appbar.visibility = if (baseFragment.hasOwnAppbar()) View.GONE else View.VISIBLE
|
|
||||||
mBottomNavigationView.menu.getItem(position).isChecked = true
|
mBottomNavigationView.menu.getItem(position).isChecked = true
|
||||||
mToolbar.title = mBottomNavigationView.menu.getItem(position).title
|
|
||||||
if (position == (if (hideExplore) 1 else 2)) {
|
if (position == (if (hideExplore) 1 else 2)) {
|
||||||
badgeTextView!!.visibility = View.GONE
|
badgeTextView!!.visibility = View.GONE
|
||||||
}
|
}
|
||||||
|
|
@ -166,7 +155,6 @@ open class MainActivity : BaseActivity(), BottomNavigationView.OnNavigationItemS
|
||||||
|
|
||||||
override fun onPageScrollStateChanged(state: Int) {}
|
override fun onPageScrollStateChanged(state: Int) {}
|
||||||
})
|
})
|
||||||
appbar.visibility = if (mAdapter.getItem(0).hasOwnAppbar()) View.GONE else View.VISIBLE
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("ApplySharedPref")
|
@SuppressLint("ApplySharedPref")
|
||||||
|
|
@ -392,10 +380,6 @@ open class MainActivity : BaseActivity(), BottomNavigationView.OnNavigationItemS
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun setTitle(newTitle: String?) {
|
|
||||||
mToolbar.title = newTitle
|
|
||||||
}
|
|
||||||
|
|
||||||
private inner class NewMessageReceiver : BroadcastReceiver() {
|
private inner class NewMessageReceiver : BroadcastReceiver() {
|
||||||
@SuppressLint("RestrictedApi")
|
@SuppressLint("RestrictedApi")
|
||||||
override fun onReceive(context: Context, intent: Intent) {
|
override fun onReceive(context: Context, intent: Intent) {
|
||||||
|
|
|
||||||
|
|
@ -1,39 +1,26 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<com.huanchengfly.tieba.post.widgets.theme.TintRelativeLayout
|
<com.huanchengfly.tieba.post.widgets.theme.TintLinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
app:backgroundTint="@color/default_color_window_background"
|
app:backgroundTint="@color/default_color_window_background"
|
||||||
android:id="@+id/background"
|
android:id="@+id/background"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical"
|
||||||
tools:context=".activities.MainActivity">
|
tools:context=".activities.MainActivity">
|
||||||
|
|
||||||
<FrameLayout
|
<androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||||
android:id="@+id/appbar"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content">
|
android:layout_height="0dp"
|
||||||
<com.huanchengfly.tieba.post.widgets.theme.TintToolbar
|
android:layout_weight="1">
|
||||||
app:popupTheme="?attr/actionOverflowMenuStyle"
|
|
||||||
app:navigationIcon="@null"
|
|
||||||
app:toolbarBackgroundTint="@color/default_color_toolbar"
|
|
||||||
app:itemTint="@color/default_color_toolbar_item"
|
|
||||||
app:secondaryItemTint="@color/default_color_toolbar_item_secondary"
|
|
||||||
app:activeItemTint="@color/default_color_toolbar_item_active"
|
|
||||||
android:id="@+id/toolbar"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="?attr/actionBarSize"
|
|
||||||
app:title="@string/title_main"
|
|
||||||
app:titleTextAppearance="@style/Toolbar.Title"
|
|
||||||
app:subtitleTextAppearance="@style/Toolbar.Subtitle" />
|
|
||||||
</FrameLayout>
|
|
||||||
|
|
||||||
<com.huanchengfly.tieba.post.widgets.MyViewPager
|
<com.huanchengfly.tieba.post.widgets.MyViewPager
|
||||||
android:layout_above="@id/navbar"
|
android:layout_above="@id/navbar"
|
||||||
android:layout_below="@id/appbar"
|
android:layout_below="@id/appbar"
|
||||||
android:id="@+id/mViewPager"
|
android:id="@+id/mViewPager"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent" />
|
android:layout_height="match_parent" />
|
||||||
|
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||||
|
|
||||||
<com.huanchengfly.tieba.post.widgets.theme.TintBottomNavigationView
|
<com.huanchengfly.tieba.post.widgets.theme.TintBottomNavigationView
|
||||||
android:id="@+id/navbar"
|
android:id="@+id/navbar"
|
||||||
|
|
@ -47,4 +34,4 @@
|
||||||
app:labelVisibilityMode="unlabeled"
|
app:labelVisibilityMode="unlabeled"
|
||||||
app:menu="@menu/navbar_main" />
|
app:menu="@menu/navbar_main" />
|
||||||
|
|
||||||
</com.huanchengfly.tieba.post.widgets.theme.TintRelativeLayout>
|
</com.huanchengfly.tieba.post.widgets.theme.TintLinearLayout>
|
||||||
Loading…
Reference in New Issue