新增首页主播卡片
This commit is contained in:
@@ -14,7 +14,9 @@ import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.util.SparseArray;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewStub;
|
||||
import android.view.animation.LinearInterpolator;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
@@ -23,6 +25,7 @@ import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentTransaction;
|
||||
import androidx.lifecycle.Observer;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
|
||||
import com.netease.nim.uikit.StatusBarUtil;
|
||||
@@ -71,6 +74,7 @@ import com.yizhuan.erban.home.fragment.HomeFragment;
|
||||
import com.yizhuan.erban.home.fragment.MeFragment;
|
||||
import com.yizhuan.erban.home.presenter.MainPresenter;
|
||||
import com.yizhuan.erban.home.view.IMainView;
|
||||
import com.yizhuan.erban.home.widget.AnchorCardView;
|
||||
import com.yizhuan.erban.luckymoney.viewholder.LuckyMoneyMsgViewHolder;
|
||||
import com.yizhuan.erban.luckymoney.viewholder.LuckyMoneyTipsViewHolder;
|
||||
import com.yizhuan.erban.main.helper.NoticationsUiHelper;
|
||||
@@ -177,6 +181,7 @@ import com.yizhuan.xchat_android_core.pay.event.NewUserChargeEvent;
|
||||
import com.yizhuan.xchat_android_core.public_chat_hall.attachment.AitMeAttachment;
|
||||
import com.yizhuan.xchat_android_core.recall.bean.CheckLostUserInfo;
|
||||
import com.yizhuan.xchat_android_core.recall.event.CheckLostUserEvent;
|
||||
import com.yizhuan.xchat_android_core.room.bean.AnchorInfo;
|
||||
import com.yizhuan.xchat_android_core.room.bean.RoomInfo;
|
||||
import com.yizhuan.xchat_android_core.statistic.StatisticManager;
|
||||
import com.yizhuan.xchat_android_core.statistic.protocol.StatisticsProtocol;
|
||||
@@ -186,6 +191,7 @@ import com.yizhuan.xchat_android_core.user.event.LoadLoginUserInfoEvent;
|
||||
import com.yizhuan.xchat_android_core.user.event.LoginUserInfoUpdateEvent;
|
||||
import com.yizhuan.xchat_android_core.user.event.NeedBindPhoneEvent;
|
||||
import com.yizhuan.xchat_android_core.user.event.NeedCompleteInfoEvent;
|
||||
import com.yizhuan.xchat_android_core.utils.CurrentTimeUtils;
|
||||
import com.yizhuan.xchat_android_core.utils.SharedPreferenceUtils;
|
||||
import com.yizhuan.xchat_android_core.utils.StringUtils;
|
||||
import com.yizhuan.xchat_android_library.base.factory.CreatePresenter;
|
||||
@@ -226,6 +232,7 @@ public class MainActivity extends BaseMvpActivity<IMainView, MainPresenter>
|
||||
private LivingIconView userLivingView;
|
||||
private View viewClose;
|
||||
private MainTabLayout mMainTabLayout;
|
||||
private AnchorCardView anchorCardView;
|
||||
private int mCurrentTabType = MainTabType.TAB_TYPE_HOME;
|
||||
/**
|
||||
* 房间最小化动画,换成属性动画,原先的补间动画影响了activity的生命周期
|
||||
@@ -236,6 +243,7 @@ public class MainActivity extends BaseMvpActivity<IMainView, MainPresenter>
|
||||
*/
|
||||
private LimitEnterRoomHelper limitEnterRoomHelper;
|
||||
private HomeViewModel homeViewModel;
|
||||
private boolean mResumed = false;
|
||||
@Nullable
|
||||
private Fragment tempFragment = null;
|
||||
private ContactEventListener listener1 = new ContactEventListener() {
|
||||
@@ -266,6 +274,8 @@ public class MainActivity extends BaseMvpActivity<IMainView, MainPresenter>
|
||||
|
||||
}
|
||||
};
|
||||
@Nullable
|
||||
private Runnable touchRunnable;
|
||||
|
||||
{
|
||||
fragmentArray.put(MainTabType.TAB_TYPE_HOME, new HomeFragment());
|
||||
@@ -334,6 +344,12 @@ public class MainActivity extends BaseMvpActivity<IMainView, MainPresenter>
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(aLong -> EventBus.getDefault().post(new RefreshHomeDataEvent()));
|
||||
|
||||
homeViewModel.getAnchorInfoLiveData().observe(this, anchorInfo -> {
|
||||
if (anchorInfo != null) {
|
||||
anchorCardView.setAnchorInfo(anchorInfo);
|
||||
DemoCache.saveAnchorCardView(2);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void otherModelInit() {
|
||||
@@ -459,6 +475,7 @@ public class MainActivity extends BaseMvpActivity<IMainView, MainPresenter>
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
mResumed = true;
|
||||
if (avatarLayout.getVisibility() == View.VISIBLE) {
|
||||
userLivingView.start();
|
||||
}
|
||||
@@ -471,15 +488,48 @@ public class MainActivity extends BaseMvpActivity<IMainView, MainPresenter>
|
||||
DemoCache.saveNewUserChargeGift(2);
|
||||
}
|
||||
}
|
||||
checkShowAnchorCardView();
|
||||
}
|
||||
}
|
||||
|
||||
private void checkShowAnchorCardView() {
|
||||
if (touchRunnable != null && !mResumed) return;
|
||||
int anchorCardViewType = DemoCache.readAnchorCardView();
|
||||
if (anchorCardViewType == 2) {
|
||||
if (CurrentTimeUtils.getCurrentTime() - DemoCache.readAnchorCardViewTime() > 15 * 60 * 1000) {
|
||||
touchRunnable = () -> {
|
||||
touchRunnable = null;
|
||||
homeViewModel.requestAnchorInfo();
|
||||
};
|
||||
mMainTabLayout.postDelayed(touchRunnable, 5000);
|
||||
}
|
||||
} else if (anchorCardViewType == 1 || DemoCache.readLaunchCount() == 1) {
|
||||
homeViewModel.requestAnchorInfo();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
mResumed = false;
|
||||
if (avatarLayout.getVisibility() == View.VISIBLE) {
|
||||
userLivingView.stop();
|
||||
}
|
||||
mMainTabLayout.removeCallbacks(touchRunnable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onTouchEvent(MotionEvent event) {
|
||||
if (touchRunnable == null) return super.onTouchEvent(event);
|
||||
switch (event.getAction()) {
|
||||
case MotionEvent.ACTION_DOWN:
|
||||
mMainTabLayout.removeCallbacks(touchRunnable);
|
||||
break;
|
||||
case MotionEvent.ACTION_UP:
|
||||
mMainTabLayout.postDelayed(touchRunnable, 5000);
|
||||
break;
|
||||
}
|
||||
return super.onTouchEvent(event);
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
@@ -494,6 +544,7 @@ public class MainActivity extends BaseMvpActivity<IMainView, MainPresenter>
|
||||
llDragInfo = findViewById(R.id.ll_drag_info);
|
||||
userLivingView.setColor(Color.WHITE);
|
||||
mMainTabLayout.setOnTabClickListener(this);
|
||||
anchorCardView = findViewById(R.id.vs_anchor_card);
|
||||
}
|
||||
|
||||
|
||||
@@ -851,9 +902,10 @@ public class MainActivity extends BaseMvpActivity<IMainView, MainPresenter>
|
||||
EventBus.getDefault().post(new UnReadCountEvent(integer));
|
||||
}
|
||||
});
|
||||
|
||||
checkShowAnchorCardView();
|
||||
}
|
||||
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
private void checkProtocolUpdate() {
|
||||
UserModel.get()
|
||||
|
@@ -37,7 +37,6 @@ import com.coorchice.library.utils.LogUtils;
|
||||
import com.heytap.msp.push.HeytapPushManager;
|
||||
import com.hjq.toast.ToastUtils;
|
||||
import com.huawei.hms.support.common.ActivityMgr;
|
||||
import com.idlefish.flutterboost.FlutterBoost;
|
||||
import com.llew.huawei.verifier.LoadedApkHuaWei;
|
||||
import com.microquation.linkedme.android.LinkedME;
|
||||
import com.mob.MobSDK;
|
||||
@@ -249,6 +248,7 @@ public class XChatApplication extends Application {
|
||||
ToastUtils.init(application);
|
||||
|
||||
if (inMainProcess(context)) {
|
||||
DemoCache.saveLaunchCount();
|
||||
// 注册自定义推送消息处理,这个是可选项
|
||||
NIMPushClient.registerMixPushMessageHandler(new PushMessageHandler());
|
||||
|
||||
|
@@ -9,6 +9,7 @@ import com.yizhuan.xchat_android_core.home.bean.HomeRoomInfo
|
||||
import com.yizhuan.xchat_android_core.home.bean.HomeTagInfo
|
||||
import com.yizhuan.xchat_android_core.home.bean.ResourceInfo
|
||||
import com.yizhuan.xchat_android_core.home.model.HomeModel
|
||||
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.SingleRoomSortInfo
|
||||
import com.yizhuan.xchat_android_core.utils.toast
|
||||
@@ -61,6 +62,9 @@ class HomeViewModel : BaseViewModel() {
|
||||
private val _homeLiveTopInfoLiveData = MutableLiveData<HomeLiveTopInfo>()
|
||||
val homeLiveTopInfoLiveData: LiveData<HomeLiveTopInfo> = _homeLiveTopInfoLiveData
|
||||
|
||||
private val _anchorInfoLiveData = MutableLiveData<AnchorInfo>()
|
||||
val anchorInfoLiveData: LiveData<AnchorInfo> = _anchorInfoLiveData
|
||||
|
||||
fun getBannerInfo() {
|
||||
safeLaunch {
|
||||
_bannerLiveData.value = HomeModel.getHomeBanner("9")
|
||||
@@ -210,5 +214,16 @@ class HomeViewModel : BaseViewModel() {
|
||||
)
|
||||
}
|
||||
|
||||
fun requestAnchorInfo() {
|
||||
safeLaunch(
|
||||
onError = {
|
||||
_anchorInfoLiveData.value = null
|
||||
},
|
||||
block = {
|
||||
_anchorInfoLiveData.value = HomeModel.requestAnchorInfo()
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
}
|
@@ -7,7 +7,6 @@ import android.widget.TextView
|
||||
import androidx.databinding.DataBindingUtil
|
||||
import androidx.fragment.app.Fragment
|
||||
import com.yizhuan.erban.R
|
||||
import com.yizhuan.erban.avroom.adapter.RoomContributeListAdapter
|
||||
import com.yizhuan.erban.avroom.adapter.RoomVPAdapter
|
||||
import com.yizhuan.erban.base.BaseFragment
|
||||
import com.yizhuan.erban.databinding.FragmentHomeBinding
|
||||
@@ -15,18 +14,13 @@ import com.yizhuan.erban.home.adapter.MainMagicIndicatorAdapter
|
||||
import com.yizhuan.erban.home.helper.OpenRoomHelper
|
||||
import com.yizhuan.erban.ui.search.SearchActivity
|
||||
import com.yizhuan.erban.ui.webview.CommonWebViewActivity
|
||||
import com.yizhuan.erban.ui.widget.OnPageSelectedListener
|
||||
import com.yizhuan.erban.ui.widget.magicindicator.ViewPagerHelper
|
||||
import com.yizhuan.erban.ui.widget.magicindicator.buildins.commonnavigator.CommonNavigator
|
||||
import com.yizhuan.xchat_android_core.DemoCache
|
||||
import com.yizhuan.xchat_android_core.UriProvider
|
||||
import com.yizhuan.xchat_android_core.home.event.RefreshHomeDataEvent
|
||||
import com.yizhuan.xchat_android_core.statistic.StatisticManager
|
||||
import com.yizhuan.xchat_android_core.statistic.protocol.StatisticsProtocol
|
||||
import io.reactivex.Observable
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import java.util.*
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
/**
|
||||
* 大鹅开黑首页
|
||||
@@ -39,6 +33,10 @@ class HomeFragment : BaseFragment(), View.OnClickListener,
|
||||
R.id.iv_search -> {
|
||||
StatisticManager.Instance().onEvent(StatisticsProtocol.EVENT_SEARCH, "进入搜索页")
|
||||
SearchActivity.start(activity)
|
||||
//为啥触发条件这么恶心
|
||||
if (DemoCache.readAnchorCardView() == 0) {
|
||||
DemoCache.saveAnchorCardView(1)
|
||||
}
|
||||
}
|
||||
R.id.iv_ranking -> {
|
||||
StatisticManager.Instance()
|
||||
|
@@ -0,0 +1,235 @@
|
||||
package com.yizhuan.erban.home.widget
|
||||
|
||||
import android.animation.Animator
|
||||
import android.animation.AnimatorListenerAdapter
|
||||
import android.animation.ObjectAnimator
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.media.AudioAttributes
|
||||
import android.os.Build
|
||||
import android.os.SystemClock
|
||||
import android.os.Vibrator
|
||||
import android.text.TextUtils
|
||||
import android.util.AttributeSet
|
||||
import android.view.LayoutInflater
|
||||
import android.view.MotionEvent
|
||||
import android.widget.FrameLayout
|
||||
import android.widget.ImageView
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter
|
||||
import com.chad.library.adapter.base.BaseViewHolder
|
||||
import com.yizhuan.erban.R
|
||||
import com.yizhuan.erban.audio.helper.AudioPlayerHelper
|
||||
import com.yizhuan.erban.audio.helper.OnPlayListener
|
||||
import com.yizhuan.erban.avroom.activity.AVRoomActivity
|
||||
import com.yizhuan.erban.databinding.LayoutAnchorCardViewBinding
|
||||
import com.yizhuan.erban.ui.user.decorationsend.UserInfoSkillDecoration
|
||||
import com.yizhuan.erban.ui.utils.load
|
||||
import com.yizhuan.erban.ui.utils.loadAvatar
|
||||
import com.yizhuan.xchat_android_core.room.bean.AnchorInfo
|
||||
import com.yizhuan.xchat_android_core.user.bean.UserInfo
|
||||
import com.yizhuan.xchat_android_core.user.bean.UserInfoSkillEntity
|
||||
import com.yizhuan.xchat_android_library.utils.ListUtils
|
||||
import com.yizhuan.xchat_android_library.utils.SingleToastUtil
|
||||
import io.reactivex.Observable
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.disposables.Disposable
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
class AnchorCardView @JvmOverloads constructor(
|
||||
context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0
|
||||
) : FrameLayout(context, attrs, defStyleAttr) {
|
||||
|
||||
private lateinit var binding: LayoutAnchorCardViewBinding
|
||||
private var disposable: Disposable? = null
|
||||
private var downY = 0f
|
||||
private var audioPlaying = false
|
||||
private var anchorInfo: AnchorInfo? = null
|
||||
private var mVibrator: Vibrator? = null
|
||||
private val patter = longArrayOf(0, 1000, 2500)
|
||||
private var count: Long = 10
|
||||
|
||||
private fun initView() {
|
||||
if (!this::binding.isInitialized) {
|
||||
mVibrator = context.getSystemService(Context.VIBRATOR_SERVICE) as Vibrator?
|
||||
binding = LayoutAnchorCardViewBinding.inflate(LayoutInflater.from(context))
|
||||
addView(
|
||||
binding.root,
|
||||
LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)
|
||||
)
|
||||
binding.recyclerviewSkillCard.adapter = object :
|
||||
BaseQuickAdapter<String, BaseViewHolder>(R.layout.item_userinfo_skill_abspicture) {
|
||||
override fun convert(helper: BaseViewHolder, item: String) {
|
||||
helper.getView<ImageView>(R.id.iv_skill_picture).load(item)
|
||||
}
|
||||
}
|
||||
binding.recyclerviewSkillCard.layoutManager = LinearLayoutManager(
|
||||
context,
|
||||
LinearLayoutManager.HORIZONTAL,
|
||||
false
|
||||
)
|
||||
binding.recyclerviewSkillCard.addItemDecoration(UserInfoSkillDecoration(context, 4))
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private fun setupData() {
|
||||
initView()
|
||||
startVibrate()
|
||||
isVisible = true
|
||||
anchorInfo?.let {
|
||||
(binding.recyclerviewSkillCard.adapter as BaseQuickAdapter<String, BaseViewHolder>).setNewData(
|
||||
it.absCardPics
|
||||
)
|
||||
initVoiceShow(it.voiceCard)
|
||||
binding.ivAvatar.loadAvatar(it.avatar)
|
||||
binding.tvNick.text = it.nick
|
||||
binding.tvSignature.text = it.signture
|
||||
if (it.gender == UserInfo.GENDER_MALE) {
|
||||
binding.ivGender.setImageResource(R.drawable.ic_gender_male)
|
||||
} else {
|
||||
binding.ivGender.setImageResource(R.drawable.ic_gender_female)
|
||||
}
|
||||
binding.tvGoRoom.setOnClickListener { _ ->
|
||||
AVRoomActivity.start(context, it.uid)
|
||||
}
|
||||
intervalRange()
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
private fun intervalRange() {
|
||||
disposable?.dispose()
|
||||
disposable = Observable.intervalRange(0, count + 1, 0, 1, TimeUnit.SECONDS)
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.doOnNext { aLong ->
|
||||
count -= 1
|
||||
binding.tvTime.text = "剩余${10 - aLong}s"
|
||||
}
|
||||
.doOnComplete {
|
||||
if (!audioPlaying) isVisible = false
|
||||
}
|
||||
.subscribe()
|
||||
}
|
||||
|
||||
override fun onDetachedFromWindow() {
|
||||
super.onDetachedFromWindow()
|
||||
disposable?.dispose()
|
||||
}
|
||||
|
||||
override fun onTouchEvent(event: MotionEvent): Boolean {
|
||||
when (event.action) {
|
||||
MotionEvent.ACTION_DOWN -> downY = event.rawY
|
||||
MotionEvent.ACTION_MOVE -> {
|
||||
if (event.rawY - downY < 0) {
|
||||
translationY = event.rawY - downY
|
||||
}
|
||||
}
|
||||
MotionEvent.ACTION_UP -> {
|
||||
val offset = event.rawY - downY
|
||||
when {
|
||||
offset < -height / 2 -> {
|
||||
val end = -height.toFloat()
|
||||
startAnimator(translationY, end) {
|
||||
stopAudio()
|
||||
isVisible = false
|
||||
}
|
||||
}
|
||||
else -> {
|
||||
startAnimator(translationY, 0f) {}
|
||||
translationY = 0f
|
||||
}
|
||||
}
|
||||
}
|
||||
else -> {
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
private fun startAnimator(start: Float, end: Float, onAnimationEnd: () -> Unit) {
|
||||
val slowdownAnim = ObjectAnimator.ofFloat(this, "TranslationY", start, end)
|
||||
slowdownAnim.duration = 200
|
||||
slowdownAnim.addListener(object : AnimatorListenerAdapter() {
|
||||
override fun onAnimationEnd(animation: Animator) {
|
||||
onAnimationEnd()
|
||||
}
|
||||
})
|
||||
slowdownAnim.start()
|
||||
}
|
||||
|
||||
private fun initVoiceShow(skillEntity: UserInfoSkillEntity?) {
|
||||
if (skillEntity != null) {
|
||||
binding.llAudio.visibility = VISIBLE
|
||||
binding.livUser.stop()
|
||||
binding.llAudio.setOnClickListener { toggleAudio(skillEntity.propVals) }
|
||||
} else {
|
||||
binding.llAudio.visibility = GONE
|
||||
}
|
||||
}
|
||||
|
||||
private fun toggleAudio(list: List<String?>) {
|
||||
if (ListUtils.isListEmpty(list)) return
|
||||
var url: String? = ""
|
||||
for (s in list) {
|
||||
if (s!!.contains("http")) {
|
||||
url = s
|
||||
}
|
||||
}
|
||||
if (TextUtils.isEmpty(url)) return
|
||||
if (!audioPlaying) {
|
||||
playAudio(url)
|
||||
} else {
|
||||
stopAudio()
|
||||
}
|
||||
}
|
||||
|
||||
private fun playAudio(url: String?) {
|
||||
if (audioPlaying) return
|
||||
disposable?.dispose()
|
||||
audioPlaying = true
|
||||
binding.livUser.start()
|
||||
binding.ivAudioControl.setImageResource(R.drawable.ic_skill_play)
|
||||
AudioPlayerHelper.get().playInThread(url, object : OnPlayListener {
|
||||
override fun onError(error: String) {
|
||||
SingleToastUtil.showToast("播放出错,请重试")
|
||||
stopAudio()
|
||||
}
|
||||
|
||||
override fun onPrepared() {}
|
||||
override fun onPlaying(currDuration: Long) {}
|
||||
override fun onCompletion() {
|
||||
stopAudio()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
private fun stopAudio() {
|
||||
if (!audioPlaying) return
|
||||
intervalRange()
|
||||
audioPlaying = false
|
||||
binding.livUser.stop()
|
||||
binding.ivAudioControl.setImageResource(R.drawable.ic_skill_pause)
|
||||
AudioPlayerHelper.get().endPlay()
|
||||
}
|
||||
|
||||
fun setAnchorInfo(anchorInfo: AnchorInfo) {
|
||||
this.anchorInfo = anchorInfo
|
||||
setupData()
|
||||
}
|
||||
|
||||
private fun startVibrate() {
|
||||
if (mVibrator == null) {
|
||||
mVibrator = context.getSystemService(Context.VIBRATOR_SERVICE) as Vibrator?
|
||||
}
|
||||
mVibrator?.cancel()
|
||||
val audioAttributes = AudioAttributes.Builder()
|
||||
.setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION)
|
||||
.setUsage(AudioAttributes.USAGE_ALARM)
|
||||
.build()
|
||||
mVibrator?.vibrate(patter, -1, audioAttributes)
|
||||
|
||||
}
|
||||
|
||||
}
|
@@ -114,6 +114,7 @@ public class PmDialogShowMrg {
|
||||
//如果弱引导,并且该uid已经存在缓存中,说明弹过一次,则不用再弹窗
|
||||
if (InitialModel.get().getTeenagerMode() == 2) {
|
||||
if (map.containsKey(currUid)) {
|
||||
hasShow = true;
|
||||
return;
|
||||
}
|
||||
show(context);
|
||||
@@ -127,6 +128,7 @@ public class PmDialogShowMrg {
|
||||
}
|
||||
}
|
||||
if (!TimeUtils.isTomorrow(currUidTime)) {
|
||||
hasShow = true;
|
||||
return;
|
||||
}
|
||||
show(context);
|
||||
|
BIN
app/src/main/res/drawable-xhdpi/bg_anchor_card.png
Normal file
BIN
app/src/main/res/drawable-xhdpi/bg_anchor_card.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 33 KiB |
10
app/src/main/res/drawable/shape_anchor_card_time.xml
Normal file
10
app/src/main/res/drawable/shape_anchor_card_time.xml
Normal file
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
<solid android:color="@color/white" />
|
||||
<corners
|
||||
android:bottomLeftRadius="10dp"
|
||||
android:bottomRightRadius="0dp"
|
||||
android:topLeftRadius="0dp"
|
||||
android:topRightRadius="8dp" />
|
||||
</shape>
|
@@ -112,8 +112,21 @@
|
||||
android:src="@drawable/ic_room_main_entrance_close" />
|
||||
|
||||
</com.yizhuan.erban.common.widget.DragLayout>
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
<com.yizhuan.erban.home.widget.AnchorCardView
|
||||
android:id="@+id/vs_anchor_card"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginTop="42dp"
|
||||
android:layout="@layout/layout_vs_anchor_card_view"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintDimensionRatio="750:220"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
|
||||
|
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<ImageView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/iv_skill_picture"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="@dimen/dp_14" />
|
130
app/src/main/res/layout/layout_anchor_card_view.xml
Normal file
130
app/src/main/res/layout/layout_anchor_card_view.xml
Normal file
@@ -0,0 +1,130 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<View
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:background="@drawable/bg_anchor_card"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintDimensionRatio="750:220"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_avatar"
|
||||
android:layout_width="66dp"
|
||||
android:layout_height="66dp"
|
||||
android:layout_marginStart="20dp"
|
||||
android:layout_marginTop="15dp"
|
||||
android:src="@drawable/default_avatar"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_gender"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/ic_gender_female"
|
||||
app:layout_constraintBottom_toBottomOf="@id/iv_avatar"
|
||||
app:layout_constraintEnd_toEndOf="@id/iv_avatar" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_nick"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="8dp"
|
||||
android:textColor="@color/color_333333"
|
||||
android:textSize="14sp"
|
||||
app:layout_constraintStart_toEndOf="@id/iv_avatar"
|
||||
app:layout_constraintTop_toTopOf="@id/iv_avatar"
|
||||
app:layout_constraintVertical_chainStyle="packed"
|
||||
tools:text="用户名字七个字" />
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/recyclerview_skill_card"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="14dp"
|
||||
android:layout_marginLeft="12dp"
|
||||
android:layout_marginRight="12dp"
|
||||
app:layout_constraintBottom_toBottomOf="@id/tv_nick"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@id/tv_nick"
|
||||
app:layout_constraintTop_toTopOf="@id/tv_nick" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_signature"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="@color/color_999999"
|
||||
android:textSize="12sp"
|
||||
app:layout_constraintBottom_toTopOf="@id/ll_audio"
|
||||
app:layout_constraintStart_toStartOf="@id/tv_nick"
|
||||
app:layout_constraintTop_toBottomOf="@id/tv_nick"
|
||||
tools:text="用户签名,就这样吧巴啦啦…" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/ll_audio"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintBottom_toBottomOf="@id/iv_avatar"
|
||||
app:layout_constraintStart_toStartOf="@id/tv_nick"
|
||||
app:layout_constraintTop_toBottomOf="@id/tv_signature"
|
||||
tools:visibility="visible">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_audio_control"
|
||||
android:layout_width="@dimen/dp_18"
|
||||
android:layout_height="@dimen/dp_18"
|
||||
android:src="@drawable/ic_skill_pause" />
|
||||
|
||||
<com.yizhuan.erban.ui.widget.LivingIconView
|
||||
android:id="@+id/liv_user"
|
||||
android:layout_width="60dp"
|
||||
android:layout_height="20dp"
|
||||
android:layout_marginLeft="@dimen/dp_6"
|
||||
android:background="@color/transparent"
|
||||
android:scaleType="fitXY"
|
||||
app:cus_dp_height="20dp"
|
||||
app:cus_dp_width="60dp"
|
||||
app:cus_drawable="@drawable/skill_audio_animation" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_go_room"
|
||||
android:layout_width="79dp"
|
||||
android:layout_height="24dp"
|
||||
android:layout_marginEnd="20dp"
|
||||
android:background="@drawable/bg_common_confirm"
|
||||
android:gravity="center"
|
||||
android:includeFontPadding="false"
|
||||
android:text="进入房间"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="12sp"
|
||||
app:layout_constraintBottom_toBottomOf="@id/iv_avatar"
|
||||
app:layout_constraintEnd_toEndOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_time"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="20dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:background="@drawable/shape_anchor_card_time"
|
||||
android:gravity="center"
|
||||
android:includeFontPadding="false"
|
||||
android:textColor="@color/color_999999"
|
||||
android:textSize="10sp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:text="剩余7s" />
|
||||
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
6
app/src/main/res/layout/layout_vs_anchor_card_view.xml
Normal file
6
app/src/main/res/layout/layout_vs_anchor_card_view.xml
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<com.yizhuan.erban.home.widget.AnchorCardView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
|
@@ -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>
|
||||
}
|
||||
|
||||
}
|
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -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
|
||||
)
|
Reference in New Issue
Block a user