1:添加元旦主题,添加新的接口
This commit is contained in:
@@ -103,7 +103,7 @@ public abstract class BaseAppCompatActivity<VDB extends ViewDataBinding> extends
|
||||
// 注册背景更新监听器
|
||||
BackgroundManager.getInstance().addListener(this);
|
||||
// 尝试加载网络背景
|
||||
loadNetworkBackground();
|
||||
// loadNetworkBackground();
|
||||
// 注册颜色变化监听器
|
||||
ColorManager.getInstance().addColorChangeListener(this);
|
||||
|
||||
@@ -179,28 +179,37 @@ public abstract class BaseAppCompatActivity<VDB extends ViewDataBinding> extends
|
||||
|
||||
protected void loadNetworkBackground() {
|
||||
// 只有当已经有背景URL时才加载
|
||||
String backgroundUrl = BackgroundManager.getInstance().getBackgroundUrl();
|
||||
if (backgroundUrl != null && !backgroundUrl.isEmpty()) {
|
||||
// 检查是否有已加载的drawable
|
||||
Drawable cachedDrawable = BackgroundManager.getInstance().getBackgroundDrawable();
|
||||
if (cachedDrawable != null) {
|
||||
getWindow().getDecorView().setBackground(cachedDrawable);
|
||||
} else {
|
||||
// 加载网络背景
|
||||
BackgroundManager.getInstance().loadBackgroundDrawable(this, new BackgroundManager.BackgroundLoadCallback() {
|
||||
@Override
|
||||
public void onLoadSuccess(Drawable drawable) {
|
||||
getWindow().getDecorView().setBackground(drawable);
|
||||
}
|
||||
int backgroundUrl = BackgroundManager.getInstance().getBackgroundUrl();
|
||||
getWindow().getDecorView().setBackgroundResource(backgroundUrl);
|
||||
|
||||
@Override
|
||||
public void onLoadFailed() {
|
||||
// 加载失败时使用默认背景
|
||||
getWindow().getDecorView().setBackgroundResource(R.mipmap.activity_bj);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// String backgroundUrl = BackgroundManager.getInstance().getBackgroundUrl();
|
||||
// if (backgroundUrl != null && !backgroundUrl.isEmpty()) {
|
||||
// // 检查是否有已加载的drawable
|
||||
// Drawable cachedDrawable = BackgroundManager.getInstance().getBackgroundDrawable();
|
||||
// if (cachedDrawable != null) {
|
||||
// getWindow().getDecorView().setBackground(cachedDrawable);
|
||||
// } else {
|
||||
// // 加载网络背景
|
||||
// BackgroundManager.getInstance().loadBackgroundDrawable(this, new BackgroundManager.BackgroundLoadCallback() {
|
||||
// @Override
|
||||
// public void onLoadSuccess(Drawable drawable) {
|
||||
// getWindow().getDecorView().setBackground(drawable);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onLoadFailed() {
|
||||
// // 加载失败时使用默认背景
|
||||
// getWindow().getDecorView().setBackgroundResource(R.mipmap.activity_bj);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onLoadComplete(int resultId) {
|
||||
//
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -213,7 +222,7 @@ public abstract class BaseAppCompatActivity<VDB extends ViewDataBinding> extends
|
||||
|
||||
// 提供一个方法供子类调用,用于设置背景URL
|
||||
protected void setNetworkBackgroundUrl(String url) {
|
||||
BackgroundManager.getInstance().setBackgroundUrl(url);
|
||||
// BackgroundManager.getInstance().setBackgroundUrl(url);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user