refactor: 移除无用代码

This commit is contained in:
HuanCheng65 2022-08-08 11:13:49 +08:00
parent c5c9cd9751
commit 3c219a3bdc
No known key found for this signature in database
GPG Key ID: E9031EF91A805148
5 changed files with 108 additions and 250 deletions

View File

@ -43,7 +43,7 @@ import com.huanchengfly.tieba.post.api.retrofit.exception.getErrorMessage
import com.huanchengfly.tieba.post.components.FillVirtualLayoutManager
import com.huanchengfly.tieba.post.components.dialogs.EditTextDialog
import com.huanchengfly.tieba.post.fragments.threadmenu.IThreadMenuFragment
import com.huanchengfly.tieba.post.fragments.threadmenu.MIUIThreadMenuFragment
import com.huanchengfly.tieba.post.fragments.threadmenu.ThreadMenuFragment
import com.huanchengfly.tieba.post.goToActivity
import com.huanchengfly.tieba.post.models.ReplyInfoBean
import com.huanchengfly.tieba.post.models.ThreadHistoryInfoBean
@ -745,7 +745,7 @@ class ThreadActivity : BaseActivity(), View.OnClickListener, IThreadMenuFragment
}
R.id.toolbar -> recyclerView.scrollToPosition(0)
R.id.thread_bottom_bar_more_btn -> {
MIUIThreadMenuFragment(
ThreadMenuFragment(
seeLz,
collect,
replyAdapter.isPureRead,

View File

@ -1,214 +0,0 @@
package com.huanchengfly.tieba.post.fragments.threadmenu
import android.os.Build
import android.view.View
import butterknife.BindView
import butterknife.OnClick
import com.google.android.material.button.MaterialButton
import com.huanchengfly.tieba.post.R
import com.huanchengfly.tieba.post.dpToPx
import com.huanchengfly.tieba.post.dpToPxFloat
import com.huanchengfly.tieba.post.ui.common.animation.addMaskAnimation
import com.huanchengfly.tieba.post.ui.common.animation.addZoomAnimation
import com.huanchengfly.tieba.post.ui.common.animation.buildPressAnimator
import com.huanchengfly.tieba.post.widgets.theme.TintImageView
import com.huanchengfly.tieba.post.widgets.theme.TintLinearLayout
import com.huanchengfly.tieba.post.widgets.theme.TintTextView
class MIUIThreadMenuFragment(
seeLz: Boolean,
collect: Boolean,
pureRead: Boolean,
sort: Boolean,
canDelete: Boolean
) : IThreadMenuFragment(seeLz, collect, pureRead, sort, canDelete) {
@BindView(R.id.thread_menu_see_lz)
lateinit var seeLzItem: TintLinearLayout
@BindView(R.id.thread_menu_see_lz_icon)
lateinit var seeLzIcon: TintImageView
@BindView(R.id.thread_menu_see_lz_text)
lateinit var seeLzText: TintTextView
@BindView(R.id.thread_menu_see_lz_status)
lateinit var seeLzStatus: TintTextView
@BindView(R.id.thread_menu_collect)
lateinit var collectItem: TintLinearLayout
@BindView(R.id.thread_menu_collect_icon)
lateinit var collectIcon: TintImageView
@BindView(R.id.thread_menu_collect_text)
lateinit var collectText: TintTextView
@BindView(R.id.thread_menu_collect_status)
lateinit var collectStatus: TintTextView
@BindView(R.id.thread_menu_pure_read)
lateinit var pureReadItem: TintLinearLayout
@BindView(R.id.thread_menu_pure_read_icon)
lateinit var pureReadIcon: TintImageView
@BindView(R.id.thread_menu_pure_read_text)
lateinit var pureReadText: TintTextView
@BindView(R.id.thread_menu_pure_read_status)
lateinit var pureReadStatus: TintTextView
@BindView(R.id.thread_menu_sort)
lateinit var sortItem: TintLinearLayout
@BindView(R.id.thread_menu_sort_icon)
lateinit var sortIcon: TintImageView
@BindView(R.id.thread_menu_sort_text)
lateinit var sortText: TintTextView
@BindView(R.id.thread_menu_sort_status)
lateinit var sortStatus: TintTextView
@BindView(R.id.thread_menu_delete)
lateinit var deleteMenuItem: View
@BindView(R.id.thread_menu)
lateinit var menuView: View
@BindView(R.id.thread_menu_jump_page)
lateinit var jumpPageItem: View
@BindView(R.id.thread_menu_close)
lateinit var closeBtn: MaterialButton
override fun initView() {
if (seeLz) {
seeLzItem.setBackgroundTintResId(R.color.default_color_accent)
seeLzIcon.setTintListResId(R.color.default_color_card)
seeLzText.tintResId = R.color.default_color_card
seeLzStatus.tintResId = R.color.default_color_card
seeLzStatus.setText(R.string.title_on)
seeLzStatus.alpha = .75f
} else {
seeLzItem.setBackgroundTintResId(R.color.default_color_card)
seeLzIcon.setTintListResId(R.color.default_color_accent)
seeLzText.tintResId = R.color.default_color_text
seeLzStatus.tintResId = R.color.default_color_text_secondary
seeLzStatus.setText(R.string.title_off)
seeLzStatus.alpha = 1f
}
if (collect) {
collectItem.setBackgroundTintResId(R.color.default_color_accent)
collectIcon.setTintListResId(R.color.default_color_card)
collectText.tintResId = R.color.default_color_card
collectStatus.tintResId = R.color.default_color_card
collectStatus.setText(R.string.title_collected)
collectStatus.alpha = .75f
} else {
collectItem.setBackgroundTintResId(R.color.default_color_card)
collectIcon.setTintListResId(R.color.default_color_accent)
collectText.tintResId = R.color.default_color_text
collectStatus.tintResId = R.color.default_color_text_secondary
collectStatus.setText(R.string.title_uncollected)
collectStatus.alpha = 1f
}
if (pureRead) {
pureReadItem.setBackgroundTintResId(R.color.default_color_accent)
pureReadIcon.setTintListResId(R.color.default_color_card)
pureReadText.tintResId = R.color.default_color_card
pureReadStatus.tintResId = R.color.default_color_card
pureReadStatus.setText(R.string.title_on)
pureReadStatus.alpha = .75f
} else {
pureReadItem.setBackgroundTintResId(R.color.default_color_card)
pureReadIcon.setTintListResId(R.color.default_color_accent)
pureReadText.tintResId = R.color.default_color_text
pureReadStatus.tintResId = R.color.default_color_text_secondary
pureReadStatus.setText(R.string.title_off)
pureReadStatus.alpha = 1f
}
if (sort) {
sortItem.setBackgroundTintResId(R.color.default_color_accent)
sortIcon.setTintListResId(R.color.default_color_card)
sortText.tintResId = R.color.default_color_card
sortStatus.tintResId = R.color.default_color_card
sortStatus.setText(R.string.title_on)
sortStatus.alpha = .75f
} else {
sortItem.setBackgroundTintResId(R.color.default_color_card)
sortIcon.setTintListResId(R.color.default_color_accent)
sortText.tintResId = R.color.default_color_text
sortStatus.tintResId = R.color.default_color_text_secondary
sortStatus.setText(R.string.title_off)
sortStatus.alpha = 1f
}
listOf(
seeLzItem,
collectItem,
pureReadItem,
sortItem
).forEach {
buildPressAnimator(it) {
addZoomAnimation(0.1f)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
addMaskAnimation(maskRadius = 10f.dpToPxFloat())
}
}.init()
}
deleteMenuItem.visibility = if (canDelete) {
View.VISIBLE
} else {
View.GONE
}
menuView.post {
mBehavior.setPeekHeight(
((4 + 8 * 2 + 16 * 3 + 8).dpToPx() + seeLzItem.height * 2 + jumpPageItem.height * 2.5f).toInt(),
false
)
}
}
override fun getLayoutId(): Int = R.layout.fragment_thread_menu_miui_style
@OnClick(
R.id.thread_menu_see_lz,
R.id.thread_menu_collect,
R.id.thread_menu_pure_read,
R.id.thread_menu_sort,
R.id.thread_menu_report,
R.id.thread_menu_jump_page,
R.id.thread_menu_copy_link,
R.id.thread_menu_share,
R.id.thread_menu_close
)
override fun onClick(v: View) {
when (v.id) {
R.id.thread_menu_see_lz, R.id.thread_menu_see_lz_icon -> {
onActionsListener?.onToggleSeeLz(!seeLz)
}
R.id.thread_menu_collect, R.id.thread_menu_collect_icon -> {
onActionsListener?.onToggleCollect(!collect)
}
R.id.thread_menu_pure_read, R.id.thread_menu_pure_read_icon -> {
onActionsListener?.onTogglePureRead(!pureRead)
}
R.id.thread_menu_sort, R.id.thread_menu_sort_icon -> {
onActionsListener?.onToggleSort(!sort)
}
R.id.thread_menu_report -> {
onActionsListener?.onReport()
}
R.id.thread_menu_jump_page -> {
onActionsListener?.onJumpPage()
}
R.id.thread_menu_copy_link -> {
onActionsListener?.onCopyLink()
}
R.id.thread_menu_share -> {
onActionsListener?.onShare()
}
}
dismiss()
}
}

View File

@ -1,12 +1,18 @@
package com.huanchengfly.tieba.post.fragments.threadmenu
import android.os.Build
import android.view.View
import butterknife.BindView
import butterknife.OnClick
import com.google.android.material.button.MaterialButton
import com.huanchengfly.tieba.post.R
import com.huanchengfly.tieba.post.dpToPx
import com.huanchengfly.tieba.post.dpToPxFloat
import com.huanchengfly.tieba.post.ui.common.animation.addMaskAnimation
import com.huanchengfly.tieba.post.ui.common.animation.addZoomAnimation
import com.huanchengfly.tieba.post.ui.common.animation.buildPressAnimator
import com.huanchengfly.tieba.post.widgets.theme.TintImageView
import com.huanchengfly.tieba.post.widgets.theme.TintLinearLayout
import com.huanchengfly.tieba.post.widgets.theme.TintTextView
class ThreadMenuFragment(
@ -14,80 +20,140 @@ class ThreadMenuFragment(
collect: Boolean,
pureRead: Boolean,
sort: Boolean,
canDelete: Boolean = false
canDelete: Boolean
) : IThreadMenuFragment(seeLz, collect, pureRead, sort, canDelete) {
@BindView(R.id.thread_menu_see_lz)
lateinit var seeLzItem: TintLinearLayout
@BindView(R.id.thread_menu_see_lz_icon)
lateinit var seeLzIcon: TintImageView
@BindView(R.id.thread_menu_see_lz_text)
lateinit var seeLzText: TintTextView
@BindView(R.id.thread_menu_see_lz_status)
lateinit var seeLzStatus: TintTextView
@BindView(R.id.thread_menu_collect)
lateinit var collectItem: TintLinearLayout
@BindView(R.id.thread_menu_collect_icon)
lateinit var collectIcon: TintImageView
@BindView(R.id.thread_menu_collect_text)
lateinit var collectText: TintTextView
@BindView(R.id.thread_menu_collect_status)
lateinit var collectStatus: TintTextView
@BindView(R.id.thread_menu_pure_read)
lateinit var pureReadItem: TintLinearLayout
@BindView(R.id.thread_menu_pure_read_icon)
lateinit var pureReadIcon: TintImageView
@BindView(R.id.thread_menu_pure_read_text)
lateinit var pureReadText: TintTextView
@BindView(R.id.thread_menu_pure_read_status)
lateinit var pureReadStatus: TintTextView
@BindView(R.id.thread_menu_sort)
lateinit var sortItem: TintLinearLayout
@BindView(R.id.thread_menu_sort_icon)
lateinit var sortIcon: TintImageView
@BindView(R.id.thread_menu_sort_text)
lateinit var sortText: TintTextView
@BindView(R.id.thread_menu_sort_status)
lateinit var sortStatus: TintTextView
@BindView(R.id.thread_menu_delete)
lateinit var deleteMenuItem: View
@BindView(R.id.thread_menu)
lateinit var menuView: View
@BindView(R.id.thread_menu_jump_page)
lateinit var jumpPageItem: View
@BindView(R.id.thread_menu_close)
lateinit var closeBtn: MaterialButton
override fun initView() {
if (seeLz) {
seeLzItem.setBackgroundTintResId(R.color.default_color_accent)
seeLzIcon.setTintListResId(R.color.default_color_card)
seeLzIcon.setBackgroundTintResId(R.color.default_color_accent)
seeLzText.setText(R.string.title_see_lz_on)
seeLzText.tintResId = R.color.default_color_card
seeLzStatus.tintResId = R.color.default_color_card
seeLzStatus.setText(R.string.title_on)
seeLzStatus.alpha = .75f
} else {
seeLzIcon.setTintListResId(R.color.default_color_text_secondary)
seeLzIcon.setBackgroundTintResId(R.color.default_color_card)
seeLzText.setText(R.string.title_see_lz)
seeLzItem.setBackgroundTintResId(R.color.default_color_card)
seeLzIcon.setTintListResId(R.color.default_color_accent)
seeLzText.tintResId = R.color.default_color_text
seeLzStatus.tintResId = R.color.default_color_text_secondary
seeLzStatus.setText(R.string.title_off)
seeLzStatus.alpha = 1f
}
if (collect) {
collectItem.setBackgroundTintResId(R.color.default_color_accent)
collectIcon.setTintListResId(R.color.default_color_card)
collectIcon.setBackgroundTintResId(R.color.default_color_accent)
collectText.setText(R.string.title_collect_on)
collectText.tintResId = R.color.default_color_card
collectStatus.tintResId = R.color.default_color_card
collectStatus.setText(R.string.title_collected)
collectStatus.alpha = .75f
} else {
collectIcon.setTintListResId(R.color.default_color_text_secondary)
collectIcon.setBackgroundTintResId(R.color.default_color_card)
collectText.setText(R.string.title_collect)
collectItem.setBackgroundTintResId(R.color.default_color_card)
collectIcon.setTintListResId(R.color.default_color_accent)
collectText.tintResId = R.color.default_color_text
collectStatus.tintResId = R.color.default_color_text_secondary
collectStatus.setText(R.string.title_uncollected)
collectStatus.alpha = 1f
}
if (pureRead) {
pureReadItem.setBackgroundTintResId(R.color.default_color_accent)
pureReadIcon.setTintListResId(R.color.default_color_card)
pureReadIcon.setBackgroundTintResId(R.color.default_color_accent)
pureReadText.setText(R.string.title_pure_read_on)
pureReadText.tintResId = R.color.default_color_card
pureReadStatus.tintResId = R.color.default_color_card
pureReadStatus.setText(R.string.title_on)
pureReadStatus.alpha = .75f
} else {
pureReadIcon.setTintListResId(R.color.default_color_text_secondary)
pureReadIcon.setBackgroundTintResId(R.color.default_color_card)
pureReadText.setText(R.string.title_pure_read)
pureReadItem.setBackgroundTintResId(R.color.default_color_card)
pureReadIcon.setTintListResId(R.color.default_color_accent)
pureReadText.tintResId = R.color.default_color_text
pureReadStatus.tintResId = R.color.default_color_text_secondary
pureReadStatus.setText(R.string.title_off)
pureReadStatus.alpha = 1f
}
if (sort) {
sortItem.setBackgroundTintResId(R.color.default_color_accent)
sortIcon.setTintListResId(R.color.default_color_card)
sortIcon.setBackgroundTintResId(R.color.default_color_accent)
sortText.setText(R.string.title_sort_on)
sortText.tintResId = R.color.default_color_card
sortStatus.tintResId = R.color.default_color_card
sortStatus.setText(R.string.title_on)
sortStatus.alpha = .75f
} else {
sortIcon.setTintListResId(R.color.default_color_text_secondary)
sortIcon.setBackgroundTintResId(R.color.default_color_card)
sortText.setText(R.string.title_sort)
sortItem.setBackgroundTintResId(R.color.default_color_card)
sortIcon.setTintListResId(R.color.default_color_accent)
sortText.tintResId = R.color.default_color_text
sortStatus.tintResId = R.color.default_color_text_secondary
sortStatus.setText(R.string.title_off)
sortStatus.alpha = 1f
}
listOf(
seeLzIcon,
collectIcon,
pureReadIcon,
sortIcon
seeLzItem,
collectItem,
pureReadItem,
sortItem
).forEach {
buildPressAnimator(it) {
addZoomAnimation()
addZoomAnimation(0.1f)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
addMaskAnimation(maskRadius = 10f.dpToPxFloat())
}
}.init()
}
deleteMenuItem.visibility = if (canDelete) {
@ -95,19 +161,21 @@ class ThreadMenuFragment(
} else {
View.GONE
}
menuView.post {
mBehavior.setPeekHeight(
((4 + 8 * 2 + 16 * 3 + 8).dpToPx() + seeLzItem.height * 2 + jumpPageItem.height * 2.5f).toInt(),
false
)
}
}
override fun getLayoutId(): Int = R.layout.fragment_thread_menu
override fun getLayoutId(): Int = R.layout.fragment_thread_menu_miui_style
@OnClick(
R.id.thread_menu_see_lz,
R.id.thread_menu_collect,
R.id.thread_menu_pure_read,
R.id.thread_menu_sort,
R.id.thread_menu_see_lz_icon,
R.id.thread_menu_collect_icon,
R.id.thread_menu_pure_read_icon,
R.id.thread_menu_sort_icon,
R.id.thread_menu_report,
R.id.thread_menu_jump_page,
R.id.thread_menu_copy_link,

View File

@ -164,6 +164,7 @@
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:layout_marginBottom="8dp"
android:baselineAligned="false"
android:orientation="horizontal">
<LinearLayout
@ -187,7 +188,7 @@
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="8dp"
android:text="关注"
android:text="@string/title_stat_concerns_num"
android:textSize="14sp"
app:tint="@color/color_text_secondary_translucent_light" />
</LinearLayout>
@ -213,7 +214,7 @@
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="8dp"
android:text="贴子"
android:text="@string/title_stat_threads_num"
android:textSize="14sp"
app:tint="@color/color_text_secondary_translucent_light" />
</LinearLayout>
@ -239,7 +240,7 @@
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="8dp"
android:text="回贴"
android:text="@string/title_stat_posts_num"
android:textSize="14sp"
app:tint="@color/color_text_secondary_translucent_light" />
</LinearLayout>

View File

@ -547,4 +547,7 @@
<string name="title_posts_num">贴子</string>
<string name="title_oksign_use_official_oksign">使用官方一键签到</string>
<string name="summary_oksign_use_official_oksign">(实验性特性)先使用官方一键签到减少需签到吧数量,以加快签到速度</string>
<string name="title_stat_threads_num">贴子</string>
<string name="title_stat_posts_num">回贴</string>
<string name="title_stat_concerns_num">关注</string>
</resources>