feat: 新增列表背景交错效果开关
This commit is contained in:
parent
d6c90050fe
commit
11264dd98d
|
|
@ -41,7 +41,7 @@ import com.huanchengfly.tieba.post.ui.theme.utils.ColorStateListUtils
|
||||||
import com.huanchengfly.tieba.post.utils.AnimUtil
|
import com.huanchengfly.tieba.post.utils.AnimUtil
|
||||||
import com.huanchengfly.tieba.post.utils.NavigationHelper
|
import com.huanchengfly.tieba.post.utils.NavigationHelper
|
||||||
import com.huanchengfly.tieba.post.utils.anim.animSet
|
import com.huanchengfly.tieba.post.utils.anim.animSet
|
||||||
import com.huanchengfly.tieba.post.utils.getItemBackgroundDrawable
|
import com.huanchengfly.tieba.post.utils.getIntermixedColorBackground
|
||||||
import com.huanchengfly.tieba.post.widgets.MyViewPager
|
import com.huanchengfly.tieba.post.widgets.MyViewPager
|
||||||
import org.litepal.LitePal
|
import org.litepal.LitePal
|
||||||
import retrofit2.Call
|
import retrofit2.Call
|
||||||
|
|
@ -321,7 +321,7 @@ class NewSearchActivity : BaseActivity(), TabLayout.OnTabSelectedListener {
|
||||||
textView.setTextColor(context.getColorCompat(R.color.red_accent))
|
textView.setTextColor(context.getColorCompat(R.color.red_accent))
|
||||||
}
|
}
|
||||||
viewHolder.setVisibility(R.id.hot_desc, View.GONE)
|
viewHolder.setVisibility(R.id.hot_desc, View.GONE)
|
||||||
viewHolder.itemView.background = getItemBackgroundDrawable(
|
viewHolder.itemView.background = getIntermixedColorBackground(
|
||||||
context,
|
context,
|
||||||
position,
|
position,
|
||||||
itemCount,
|
itemCount,
|
||||||
|
|
|
||||||
|
|
@ -44,10 +44,14 @@ class MainForumListAdapter(
|
||||||
getRadiusDrawable()
|
getRadiusDrawable()
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
if (position % 2 == 1) {
|
if (context.appPreferences.listItemsBackgroundIntermixed) {
|
||||||
viewHolder.itemView.backgroundTintList = ColorStateListUtils.createColorStateList(context, R.color.default_color_card)
|
if (position % 2 == 1) {
|
||||||
|
viewHolder.itemView.backgroundTintList = ColorStateListUtils.createColorStateList(context, R.color.default_color_card)
|
||||||
|
} else {
|
||||||
|
viewHolder.itemView.backgroundTintList = ColorStateListUtils.createColorStateList(context, R.color.default_color_divider)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
viewHolder.itemView.backgroundTintList = ColorStateListUtils.createColorStateList(context, R.color.default_color_divider)
|
viewHolder.itemView.backgroundTintList = ColorStateListUtils.createColorStateList(context, R.color.default_color_card)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//双列左
|
//双列左
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ import com.huanchengfly.tieba.post.api.models.SearchForumBean
|
||||||
import com.huanchengfly.tieba.post.api.models.SearchForumBean.ExactForumInfoBean
|
import com.huanchengfly.tieba.post.api.models.SearchForumBean.ExactForumInfoBean
|
||||||
import com.huanchengfly.tieba.post.components.MyViewHolder
|
import com.huanchengfly.tieba.post.components.MyViewHolder
|
||||||
import com.huanchengfly.tieba.post.utils.ImageUtil
|
import com.huanchengfly.tieba.post.utils.ImageUtil
|
||||||
import com.huanchengfly.tieba.post.utils.getItemBackgroundDrawable
|
import com.huanchengfly.tieba.post.utils.getIntermixedColorBackground
|
||||||
|
|
||||||
class SearchForumAdapter(context: Context?) : BaseMultiTypeDelegateAdapter<SearchForumBean.ForumInfoBean>(context!!, LinearLayoutHelper()) {
|
class SearchForumAdapter(context: Context?) : BaseMultiTypeDelegateAdapter<SearchForumBean.ForumInfoBean>(context!!, LinearLayoutHelper()) {
|
||||||
override fun convert(viewHolder: MyViewHolder, item: SearchForumBean.ForumInfoBean, position: Int, viewType: Int) {
|
override fun convert(viewHolder: MyViewHolder, item: SearchForumBean.ForumInfoBean, position: Int, viewType: Int) {
|
||||||
|
|
@ -18,7 +18,7 @@ class SearchForumAdapter(context: Context?) : BaseMultiTypeDelegateAdapter<Searc
|
||||||
val exactForumInfoBean = item as ExactForumInfoBean
|
val exactForumInfoBean = item as ExactForumInfoBean
|
||||||
viewHolder.setText(R.id.item_search_forum_subtitle, exactForumInfoBean.slogan)
|
viewHolder.setText(R.id.item_search_forum_subtitle, exactForumInfoBean.slogan)
|
||||||
}
|
}
|
||||||
viewHolder.itemView.background = getItemBackgroundDrawable(
|
viewHolder.itemView.background = getIntermixedColorBackground(
|
||||||
context,
|
context,
|
||||||
position,
|
position,
|
||||||
itemCount,
|
itemCount,
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ import com.huanchengfly.tieba.post.api.models.SearchUserBean
|
||||||
import com.huanchengfly.tieba.post.components.MyViewHolder
|
import com.huanchengfly.tieba.post.components.MyViewHolder
|
||||||
import com.huanchengfly.tieba.post.utils.ImageUtil
|
import com.huanchengfly.tieba.post.utils.ImageUtil
|
||||||
import com.huanchengfly.tieba.post.utils.StringUtil
|
import com.huanchengfly.tieba.post.utils.StringUtil
|
||||||
import com.huanchengfly.tieba.post.utils.getItemBackgroundDrawable
|
import com.huanchengfly.tieba.post.utils.getIntermixedColorBackground
|
||||||
|
|
||||||
class SearchUserAdapter(
|
class SearchUserAdapter(
|
||||||
context: Context
|
context: Context
|
||||||
|
|
@ -26,7 +26,7 @@ class SearchUserAdapter(
|
||||||
}
|
}
|
||||||
subTitleBuilder.append(context.getString(R.string.fans_num, item.fansNum))
|
subTitleBuilder.append(context.getString(R.string.fans_num, item.fansNum))
|
||||||
viewHolder.setText(R.id.item_search_user_subtitle, subTitleBuilder.toString())
|
viewHolder.setText(R.id.item_search_user_subtitle, subTitleBuilder.toString())
|
||||||
viewHolder.itemView.background = getItemBackgroundDrawable(
|
viewHolder.itemView.background = getIntermixedColorBackground(
|
||||||
context,
|
context,
|
||||||
position,
|
position,
|
||||||
itemCount,
|
itemCount,
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,7 @@ import com.huanchengfly.tieba.post.goToActivity
|
||||||
import com.huanchengfly.tieba.post.interfaces.Refreshable
|
import com.huanchengfly.tieba.post.interfaces.Refreshable
|
||||||
import com.huanchengfly.tieba.post.models.MyInfoBean
|
import com.huanchengfly.tieba.post.models.MyInfoBean
|
||||||
import com.huanchengfly.tieba.post.ui.theme.interfaces.ExtraRefreshable
|
import com.huanchengfly.tieba.post.ui.theme.interfaces.ExtraRefreshable
|
||||||
|
import com.huanchengfly.tieba.post.ui.theme.utils.ColorStateListUtils
|
||||||
import com.huanchengfly.tieba.post.ui.theme.utils.ThemeUtils
|
import com.huanchengfly.tieba.post.ui.theme.utils.ThemeUtils
|
||||||
import com.huanchengfly.tieba.post.utils.*
|
import com.huanchengfly.tieba.post.utils.*
|
||||||
import com.huanchengfly.tieba.post.widgets.theme.TintSwitch
|
import com.huanchengfly.tieba.post.widgets.theme.TintSwitch
|
||||||
|
|
@ -209,6 +210,19 @@ class MyInfoFragment : BaseFragment(), View.OnClickListener, CompoundButton.OnCh
|
||||||
nightSwitch.setOnCheckedChangeListener(null)
|
nightSwitch.setOnCheckedChangeListener(null)
|
||||||
nightSwitch.isChecked = ThemeUtil.isNightMode(attachContext)
|
nightSwitch.isChecked = ThemeUtil.isNightMode(attachContext)
|
||||||
nightSwitch.setOnCheckedChangeListener(this)
|
nightSwitch.setOnCheckedChangeListener(this)
|
||||||
|
listOf(
|
||||||
|
R.id.my_info_history,
|
||||||
|
R.id.my_info_service_center,
|
||||||
|
R.id.my_info_about
|
||||||
|
).forEach {
|
||||||
|
mRefreshView.findViewById<View>(it).apply {
|
||||||
|
backgroundTintList = if (appPreferences.listItemsBackgroundIntermixed) {
|
||||||
|
ColorStateListUtils.createColorStateList(attachContext, R.color.default_color_divider)
|
||||||
|
} else {
|
||||||
|
ColorStateListUtils.createColorStateList(attachContext, R.color.default_color_card)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onClick(v: View) {
|
override fun onClick(v: View) {
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,8 @@ open class AppPreferencesUtils(context: Context) {
|
||||||
|
|
||||||
var imageLoadType by SharedPreferenceDelegates.string(key = "image_load_type", defaultValue = "0")
|
var imageLoadType by SharedPreferenceDelegates.string(key = "image_load_type", defaultValue = "0")
|
||||||
|
|
||||||
|
var listItemsBackgroundIntermixed by SharedPreferenceDelegates.boolean(defaultValue = true)
|
||||||
|
|
||||||
var listSingle by SharedPreferenceDelegates.boolean(defaultValue = false)
|
var listSingle by SharedPreferenceDelegates.boolean(defaultValue = false)
|
||||||
|
|
||||||
var littleTail by SharedPreferenceDelegates.string(key = "little_tail")
|
var littleTail by SharedPreferenceDelegates.string(key = "little_tail")
|
||||||
|
|
|
||||||
|
|
@ -85,3 +85,29 @@ fun getRadiusDrawable(
|
||||||
fun wrapRipple(rippleColor: Int, drawable: Drawable): Drawable {
|
fun wrapRipple(rippleColor: Int, drawable: Drawable): Drawable {
|
||||||
return RippleDrawable(ColorStateList.valueOf(rippleColor), drawable, drawable)
|
return RippleDrawable(ColorStateList.valueOf(rippleColor), drawable, drawable)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@JvmOverloads
|
||||||
|
fun getIntermixedColorBackground(
|
||||||
|
context: Context,
|
||||||
|
position: Int,
|
||||||
|
itemCount: Int,
|
||||||
|
positionOffset: Int = 0,
|
||||||
|
radius: Float = 8f.dpToPxFloat(),
|
||||||
|
colors: IntArray = intArrayOf(R.color.default_color_card),
|
||||||
|
ripple: Boolean = true
|
||||||
|
): Drawable {
|
||||||
|
return getItemBackgroundDrawable(
|
||||||
|
context,
|
||||||
|
position,
|
||||||
|
itemCount,
|
||||||
|
positionOffset,
|
||||||
|
radius,
|
||||||
|
if (context.appPreferences.listItemsBackgroundIntermixed) {
|
||||||
|
colors
|
||||||
|
} else {
|
||||||
|
intArrayOf(colors[0])
|
||||||
|
},
|
||||||
|
ripple
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
@ -446,4 +446,5 @@
|
||||||
<string name="title_fetching_forum_list">正在获取吧列表</string>
|
<string name="title_fetching_forum_list">正在获取吧列表</string>
|
||||||
<string name="text_oksign_no_signable">没有可签到的吧</string>
|
<string name="text_oksign_no_signable">没有可签到的吧</string>
|
||||||
<string name="title_forum_info">关于本吧</string>
|
<string name="title_forum_info">关于本吧</string>
|
||||||
|
<string name="settings_list_items_background_intermixed">列表背景颜色交错效果</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
||||||
|
|
@ -140,6 +140,11 @@
|
||||||
android:title="@string/settings_status_bar_darker"
|
android:title="@string/settings_status_bar_darker"
|
||||||
android:summary="@string/tip_status_bar_darker" />
|
android:summary="@string/tip_status_bar_darker" />
|
||||||
|
|
||||||
|
<SwitchPreference
|
||||||
|
android:key="listItemsBackgroundIntermixed"
|
||||||
|
android:defaultValue="true"
|
||||||
|
android:title="@string/settings_list_items_background_intermixed" />
|
||||||
|
|
||||||
<SwitchPreference
|
<SwitchPreference
|
||||||
android:icon="@drawable/ic_forum_single_blue"
|
android:icon="@drawable/ic_forum_single_blue"
|
||||||
android:key="listSingle"
|
android:key="listSingle"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue