fix: 修复透明主题异常
This commit is contained in:
parent
ceab9ae853
commit
129b9e7056
|
|
@ -0,0 +1,7 @@
|
||||||
|
package com.huanchengfly.tieba.post.interfaces
|
||||||
|
|
||||||
|
interface BackgroundTintable {
|
||||||
|
fun setBackgroundTintResId(resId: Int)
|
||||||
|
|
||||||
|
fun getBackgroundTintResId(): Int
|
||||||
|
}
|
||||||
|
|
@ -32,6 +32,7 @@ import com.google.android.material.appbar.AppBarLayout;
|
||||||
import com.huanchengfly.tieba.post.BaseApplication;
|
import com.huanchengfly.tieba.post.BaseApplication;
|
||||||
import com.huanchengfly.tieba.post.R;
|
import com.huanchengfly.tieba.post.R;
|
||||||
import com.huanchengfly.tieba.post.activities.BaseActivity;
|
import com.huanchengfly.tieba.post.activities.BaseActivity;
|
||||||
|
import com.huanchengfly.tieba.post.interfaces.BackgroundTintable;
|
||||||
import com.huanchengfly.tieba.post.ui.theme.utils.ThemeUtils;
|
import com.huanchengfly.tieba.post.ui.theme.utils.ThemeUtils;
|
||||||
import com.huanchengfly.tieba.post.widgets.theme.TintSwipeRefreshLayout;
|
import com.huanchengfly.tieba.post.widgets.theme.TintSwipeRefreshLayout;
|
||||||
import com.scwang.smart.refresh.header.MaterialHeader;
|
import com.scwang.smart.refresh.header.MaterialHeader;
|
||||||
|
|
@ -281,6 +282,9 @@ public class ThemeUtil {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
view.setBackgroundTintList(null);
|
view.setBackgroundTintList(null);
|
||||||
|
if (view instanceof BackgroundTintable) {
|
||||||
|
((BackgroundTintable) view).setBackgroundTintResId(0);
|
||||||
|
}
|
||||||
String backgroundFilePath = SharedPreferencesUtil.get(BaseApplication.getInstance(), SharedPreferencesUtil.SP_SETTINGS)
|
String backgroundFilePath = SharedPreferencesUtil.get(BaseApplication.getInstance(), SharedPreferencesUtil.SP_SETTINGS)
|
||||||
.getString(SP_TRANSLUCENT_THEME_BACKGROUND_PATH, null);
|
.getString(SP_TRANSLUCENT_THEME_BACKGROUND_PATH, null);
|
||||||
if (backgroundFilePath == null) {
|
if (backgroundFilePath == null) {
|
||||||
|
|
@ -329,7 +333,7 @@ public class ThemeUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setTranslucentThemeBackground(View view) {
|
public static void setTranslucentThemeBackground(View view) {
|
||||||
setTranslucentThemeBackground(view, true, true);
|
setTranslucentThemeBackground(view, true, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@StyleRes
|
@StyleRes
|
||||||
|
|
|
||||||
|
|
@ -10,12 +10,13 @@ import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||||
|
|
||||||
|
import com.huanchengfly.tieba.post.R;
|
||||||
|
import com.huanchengfly.tieba.post.interfaces.BackgroundTintable;
|
||||||
import com.huanchengfly.tieba.post.ui.theme.interfaces.Tintable;
|
import com.huanchengfly.tieba.post.ui.theme.interfaces.Tintable;
|
||||||
import com.huanchengfly.tieba.post.ui.theme.utils.ThemeUtils;
|
import com.huanchengfly.tieba.post.ui.theme.utils.ThemeUtils;
|
||||||
import com.huanchengfly.tieba.post.R;
|
|
||||||
|
|
||||||
@SuppressLint("CustomViewStyleable")
|
@SuppressLint("CustomViewStyleable")
|
||||||
public class TintConstraintLayout extends ConstraintLayout implements Tintable {
|
public class TintConstraintLayout extends ConstraintLayout implements Tintable, BackgroundTintable {
|
||||||
private int mBackgroundTintResId;
|
private int mBackgroundTintResId;
|
||||||
|
|
||||||
public TintConstraintLayout(@NonNull Context context) {
|
public TintConstraintLayout(@NonNull Context context) {
|
||||||
|
|
@ -57,10 +58,12 @@ public class TintConstraintLayout extends ConstraintLayout implements Tintable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int getBackgroundTintResId() {
|
public int getBackgroundTintResId() {
|
||||||
return mBackgroundTintResId;
|
return mBackgroundTintResId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setBackgroundTintResId(int backgroundTintResId) {
|
public void setBackgroundTintResId(int backgroundTintResId) {
|
||||||
mBackgroundTintResId = backgroundTintResId;
|
mBackgroundTintResId = backgroundTintResId;
|
||||||
tint();
|
tint();
|
||||||
|
|
|
||||||
|
|
@ -10,12 +10,13 @@ import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.coordinatorlayout.widget.CoordinatorLayout;
|
import androidx.coordinatorlayout.widget.CoordinatorLayout;
|
||||||
|
|
||||||
|
import com.huanchengfly.tieba.post.R;
|
||||||
|
import com.huanchengfly.tieba.post.interfaces.BackgroundTintable;
|
||||||
import com.huanchengfly.tieba.post.ui.theme.interfaces.Tintable;
|
import com.huanchengfly.tieba.post.ui.theme.interfaces.Tintable;
|
||||||
import com.huanchengfly.tieba.post.ui.theme.utils.ThemeUtils;
|
import com.huanchengfly.tieba.post.ui.theme.utils.ThemeUtils;
|
||||||
import com.huanchengfly.tieba.post.R;
|
|
||||||
|
|
||||||
@SuppressLint("CustomViewStyleable")
|
@SuppressLint("CustomViewStyleable")
|
||||||
public class TintCoordinatorLayout extends CoordinatorLayout implements Tintable {
|
public class TintCoordinatorLayout extends CoordinatorLayout implements Tintable, BackgroundTintable {
|
||||||
private int mBackgroundTintResId;
|
private int mBackgroundTintResId;
|
||||||
|
|
||||||
public TintCoordinatorLayout(@NonNull Context context) {
|
public TintCoordinatorLayout(@NonNull Context context) {
|
||||||
|
|
@ -56,4 +57,15 @@ public class TintCoordinatorLayout extends CoordinatorLayout implements Tintable
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setBackgroundTintResId(int resId) {
|
||||||
|
mBackgroundTintResId = resId;
|
||||||
|
tint();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getBackgroundTintResId() {
|
||||||
|
return mBackgroundTintResId;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,12 +10,13 @@ import android.widget.FrameLayout;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
|
import com.huanchengfly.tieba.post.R;
|
||||||
|
import com.huanchengfly.tieba.post.interfaces.BackgroundTintable;
|
||||||
import com.huanchengfly.tieba.post.ui.theme.interfaces.Tintable;
|
import com.huanchengfly.tieba.post.ui.theme.interfaces.Tintable;
|
||||||
import com.huanchengfly.tieba.post.ui.theme.utils.ThemeUtils;
|
import com.huanchengfly.tieba.post.ui.theme.utils.ThemeUtils;
|
||||||
import com.huanchengfly.tieba.post.R;
|
|
||||||
|
|
||||||
@SuppressLint("CustomViewStyleable")
|
@SuppressLint("CustomViewStyleable")
|
||||||
public class TintFrameLayout extends FrameLayout implements Tintable {
|
public class TintFrameLayout extends FrameLayout implements Tintable, BackgroundTintable {
|
||||||
private int mBackgroundTintResId;
|
private int mBackgroundTintResId;
|
||||||
|
|
||||||
public TintFrameLayout(@NonNull Context context) {
|
public TintFrameLayout(@NonNull Context context) {
|
||||||
|
|
@ -56,4 +57,15 @@ public class TintFrameLayout extends FrameLayout implements Tintable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setBackgroundTintResId(int resId) {
|
||||||
|
mBackgroundTintResId = resId;
|
||||||
|
tint();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getBackgroundTintResId() {
|
||||||
|
return mBackgroundTintResId;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,12 +10,13 @@ import android.widget.LinearLayout;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
|
import com.huanchengfly.tieba.post.R;
|
||||||
|
import com.huanchengfly.tieba.post.interfaces.BackgroundTintable;
|
||||||
import com.huanchengfly.tieba.post.ui.theme.interfaces.Tintable;
|
import com.huanchengfly.tieba.post.ui.theme.interfaces.Tintable;
|
||||||
import com.huanchengfly.tieba.post.ui.theme.utils.ThemeUtils;
|
import com.huanchengfly.tieba.post.ui.theme.utils.ThemeUtils;
|
||||||
import com.huanchengfly.tieba.post.R;
|
|
||||||
|
|
||||||
@SuppressLint("CustomViewStyleable")
|
@SuppressLint("CustomViewStyleable")
|
||||||
public class TintLinearLayout extends LinearLayout implements Tintable {
|
public class TintLinearLayout extends LinearLayout implements Tintable, BackgroundTintable {
|
||||||
private int mBackgroundTintResId;
|
private int mBackgroundTintResId;
|
||||||
|
|
||||||
public TintLinearLayout(@NonNull Context context) {
|
public TintLinearLayout(@NonNull Context context) {
|
||||||
|
|
@ -56,4 +57,15 @@ public class TintLinearLayout extends LinearLayout implements Tintable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setBackgroundTintResId(int resId) {
|
||||||
|
mBackgroundTintResId = resId;
|
||||||
|
tint();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getBackgroundTintResId() {
|
||||||
|
return mBackgroundTintResId;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,11 +12,12 @@ import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
import com.huanchengfly.tieba.post.R;
|
import com.huanchengfly.tieba.post.R;
|
||||||
|
import com.huanchengfly.tieba.post.interfaces.BackgroundTintable;
|
||||||
import com.huanchengfly.tieba.post.ui.theme.interfaces.Tintable;
|
import com.huanchengfly.tieba.post.ui.theme.interfaces.Tintable;
|
||||||
import com.huanchengfly.tieba.post.ui.theme.utils.ThemeUtils;
|
import com.huanchengfly.tieba.post.ui.theme.utils.ThemeUtils;
|
||||||
|
|
||||||
@SuppressLint("CustomViewStyleable")
|
@SuppressLint("CustomViewStyleable")
|
||||||
public class TintRelativeLayout extends RelativeLayout implements Tintable {
|
public class TintRelativeLayout extends RelativeLayout implements Tintable, BackgroundTintable {
|
||||||
private int mBackgroundTintResId;
|
private int mBackgroundTintResId;
|
||||||
|
|
||||||
public TintRelativeLayout(@NonNull Context context) {
|
public TintRelativeLayout(@NonNull Context context) {
|
||||||
|
|
@ -63,4 +64,15 @@ public class TintRelativeLayout extends RelativeLayout implements Tintable {
|
||||||
super.setBackground(background);
|
super.setBackground(background);
|
||||||
applyTintColor();
|
applyTintColor();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setBackgroundTintResId(int resId) {
|
||||||
|
mBackgroundTintResId = resId;
|
||||||
|
tint();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getBackgroundTintResId() {
|
||||||
|
return mBackgroundTintResId;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue