pref: 优化“消息”页面样式

This commit is contained in:
HuanChengFly 2020-12-05 16:16:43 +08:00
parent fa0108f073
commit ca40f123d4
4 changed files with 16 additions and 11 deletions

View File

@ -140,7 +140,7 @@ open class MainActivity : BaseActivity(), BottomNavigationView.OnNavigationItemS
val personalizedFeedFragment = PersonalizedFeedFragment() val personalizedFeedFragment = PersonalizedFeedFragment()
mAdapter.addFragment(personalizedFeedFragment) mAdapter.addFragment(personalizedFeedFragment)
} }
mAdapter.addFragment(MessageFragment.newInstance(MessageFragment.TYPE_REPLY_ME)) mAdapter.addFragment(MessageFragment.newInstance(MessageFragment.TYPE_REPLY_ME, true))
mAdapter.addFragment(MyInfoFragment()) mAdapter.addFragment(MyInfoFragment())
mViewPager.isCanScroll = false mViewPager.isCanScroll = false
mViewPager.adapter = mAdapter mViewPager.adapter = mAdapter
@ -194,8 +194,7 @@ open class MainActivity : BaseActivity(), BottomNavigationView.OnNavigationItemS
showDialog(DialogUtil.build(this) showDialog(DialogUtil.build(this)
.setTitle(R.string.title_dialog_notice) .setTitle(R.string.title_dialog_notice)
.setMessage(R.string.message_dialog_notice) .setMessage(R.string.message_dialog_notice)
.setPositiveButton(R.string.button_sure_default) { _: DialogInterface?, .setPositiveButton(R.string.button_sure_default) { _, _ ->
_: Int ->
SharedPreferencesUtil.put(this, SharedPreferencesUtil.SP_APP_DATA, "notice_dialog", true) SharedPreferencesUtil.put(this, SharedPreferencesUtil.SP_APP_DATA, "notice_dialog", true)
} }
.setCancelable(false) .setCancelable(false)

View File

@ -37,7 +37,7 @@ public class MessageActivity extends BaseActivity {
if (savedInstanceState == null) { if (savedInstanceState == null) {
getSupportFragmentManager().beginTransaction() getSupportFragmentManager().beginTransaction()
.replace(R.id.activity_message_list_content, .replace(R.id.activity_message_list_content,
MessageFragment.newInstance(getIntent().getIntExtra("type", MessageFragment.TYPE_REPLY_ME), true), MessageFragment.class.getSimpleName()).commit(); MessageFragment.newInstance(getIntent().getIntExtra("type", MessageFragment.TYPE_REPLY_ME), false), MessageFragment.class.getSimpleName()).commit();
} }
} }
} }

View File

@ -10,6 +10,7 @@ import androidx.recyclerview.widget.RecyclerView
import androidx.viewpager.widget.ViewPager import androidx.viewpager.widget.ViewPager
import butterknife.BindView import butterknife.BindView
import com.google.android.material.appbar.AppBarLayout import com.google.android.material.appbar.AppBarLayout
import com.google.android.material.appbar.AppBarLayout.LayoutParams.SCROLL_FLAG_NO_SCROLL
import com.google.android.material.tabs.TabLayout import com.google.android.material.tabs.TabLayout
import com.google.android.material.tabs.TabLayout.OnTabSelectedListener import com.google.android.material.tabs.TabLayout.OnTabSelectedListener
import com.huanchengfly.tieba.post.R import com.huanchengfly.tieba.post.R
@ -52,7 +53,7 @@ class MessageFragment : BaseFragment(), Refreshable, OnTabSelectedListener, Tool
private var atMe: MessageListHelper? = null private var atMe: MessageListHelper? = null
var type = 0 var type = 0
private set private set
private var isFromNotification = false private var isFromMain = false
public override fun onFragmentVisibleChange(isVisible: Boolean) { public override fun onFragmentVisibleChange(isVisible: Boolean) {
if (isVisible) { if (isVisible) {
refreshIfNeed() refreshIfNeed()
@ -68,7 +69,7 @@ class MessageFragment : BaseFragment(), Refreshable, OnTabSelectedListener, Tool
val args = arguments val args = arguments
if (args != null) { if (args != null) {
type = args.getInt(PARAM_TYPE, TYPE_REPLY_ME) type = args.getInt(PARAM_TYPE, TYPE_REPLY_ME)
isFromNotification = args.getBoolean(PARAM_FROM_NOTIFICATION, false) isFromMain = args.getBoolean(PARAM_FROM_MAIN, false)
} }
} }
@ -78,7 +79,11 @@ class MessageFragment : BaseFragment(), Refreshable, OnTabSelectedListener, Tool
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState) super.onViewCreated(view, savedInstanceState)
mToolbar!!.setOnMenuItemClickListener(this) if (!isFromMain) {
mToolbar?.visibility = View.GONE
(mToolbar?.layoutParams as AppBarLayout.LayoutParams?)?.scrollFlags = SCROLL_FLAG_NO_SCROLL
}
mToolbar?.setOnMenuItemClickListener(this)
val viewPager: ViewPager = view.findViewById(R.id.fragment_message_vp) val viewPager: ViewPager = view.findViewById(R.id.fragment_message_vp)
val viewPagerAdapter = TabViewPagerAdapter() val viewPagerAdapter = TabViewPagerAdapter()
replyMe = MessageListHelper(attachContext, TYPE_REPLY_ME) replyMe = MessageListHelper(attachContext, TYPE_REPLY_ME)
@ -89,7 +94,7 @@ class MessageFragment : BaseFragment(), Refreshable, OnTabSelectedListener, Tool
tabLayout!!.setupWithViewPager(viewPager) tabLayout!!.setupWithViewPager(viewPager)
tabLayout!!.addOnTabSelectedListener(this) tabLayout!!.addOnTabSelectedListener(this)
viewPager.setCurrentItem(type, false) viewPager.setCurrentItem(type, false)
if (isFromNotification) { if (!isFromMain) {
refreshIfNeed() refreshIfNeed()
} }
} }
@ -251,15 +256,15 @@ class MessageFragment : BaseFragment(), Refreshable, OnTabSelectedListener, Tool
const val TYPE_AT_ME = 1 const val TYPE_AT_ME = 1
val TAG = MessageFragment::class.java.simpleName val TAG = MessageFragment::class.java.simpleName
private const val PARAM_TYPE = "type" private const val PARAM_TYPE = "type"
const val PARAM_FROM_NOTIFICATION = "from_notification" const val PARAM_FROM_MAIN = "from_main"
@JvmStatic @JvmStatic
@JvmOverloads @JvmOverloads
fun newInstance(type: Int, isFromNotification: Boolean = false): MessageFragment { fun newInstance(type: Int, fromMain: Boolean = false): MessageFragment {
return MessageFragment().apply { return MessageFragment().apply {
arguments = Bundle().apply { arguments = Bundle().apply {
putInt(PARAM_TYPE, type) putInt(PARAM_TYPE, type)
putBoolean(PARAM_FROM_NOTIFICATION, isFromNotification) putBoolean(PARAM_FROM_MAIN, fromMain)
} }
} }
} }

View File

@ -5,6 +5,7 @@
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"
app:backgroundTint="@color/default_color_window_background"
tools:context=".activities.MessageActivity"> tools:context=".activities.MessageActivity">
<include <include