新增首页主播卡片

This commit is contained in:
huangjian
2022-08-01 17:04:27 +08:00
parent 5660fc4cbe
commit 60b910179c
16 changed files with 537 additions and 32 deletions

View File

@@ -6,6 +6,7 @@ import com.yizhuan.xchat_android_core.bean.response.ServiceResult
import com.yizhuan.xchat_android_core.community.CommunityConstant
import com.yizhuan.xchat_android_core.community.bean.UnReadCountInfo
import com.yizhuan.xchat_android_core.home.bean.*
import com.yizhuan.xchat_android_core.room.bean.AnchorInfo
import com.yizhuan.xchat_android_core.room.bean.HomeLiveTopInfo
import com.yizhuan.xchat_android_core.room.bean.MeCenterInfo
import com.yizhuan.xchat_android_core.room.bean.SingleRoomSortInfo
@@ -174,6 +175,11 @@ object HomeModel : BaseModel() {
api.getGameList()
}
suspend fun requestAnchorInfo(): AnchorInfo? =
launchRequest {
api.requestAnchorInfo()
}
private interface Api {
/**
@@ -367,6 +373,12 @@ object HomeModel : BaseModel() {
suspend fun getGameList(
): ServiceResult<List<GameInfo>>
/**
* @return
*/
@GET("user/get/userCard")
suspend fun requestAnchorInfo(): ServiceResult<AnchorInfo>
}
}

View File

@@ -51,6 +51,9 @@ public class DemoCache {
private static final String KEY_NEW_USER_CHARGE_GIFT = "key_new_user_charge_gift";
private static final String KEY_MAIN_TAB_DATA = "key_main_tab_data";
private static final String KEY_SPEEDY_MESSAGE_GONE_TIME = "SpeedyMessageGoneTime";
private static final String KEY_ANCHOR_CARD_VIEW = "key_anchor_card_view";
private static final String KEY_ANCHOR_CARD_VIEW_TIME = "key_anchor_card_view_time";
private static final String KEY_LAUNCH_COUNT = "key_launch_count";
private static StatusBarNotificationConfig notificationConfig;
public static Long readSpeedyMessageGoneTime() {
@@ -249,7 +252,7 @@ public class DemoCache {
SettingsPref.instance().putBoolean(KEY_NEW_USER_GIFT, value);
}
public static Boolean readNewUserGift() {
public static boolean readNewUserGift() {
return SettingsPref.instance().getBoolean(KEY_NEW_USER_GIFT, true);
}
@@ -264,5 +267,31 @@ public class DemoCache {
return SettingsPref.instance().getInt(KEY_NEW_USER_CHARGE_GIFT, 0);
}
/**
* @param value 0初始值 1 显示首次弹窗 2 非首次弹窗,需要判断时间再显示
*/
public static void saveAnchorCardView(int value) {
SettingsPref.instance().putInt(KEY_ANCHOR_CARD_VIEW, value);
if (value == 2) {
SettingsPref.instance().putLong(KEY_ANCHOR_CARD_VIEW_TIME, CurrentTimeUtils.getCurrentTime());
}
}
public static int readAnchorCardView() {
return SettingsPref.instance().getInt(KEY_ANCHOR_CARD_VIEW, 0);
}
public static long readAnchorCardViewTime() {
return SettingsPref.instance().getLong(KEY_ANCHOR_CARD_VIEW_TIME, 0);
}
public static void saveLaunchCount() {
SettingsPref.instance().putInt(KEY_LAUNCH_COUNT, readLaunchCount() + 1);
}
public static int readLaunchCount() {
return SettingsPref.instance().getInt(KEY_LAUNCH_COUNT, -1);
}
}

View File

@@ -115,6 +115,9 @@ public class InitialModel extends BaseModel implements IInitialModel {
*/
private int findNewbieCharmLevel;
@Nullable
private InitInfo cacheInitInfo;
private InitialModel() {
api = RxNet.create(Api.class);
loadMainTabInfoList();
@@ -201,6 +204,7 @@ public class InitialModel extends BaseModel implements IInitialModel {
private void cacheInitData(InitInfo initInfo) {
if (initInfo == null) return;
this.cacheInitInfo = initInfo;
DemoCache.saveInitInfo(initInfo);
// 更新时间
DemoCache.saveInitInfoSavingTime(System.currentTimeMillis());
@@ -230,7 +234,7 @@ public class InitialModel extends BaseModel implements IInitialModel {
}
// 兑换比率
if (initInfo != null && initInfo.getExchangeGoldRate() != 0) {
if (initInfo.getExchangeGoldRate() != 0) {
SharedPreferenceUtils.setExchangeGoldRate(initInfo.getExchangeGoldRate());
}
@@ -325,27 +329,7 @@ public class InitialModel extends BaseModel implements IInitialModel {
@Nullable
@Override
public InitInfo getCacheInitInfo() {
// 过期了
if (System.currentTimeMillis() - DemoCache.readInitInfoSavingTime() > TIME_EXPIRED)
return null;
// 没有缓存
InitInfo initInfo = DemoCache.readInitInfo();
if (initInfo == null) {
return null;
} else if (initInfo.getSplashVo() == null) {
return null;
}
// 图片是否存在
// String path = DemoCache.readSplashPicture();
// if (TextUtils.isEmpty(path)) {
// return null;
// } else {
// if (!new File(path).exists()) {
// downloadSplashPicture(path);
// return null;
// }
// }
return initInfo;
return cacheInitInfo == null ? DemoCache.readInitInfo() : cacheInitInfo;
}
/**

View File

@@ -0,0 +1,14 @@
package com.yizhuan.xchat_android_core.room.bean
import com.yizhuan.xchat_android_core.user.bean.UserInfoSkillEntity
data class AnchorInfo(
val absCardPics: List<String>? = null,
val avatar: String = "",
val erbanNo: Int = 0,
val gender: Int = 0,
val nick: String = "",
val signture: String = "",
val uid: Long = 0,
val voiceCard: UserInfoSkillEntity? = null
)