fix: 修复透明主题页面主题色无法正常显示
This commit is contained in:
parent
24084fa9a6
commit
99dbe90626
|
|
@ -1,9 +1,7 @@
|
||||||
package com.huanchengfly.tieba.post.adapters
|
package com.huanchengfly.tieba.post.adapters
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.res.ColorStateList
|
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.view.View
|
|
||||||
import com.google.android.material.card.MaterialCardView
|
import com.google.android.material.card.MaterialCardView
|
||||||
import com.huanchengfly.tieba.post.BaseApplication.ThemeDelegate.getColorByAttr
|
import com.huanchengfly.tieba.post.BaseApplication.ThemeDelegate.getColorByAttr
|
||||||
import com.huanchengfly.tieba.post.R
|
import com.huanchengfly.tieba.post.R
|
||||||
|
|
@ -45,8 +43,8 @@ class AppThemeAdapter private constructor(
|
||||||
}
|
}
|
||||||
viewHolder.getView<MaterialCardView>(R.id.theme_preview).strokeColor =
|
viewHolder.getView<MaterialCardView>(R.id.theme_preview).strokeColor =
|
||||||
getThemePrimaryColor(item.value)
|
getThemePrimaryColor(item.value)
|
||||||
viewHolder.getView<View>(R.id.theme_preview_bg).backgroundTintList =
|
viewHolder.getView<MaterialCardView>(R.id.theme_preview)
|
||||||
ColorStateList.valueOf(getThemeColor(item.value))
|
.setCardBackgroundColor(getThemeColor(item.value))
|
||||||
viewHolder.itemView.apply {
|
viewHolder.itemView.apply {
|
||||||
contentDescription = item.name
|
contentDescription = item.name
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@ import androidx.annotation.NonNull;
|
||||||
import androidx.palette.graphics.Palette;
|
import androidx.palette.graphics.Palette;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
|
import com.google.android.material.card.MaterialCardView;
|
||||||
import com.huanchengfly.tieba.post.R;
|
import com.huanchengfly.tieba.post.R;
|
||||||
import com.huanchengfly.tieba.post.components.MyViewHolder;
|
import com.huanchengfly.tieba.post.components.MyViewHolder;
|
||||||
import com.huanchengfly.tieba.post.interfaces.OnItemClickListener;
|
import com.huanchengfly.tieba.post.interfaces.OnItemClickListener;
|
||||||
|
|
@ -79,8 +80,9 @@ public class TranslucentThemeColorAdapter extends RecyclerView.Adapter<MyViewHol
|
||||||
getOnItemClickListener().onClick(holder.itemView, mColors.get(position), position, 0);
|
getOnItemClickListener().onClick(holder.itemView, mColors.get(position), position, 0);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
View preview = holder.getView(R.id.theme_preview);
|
MaterialCardView preview = holder.getView(R.id.theme_preview);
|
||||||
preview.setBackgroundTintList(ColorStateList.valueOf(mColors.get(position)));
|
preview.setCardBackgroundColor(mColors.get(position));
|
||||||
|
preview.setStrokeColor(ColorStateList.valueOf(mColors.get(position)));
|
||||||
if (mSelectedColor == mColors.get(position)) {
|
if (mSelectedColor == mColors.get(position)) {
|
||||||
holder.setVisibility(R.id.theme_selected, View.VISIBLE);
|
holder.setVisibility(R.id.theme_selected, View.VISIBLE);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@
|
||||||
android:id="@+id/theme_preview"
|
android:id="@+id/theme_preview"
|
||||||
android:layout_width="48dp"
|
android:layout_width="48dp"
|
||||||
android:layout_height="48dp"
|
android:layout_height="48dp"
|
||||||
app:cardBackgroundColor="@color/transparent"
|
app:cardBackgroundColor="@color/white"
|
||||||
app:cardCornerRadius="10dp"
|
app:cardCornerRadius="10dp"
|
||||||
app:cardElevation="0dp"
|
app:cardElevation="0dp"
|
||||||
app:strokeWidth="2dp">
|
app:strokeWidth="2dp">
|
||||||
|
|
@ -20,8 +20,7 @@
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
android:id="@+id/theme_preview_bg"
|
android:id="@+id/theme_preview_bg"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent">
|
||||||
android:background="@color/white">
|
|
||||||
|
|
||||||
<com.huanchengfly.tieba.post.widgets.theme.TintImageView
|
<com.huanchengfly.tieba.post.widgets.theme.TintImageView
|
||||||
android:id="@+id/theme_icon"
|
android:id="@+id/theme_icon"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue