春节主题:登录、主页面。
This commit is contained in:
@@ -315,9 +315,10 @@ open class Application : CommonAppContext() {
|
||||
private fun initLogUtils() {
|
||||
LogUtils.getConfig()
|
||||
.setLogSwitch(true) // 全局开关
|
||||
.setLogHeadSwitch(false)
|
||||
.setLog2FileSwitch(true) // 必须设为 true!
|
||||
.setDir(LOGUTILS_SAVE_PATH) // 设置有效路径
|
||||
.setFileFilter(LogUtils.V); // 允许所有级别
|
||||
.setDir(LOGUTILS_SAVE_PATH) // 设置有效路径
|
||||
.setFileFilter(LogUtils.V) // 允许所有级别
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.Color;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
@@ -111,37 +112,6 @@ public class MainActivity extends BaseMvpActivity<HomePresenter, ActivityMainBin
|
||||
private Fragment[] fragments;
|
||||
private AppUpdateDialog appUpdateDialog;
|
||||
|
||||
private boolean isMediaSelected = false;
|
||||
private int unselectedMediaUrl; // 从服务器获取
|
||||
private int selectedMediaUrl; // 从服务器获取
|
||||
|
||||
// 添加其他 tab 的图标 URL
|
||||
private int unselectedTrendUrl;
|
||||
private int selectedTrendUrl;
|
||||
private int unselectedNewsUrl;
|
||||
private int selectedNewsUrl;
|
||||
private int unselectedMeUrl;
|
||||
private int selectedMeUrl;
|
||||
|
||||
// 添加文字颜色变量
|
||||
private int selectedTextColor = 0; // 选中文字颜色 (从服务器获取)
|
||||
private int unselectedTextColor = 0; // 未选中文字颜色 (从服务器获取)
|
||||
// private String unselectedMediaUrl = ""; // 从服务器获取
|
||||
// private String selectedMediaUrl = ""; // 从服务器获取
|
||||
//
|
||||
// // 添加其他 tab 的图标 URL
|
||||
// private String unselectedTrendUrl = "";
|
||||
// private String selectedTrendUrl = "";
|
||||
// private String unselectedNewsUrl = "";
|
||||
// private String selectedNewsUrl = "";
|
||||
// private String unselectedMeUrl = "";
|
||||
// private String selectedMeUrl = "";
|
||||
//
|
||||
// // 添加文字颜色变量
|
||||
// private int selectedTextColor = 0; // 选中文字颜色 (从服务器获取)
|
||||
// private int unselectedTextColor = 0; // 未选中文字颜色 (从服务器获取)
|
||||
|
||||
private InviteDialog inviteDialog;
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
@@ -173,6 +143,20 @@ public class MainActivity extends BaseMvpActivity<HomePresenter, ActivityMainBin
|
||||
LogUtils.e("MainActivity", "onWindowFocusChanged:" + hasFocus);
|
||||
}
|
||||
|
||||
|
||||
private int getTabBg(){
|
||||
// 1. 定义需要获取的自定义属性数组
|
||||
int[] attrs = new int[]{com.xscm.moduleutil.R.attr.app_main_tab_bg};
|
||||
// 2. 从Context的Theme中获取TypedArray(核心:绑定当前主题的属性值)
|
||||
TypedArray ta = obtainStyledAttributes(attrs);
|
||||
// 3. 获取attr对应的资源ID,默认值0(无有效资源时返回0)
|
||||
int bgResId = ta.getResourceId(0, 0);
|
||||
// 4. 关键:手动回收TypedArray,释放系统资源,避免内存泄漏
|
||||
ta.recycle();
|
||||
// 5. 有有效资源ID时,设置背景
|
||||
return bgResId;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
@@ -356,13 +340,8 @@ public class MainActivity extends BaseMvpActivity<HomePresenter, ActivityMainBin
|
||||
// 初始化显示派对Tab
|
||||
reset();
|
||||
mBinding.rlMedia.setSelected(true);
|
||||
mBinding.llBottomBar.setBackgroundResource(com.xscm.moduleutil.R.drawable.home_bbar_xz);
|
||||
mBinding.llBottomBar.setBackgroundResource(getTabBg());
|
||||
FragmentUtils.showHide(0, fragments);
|
||||
index = 0;
|
||||
isMediaSelected = true; // 确保设置为选中状态
|
||||
selectedTextColor = ColorManager.getInstance().getPrimaryColorInt();
|
||||
unselectedTextColor = Color.parseColor("#6D6D6D");
|
||||
updateAllTabUI(); // 这会同时更新图标和文字颜色
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -384,7 +363,7 @@ public class MainActivity extends BaseMvpActivity<HomePresenter, ActivityMainBin
|
||||
public void onClick(View view) {
|
||||
int id = view.getId();
|
||||
if (id == R.id.rl_media) {
|
||||
mBinding.llBottomBar.setBackgroundResource(com.xscm.moduleutil.R.drawable.home_bbar_xz);
|
||||
mBinding.llBottomBar.setBackgroundResource(getTabBg());
|
||||
selectShow(0);
|
||||
} else if (id == R.id.rl_trend) {
|
||||
mBinding.llBottomBar.setBackgroundResource(com.xscm.moduleutil.R.drawable.home_bbar_yuan);
|
||||
@@ -395,7 +374,7 @@ public class MainActivity extends BaseMvpActivity<HomePresenter, ActivityMainBin
|
||||
|
||||
selectShow(2);
|
||||
} else if (id == R.id.rl_me) {
|
||||
mBinding.llBottomBar.setBackgroundResource(com.xscm.moduleutil.R.drawable.home_bbar_xz);
|
||||
mBinding.llBottomBar.setBackgroundResource(getTabBg());
|
||||
|
||||
selectShow(3);
|
||||
//C0101我的界面
|
||||
@@ -452,7 +431,6 @@ public class MainActivity extends BaseMvpActivity<HomePresenter, ActivityMainBin
|
||||
switch (postion) {
|
||||
case 0:
|
||||
mBinding.rlMedia.setSelected(true);
|
||||
isMediaSelected = true;
|
||||
break;
|
||||
case 1:
|
||||
mBinding.rlTrend.setSelected(true);
|
||||
@@ -465,35 +443,9 @@ public class MainActivity extends BaseMvpActivity<HomePresenter, ActivityMainBin
|
||||
mBinding.rlMe.setSelected(true);
|
||||
break;
|
||||
}
|
||||
// 更新所有图标状态
|
||||
updateMediaIcon();
|
||||
updateTrendIcon();
|
||||
updateNewsIcon();
|
||||
updateMeIcon();
|
||||
// 更新文字颜色
|
||||
updateTabTextColors();
|
||||
FragmentUtils.showHide(postion, fragments);
|
||||
}
|
||||
|
||||
private void updateMediaIcon() {
|
||||
int imageUrl = (index == 0) ? selectedMediaUrl : unselectedMediaUrl;
|
||||
mBinding.imSy.setImageResource(imageUrl);
|
||||
|
||||
|
||||
// if (!TextUtils.isEmpty(imageUrl)) {
|
||||
// Glide.with(this)
|
||||
// .load(imageUrl)
|
||||
// .placeholder(com.xscm.moduleutil.R.mipmap.tab_main_media_unselected) // 默认图标
|
||||
// .into(mBinding.imSy);
|
||||
// } else {
|
||||
// // 如果没有网络图标,使用默认的选中/未选中状态
|
||||
// int resId = (index == 0) ?
|
||||
// com.xscm.moduleutil.R.mipmap.tab_main_media_selected :
|
||||
// com.xscm.moduleutil.R.mipmap.tab_main_media_unselected;
|
||||
// mBinding.imTrend.setImageResource(resId);
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
private boolean shouldRestoreRoom() {
|
||||
// 检查是否应该恢复房间:
|
||||
@@ -869,43 +821,9 @@ public class MainActivity extends BaseMvpActivity<HomePresenter, ActivityMainBin
|
||||
@Override
|
||||
public void getThemeData(ThemeBean themeBean) {
|
||||
if (themeBean != null) {
|
||||
// 首页 tab 图标
|
||||
selectedMediaUrl = themeBean.getHome_sel();
|
||||
unselectedMediaUrl = themeBean.getHome_nor();
|
||||
|
||||
// 语圈 tab 图标
|
||||
selectedTrendUrl = themeBean.getFind_sel();
|
||||
unselectedTrendUrl = themeBean.getFind_nor();
|
||||
|
||||
// 消息 tab 图标
|
||||
selectedNewsUrl = themeBean.getMsg_sel();
|
||||
unselectedNewsUrl = themeBean.getMsg_nor();
|
||||
|
||||
// 我的 tab 图标
|
||||
selectedMeUrl = themeBean.getMine_sel();
|
||||
unselectedMeUrl = themeBean.getMine_nor();
|
||||
// 获取文字颜色
|
||||
try {
|
||||
if (themeBean.getBtn_text_color() != null && !themeBean.getBtn_text_color().isEmpty()) {
|
||||
if (CommonAppContext.getInstance().is_open == 1){
|
||||
selectedTextColor = Color.parseColor("#FF663B");
|
||||
}else {
|
||||
selectedTextColor = Color.parseColor(themeBean.getTheme_color());
|
||||
}
|
||||
}
|
||||
unselectedTextColor = Color.parseColor("#898989");
|
||||
} catch (Exception e) {
|
||||
// 使用默认颜色
|
||||
selectedTextColor = ColorManager.getInstance().getPrimaryColorInt();
|
||||
unselectedTextColor = Color.parseColor("#898989");
|
||||
}
|
||||
Map<String, String> colorMap = new HashMap<>();
|
||||
colorMap.put("theme_color", themeBean.getTheme_color());
|
||||
colorMap.put("btn_text_color", themeBean.getBtn_text_color());
|
||||
// 更新 UI
|
||||
updateAllTabUI();
|
||||
// if (themeBean.getApp_bg() != null) {
|
||||
BackgroundManager.getInstance().setBackgroundUrl(themeBean.getApp_bg());
|
||||
// BackgroundManager.getInstance().setBackgroundUrl(themeBean.getApp_bg());
|
||||
loadNetworkBackground();
|
||||
// }
|
||||
|
||||
@@ -1136,96 +1054,6 @@ public class MainActivity extends BaseMvpActivity<HomePresenter, ActivityMainBin
|
||||
});
|
||||
}
|
||||
|
||||
private void updateAllTabUI() {
|
||||
index = 0;
|
||||
// 更新图标
|
||||
updateMediaIcon();
|
||||
updateTrendIcon();
|
||||
updateNewsIcon();
|
||||
updateMeIcon();
|
||||
|
||||
// 更新文字
|
||||
updateTabTextColors();
|
||||
}
|
||||
|
||||
private void updateTrendIcon() {
|
||||
int imageUrl = (index == 1) ? selectedTrendUrl : unselectedTrendUrl;
|
||||
mBinding.imTrend.setImageResource(imageUrl);
|
||||
// if (!TextUtils.isEmpty(imageUrl)) {
|
||||
// Glide.with(this)
|
||||
// .load(imageUrl)
|
||||
// .placeholder(com.xscm.moduleutil.R.mipmap.icon_me_trend_unselect)
|
||||
// .into(mBinding.imTrend);
|
||||
// } else {
|
||||
// // 如果没有网络图标,使用默认的选中/未选中状态
|
||||
// int resId = (index == 1) ?
|
||||
// com.xscm.moduleutil.R.mipmap.icon_me_trend_select :
|
||||
// com.xscm.moduleutil.R.mipmap.icon_me_trend_unselect;
|
||||
// mBinding.imTrend.setImageResource(resId);
|
||||
// }
|
||||
}
|
||||
|
||||
private void updateNewsIcon() {
|
||||
int imageUrl = (index == 2) ? selectedNewsUrl : unselectedNewsUrl;
|
||||
mBinding.ivNews.setImageResource(imageUrl);
|
||||
// if (!TextUtils.isEmpty(imageUrl)) {
|
||||
// Glide.with(this)
|
||||
// .load(imageUrl)
|
||||
// .placeholder(com.xscm.moduleutil.R.mipmap.icon_news_un_select)
|
||||
// .into(mBinding.ivNews);
|
||||
// } else {
|
||||
// // 如果没有网络图标,使用默认的选中/未选中状态
|
||||
// int resId = (index == 2) ?
|
||||
// com.xscm.moduleutil.R.mipmap.icon_news_select :
|
||||
// com.xscm.moduleutil.R.mipmap.icon_news_un_select;
|
||||
// mBinding.ivNews.setImageResource(resId);
|
||||
// }
|
||||
}
|
||||
|
||||
private void updateMeIcon() {
|
||||
int imageUrl = (index == 3) ? selectedMeUrl : unselectedMeUrl;
|
||||
mBinding.imMe.setImageResource(imageUrl);
|
||||
// if (!TextUtils.isEmpty(imageUrl)) {
|
||||
// Glide.with(this)
|
||||
// .load(imageUrl)
|
||||
// .placeholder(com.xscm.moduleutil.R.mipmap.icon_my_un_select)
|
||||
// .into(mBinding.imMe);
|
||||
// } else {
|
||||
// // 如果没有网络图标,使用默认的选中/未选中状态
|
||||
// int resId = (index == 3) ?
|
||||
// com.xscm.moduleutil.R.mipmap.icon_my_select :
|
||||
// com.xscm.moduleutil.R.mipmap.icon_my_un_select;
|
||||
// mBinding.imMe.setImageResource(resId);
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
private void updateTabTextColors() {
|
||||
// 更新声播 tab 文字颜色
|
||||
if (selectedTextColor != 0 && unselectedTextColor != 0) {
|
||||
int mediaTextColor = (index == 0) ? selectedTextColor : unselectedTextColor;
|
||||
mBinding.tvMedia.setTextColor(mediaTextColor);
|
||||
}
|
||||
|
||||
// 更新语圈 tab 文字颜色
|
||||
if (selectedTextColor != 0 && unselectedTextColor != 0) {
|
||||
int trendTextColor = (index == 1) ? selectedTextColor : unselectedTextColor;
|
||||
mBinding.tvTrend.setTextColor(trendTextColor);
|
||||
}
|
||||
|
||||
// 更新消息 tab 文字颜色
|
||||
if (selectedTextColor != 0 && unselectedTextColor != 0) {
|
||||
int newsTextColor = (index == 2) ? selectedTextColor : unselectedTextColor;
|
||||
mBinding.tvNews.setTextColor(newsTextColor);
|
||||
}
|
||||
|
||||
// 更新我的 tab 文字颜色
|
||||
if (selectedTextColor != 0 && unselectedTextColor != 0) {
|
||||
int meTextColor = (index == 3) ? selectedTextColor : unselectedTextColor;
|
||||
mBinding.tvMe.setTextColor(meTextColor);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
public void isShowLoading(boolean isShow) {
|
||||
if (isShow) {
|
||||
|
||||
Reference in New Issue
Block a user