Compare commits

...

51 Commits

Author SHA1 Message Date
max
e30f4fd15f feat: 更正 tabbar size 2024-08-30 20:57:09 +08:00
max
90ece5366b feat: 更新数据明文处理 2024-08-30 20:54:13 +08:00
max
555b81589c feat: 修正 en 语言的部分 UI 2024-08-30 16:15:31 +08:00
max
e4cdc39ad8 feat: 修正反饋問題 2024-08-30 15:54:20 +08:00
max
09411df1ff feat:UI 調整 2024-08-29 19:21:07 +08:00
max
9cbc6cf39f fix: 修正 VIP 購買選項 model 2024-08-29 18:19:44 +08:00
max
444d043aa8 feat: 修改聯繫人列表 UI 2024-08-29 17:06:40 +08:00
max
f99d193598 feat: 修改信息列表 UI 2024-08-29 16:42:24 +08:00
max
4a57bd50c5 feat:UI 調整 2024-08-29 12:00:28 +08:00
eggmanQQQ
8a59f8a769 feat: 调整 RTL 布局 UI 2024-08-29 11:59:28 +08:00
max
2c1ecbb263 feat:UI 調整 2024-08-28 21:41:19 +08:00
max
aa2987cb0d feat:修正問題 2024-08-28 21:40:15 +08:00
eggmanQQQ
5e6864d87f feat: 更新 UI 2024-08-28 21:39:59 +08:00
eggmanQQQ
6aabeb3eb3 feat: 更新 UI 2024-08-28 17:36:16 +08:00
eggmanQQQ
9ff48bc500 feat: 移除资源,补充多语言 2024-08-28 13:55:59 +08:00
max
e9ba0b1929 feat:調整 VIP 顯示邏輯,移除公聊廳 2024-08-28 13:55:12 +08:00
max
adf2adc173 feat:調整 VIP 顯示邏輯,移除公聊廳 2024-08-27 16:51:46 +08:00
max
74b2d71821 調試 UI 2024-08-27 16:51:46 +08:00
eggmanQQQ
81a5c6ba65 feat: 補充卡片背景,補充 VIP 資源播放 MP4 的功能 2024-08-27 16:31:44 +08:00
eggmanQQQ
5f8a8113c6 feat:个人资料卡支持 MP4 资源 2024-08-27 11:53:49 +08:00
eggmanQQQ
b0bf9ce98d feat: 调整文案 2024-08-27 11:24:32 +08:00
eggmanQQQ
c3fcbc3942 feat: 更新资源,调整布局 2024-08-27 10:33:34 +08:00
max
6e08f397ee fix:Vip 頁面支持 MP4 播放,修正佈局問題 2024-08-26 16:58:19 +08:00
eggmanQQQ
3d29568b3c feat: 更新 VIP 页面 UI & 功能 2024-08-26 09:13:28 +08:00
eggmanQQQ
cb4dac8e81 feat: 更新 VIP 页面 UI & 功能 2024-08-23 19:29:38 +08:00
eggmanQQQ
f58701a2d6 version update 2024-08-20 10:53:52 +08:00
max
654bc45c8c fix:修正信息 tag 列表項阿語環境在 Android 低版本時佈局異常問題 2024-08-13 18:35:23 +08:00
max
87a36d796c Version Update 2024-08-13 18:19:19 +08:00
eggmanQQQ
0bc1023c99 fix: 修正用户访问失败时的返回处理 2024-08-06 19:27:00 +08:00
max
154e688673 version code update 2024-08-06 11:20:31 +08:00
max
a91dee592d fix:補充查找禮物的類型 2024-08-05 21:42:47 +08:00
eggmanQQQ
7ef78bc3e1 fix: 調整多語言時,點擊 tab 的移動判斷 2024-08-05 19:22:44 +08:00
eggmanQQQ
b5bcd9cb5f fix: 調整多語言時,禮物面板 tab 的默認方向 2024-08-05 19:06:08 +08:00
max
de7eb25045 feat:隱藏超級幸運禮物標記 2024-08-05 18:57:18 +08:00
eggmanQQQ
029b7fcf96 feat: 完成礼物面板调整 2024-08-05 16:39:41 +08:00
eggmanQQQ
23a3858a2c feat: "我的" 列表支持跳转至“我的装扮” 2024-08-02 10:32:49 +08:00
eggmanQQQ
67044ded6b fix:修正个播房玩法入口布局 2024-08-01 17:57:01 +08:00
eggmanQQQ
3e6d34a986 fix:修正个播房玩法入口布局 2024-07-31 18:48:14 +08:00
max
e7ca237a3e fix:修正個播房遊戲玩法入口的顯示問題 2024-07-31 17:51:20 +08:00
max
e26d548515 version_code update 2024-07-29 10:24:14 +08:00
eggmanQQQ
539be23e47 feat:调整配置入口按钮间距 2024-07-26 16:56:52 +08:00
eggmanQQQ
dcafb35e24 feat:调整配置入口按钮显示逻辑 2024-07-26 15:35:02 +08:00
eggmanQQQ
8fa429aca6 feat:更新数据的获取逻辑,接入配置按钮的跳转行为 2024-07-26 11:31:15 +08:00
max
f08b6d4577 新增 model 2024-07-25 22:28:54 +08:00
max
3ea7aecd5c feat:處理底部按鈕顯示邏輯 2024-07-25 18:31:50 +08:00
eggmanQQQ
178f4e24ef 更换资源 2024-07-25 16:12:07 +08:00
max
e2861459fb feat:玩法列表支持最多 3 行並滾動 2024-07-25 15:14:08 +08:00
eggmanQQQ
d704a44106 feat:更新玩法按鈕以及顯示內容 2024-07-24 20:08:03 +08:00
max
da81a4e905 feat:更新房間底部 layout 2024-07-24 14:54:41 +08:00
max
6c081d9a38 fix:修正英語翻譯 2024-07-24 12:13:56 +08:00
max
37d897035f feat:固化混淆配置 2024-07-12 19:07:32 +08:00
206 changed files with 2656 additions and 2302 deletions

View File

@@ -205,6 +205,7 @@ dependencies {
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.2'
api 'androidx.multidex:multidex:2.0.1'
implementation 'androidx.gridlayout:gridlayout:1.0.0'
debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.9.1'
@@ -270,6 +271,8 @@ dependencies {
//wheelView
implementation 'com.contrarywind:wheelview:4.1.0'
// 轮播组件
implementation 'io.github.youth5201314:banner:2.2.3'
implementation project(':modules:module_base')
if (!isolationMode && file("../modules/module_google/build.gradle").exists()) {

View File

@@ -733,8 +733,8 @@
android:name=".ui.setting.PermissionGuideActivity"
android:screenOrientation="portrait" />
<activity
android:name=".vip.VipMainActivity"
android:screenOrientation="portrait" /> <!-- 隐私设置 -->
android:name=".vip.VipCenterActivity"
android:screenOrientation="portrait" />
<activity
android:name=".vip.VipSettingActivity"
android:screenOrientation="portrait" /> <!-- 通知提醒设置 -->

View File

@@ -47,8 +47,7 @@ public abstract class BottomViewListenerWrapper {
}
public void onRoomGameplayClick(){
public void onRoomGameplayClick(boolean isOnlyPK){
}
}

View File

@@ -11,6 +11,7 @@ import androidx.lifecycle.Lifecycle
import androidx.lifecycle.LifecycleEventObserver
import androidx.lifecycle.LifecycleObserver
import androidx.lifecycle.LifecycleOwner
import androidx.recyclerview.widget.RecyclerView
import com.chwl.app.R
import com.chwl.app.avroom.adapter.RoomGameListAdapter
import com.chwl.app.base.BaseActivity
@@ -38,7 +39,7 @@ class RoomGameListDialog :
private var compositeDisposable: CompositeDisposable? = null
private val adapter = RoomGameListAdapter()
private var dialogManager: DialogManager? = null
private lateinit var recycleView: RecyclerView
override fun getTheme(): Int {
return R.style.ErbanBottomSheetDialogDimFalse
}
@@ -61,6 +62,8 @@ class RoomGameListDialog :
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
initView()
val recyclerView: RecyclerView = view.findViewById(R.id.recyclerView)
recycleView = recyclerView
switchStatus(0)
requestData()
}
@@ -89,6 +92,14 @@ class RoomGameListDialog :
binding?.recyclerView?.adapter = adapter
}
private fun updateDialogHeight(count: Int) {
if (count > 10) {
val layoutParams = recycleView.layoutParams
layoutParams.height = 600
recycleView.layoutParams = layoutParams
}
}
private fun requestData() {
val dataService =
AudioRoomContext.get()
@@ -96,6 +107,7 @@ class RoomGameListDialog :
val cacheKey = "game_list#${parentFragment.hashCode()}"
val list = dataService?.getData(cacheKey) as? List<GameInfo>
if (!list.isNullOrEmpty()) {
updateDialogHeight(list.size)
loadData(list)
return
}
@@ -106,6 +118,7 @@ class RoomGameListDialog :
}
.subscribe { it: List<GameInfo> ->
dataService?.putData(cacheKey, it)
updateDialogHeight(it.size)
loadData(it)
}
getCompositeDisposable().add(disposable)

View File

@@ -10,6 +10,8 @@ import androidx.core.view.isVisible
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.LifecycleEventObserver
import androidx.lifecycle.LifecycleOwner
import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.chwl.app.R
import com.chwl.app.avroom.activity.CreatePKActivity
import com.chwl.app.avroom.adapter.RoomGameplayAdapter
@@ -39,8 +41,11 @@ import com.google.android.material.bottomsheet.BottomSheetDialogFragment
import com.google.gson.Gson
import io.reactivex.disposables.CompositeDisposable
class RoomGameplayDialog :
BottomSheetDialogFragment() {
class RoomGameplayDialog : BottomSheetDialogFragment() {
var isOnlyPK = false
private lateinit var recycleView: RecyclerView
private var binding: RoomGameplayDialogBinding? = null
private var compositeDisposable: CompositeDisposable? = null
private val adapter = RoomGameplayAdapter()
@@ -69,6 +74,10 @@ class RoomGameplayDialog :
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
initView()
val recyclerView: RecyclerView = view.findViewById(R.id.recyclerView)
recycleView = recyclerView
switchStatus(0)
requestData()
}
@@ -97,28 +106,46 @@ class RoomGameplayDialog :
}
private fun requestData() {
val dataService =
AudioRoomContext.get()
?.findAbility<RoomDataService>(RoomDataService::class.java.simpleName)
val cacheKey = "gameplay_list#${parentFragment.hashCode()}"
val list = dataService?.getData(cacheKey) as? List<RoomIcon>
if (!list.isNullOrEmpty()) {
loadSuccess(list)
return
if (isOnlyPK) {
loadSuccess(arrayListOf())
} else {
val dataService =
AudioRoomContext.get()
?.findAbility<RoomDataService>(RoomDataService::class.java.simpleName)
val cacheKey = "gameplay_list#${parentFragment.hashCode()}"
val list = dataService?.getData(cacheKey) as? List<RoomIcon>
if (!list.isNullOrEmpty()) {
updateDialogHeight(list.size)
loadSuccess(list)
return
}
val disposable = AvRoomModel.get().roomGamePlayList
.doOnError {
loadFail(it)
}
.subscribe { it: List<RoomIcon> ->
dataService?.putData(cacheKey, it)
updateDialogHeight(it.size)
loadSuccess(it)
}
getCompositeDisposable().add(disposable)
}
}
private fun updateDialogHeight(count: Int) {
if (count > 10) {
val layoutParams = recycleView.layoutParams
layoutParams.height = 600
recycleView.layoutParams = layoutParams
}
val disposable = AvRoomModel.get().roomGamePlayList
.doOnError {
loadFail(it)
}
.subscribe { it: List<RoomIcon> ->
dataService?.putData(cacheKey, it)
loadSuccess(it)
}
getCompositeDisposable().add(disposable)
}
private fun loadSuccess(list: List<RoomIcon>?) {
val finalList = getLocalList()
var finalList = mutableListOf<RoomGameplayItem>()
if (isOnlyPK) {
finalList = getLocalList()
}
list?.let {
finalList.addAll(list.map {
RoomGameplayItem.RoomIconItem(it) { dialog, item ->

View File

@@ -48,7 +48,6 @@ import com.chwl.app.avroom.dialog.RoomGameListDialog
import com.chwl.app.avroom.dialog.RoomGameplayDialog
import com.chwl.app.avroom.dialog.RoomOperationDialog
import com.chwl.app.avroom.presenter.BaseRoomPresenter
import com.chwl.app.avroom.public_chat.PublicChatRoomMessageWidget
import com.chwl.app.avroom.room_album.RoomAlbumModel
import com.chwl.app.avroom.view.IBaseRoomView
import com.chwl.app.avroom.widget.BottomView
@@ -63,6 +62,7 @@ import com.chwl.app.music.widget.MusicPlayerView
import com.chwl.app.public_chat.ui.message.HeadlineViewModel
import com.chwl.app.room_chat.activity.RoomMsgActivity
import com.chwl.app.ui.pay.ChargeActivity
import com.chwl.app.ui.webview.CommonWebViewActivity
import com.chwl.app.ui.webview.DialogWebViewActivity
import com.chwl.app.ui.widget.ButtonItem
import com.chwl.app.ui.widget.GiftDialog
@@ -98,6 +98,8 @@ import com.chwl.core.manager.RoomEvent
import com.chwl.core.mentoring_relationship.event.MentoringStopCountingEvent
import com.chwl.core.room.anotherroompk.ShowGiftDialogEvent
import com.chwl.core.room.anotherroompk.ShowUserInfoDialogEvent
import com.chwl.core.room.bean.RightBottomIconConfig
import com.chwl.core.room.bean.RoomIcon
import com.chwl.core.room.bean.RoomInfo
import com.chwl.core.room.event.RoomAtEvent
import com.chwl.core.room.event.RoomClearScreenEvent
@@ -122,6 +124,7 @@ import com.chwl.library.common.util.LimitClickUtils
import com.chwl.library.net.rxnet.utils.RxNetWorkUtils
import com.chwl.library.rxbus.RxBus
import com.chwl.library.utils.*
import com.google.gson.Gson
import com.netease.nim.uikit.common.antispam.AntiSpamEvent
import com.netease.nimlib.sdk.StatusCode
import com.netease.nimlib.sdk.chatroom.ChatRoomMessageBuilder
@@ -153,12 +156,10 @@ open class BaseRoomFragment<V : IBaseRoomView?, P1 : BaseRoomPresenter<V>?> :
private var myUid: Long = 0
protected lateinit var messagePager: ViewPager2
protected lateinit var messageView: MessageView
protected var publicChatMessageWidget: PublicChatRoomMessageWidget? = null
protected lateinit var bottomView: BottomView
protected lateinit var inputLayout: RelativeLayout
protected lateinit var inputEdit: EditText
protected lateinit var inputSend: ImageView
protected lateinit var inputHeadlineSend: ImageView
protected lateinit var microView: MicroView
private var musicPlayerView: MusicPlayerView? = null
private var mVsMusicPlayer: ViewStub? = null
@@ -200,8 +201,6 @@ open class BaseRoomFragment<V : IBaseRoomView?, P1 : BaseRoomPresenter<V>?> :
// 房间小组件
private var widgets: HashMap<String, RoomWidget> = HashMap()
private val headlineViewModel by activityViewModels<HeadlineViewModel>()
@CallSuper
override fun onFindViews() {
initMessageView()
@@ -217,7 +216,6 @@ open class BaseRoomFragment<V : IBaseRoomView?, P1 : BaseRoomPresenter<V>?> :
false
}
inputSend = mView.findViewById(R.id.input_send)
inputHeadlineSend = mView.findViewById(R.id.input_headline_send)
microView = mView.findViewById(R.id.micro_view)
mVsMusicPlayer = mView.findViewById(R.id.vs_music_player)
messageView.setClickConsumer {
@@ -240,10 +238,9 @@ open class BaseRoomFragment<V : IBaseRoomView?, P1 : BaseRoomPresenter<V>?> :
protected open fun initMessageView() {
messagePager = mView.findViewById<ViewPager2>(R.id.message_pager)
messageView = MessageView(context)
publicChatMessageWidget = PublicChatRoomMessageWidget(requireContext())
val tabList: MutableList<String> = java.util.ArrayList(2)
tabList.add(getString(R.string.room))
tabList.add(getString(R.string.public_chat))
// tabList.add(getString(R.string.public_chat))
val messageIndicator = mView.findViewById<MagicIndicator>(R.id.message_indicator)
messagePager.offscreenPageLimit = tabList.size
messagePager.adapter = object : RecyclerView.Adapter<RecyclerView.ViewHolder>() {
@@ -251,12 +248,8 @@ open class BaseRoomFragment<V : IBaseRoomView?, P1 : BaseRoomPresenter<V>?> :
parent: ViewGroup,
viewType: Int
): RecyclerView.ViewHolder {
val view = if (viewType == 0) {
messageView
} else {
publicChatMessageWidget
}
view?.layoutParams = ViewGroup.LayoutParams(
val view = messageView
view.layoutParams = ViewGroup.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT
)
@@ -310,7 +303,6 @@ open class BaseRoomFragment<V : IBaseRoomView?, P1 : BaseRoomPresenter<V>?> :
override fun onSetListener() {
bottomView.setMagicBtnEnable(true)
inputSend.setOnClickListener(this)
inputHeadlineSend.setOnClickListener(this)
inputLayout.setOnTouchListener { _: View?, _: MotionEvent? ->
inputEdit.clearFocus()
inputLayout.visibility = View.GONE
@@ -318,7 +310,6 @@ open class BaseRoomFragment<V : IBaseRoomView?, P1 : BaseRoomPresenter<V>?> :
false
}
messageView.setOnLongClickListener { _, account, name ->
showInputLayout()
if (atProxy == null) atProxy = AtProxy(inputEdit)
@@ -374,44 +365,6 @@ open class BaseRoomFragment<V : IBaseRoomView?, P1 : BaseRoomPresenter<V>?> :
//获取免费礼物详情
mvpPresenter?.queryFreeFlower()
initRoomAlbum()
initHeadline()
}
private fun initHeadline() {
headlineViewModel.loadingLiveData.observe(this) {
if (it) dialogManager?.showProgressDialog(context)
else dialogManager?.dismissDialog()
}
lifecycleScope.launch(Dispatchers.Main) {
headlineViewModel.sendHeadlineFlow.collect {
if (it.isSuccess) {
SingleToastUtil.showToast(R.string.sent_success)
inputEdit.setText("")
KeyBoardUtils.hideKeyBoard(activity, inputEdit)
} else {
if (it.code == BalanceNotEnoughExeption.code) {
showBalanceNotEnoughDialog()
} else {
SingleToastUtil.showToast(it.message)
}
}
}
}
headlineViewModel.getHeadlinePayMoneyIsNull()
}
private fun showBalanceNotEnoughDialog() {
val tipDialog = CommonTipDialog(context)
tipDialog.setTipMsg(ResUtil.getString(R.string.insufficient_balance_recharge_tips))
tipDialog.setOkText(getString(R.string.charge))
tipDialog.setOnActionListener(
object : CommonTipDialog.OnActionListener {
override fun onOk() {
ChargeActivity.start(context)
}
}
)
tipDialog.show()
}
@SuppressLint("CheckResult")
@@ -665,6 +618,7 @@ open class BaseRoomFragment<V : IBaseRoomView?, P1 : BaseRoomPresenter<V>?> :
bottomView.showHomePartyDownMicBottom()
}
bottomView.showInputOrIcon(isOnMic)
bottomView.updateGameEntrance()
// 更新聽筒消息
bottomView.setRemoteMuteOpen(!AudioEngineManager.get().isRemoteMute)
if (isOnMic) {
@@ -792,21 +746,66 @@ open class BaseRoomFragment<V : IBaseRoomView?, P1 : BaseRoomPresenter<V>?> :
override fun onClick(v: View) {
if (mClickLimit.checkForTime(500)) return
when (v.id) {
R.id.iv_config_entrance -> {
val roomInfo = AvRoomDataManager.get().mCurrentRoomInfo ?: return
val configInfo = AvRoomDataManager.get().rightBottomIconConfig ?: return
if (configInfo.skipType == 1) {
playConfigWeb(configInfo.skipUrl)
} else if (configInfo.skipType == 2) {
playConfigBaishunGame(configInfo)
}
}
R.id.iv_game -> {
RoomGameListDialog().show(childFragmentManager, "GAME_LIST")
val dialog = RoomGameplayDialog()
dialog.isOnlyPK = false
dialog.listener = object : RoomGameplayDialog.GameplayDialogListener {
override fun onShowBaiShunGame(url: String, config: BaiShunGameConfig) {
(activity as? AVRoomActivity)?.showBaiShunGame(url, config)
}
}
dialog.show(childFragmentManager, "ROOM_GAME_PLAY")
}
R.id.input_send -> {
sendMsg()
}
R.id.input_headline_send -> {
sendHeadline()
}
R.id.layout_room_rank -> {
DialogWebViewActivity.start(mContext, UriProvider.getRoomRanking())
}
}
}
private fun playConfigWeb(url: String) {
CommonWebViewActivity.start(mContext, url)
}
private fun playConfigBaishunGame(configInfo: RightBottomIconConfig) {
val roomIcon: RoomIcon = RoomIcon(
skipContent = configInfo.skipUrl,
skipType = 3,
showType = 1,
code = "BAISHUN",
ruleValue = configInfo.reserve)
try {
val url = roomIcon.skipContent
val ruleValue = Gson().fromJson<RoomIcon.RuleValueBean>(
roomIcon.ruleValue,
RoomIcon.RuleValueBean::class.java
)
val config = Gson().fromJson<BaiShunGameConfig>(
ruleValue.RESERVE,
BaiShunGameConfig::class.java
)
if (config != null && url != null) {
config.reloadDynamicParams()
(activity as? AVRoomActivity)?.showBaiShunGame(url, config)
} else {
SingleToastUtil.showToast(R.string.manager_trtc_trtcengineadapter_042)
}
} catch (e: Exception) {
e.printStackTrace()
}
}
private fun sendMsg() {
val message = inputEdit.text.toString().trim()
if (isPublicMessageTab()) {
@@ -816,41 +815,6 @@ open class BaseRoomFragment<V : IBaseRoomView?, P1 : BaseRoomPresenter<V>?> :
}
}
private fun sendHeadline() {
val message = inputEdit.text.toString().trim()
if (TextUtils.isEmpty(message)) {
SingleToastUtil.showToast(ResUtil.getString(R.string.avroom_fragment_baseroomfragment_08))
return
}
if (message.length > 100) {
toast(R.string.headline_input_length_limit_tips)
return
}
val money = headlineViewModel.headlinePayMoneyLiveData.value
if (money != null) {
showHeadlinePayDialog(money, message)
} else {
SingleToastUtil.showToast(R.string.ui_setting_modifypwdactivity_01)
headlineViewModel.getHeadlinePayMoney()
}
}
private fun showHeadlinePayDialog(money: Long, message: String) {
KeyBoardUtils.hideKeyBoard(activity, inputEdit)
SelectPayTypeDialog.newInstance(
money.toString(),
money,
false
).apply {
setOnDiamondChargeClick {
headlineViewModel.sendHeadline(message)
}
setOnChargeClick {
ChargeActivity.start(context)
}
}.show(context)
}
@SuppressLint("CheckResult")
fun sendMsg(msg: String) {
if (!AuthModel.get().isImLogin) {
@@ -881,7 +845,6 @@ open class BaseRoomFragment<V : IBaseRoomView?, P1 : BaseRoomPresenter<V>?> :
return
}
mvpPresenter?.sendPublicChatTextMessage(message)
publicChatMessageWidget?.getMessageView()?.setNeedAutoScroll(true) // 發送後自動滾動公屏列表
inputEdit.setText("")
}
@@ -1197,7 +1160,6 @@ open class BaseRoomFragment<V : IBaseRoomView?, P1 : BaseRoomPresenter<V>?> :
}
override fun onSendPublicChatMsgSuccess(msg: ChatRoomMessage) {
publicChatMessageWidget?.getMessageView()?.addMessages(msg)
inputEdit.setText("")
KeyBoardUtils.hideKeyBoard(activity, inputEdit)
}
@@ -1434,14 +1396,19 @@ open class BaseRoomFragment<V : IBaseRoomView?, P1 : BaseRoomPresenter<V>?> :
RoomMsgActivity.start(mContext)
}
override fun onRoomGameplayClick() {
val dialog = RoomGameplayDialog()
dialog.listener = object : RoomGameplayDialog.GameplayDialogListener {
override fun onShowBaiShunGame(url: String, config: BaiShunGameConfig) {
(activity as? AVRoomActivity)?.showBaiShunGame(url, config)
override fun onRoomGameplayClick(isOnlyPK: Boolean) {
if (isOnlyPK) {
val dialog = RoomGameplayDialog()
dialog.isOnlyPK = isOnlyPK
dialog.listener = object : RoomGameplayDialog.GameplayDialogListener {
override fun onShowBaiShunGame(url: String, config: BaiShunGameConfig) {
(activity as? AVRoomActivity)?.showBaiShunGame(url, config)
}
}
dialog.show(childFragmentManager, "ROOM_GAME_PLAY")
} else {
RoomGameListDialog().show(childFragmentManager, "GAME_LIST")
}
dialog.show(childFragmentManager, "ROOM_GAME_PLAY")
}
}
@@ -1484,9 +1451,6 @@ open class BaseRoomFragment<V : IBaseRoomView?, P1 : BaseRoomPresenter<V>?> :
}
open fun initWidget() {
publicChatMessageWidget?.let {
registerWidget(PublicChatRoomMessageWidget::class.java.simpleName, it)
}
}
@Subscribe(threadMode = ThreadMode.MAIN)
@@ -1504,7 +1468,6 @@ open class BaseRoomFragment<V : IBaseRoomView?, P1 : BaseRoomPresenter<V>?> :
* 打开公屏输入
*/
fun openMessageInput(text: String?) {
inputHeadlineSend.isVisible = isPublicMessageTab()
inputLayout.visibility = View.VISIBLE
if (text != null) {
inputEdit.setText(text)

View File

@@ -100,9 +100,6 @@ class GameRoomFragment : BaseRoomFragment<IGameRoomView?, GameRoomPresenter?>(),
messageView.messageListView?.let {
setMessagePagerAutoHeight(it)
}
publicChatMessageWidget?.getMessageView()?.messageListView?.let {
setMessagePagerAutoHeight(it)
}
}
override fun onClick(v: View) {

View File

@@ -4,6 +4,7 @@ import android.annotation.SuppressLint;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;
import androidx.annotation.NonNull;
import androidx.databinding.DataBindingUtil;
@@ -14,8 +15,13 @@ import com.chwl.app.avroom.headline.RoomHeadlineWidget;
import com.chwl.app.avroom.online.RoomOnlineWidget;
import com.chwl.app.avroom.rank.RoomRankNumberWidget;
import com.chwl.app.music.widget.MusicPlayerView;
import com.chwl.app.ui.utils.ImageLoadUtils;
import com.chwl.app.ui.webview.DialogWebViewActivity;
import com.chwl.core.room.bean.RightBottomIconConfig;
import com.chwl.core.room.bean.RoomIcon;
import com.chwl.core.room.core.RoomDataService;
import com.chwl.core.room.pk.event.PKDataUpdateEvent;
import com.chwl.core.support.room.AudioRoomContext;
import com.netease.nim.uikit.common.util.log.LogUtil;
import com.trello.rxlifecycle3.android.FragmentEvent;
import com.chwl.app.R;
@@ -79,6 +85,7 @@ import io.reactivex.Single;
import io.reactivex.SingleObserver;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable;
import io.reactivex.functions.Consumer;
/**
* 轰趴房间
@@ -101,6 +108,8 @@ public class HomePartyRoomFragment extends BaseRoomFragment<IHomePartyView, Home
private PKMicQueueDialog pkMicQueueDialog;
private Disposable roomPkOrderDisposable;
private boolean hasBaishunGames;
public static HomePartyRoomFragment newInstance() {
HomePartyRoomFragment roomFragment = new HomePartyRoomFragment();
Bundle bundle = new Bundle();
@@ -149,6 +158,28 @@ public class HomePartyRoomFragment extends BaseRoomFragment<IHomePartyView, Home
updateQueuingMicBtn();
updatePkScoreBoard();
initRoomPkOrder(AvRoomDataManager.get().showPkBeginTime, AvRoomDataManager.get().pkBeginTime);
requestData();
}
private void requestData() {
RoomDataService dataService = (RoomDataService) AudioRoomContext.Companion.get().findAbility(RoomDataService.class.getSimpleName());
String cacheKey = "gameplay_list#" + hashCode();
Disposable disposable = AvRoomModel.get().getRoomGamePlayList().doOnError(new Consumer<Throwable>() {
@Override
public void accept(Throwable throwable) throws Exception {
hasBaishunGames = false;
updateConfigButtonArea();
}
}).subscribe(new Consumer<List<RoomIcon>>() {
@Override
public void accept(List<RoomIcon> roomIcons) throws Exception {
if (dataService != null) {
dataService.putData(cacheKey, roomIcons);
}
hasBaishunGames = roomIcons.size() > 0;
updateConfigButtonArea();
}
});
}
@Override
@@ -197,6 +228,7 @@ public class HomePartyRoomFragment extends BaseRoomFragment<IHomePartyView, Home
gameBinding.setRoomInfo(AvRoomDataManager.get().mCurrentRoomInfo);
updateQueuingMicBtn();
updatePkScoreBoard();
updateConfigButtonArea();
getMvpPresenter().updateLeaveMode();
break;
case RoomEvent.ENTER_ROOM:
@@ -470,11 +502,7 @@ public class HomePartyRoomFragment extends BaseRoomFragment<IHomePartyView, Home
updateMicroView();
changeModelShowView();
refreshDatingNextStatus();
if (AvRoomDataManager.get().isDatingMode()) {
gameBinding.ivGame.setVisibility(View.GONE);
} else {
gameBinding.ivGame.setVisibility(View.VISIBLE);
}
// updateConfigButtonArea();
}
protected void updateMicroView(){
@@ -502,6 +530,30 @@ public class HomePartyRoomFragment extends BaseRoomFragment<IHomePartyView, Home
refreshDatingNextStatus();
}
public void updateConfigButtonArea() {
RightBottomIconConfig configModel = AvRoomDataManager.get().rightBottomIconConfig;
if (configModel == null) {
gameBinding.ivConfigEntrance.setVisibility(View.GONE);
} else {
if (configModel.getIcon1Url() == null) {
gameBinding.ivConfigEntrance.setVisibility(View.GONE);
} else {
ImageLoadUtils.loadAvatar(configModel.getIcon1Url(), gameBinding.ivConfigEntrance);
gameBinding.ivConfigEntrance.setVisibility(View.VISIBLE);
}
if (configModel.getIcon2Url() != null) {
ImageLoadUtils.loadAvatar(configModel.getIcon2Url(), gameBinding.ivGame);
}
}
if (hasBaishunGames) {
gameBinding.ivGame.setVisibility(View.VISIBLE);
}else {
gameBinding.ivGame.setVisibility(View.GONE);
}
}
private void updateQueuingMicBtn() {
if (AvRoomDataManager.get().mCurrentRoomInfo != null) {
bottomView.updateQueuingMicButton();
@@ -564,7 +616,6 @@ public class HomePartyRoomFragment extends BaseRoomFragment<IHomePartyView, Home
super.onDestroy();
}
@Subscribe(threadMode = ThreadMode.MAIN)
public void onDatingSelectUserEvent(DatingSelectUserEvent event) {
if (getMvpPresenter() != null) {

View File

@@ -26,6 +26,7 @@ import com.chwl.app.fansteam.FansTeamJoinActivity
import com.chwl.app.fansteam.FansTeamJoinedActivity
import com.chwl.app.fansteam.FansTeamViewModel
import com.chwl.app.music.widget.MusicPlayerView
import com.chwl.app.ui.utils.ImageLoadUtils
import com.chwl.app.ui.webview.CommonWebViewActivity
import com.chwl.app.ui.webview.DialogWebViewActivity
import com.chwl.core.UriProvider
@@ -36,6 +37,10 @@ import com.chwl.core.im.custom.bean.RequestUpmicAttachment
import com.chwl.core.im.custom.bean.RoomPKAttachment
import com.chwl.core.manager.AvRoomDataManager
import com.chwl.core.manager.RoomEvent
import com.chwl.core.room.core.RoomDataService
import com.chwl.core.room.model.AvRoomModel
import com.chwl.core.support.room.AudioRoomContext.Companion.get
import com.chwl.core.support.room.RoomAbility
import com.chwl.core.user.bean.UserInfo
import com.chwl.library.base.factory.CreatePresenter
import com.netease.nim.uikit.common.util.sys.ScreenUtil
@@ -63,6 +68,8 @@ class SingleRoomFragment : BaseRoomFragment<ISingleRoomView?, SingleRoomPresente
private lateinit var gameBinding: FragmentSingleRoomBinding
private lateinit var upMicDialog: RequestUpMicDialog
private var hasBaishunGames = false
private val fansTeamViewModel: FansTeamViewModel by viewModels()
override fun getRootLayoutId(): Int {
return R.layout.fragment_single_room

View File

@@ -93,8 +93,8 @@ class RoomHeadlineWidget : FrameLayoutRoomWidget {
private fun requestCurrentHeadline() {
safeLaunch {
val data = PublicChatModel.getCurrentHeadline()
updateHeadline(data)
// val data = PublicChatModel.getCurrentHeadline()
// updateHeadline(data)
}
}

View File

@@ -1,884 +0,0 @@
package com.chwl.app.avroom.public_chat;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Context;
import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.text.Spannable;
import android.text.TextUtils;
import android.text.method.LinkMovementMethod;
import android.text.style.ForegroundColorSpan;
import android.text.style.ImageSpan;
import android.util.AttributeSet;
import android.util.Log;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.content.ContextCompat;
import androidx.core.content.res.ResourcesCompat;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import androidx.recyclerview.widget.SimpleItemAnimator;
import com.chwl.app.R;
import com.chwl.app.UIHelper;
import com.chwl.app.avroom.activity.AVRoomActivity;
import com.chwl.app.avroom.dialog.RoomTeamPKResultDialog;
import com.chwl.app.avroom.widget.OnMsgLongClickListener;
import com.chwl.app.avroom.widget.TemplateMessageAdapter;
import com.chwl.app.common.widget.CustomImageSpan;
import com.chwl.app.common.widget.OriginalDrawStatusClickSpan;
import com.chwl.app.photo.BigPhotoActivity;
import com.chwl.app.photo.PagerOption;
import com.chwl.app.public_chat.core.viewholder.ChatRoomMessageViewHolderThumbBase;
import com.chwl.app.ui.utils.ImageLoadUtils;
import com.chwl.app.ui.utils.ImageLoadUtilsV2;
import com.chwl.app.ui.widget.DividerItemDecoration;
import com.chwl.app.ui.widget.MyItemAnimator;
import com.chwl.app.ui.widget.RecyclerViewNoViewpagerScroll;
import com.chwl.app.ui.widget.TextSpannableBuilder;
import com.chwl.app.ui.widget.magicindicator.buildins.UIUtil;
import com.chwl.app.utils.ObjectTypeHelper;
import com.chwl.app.utils.RegexUtil;
import com.chwl.core.DemoCache;
import com.chwl.core.auth.AuthModel;
import com.chwl.core.bean.attachmsg.RoomQueueMsgAttachment;
import com.chwl.core.decoration.car.bean.CarInfo;
import com.chwl.core.home.event.FollowRoomEvent;
import com.chwl.core.home.model.CollectionRoomModel;
import com.chwl.core.im.custom.bean.CustomAttachment;
import com.chwl.core.im.custom.bean.HeadlineChangedAttachment;
import com.chwl.core.im.custom.bean.MonsterHuntingResultAttachment;
import com.chwl.core.im.custom.bean.MonsterStatusAttachment;
import com.chwl.core.im.custom.bean.RoomBoxPrizeAttachment;
import com.chwl.core.im.custom.bean.RoomFollowOwnerAttachment2;
import com.chwl.core.im.custom.bean.RoomTipAttachment;
import com.chwl.core.im.custom.bean.TarotAttachment;
import com.chwl.core.level.UserLevelResourceType;
import com.chwl.core.manager.AvRoomDataManager;
import com.chwl.core.monsterhunting.bean.MonsterDataBean;
import com.chwl.core.monsterhunting.bean.MonsterHuntingResult;
import com.chwl.core.noble.NobleUtil;
import com.chwl.core.praise.PraiseModel;
import com.chwl.core.public_chat_hall.bean.HeadlineBean;
import com.chwl.core.room.bean.RoomInfo;
import com.chwl.core.room.pk.attachment.RoomPkAttachment;
import com.chwl.core.user.bean.UserInfo;
import com.chwl.core.utils.ExtensionUtil;
import com.chwl.library.common.util.Utils;
import com.chwl.library.utils.JavaUtil;
import com.chwl.library.utils.ListUtils;
import com.chwl.library.utils.ResUtil;
import com.chwl.library.utils.SingleToastUtil;
import com.chwl.library.utils.SizeUtils;
import com.example.lib_utils.UiUtils;
import com.example.lib_utils.spannable.SpannableTextBuilder;
import com.netease.nim.uikit.business.session.emoji.MoonUtil;
import com.netease.nim.uikit.common.util.media.ImageUtil;
import com.netease.nim.uikit.common.util.sys.ScreenUtil;
import com.netease.nimlib.sdk.chatroom.model.ChatRoomMessage;
import com.netease.nimlib.sdk.chatroom.model.ChatRoomMessageExtension;
import com.netease.nimlib.sdk.chatroom.model.ChatRoomNotificationAttachment;
import com.netease.nimlib.sdk.msg.attachment.ImageAttachment;
import com.netease.nimlib.sdk.msg.attachment.MsgAttachment;
import com.netease.nimlib.sdk.msg.constant.MsgTypeEnum;
import com.netease.nimlib.sdk.msg.constant.NotificationType;
import org.greenrobot.eventbus.EventBus;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import io.reactivex.Single;
import io.reactivex.functions.Consumer;
import kotlin.jvm.functions.Function1;
/**
* 直播間消息界面
*
* @author xiaoyu
*/
public class PublicChatMessageView extends FrameLayout {
private static final String TAG = "PublicChatMessageView";
private final static int MAX_MESSAGE_SIZE = 100;//公屏最多展示條數
private final static int BLOCK_MAX_MESSAGE_SIZE = MAX_MESSAGE_SIZE * 3 / 2;//在查看消息停住的時候 最多消息條數.
private final List<ChatRoomMessage> atMessages = new ArrayList<>();
private final List<ChatRoomMessage> chatRoomMessages = new LinkedList<>();
private RecyclerView messageListView;
private TextView tvBottomTip;
private TextView tvAtTip;
private MessageAdapter mMessageAdapter;
private LinearLayoutManager layoutManger;
private int paddingWidth;
private int paddingHeight;
private int whiteColor;
private int greyColor;
private int roomTipColor;
private int badgeWidth;
private int badgeHeight;
private int expLevelHeight;
private int defTextSize = 12;
private volatile boolean needAutoScroll = true;//是否自動滾動到底部
private Consumer<String> clickConsumer;
private OnClick onClick;
private OnMsgLongClickListener onLongClickListener;
private TemplateMessageAdapter templateMessageAdapter;
public PublicChatMessageView(Context context) {
this(context, null);
}
public PublicChatMessageView(Context context, AttributeSet attr) {
this(context, attr, 0);
}
public PublicChatMessageView(Context context, AttributeSet attr, int i) {
super(context, attr, i);
init(context);
}
public void setOnLongClickListener(OnMsgLongClickListener onLongClickListener) {
this.onLongClickListener = onLongClickListener;
}
public void setClickConsumer(Consumer<String> clickConsumer) {
this.clickConsumer = clickConsumer;
}
public void setOnClick(OnClick onClick) {
this.onClick = onClick;
}
@Override
protected void onAttachedToWindow() {
super.onAttachedToWindow();
}
@Override
protected void onDetachedFromWindow() {
super.onDetachedFromWindow();
}
@SuppressLint("ClickableViewAccessibility")
private void init(Context context) {
whiteColor = ContextCompat.getColor(context, R.color.white);
greyColor = ContextCompat.getColor(context, R.color.white_transparent_50);
roomTipColor = ContextCompat.getColor(context, R.color.color_FEE057);
paddingWidth = Utils.dip2px(context, 11);
paddingHeight = Utils.dip2px(context, 6);
badgeWidth = Utils.dip2px(context, 15);
badgeHeight = Utils.dip2px(context, 15);
//經驗等級圖片後臺已經更換尺寸了公屏同步下尺寸是36:18
expLevelHeight = Utils.dip2px(context, 18);
// 內容區域
layoutManger = new LinearLayoutManager(context, RecyclerView.VERTICAL, false);
LayoutParams params = new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
messageListView = new RecyclerViewNoViewpagerScroll(context);
messageListView.setLayoutParams(params);
messageListView.setFadingEdgeLength(60);
messageListView.setVerticalFadingEdgeEnabled(true);
messageListView.setOverScrollMode(OVER_SCROLL_NEVER);
messageListView.setHorizontalScrollBarEnabled(false);
addView(messageListView);
messageListView.setLayoutManager(layoutManger);
messageListView.addItemDecoration(new DividerItemDecoration(context, layoutManger.getOrientation(), 16, R.color.transparent));
mMessageAdapter = new MessageAdapter(getContext());
mMessageAdapter.setData(chatRoomMessages);
messageListView.setAdapter(mMessageAdapter);
messageListView.setItemAnimator(new MyItemAnimator());
messageListView.getItemAnimator().setAddDuration(0);
messageListView.getItemAnimator().setChangeDuration(0);
messageListView.getItemAnimator().setMoveDuration(0);
messageListView.getItemAnimator().setRemoveDuration(0);
((SimpleItemAnimator) messageListView.getItemAnimator()).setSupportsChangeAnimations(false);
// 底部有新消息
tvBottomTip = new TextView(context);
LayoutParams params1 = new LayoutParams(
Utils.dip2px(context, 115F), Utils.dip2px(context, 27));
params1.gravity = Gravity.BOTTOM;
params1.leftMargin = UIUtil.getScreenWidth(context) / 2 - UIUtil.dip2px(context, 115 / 2);
tvBottomTip.setBackgroundResource(R.drawable.bg_messge_view_bottom_tip);
tvBottomTip.setGravity(Gravity.CENTER);
tvBottomTip.setText(context.getString(R.string.message_view_bottom_tip));
tvBottomTip.setTextColor(context.getResources().getColor(R.color.appColor));
tvBottomTip.setLayoutParams(params1);
tvBottomTip.setVisibility(GONE);
tvBottomTip.setOnClickListener(v -> {
tvBottomTip.setVisibility(GONE);
needAutoScroll = true;
if (mMessageAdapter.getItemCount() > 0) {
messageListView.smoothScrollToPosition(mMessageAdapter.getItemCount() - 1);
}
});
addView(tvBottomTip);
//有人@我
tvAtTip = new TextView(context);
LayoutParams params2 = new LayoutParams(
Utils.dip2px(context, 115F), Utils.dip2px(context, 27));
params2.gravity = Gravity.BOTTOM;
params2.leftMargin = UIUtil.getScreenWidth(context) / 2 - UIUtil.dip2px(context, 115 / 2);
tvAtTip.setBackgroundResource(R.drawable.bg_messge_view_bottom_tip);
tvAtTip.setGravity(Gravity.CENTER);
tvAtTip.setText(context.getString(R.string.message_view_bottom_tip));
tvAtTip.setTextColor(context.getResources().getColor(R.color.color_FD85C9));
tvAtTip.setLayoutParams(params2);
tvAtTip.setVisibility(GONE);
tvAtTip.setOnClickListener(v -> {
if (!atMessages.isEmpty()) {
int scrollIndex = chatRoomMessages.indexOf(atMessages.remove(0));
if (scrollIndex != -1 && scrollIndex < mMessageAdapter.getItemCount()) {
messageListView.smoothScrollToPosition(scrollIndex);
}
}
needAutoScroll = false;
checkShowAtTip();
});
addView(tvAtTip);
messageListView.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
}
@Override
public void onScrollStateChanged(final RecyclerView recyclerView, int newState) {
super.onScrollStateChanged(recyclerView, newState);
if (newState == RecyclerView.SCROLL_STATE_DRAGGING) {
// Logger.e(TAG, "onScrollStateChanged: SCROLL_STATE_DRAGGING");
needAutoScroll = false;
}
if (newState == RecyclerView.SCROLL_STATE_IDLE) {
// Logger.e(TAG, "onScrollStateChanged: SCROLL_STATE_IDLE");
int lastVisibleItemPosition = layoutManger.findLastVisibleItemPosition();
if (lastVisibleItemPosition == RecyclerView.NO_POSITION) {
// Logger.e(TAG, "lastCompletelyVisibleItemPosition : RecyclerView.NO_POSITION");
needAutoScroll = true;
} else if (!atMessages.isEmpty() && atMessages.remove(chatRoomMessages.get(lastVisibleItemPosition))) {
checkShowAtTip();
}
// Log.e(TAG, "lastVisibleItemPosition:" + lastVisibleItemPosition
// + " mMessageAdapter.getItemCount()-1:" + (recyclerView.getAdapter().getItemCount()-1)
// + " dis:"+ (lastVisibleItemPosition-(recyclerView.getAdapter().getItemCount()-1)));
if (lastVisibleItemPosition >= recyclerView.getAdapter().getItemCount() - 3) {
//最後一個顯示出來了
// Logger.e(TAG, ResUtil.getString(R.string.avroom_widget_messageview_01));
needAutoScroll = true;
tvBottomTip.setVisibility(GONE);
keepSizeUnderLimit();
} else {
// Logger.e(TAG, ResUtil.getString(R.string.avroom_widget_messageview_02));
// needAutoScroll = false;
}
}
}
});
}
private TemplateMessageAdapter getTemplateMessageAdapter() {
if (templateMessageAdapter == null) {
templateMessageAdapter = new TemplateMessageAdapter(uid -> {
if (clickConsumer != null) {
Single.just(String.valueOf(uid)).subscribe(clickConsumer);
}
});
}
return templateMessageAdapter;
}
/**
* 添加公屏消息請使用 {@link AvRoomDataManager#addChatRoomMessage(ChatRoomMessage)}
*/
public void addMessages(ChatRoomMessage msg) {
if (msg == null) return;
chatRoomMessages.add(msg);
//通知adapter 刷新
mMessageAdapter.notifyItemInserted(mMessageAdapter.getItemCount() - 1);
showTipsOrScrollToBottom();
checkAtMe(msg, false);
}
public void addMessages(List<ChatRoomMessage> messages) {
if (messages == null) return;
chatRoomMessages.addAll(messages);
//通知adapter 刷新
mMessageAdapter.notifyDataSetChanged();
showTipsOrScrollToBottom();
for (ChatRoomMessage message : messages) {
checkAtMe(message, true);
}
}
public void addHistoryMessages(List<ChatRoomMessage> messages) {
chatRoomMessages.addAll(0, messages);
mMessageAdapter.notifyDataSetChanged();
messageListView.scrollToPosition(mMessageAdapter.getItemCount() - 1);
for (ChatRoomMessage message : messages) {
checkAtMe(message, true);
}
}
private void keepSizeUnderLimit() {
while (chatRoomMessages.size() > MAX_MESSAGE_SIZE) {
Log.i("keepSizeUnderLimit", "size" + chatRoomMessages.size());
ChatRoomMessage message = chatRoomMessages.remove(0);
if (atMessages.remove(message)) {
checkShowAtTip();
}
mMessageAdapter.notifyItemRemoved(0);
}
}
private void checkShowAtTip() {
tvAtTip.setText(getContext().getString(R.string.message_at_tip, atMessages.size()));
tvAtTip.setVisibility(atMessages.size() == 0 ? GONE : VISIBLE);
}
private void checkAtMe(ChatRoomMessage msg, boolean history) {
if (msg.getMsgType() != MsgTypeEnum.text) return;
List<String> atUids = ExtensionUtil.getListExtension(msg, UserInfo.AT_UIDS);
List<String> atNames = ExtensionUtil.getListExtension(msg, UserInfo.AT_NAMES);
if (!ListUtils.isListEmpty(atUids) && !ListUtils.isListEmpty(atNames)) {
for (int i = 0; i < atUids.size(); i++) {
String uid = atUids.get(i);
// 只有當被 @ 人的數組中包含自己的時候才會去變色
if (Objects.equals(uid, String.valueOf(AuthModel.get().getCurrentUid()))) {
Map<String, Long> atMap = DemoCache.readAtMsgUuid();
if (atMap == null || !atMap.containsKey(msg.getUuid())) {
if (!atMessages.contains(msg) && (!needAutoScroll || history)) {
atMessages.add(msg);
checkShowAtTip();
}
DemoCache.saveAtMsgUuid(msg.getUuid());
}
}
}
}
}
public void showTipsOrScrollToBottom() {
if (!needAutoScroll) {
tvBottomTip.setVisibility(VISIBLE);
//超過某值後自動滾動下去
if (mMessageAdapter.getItemCount() > BLOCK_MAX_MESSAGE_SIZE) {
if (mMessageAdapter.getItemCount() > 0) {
messageListView.smoothScrollToPosition(mMessageAdapter.getItemCount() - 1);
}
}
return;
}
}
public void release() {
}
public void clear() {
if (mMessageAdapter != null) {
chatRoomMessages.clear();
mMessageAdapter.notifyDataSetChanged();
}
if (tvBottomTip != null) {
needAutoScroll = true;
tvBottomTip.setVisibility(GONE);
}
}
public void setNeedAutoScroll(boolean needAutoScroll) {
this.needAutoScroll = needAutoScroll;
}
public RecyclerView getMessageListView(){
return messageListView;
}
public interface OnClick {
/**
* 公屏查看公告
*/
void onShowRoomIntroduction();
}
private class MessageAdapter extends RecyclerView.Adapter<MessageAdapter.MessageViewHolder> implements OnClickListener,Function1<Drawable, ImageSpan> {
private Context mContext;
private List<ChatRoomMessage> data;
private int ITEM_TYPE_IMAGE = 1;
public MessageAdapter(Context mContext) {
this.mContext = mContext;
}
public void setData(List<ChatRoomMessage> data) {
this.data = data;
}
@Override
public int getItemViewType(int position) {
ChatRoomMessage chatRoomMessage = data.get(position);
if (chatRoomMessage.getMsgType() == MsgTypeEnum.image) {
return ITEM_TYPE_IMAGE;
}
return super.getItemViewType(position);
}
@Override
public MessageViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
if (viewType == ITEM_TYPE_IMAGE) {
return new MessageAdapter.MessageViewHolder(LayoutInflater.from(parent.getContext())
.inflate(R.layout.list_item_chatroom_msg_image, parent, false));
}
return new MessageViewHolder(LayoutInflater.from(parent.getContext())
.inflate(R.layout.list_item_chatrrom_msg, parent, false));
}
@Override
public void onBindViewHolder(MessageViewHolder holder, int position) {
if (getItemViewType(position) == ITEM_TYPE_IMAGE) {
convertImage(holder, data.get(position));
} else {
convert(holder, data.get(position));
}
}
@Override
public int getItemCount() {
return data.size();
}
protected void convertImage(MessageViewHolder baseViewHolder, ChatRoomMessage chatRoomMessage) {
TextView tvContent = baseViewHolder.tvContent;
tvContent.setLineSpacing(0, 1);
tvContent.setGravity(Gravity.START | Gravity.CENTER_VERTICAL);
tvContent.setOnClickListener(this);
tvContent.setTag(chatRoomMessage);
if (UiUtils.INSTANCE.isRtl(tvContent.getContext())) {
tvContent.setTextDirection(View.TEXT_DIRECTION_RTL);
}
try {
setVIPMessageBackground(chatRoomMessage, baseViewHolder.itemView);
ChatRoomMessageExtension extension = chatRoomMessage.getChatRoomMessageExtension();
TextSpannableBuilder text = new TextSpannableBuilder(tvContent);
addCommonTag(chatRoomMessage, text, tvContent);
String nickName = extension == null ? ResUtil.getString(R.string.avroom_widget_messageview_0116) : RegexUtil.getPrintableString(extension.getSenderNick());
text.append(nickName, new ForegroundColorSpan(greyColor));
tvContent.setText(text.build());
ImageView imageView = baseViewHolder.itemView.findViewById(R.id.iv_image);
ImageAttachment msgAttachment = (ImageAttachment) chatRoomMessage.getAttachment();
String path = msgAttachment.getThumbPath();
if (TextUtils.isEmpty(path)) {
path = msgAttachment.getPath();
}
if (TextUtils.isEmpty(path)) {
path = "";
}
ImageLoadUtilsV2.loadImage(imageView, path);
int[] bounds = new int[]{msgAttachment.getWidth(), msgAttachment.getHeight()};
ImageUtil.ImageSize imageSize = ImageUtil.getThumbnailDisplaySize(bounds[0], bounds[1], ChatRoomMessageViewHolderThumbBase.getImageMaxEdge(), ChatRoomMessageViewHolderThumbBase.getImageMinEdge());
ViewGroup.LayoutParams maskParams = imageView.getLayoutParams();
maskParams.width = imageSize.width;
maskParams.height = imageSize.height;
imageView.setLayoutParams(maskParams);
String finalPath = path;
imageView.setOnClickListener(v -> {
BigPhotoActivity.start((Activity) mContext, ObjectTypeHelper.pathToCustomItems(finalPath),
0, new PagerOption());
});
} catch (Exception e) {
e.printStackTrace();
}
}
protected void convert(MessageViewHolder baseViewHolder, ChatRoomMessage chatRoomMessage) {
if (chatRoomMessage == null) return;
TextView tvContent = baseViewHolder.tvContent;
tvContent.setLineSpacing(0, 1);
tvContent.setTextColor(Color.WHITE);
tvContent.setTextSize(defTextSize);
tvContent.setOnClickListener(this);
tvContent.setOnLongClickListener(null);
tvContent.setTag(chatRoomMessage);
tvContent.setGravity(Gravity.START | Gravity.CENTER_VERTICAL);
if (UiUtils.INSTANCE.isRtl(tvContent.getContext())) {
tvContent.setTextDirection(View.TEXT_DIRECTION_RTL);
}
clearBackground(tvContent);
try {
if (chatRoomMessage.getMsgType() == MsgTypeEnum.tip) {
// 房間通告
tvContent.setTextColor(ContextCompat.getColor(mContext, R.color.color_white));
tvContent.setText(chatRoomMessage.getContent());
tvContent.setBackgroundResource(R.drawable.shape_room_message_tip_bg);
} else if (chatRoomMessage.getMsgType() == MsgTypeEnum.text) {
setMsgText(chatRoomMessage, tvContent);
setVIPMessageBackground(chatRoomMessage, tvContent);
} else if (chatRoomMessage.getMsgType() == MsgTypeEnum.notification) {
// 加上勛章
setMsgNotification(chatRoomMessage, tvContent, baseViewHolder.getAdapterPosition());
setVIPMessageBackground(chatRoomMessage, tvContent);
} else if (chatRoomMessage.getMsgType() == MsgTypeEnum.custom) {
if (chatRoomMessage.getAttachment() != null && chatRoomMessage.getAttachment() instanceof CustomAttachment) {
CustomAttachment attachment = (CustomAttachment) chatRoomMessage.getAttachment();
int first = attachment.getFirst();
int second = attachment.getSecond();
if (first == CustomAttachment.CUSTOM_MSG_HEADLINE_CHANGED) {
if (second == CustomAttachment.CUSTOM_MSG_HEADLINE_CHANGED_SUB) {
setHeadlineMsg(chatRoomMessage, tvContent, attachment);
}
} else {
tvContent.setTextColor(Color.WHITE);
tvContent.setText(tvContent.getResources().getText(R.string.not_support_message_tip));
}
} else {
tvContent.setText("");
}
}
} catch (UnsupportedOperationException e) {
e.printStackTrace();
clearBackground(tvContent);
tvContent.setTextColor(Color.WHITE);
tvContent.setText(tvContent.getResources().getText(R.string.not_support_message_tip));
} catch (Exception e) {
clearBackground(tvContent);
tvContent.setText("");
}
}
private void clearBackground(TextView textView) {
// 清除文字
textView.setText("");
// 清除聊天氣泡
textView.setBackgroundResource(R.drawable.shape_room_message_bg);
textView.setPadding(paddingWidth, paddingHeight, paddingWidth, paddingHeight);
}
private void setNullBackground(TextView textView) {
// 清除聊天氣泡
textView.setBackground(null);
textView.setPadding(0, 0, 0, 0);
}
public void setVIPMessageBackground(ChatRoomMessage chatRoomMessage, View view) {
String androidBubbleUrl = NobleUtil.getResource(UserInfo.BUBBLE_URL_ANDROID, chatRoomMessage);
if (TextUtils.isEmpty(androidBubbleUrl)) return;
view.setPadding(paddingWidth, ScreenUtil.dip2px(10), paddingWidth, ScreenUtil.dip2px(10));
ImageLoadUtils.loadNinePatchBg(view, androidBubbleUrl);
}
/**
* {badge}{level}xxx: 文字內容
*
* @param chatRoomMessage -
* @param tvContent -
*/
private void setMsgText(ChatRoomMessage chatRoomMessage, TextView tvContent) {
TextSpannableBuilder text = new TextSpannableBuilder(tvContent);
addCommonTag(chatRoomMessage, text, tvContent);
String nickName;
if (chatRoomMessage.getFromAccount() != null && chatRoomMessage.getFromAccount().equals(AuthModel.get().getCurrentUid() + "")) {
nickName = ResUtil.getString(R.string.avroom_widget_messageview_0116);
} else {
nickName = NobleUtil.getNamePlate(UserInfo.NICK, chatRoomMessage);
}
text.append(nickName, new ForegroundColorSpan(greyColor));
text.append(": " + chatRoomMessage.getContent(), new ForegroundColorSpan(getResources().getColor(R.color.white)));
List<String> atUids = ExtensionUtil.getListExtension(chatRoomMessage, UserInfo.AT_UIDS);
List<String> atNames = ExtensionUtil.getListExtension(chatRoomMessage, UserInfo.AT_NAMES);
if (!ListUtils.isListEmpty(atUids) && !ListUtils.isListEmpty(atNames)) {
for (int i = 0; i < atUids.size(); i++) {
String name = atNames.get(i);
String uid = atUids.get(i);
// 只有當被 @ 人的數組中包含自己的時候才會去變色
if (Objects.equals(uid, String.valueOf(AuthModel.get().getCurrentUid()))) {
Pattern pattern = Pattern.compile(Pattern.quote(name));
Matcher matcher = pattern.matcher(text.build().toString());
while (matcher.find()) {
int start = matcher.start();
int end = matcher.end();
text.build().setSpan(new ForegroundColorSpan(getContext().getResources().getColor(R.color.color_FD85C9)),
start, end, Spannable.SPAN_INCLUSIVE_INCLUSIVE);
}
}
}
}
if (Objects.equals(chatRoomMessage.getFromAccount(), String.valueOf(AuthModel.get().getCurrentUid()))) {
tvContent.setOnLongClickListener(null);
} else {
tvContent.setOnLongClickListener(v -> {
if (onLongClickListener != null) {
onLongClickListener.onLongClick(v, chatRoomMessage.getFromAccount(), nickName);
}
return true;
});
}
MoonUtil.replaceEmoticons(getContext(), text.builder.toString(), text.builder, this);
tvContent.setText(text.build());
}
private void addCommonTag(ChatRoomMessage chatRoomMessage, @NonNull TextSpannableBuilder builder, TextView tvContent) {
ChatRoomMessageExtension extension = chatRoomMessage.getChatRoomMessageExtension();
String userLevel = NobleUtil.getLevel(UserLevelResourceType.EXPER_URL, chatRoomMessage);
boolean isOfficial = NobleUtil.getIsOfficial(UserInfo.IS_OFFICIAL, chatRoomMessage);
String vipIcon = NobleUtil.getResource(UserInfo.VIP_ICON, chatRoomMessage);
builder.append(vipIcon, expLevelHeight)
.append(isOfficial ? ResourcesCompat.getDrawable(getResources(),
R.mipmap.ic_user_official_13dp, null) : null,
badgeWidth, badgeHeight)
.append(getNewUserDrawable(chatRoomMessage), badgeWidth, badgeHeight)
.append(AvRoomDataManager.get().isSuperAdmin(chatRoomMessage.getFromAccount()) ? ResourcesCompat.getDrawable(getResources(),
R.drawable.ic_room_super_admin, null) : null,
SizeUtils.dp2px(tvContent.getContext(), 23), expLevelHeight);
// 官方主播認證
String tvOfficialMask = NobleUtil.getLevel(UserInfo.OAC_NAME, chatRoomMessage).trim();
String ivOfficialMask = NobleUtil.getLevel(UserInfo.OAC_ICON, chatRoomMessage);
if (!TextUtils.isEmpty(tvOfficialMask) && !TextUtils.isEmpty(ivOfficialMask) && extension != null) { // extension != null 表示自己
builder.appendBgAndContent(ivOfficialMask, tvOfficialMask);
} else if (!TextUtils.isEmpty(ivOfficialMask)) {
builder.append(ivOfficialMask, SizeUtils.dp2px(tvContent.getContext(), 62), expLevelHeight);
}
//等級
builder.append(userLevel, expLevelHeight);
//銘牌
String tvNamePlate = NobleUtil.getNamePlate(UserInfo.NAMEPLATE_WORD, chatRoomMessage).trim();
String ivNamePlate = NobleUtil.getNamePlate(UserInfo.NAMEPLATE_PIC, chatRoomMessage);
if (!TextUtils.isEmpty(tvNamePlate) && !TextUtils.isEmpty(ivNamePlate)) { // extension != null 表示自己
builder.appendBgAndContent(ivNamePlate, tvNamePlate);
} else if (!TextUtils.isEmpty(ivNamePlate)) {
builder.append(ivNamePlate, expLevelHeight);
}
}
private void setHeadlineMsg(ChatRoomMessage chatRoomMessage, TextView tvContent, CustomAttachment attachment) {
HeadlineChangedAttachment headlineAttachment = (HeadlineChangedAttachment) attachment;
SpannableTextBuilder builder = new SpannableTextBuilder(tvContent);
if (attachment.getSecond() == CustomAttachment.CUSTOM_MSG_HEADLINE_CHANGED_SUB) {
HeadlineBean data = headlineAttachment.getHeadlineData();
String nick = null;
if (data != null) {
nick = data.getNick();
}
if (nick == null) {
nick = "";
}
builder.appendText(String.format(ResUtil.getString(R.string.headline_message_format), nick), null, null, null, null, null, null);
builder.setTextStyle(nick, ContextCompat.getColor(getContext(), R.color.color_DE3446), null, null, null, null, null);
}
tvContent.setText(builder.build());
tvContent.setTextSize(11);
setNullBackground(tvContent);
}
/**
* {badge}xxx來了
*
* @param chatRoomMessage -
* @param tvContent -
*/
private void setMsgNotification(ChatRoomMessage chatRoomMessage, TextView tvContent, int position) {
int fromType = 0;
String fromNick = "";
String fromUid = "";
Map<String, Object> remoteExtension = chatRoomMessage.getRemoteExtension();
if (remoteExtension != null) {
fromType = (int) remoteExtension.get("fromType");
fromNick = (String) remoteExtension.get("fromNick");
fromUid = (String) remoteExtension.get("fromUid");
}
ChatRoomNotificationAttachment attachment = (ChatRoomNotificationAttachment) chatRoomMessage.getAttachment();
String senderNick = "";
List<String> nicks = attachment.getTargetNicks();
if (nicks != null && nicks.size() > 0)
senderNick = RegexUtil.getPrintableString(attachment.getTargetNicks().get(0));
if (attachment.getType() != NotificationType.ChatRoomMemberIn) return;
// 座駕
String carName = NobleUtil.getCarName(CarInfo.CAR_NAME, chatRoomMessage);
carName = TextUtils.isEmpty(carName) ? "" : "\"" + carName + "\"";
TextSpannableBuilder text = new TextSpannableBuilder(tvContent);
addCommonTag(chatRoomMessage, text, tvContent);
text.append(senderNick, new ForegroundColorSpan(roomTipColor),
new OriginalDrawStatusClickSpan() {
@Override
public void onClick(@NonNull View view) {
if (clickConsumer != null) {
Single.just(chatRoomMessage.getFromAccount())
.doOnSuccess(clickConsumer).subscribe();
}
}
});
text.append(TextUtils.isEmpty(carName) ? "" : ResUtil.getString(R.string.avroom_widget_messageview_0150), new ForegroundColorSpan(greyColor))
.append(carName, new ForegroundColorSpan(roomTipColor));
String enterText = ResUtil.getString(R.string.avroom_widget_messageview_0151);
if (fromType == AVRoomActivity.FROM_TYPE_RECOMMEND) {
enterText = ResUtil.getString(R.string.avroom_widget_messageview_0152);
}
if (fromType == AVRoomActivity.FROM_TYPE_USER || fromType == AVRoomActivity.FROM_TYPE_HELLO) {
String finalFromUid = fromUid;
text.append(ResUtil.getString(R.string.avroom_widget_messageview_0153), new ForegroundColorSpan(whiteColor))
.append(fromNick, new ForegroundColorSpan(roomTipColor),
new OriginalDrawStatusClickSpan() {
@Override
public void onClick(@NonNull View view) {
if (clickConsumer != null) {
Single.just(finalFromUid).doOnSuccess(clickConsumer).subscribe();
}
}
});
enterText = ResUtil.getString(R.string.avroom_widget_messageview_0154);
}
if (fromType == AVRoomActivity.FROM_TYPE_GAME_RECOMMEND) {
String finalFromUid = fromUid;
text.append(ResUtil.getString(R.string.avroom_widget_messageview_0155), new ForegroundColorSpan(whiteColor))
.append(fromNick, new ForegroundColorSpan(roomTipColor),
new OriginalDrawStatusClickSpan() {
@Override
public void onClick(@NonNull View view) {
if (clickConsumer != null) {
Single.just(finalFromUid).doOnSuccess(clickConsumer).subscribe();
}
}
});
enterText = ResUtil.getString(R.string.avroom_widget_messageview_0156);
}
text.append(enterText, new ForegroundColorSpan(whiteColor));
tvContent.setText(text.build());
tvContent.setOnClickListener(null);
tvContent.setMovementMethod(new LinkMovementMethod());
}
@Nullable
private Drawable getNewUserDrawable(ChatRoomMessage chatRoomMessage) {
boolean newUser = NobleUtil.getIsNewUser(UserInfo.IS_NEW_USER, chatRoomMessage);
boolean isHelloUser = NobleUtil.getIsNewUser(UserInfo.IS_FROM_SAY_HELLO_CHANNEL, chatRoomMessage);
if (newUser) {
return ResourcesCompat.getDrawable(getResources(),
isHelloUser ? R.drawable.ic_new_user_hello : R.drawable.ic_new_user,
null);
}
return null;
}
@SuppressLint("CheckResult")
@Override
public void onClick(View v) {
String account = "";
ChatRoomMessage chatRoomMessage = (ChatRoomMessage) v.getTag();
if (chatRoomMessage.getMsgType() != MsgTypeEnum.tip) {
if (chatRoomMessage.getMsgType() == MsgTypeEnum.text) {
account = chatRoomMessage.getFromAccount();
} else if (chatRoomMessage.getMsgType() == MsgTypeEnum.notification) {
account = chatRoomMessage.getFromAccount();
} else if (chatRoomMessage.getMsgType() == MsgTypeEnum.custom) {
CustomAttachment attachment = (CustomAttachment) chatRoomMessage.getAttachment();
if (attachment.getFirst() == CustomAttachment.CUSTOM_MSG_HEADER_TYPE_ROOM_TIP) {
account = ((RoomTipAttachment) attachment).getUid() + "";
} else if (attachment.getFirst() == CustomAttachment.CUSTOM_MSG_BOX) {
account = String.valueOf(((RoomBoxPrizeAttachment) attachment).getUid());
} else if (attachment.getFirst() == CustomAttachment.CUSTOM_MSG_HEADER_TYPE_QUEUE) {
long handleUid = ((RoomQueueMsgAttachment) attachment).handleUid;
if (handleUid > 0) {
account = ((RoomQueueMsgAttachment) attachment).handleUid + "";
} else {
//ios沒用handleUid導致iOS發的自定義消息拿不到uid
account = chatRoomMessage.getFromAccount();
}
} else if (attachment.getFirst() == CustomAttachment.CUSTOM_MSG_HEADER_TYPE_MONSTER_HUNTING) {
switch (attachment.getSecond()) {
case CustomAttachment.CUSTOM_MSG_SUB_TYPE_MONSTER_HUNTING:
MonsterDataBean dataBean = ((MonsterStatusAttachment) attachment).getDataBean();
RoomInfo mCurrentRoomInfo = AvRoomDataManager.get().mCurrentRoomInfo;
if (!Objects.equals(mCurrentRoomInfo.getUid(), dataBean.getAppearRoomUid())) {
AVRoomActivity.start(getContext(), dataBean.getAppearRoomUid());
} else {
SingleToastUtil.showToast("你已經在怪獸房間內");
}
break;
case CustomAttachment.CUSTOM_NOTI_SUB_GAME_RESULT:
MonsterHuntingResult result = ((MonsterHuntingResultAttachment) attachment).getResult();
UIHelper.showMonsterResult(getContext(), String.valueOf(result.getMonster().getMonsterId()));
break;
}
} else if (attachment.getFirst() == CustomAttachment.CUSTOM_MESS_HEAD_ROOM_PK) {
if (attachment.getSecond() == CustomAttachment.CUSTOM_MESS_SUB_ROOM_PK_RESULT) {
RoomTeamPKResultDialog pkResultDialog = new RoomTeamPKResultDialog(getContext(), ((RoomPkAttachment) attachment).getRoomPkData());
pkResultDialog.show();
}
} else if (attachment instanceof RoomFollowOwnerAttachment2 && !AvRoomDataManager.get().isRoomFans) {
CollectionRoomModel.get().followRoom("1", ((RoomFollowOwnerAttachment2) attachment).getOwnerUid())
.subscribe(s -> {
AvRoomDataManager.get().isRoomFans = true;
SingleToastUtil.showToast("收藏成功!");
EventBus.getDefault().post(new FollowRoomEvent());
PraiseModel.get().setFollowRoomSuccessRoomTip(JavaUtil.str2long(chatRoomMessage.getFromAccount()));
});
} else if (attachment.getFirst() == CustomAttachment.CUSTOM_MESS_TAROT) {
if (attachment instanceof TarotAttachment) {
account = ((TarotAttachment) attachment).getTarotMsgBean().getUid() + "";
}
}
}
if (TextUtils.isEmpty(account)) return;
if (clickConsumer != null) {
Single.just(account).subscribe(clickConsumer);
}
} else {
String content = chatRoomMessage.getContent();
if (!TextUtils.isEmpty(content) && content.equals(ResUtil.getString(R.string.yizhuan_xchat_android_constants_xchatconstants_08)))
if (onClick != null) {
onClick.onShowRoomIntroduction();
}
}
}
@Override
public ImageSpan invoke(Drawable drawable) {
return new CustomImageSpan(drawable);
}
class MessageViewHolder extends RecyclerView.ViewHolder {
TextView tvContent;
public MessageViewHolder(View itemView) {
super(itemView);
tvContent = itemView.findViewById(R.id.tv_content);
}
}
}
}

View File

@@ -1,111 +0,0 @@
package com.chwl.app.avroom.public_chat
import android.content.Context
import android.util.AttributeSet
import com.chwl.app.R
import com.chwl.app.public_chat.core.ChatRoomClient
import com.chwl.app.public_chat.core.ChatRoomClientManager
import com.chwl.core.im.custom.bean.HeadlineChangedAttachment
import com.chwl.core.support.room.FrameLayoutRoomWidget
import com.chwl.core.support.room.RoomView
import com.chwl.library.utils.SingleToastUtil
import com.netease.nim.uikit.api.model.NimException
import com.netease.nimlib.sdk.chatroom.model.ChatRoomMessage
import com.netease.nimlib.sdk.msg.constant.MsgTypeEnum
import com.netease.nimlib.sdk.msg.model.QueryDirectionEnum
class PublicChatRoomMessageWidget : FrameLayoutRoomWidget {
private val messageView: PublicChatMessageView = PublicChatMessageView(context)
private var chatRoomClient: ChatRoomClient? = null
constructor(context: Context) : super(context)
constructor(context: Context, attrs: AttributeSet?) : super(context, attrs)
constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : super(
context,
attrs,
defStyleAttr
)
constructor(
context: Context,
attrs: AttributeSet?,
defStyleAttr: Int,
defStyleRes: Int
) : super(context, attrs, defStyleAttr, defStyleRes)
init {
addView(messageView, LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT))
}
override fun onStart(roomView: RoomView) {
super.onStart(roomView)
chatRoomClient = ChatRoomClientManager.getPublicChatClient()
if (chatRoomClient == null) {
SingleToastUtil.showToast(R.string.public_chat_not_found)
}
chatRoomClient?.let {
initChatRoom(it)
}
}
private fun onReceiveMessage(message: ChatRoomMessage) {
if (!filterMessageForMessageList(message)) {
messageView.addMessages(message)
}
}
private fun initChatRoom(chatRoomClient: ChatRoomClient) {
getCompositeDisposable().add(
chatRoomClient.enterChatRoom()
.subscribe({ requestHistory(chatRoomClient) },
{
if (it is NimException) {
SingleToastUtil.showToast(context.getString(R.string.avroom_fragment_homepartyroomfragment_011) + "(${it.code})")
} else {
SingleToastUtil.showToast(R.string.avroom_fragment_homepartyroomfragment_011)
}
})
)
getCompositeDisposable().add(chatRoomClient.messageObservable.subscribe {
it.forEach { message ->
onReceiveMessage(message)
}
})
}
private fun requestHistory(chatRoomClient: ChatRoomClient) {
val typeEnums = arrayOf(MsgTypeEnum.text, MsgTypeEnum.image)
getCompositeDisposable().add(
chatRoomClient.requestRemoteMessageType(
0,
50,
QueryDirectionEnum.QUERY_OLD,
typeEnums
).subscribe({
messageView.addHistoryMessages(it.reversed())
}, {
it.printStackTrace()
})
)
}
private fun filterMessageForMessageList(message: ChatRoomMessage): Boolean {
if (message.msgType == MsgTypeEnum.custom && message.attachment is HeadlineChangedAttachment) {
val data = (message.attachment as HeadlineChangedAttachment).headlineData
if (data == null || !data.isValid()) {
return true
}
}
return false
}
fun getMessageView() = messageView
override fun onStop() {
super.onStop()
chatRoomClient = null
}
}

View File

@@ -16,12 +16,11 @@ import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.PopupWindow;
import android.widget.TextView;
import com.chwl.core.manager.AvRoomDataManager;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.chwl.app.avroom.activity.RoomTypeSwitchActivity;
import com.chwl.app.avroom.dialog.RoomGameplayDialog;
import com.chwl.core.utils.extension.StringExtensionKt;
import com.netease.nim.uikit.api.NimUIKit;
import com.netease.nim.uikit.common.util.sys.ScreenUtil;
@@ -30,7 +29,6 @@ import com.netease.nimlib.sdk.uinfo.model.UserInfo;
import com.chwl.app.R;
import com.chwl.app.avroom.BottomViewListenerWrapper;
import com.chwl.app.ui.utils.ImageLoadUtils;
import com.chwl.app.vip.VipMainActivity;
import com.chwl.app.room_chat.activity.RoomMsgActivity;
import com.chwl.core.helper.ImHelperUtils;
import com.chwl.core.manager.AvRoomDataManager;
@@ -75,6 +73,10 @@ public class BottomView extends LinearLayout implements View.OnClickListener {
private ImageView iconMicQueue;
private ImageView iconRoomMsg;
private ImageView iconRoomBaiShunGame;
private ImageView pkGameView;
@Nullable
private PopupWindow msgTipPopupWindow;
@NonNull
@@ -106,11 +108,12 @@ public class BottomView extends LinearLayout implements View.OnClickListener {
remoteMute = findViewById(R.id.icon_room_open_remote_mic);
faceLayout = findViewById(R.id.room_face_layout);
micLayout = findViewById(R.id.room_mic_layout);
iconRoomBaiShunGame = findViewById(R.id.icon_room_baishun_game);
iconMicQueue = (ImageView) findViewById(R.id.icon_mic_queue);
iconRoomMsg = findViewById(R.id.iv_room_message);
ImageView gameView = findViewById(R.id.icon_room_game);
pkGameView = findViewById(R.id.icon_room_PK_game);
openMic.setOnClickListener(this);
sendMsgInput.setOnClickListener(this);
sendFace.setOnClickListener(this);
@@ -119,7 +122,8 @@ public class BottomView extends LinearLayout implements View.OnClickListener {
sendMagic.setOnClickListener(this);
iconMicQueue.setOnClickListener(this);
iconRoomMsg.setOnClickListener(this);
gameView.setOnClickListener(this);
pkGameView.setOnClickListener(this);
iconRoomBaiShunGame.setOnClickListener(this);
setMicBtnEnable(false);
setMicBtnOpen(false);
@@ -243,6 +247,10 @@ public class BottomView extends LinearLayout implements View.OnClickListener {
}
}
public void setBaiShunBtnOpen(boolean isOpen) {
iconRoomBaiShunGame.setVisibility(isOpen ? VISIBLE : GONE);
}
public void notifyStateChanged() {
setMagicBtnEnable(true);
}
@@ -252,6 +260,21 @@ public class BottomView extends LinearLayout implements View.OnClickListener {
micLayout.setVisibility(VISIBLE);
}
public void updateGameEntrance() {
if (AvRoomDataManager.get().isManager() || SuperAdminUtil.isSuperAdmin()) {
if (!AvRoomDataManager.get().isCpRoom()) {
pkGameView.setVisibility(VISIBLE);
iconRoomBaiShunGame.setVisibility(VISIBLE);
}
} else {
pkGameView.setVisibility(GONE);
iconRoomBaiShunGame.setVisibility(GONE);
}
if (AvRoomDataManager.get().isSingleRoom() || AvRoomDataManager.get().isDatingMode()) {
pkGameView.setVisibility(GONE);
}
}
public void showHomePartyDownMicBottom() {
faceLayout.setVisibility(GONE);
micLayout.setVisibility(GONE);
@@ -351,9 +374,14 @@ public class BottomView extends LinearLayout implements View.OnClickListener {
wrapper.onRoomMessageClick();
}
break;
case R.id.icon_room_game:
case R.id.icon_room_PK_game:
if (wrapper != null) {
wrapper.onRoomGameplayClick();
wrapper.onRoomGameplayClick(true);
}
break;
case R.id.icon_room_baishun_game:
if (wrapper != null) {
wrapper.onRoomGameplayClick(false);
}
break;
default:

View File

@@ -1442,6 +1442,7 @@ class RoomEffectView @JvmOverloads constructor(
enterRoomEffects = remoteExtension[UserInfo.ENTER_ROOM_EFFECTS] as String?
}
val wrapNick = "" + targetNicks[0].subAndReplaceDot(7) + "" + enterText
if (!TextUtils.isEmpty(enterRoomEffects)) {
playMemberInAnimByUrl(wrapNick, enterRoomEffects)
} else {
@@ -1495,7 +1496,11 @@ class RoomEffectView @JvmOverloads constructor(
private fun playMemberInAnim(text: String, svgaVideoEntity: SVGAVideoEntity) {
binding.roomMenberInSvga.visibility = VISIBLE
binding.roomMenberInSvga.loops = 1
if (svgaVideoEntity.frames == 1) {
binding.roomMenberInSvga.loops = 50
} else {
binding.roomMenberInSvga.loops = 1
}
binding.roomMenberInSvga.clearsAfterStop = true
val dynamicEntity = SVGADynamicEntity()
val textPaint = TextPaint()

View File

@@ -28,6 +28,7 @@ import android.text.Spannable;
import android.text.SpannableString;
import android.text.TextUtils;
import android.text.style.StyleSpan;
import android.view.Gravity;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.MenuItem;
@@ -46,6 +47,7 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.chwl.app.notify.GlobalNotifyManager;
import com.chwl.library.language.LanguageHelper;
import com.example.lib_utils.UiUtils;
import com.google.gson.Gson;
import com.netease.nim.uikit.common.util.log.LogUtil;
import com.netease.nimlib.sdk.NIMSDK;
@@ -236,6 +238,21 @@ public abstract class BaseActivity extends RxAppCompatActivity
}
}
public void initVipCenterBar(String title) {
mTitleBar = findViewById(R.id.title_bar);
if (mTitleBar != null) {
mTitleBar.setTitle(title);
mTitleBar.setImmersive(false);
mTitleBar.setTitleColor(getResources().getColor(R.color.color_FFE3AF));
mTitleBar.setLeftImageResource(R.drawable.vip_center_back_button);
mTitleBar.setBackgroundResource(R.color.transparent);
mTitleBar.setLeftClickListener(v -> onLeftClickListener());
if(UiUtils.INSTANCE.isRtl(context)){
mTitleBar.leftTextViewUpdateScaleXForRTL();
}
}
}
public void initWhiteTitleBar(String title) {
mTitleBar = findViewById(R.id.title_bar);
if (mTitleBar != null) {

View File

@@ -63,6 +63,10 @@ public class TitleBar extends ViewGroup implements View.OnClickListener {
private LayoutInflater mInflater;
public void leftTextViewUpdateScaleXForRTL() {
mLeftText.setScaleX(-1);
}
public TitleBar(Context context) {
super(context);
init(context);

View File

@@ -11,7 +11,15 @@ import com.chwl.app.databinding.ItemMyUserCardWearBinding;
import com.chwl.app.ui.utils.ImageLoadUtils;
import com.chwl.core.decoration.headwear.bean.HeadWearInfo;
import com.chwl.core.decoration.headwear.bean.UserCardWearInfo;
import com.chwl.library.download.DownloadException;
import com.chwl.library.download.DownloadManager;
import com.chwl.library.download.DownloadRequest;
import com.chwl.library.download.DownloadTask;
import com.chwl.library.download.FileDownloadListener;
import com.chwl.library.utils.ResUtil;
import com.chwl.library.utils.PathHelper;
import java.io.File;
/**
* Created by huangmeng1 on 2018/5/11.
@@ -27,7 +35,24 @@ public class MyUserCardWearAdapter extends BaseAdapter<UserCardWearInfo> {
protected void convert(@NonNull BindingViewHolder helper, UserCardWearInfo item) {
super.convert(helper, item);
ItemMyUserCardWearBinding binding = (ItemMyUserCardWearBinding) helper.getBinding();
ImageLoadUtils.loadImage(mContext, item.getPic(), binding.ivUserCardWear);
binding.ivUserCardWearMp4.setLoop(Integer.MAX_VALUE);
String filePath = PathHelper.INSTANCE.generateResourcesFilePath(item.getPic());
DownloadRequest request = DownloadRequest.Companion.build(item.getPic(), filePath, "gift_effect_download", null, 60000L);
DownloadManager.INSTANCE.download(request, new FileDownloadListener() {
@Override
public void onDownloadCompleted(@NonNull DownloadTask task) {
String path = task.getRequest().getPath();
binding.ivUserCardWearMp4.startPlay(new File(path));
}
@Override
public void onDownloadError(@NonNull DownloadException exception) {
ImageLoadUtils.loadImage(mContext, item.getPic(), binding.ivUserCardWear);
}
});
helper.addOnClickListener(R.id.tv_used);
if (item.getLabelType() == HeadWearInfo.LABEL_TYPE_NORMAL) {

View File

@@ -93,18 +93,18 @@ public class MyUserCardWearFragment extends BaseBindingFragment<FrgMyDecorationC
String cardId = headWearInfo.isUsed() ? null : headWearInfo.getCardId();
wearVm.userHeadWear(cardId)
.compose(bindUntilEvent(FragmentEvent.DESTROY))
.doOnError(throwable -> {
toast(throwable.getMessage());
})
.subscribe(s -> {
for (int i = 0; i < shopAdapter.getData().size(); i++) {
shopAdapter.getData().get(i).setUsed(Objects.equals(cardId,shopAdapter.getData().get(i).getCardId()));
}
shopAdapter.notifyDataSetChanged();
//更新用户信息
UserModel.get().updateCurrentUserInfo().subscribe();
});
.compose(bindUntilEvent(FragmentEvent.DESTROY))
.doOnError(throwable -> {
toast(throwable.getMessage());
})
.subscribe(s -> {
for (int i = 0; i < shopAdapter.getData().size(); i++) {
shopAdapter.getData().get(i).setUsed(Objects.equals(cardId,shopAdapter.getData().get(i).getCardId()));
}
shopAdapter.notifyDataSetChanged();
//更新用户信息
UserModel.get().updateCurrentUserInfo().subscribe();
});
}
}

View File

@@ -129,9 +129,9 @@ class ConvertDiamondActivity : BaseViewBindingActivity<ActivityConvertDiamondBin
}
binding.tvConvert.setOnClickListener { view ->
if (binding.edDiamond.text.toString().toLong() < it.minDiamonds) {
if (binding.edGold.text.toString().toLong() < it.minDiamonds) {
toast(getString(R.string.convert_diamonds_01).format(it.minDiamonds))
} else if (binding.edDiamond.text.toString().toLong() > it.maxDiamonds) {
} else if (binding.edGold.text.toString().toLong() > it.maxDiamonds) {
toast(getString(R.string.convert_diamonds_02).format(it.minDiamonds))
} else {
//去掉小数凑整:不管小数是多少,都进一

View File

@@ -13,8 +13,8 @@ class HomeMessageViewModel : BaseViewModel() {
safeLaunch(needLoading = false, onError = {
topPublicChatMessageLiveData.postValue(BeanResult.failed(it))
}) {
val value = PublicChatModel.getTopMessage()
topPublicChatMessageLiveData.postValue(BeanResult.success(value ?: emptyList()))
// val value = PublicChatModel.getTopMessage()
// topPublicChatMessageLiveData.postValue(BeanResult.success(value ?: emptyList()))
}
}

View File

@@ -21,8 +21,8 @@ public class HomeIndicatorAdapter extends CommonNavigatorAdapter {
private final Context mContext;
private final List<? extends CharSequence> mTitleList;
private int textSize = 21;
private float minScale = 0.857f;
private int textSize = 20;
private float minScale = 0.8f;
private boolean showIndicator = true;
private OnItemSelectListener mOnItemSelectListener;
@@ -39,8 +39,8 @@ public class HomeIndicatorAdapter extends CommonNavigatorAdapter {
@Override
public IPagerTitleView getTitleView(Context context, final int i) {
ScaleTransitionPagerTitleView scaleTransitionPagerTitleView = new ScaleTransitionPagerTitleView(context, true);
scaleTransitionPagerTitleView.setNormalColor(ContextCompat.getColor(context, R.color.color_990C1D18));
scaleTransitionPagerTitleView.setSelectedColor(ContextCompat.getColor(context, R.color.color_0C1D18));
scaleTransitionPagerTitleView.setNormalColor(ContextCompat.getColor(context, R.color.color_313131));
scaleTransitionPagerTitleView.setSelectedColor(ContextCompat.getColor(context, R.color.color_313131));
scaleTransitionPagerTitleView.setMinScale(minScale);
scaleTransitionPagerTitleView.setTextSize(textSize);
int padding = UIUtil.dip2px(context, 13);
@@ -62,7 +62,7 @@ public class HomeIndicatorAdapter extends CommonNavigatorAdapter {
indicator.setLineHeight(context.getResources().getDimensionPixelOffset(R.dimen.dp_4));
indicator.setRoundRadius(context.getResources().getDimensionPixelOffset(R.dimen.dp_2));
indicator.setLineWidth(context.getResources().getDimensionPixelOffset(R.dimen.dp_13));
indicator.setColors(context.getResources().getColor(R.color.color_002512));
indicator.setColors(context.getResources().getColor(R.color.color_e29030));
FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
// lp.bottomMargin = mBottomMargin;
indicator.setLayoutParams(lp);

View File

@@ -1,58 +0,0 @@
package com.chwl.app.home.adapter
import android.text.style.ImageSpan
import android.view.LayoutInflater
import android.view.ViewGroup
import android.widget.ImageView
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import com.chad.library.adapter.base.BaseViewHolder
import com.chwl.app.R
import com.chwl.app.ui.utils.loadAvatar
import com.chwl.core.public_chat_hall.bean.PublicChatMessageBean
import com.netease.nim.uikit.api.NimUIKit
import com.netease.nim.uikit.business.session.emoji.MoonUtil
class PublicChatLaneAdapter(private val data: MutableList<PublicChatMessageBean>) :
RecyclerView.Adapter<BaseViewHolder>() {
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): BaseViewHolder {
return BaseViewHolder(
LayoutInflater.from(parent.context).inflate(R.layout.public_chat_lane_item, null)
)
}
override fun onBindViewHolder(holder: BaseViewHolder, position: Int) {
val item = getItem(position)
val textView = holder.getView<TextView>(R.id.tv_message)
MoonUtil.identifyFaceExpressionSmall(
NimUIKit.getContext(),
textView,
item?.content ?: "",
ImageSpan.ALIGN_CENTER
)
val avatarView = holder.getView<ImageView>(R.id.iv_avatar)
avatarView.loadAvatar(item?.fromAvatar ?: "")
}
override fun getItemCount(): Int {
return Int.MAX_VALUE
}
fun getRealItemCount(): Int {
return data.size
}
fun setNewData(list: List<PublicChatMessageBean>) {
data.clear()
data.addAll(list)
notifyDataSetChanged()
}
private fun getItem(position: Int): PublicChatMessageBean? {
if (data.isEmpty()) {
return null
}
return data[position % data.size]
}
}

View File

@@ -19,7 +19,6 @@ import com.chwl.app.avroom.adapter.CommonVPAdapter
import com.chwl.app.base.BaseViewBindingFragment
import com.chwl.app.databinding.FragmentContactListBinding
import com.chwl.app.home.HomeMessageViewModel
import com.chwl.app.home.adapter.PublicChatLaneAdapter
import com.chwl.app.home.helper.AutoScrollTask
import com.chwl.app.public_chat.ui.message.PublicChatRoomMessageActivity
import com.chwl.app.support.FragmentVisibleStateHelper
@@ -42,7 +41,6 @@ class ContactsListFragment : BaseViewBindingFragment<FragmentContactListBinding>
MainTabContentView {
private val viewModel: HomeMessageViewModel by activityViewModels()
private val publicChatAdapter = PublicChatLaneAdapter(ArrayList())
private val stateHelper = FragmentVisibleStateHelper(this).start {
onVisibleChanged(it)
@@ -64,7 +62,6 @@ class ContactsListFragment : BaseViewBindingFragment<FragmentContactListBinding>
} else {
2
}
binding.recyclerViewPublicChat.scrollBy(x, 0)
}
override fun init() {
@@ -86,6 +83,8 @@ class ContactsListFragment : BaseViewBindingFragment<FragmentContactListBinding>
tagList.add(getString(R.string.layout_fragment_contact_list_04))
val commonNavigator = CommonNavigator(context)
commonNavigator.setTitleWrapContent(false)
commonNavigator.rightPadding = 20
commonNavigator.leftPadding = 20
val magicIndicatorAdapter = ContactsIndicatorAdapter(context, tagList)
magicIndicatorAdapter.setOnItemSelectListener { position: Int, view: TextView? ->
binding.viewPager.currentItem = position
@@ -159,37 +158,20 @@ class ContactsListFragment : BaseViewBindingFragment<FragmentContactListBinding>
return true
}
})
binding.layoutPublicChat.singleClick {
PublicChatRoomMessageActivity.start(requireContext())
}
binding.recyclerViewPublicChat.setOnTouchListener { v, event ->
gestureDetectorCompat.onTouchEvent(event)
}
binding.recyclerViewPublicChat.layoutManager =
StaggeredGridLayoutManager(2, RecyclerView.HORIZONTAL)
binding.recyclerViewPublicChat.adapter = publicChatAdapter
viewModel.topPublicChatMessageLiveData.observe(this) {
val newList = it.data
if (it.isSuccess && !newList.isNullOrEmpty()) {
publicChatAdapter.setNewData(newList)
switchPublicChatMessageScrollState(stateHelper.isVisible)
}
binding.recyclerViewPublicChat.isVisible = (publicChatAdapter.getRealItemCount() > 0)
}
}
private fun switchPublicChatMessageScrollState(isVisible: Boolean) {
if (isVisible && publicChatAdapter.getRealItemCount() > 0) {
autoScrollTask.start()
} else {
autoScrollTask.stop()
}
// if (isVisible && publicChatAdapter.getRealItemCount() > 0) {
// autoScrollTask.start()
// } else {
// autoScrollTask.stop()
// }
}
private fun onVisibleChanged(isVisible: Boolean) {
switchPublicChatMessageScrollState(isVisible)
if (isVisible) {
viewModel.getTopPublicChatMessageIfNull()
}
// switchPublicChatMessageScrollState(isVisible)
// if (isVisible) {
// viewModel.getTopPublicChatMessageIfNull()
// }
}
}

View File

@@ -56,7 +56,7 @@ class HomeFragment : BaseViewBindingFragment<FragmentHomeBinding>(), View.OnClic
titleList.add(getString(R.string.main_tab_recommend))
titleList.add(getString(R.string.main_me))
val commonNavigator = CommonNavigator(context)
commonNavigator.setTitleWrapContent(false)
commonNavigator.setTitleWrapContent(true)
val magicIndicatorAdapter = HomeIndicatorAdapter(context, titleList)
magicIndicatorAdapter.setOnItemSelectListener { position: Int, view: TextView? ->
binding.viewPager.currentItem = position

View File

@@ -35,7 +35,7 @@ import com.chwl.app.ui.utils.ImageLoadUtils
import com.chwl.app.ui.wallet.WalletActivity
import com.chwl.app.ui.webview.CommonWebViewActivity
import com.chwl.app.view.GenderAgeTextView
import com.chwl.app.vip.VipMainActivity
import com.chwl.app.vip.VipCenterActivity
import com.chwl.app.vip.VipViewModel
import com.chwl.core.auth.AuthModel
import com.chwl.core.initial.InitialModel
@@ -353,7 +353,7 @@ class MeFragment : BaseFragment(), View.OnClickListener {
}
R.id.iv_vip -> {
VipMainActivity.start(mContext)
VipCenterActivity.start(mContext)
//进入贵族中心埋点
val goldWalletInfo = PayModel.get().currentWalletInfo
val map = HashMap<String, Any>(5)

View File

@@ -9,6 +9,7 @@ import com.chwl.app.earn.activity.EarnRecordActivity;
import com.chwl.app.pay.activity.GiveGoldActivity;
import com.chwl.app.ui.feedback.FeedbackActivity;
import com.chwl.app.ui.game_team.record.GameTeamRecordActivity;
import com.chwl.app.vip.VipCenterActivity;
import com.chwl.core.module_hall.hall.bean.H5FamilyInfo;
import com.chwl.core.module_hall.hall.bean.UserClanInfo;
import com.trello.rxlifecycle3.components.support.RxAppCompatActivity;
@@ -38,7 +39,6 @@ import com.chwl.app.ui.pay.ChargeActivity;
import com.chwl.app.ui.setting.ModifyPwdActivity;
import com.chwl.app.ui.user.activity.UserInfoActivity;
import com.chwl.app.ui.webview.CommonWebViewActivity;
import com.chwl.app.vip.VipMainActivity;
import com.chwl.core.DemoCache;
import com.chwl.core.auth.AuthModel;
import com.chwl.core.community.event.SquareTaskEvent;
@@ -216,7 +216,7 @@ public class RouterHandler {
ModifyPwdActivity.start(context, ModifyPwdActivity.LOGIN_PWD);
break;
case RouterType.VIP_MAIN:
VipMainActivity.start(context);
VipCenterActivity.start(context);
break;
case RouterType.CP_INVITE:
CpInviteRecordActivity.Companion.start(context, false);
@@ -297,6 +297,9 @@ public class RouterHandler {
case RouterType.GAME_TEAM_RECORD:
GameTeamRecordActivity.Companion.start(context);
break;
case RouterType.MY_DRESS_ITEM:
MyDecorationActivity.start(context, 0);
break;
default:
SingleToastUtil.showToast(ResUtil.getString(R.string.ui_im_routerhandler_07));
return false;

View File

@@ -79,9 +79,9 @@ public abstract class RecentViewHolder extends RecyclerViewHolder<BaseQuickAdapt
protected void updateBackground(NIMBaseViewHolder holder, RecentContact recent, int position) {
if ((recent.getTag() & RecentContactsFragment.RECENT_TAG_STICKY) == 0) {
holder.getConvertView().setBackgroundResource(R.color.transparent);
// holder.getConvertView().setBackgroundResource(R.drawable.shape_white_10dp_round);
} else {
holder.getConvertView().setBackgroundResource(R.color.transparent);
holder.getConvertView().setBackgroundResource(R.drawable.shape_white_10dp_round);
}
}

View File

@@ -245,6 +245,9 @@ public class UserInfoActivity extends BaseBindingActivity<ActivityUserInfoBindin
initPhoto(dataBean.getPrivatePhoto());
setWhereVisible();
});
viewModel.getUserInfoDetailError().observe(this, String -> {
finish();
});
}
private void setTitleVisible(boolean visible) {

View File

@@ -1,6 +1,7 @@
package com.chwl.app.ui.user.adapter;
import android.content.Context;
import android.graphics.Typeface;
import android.view.Gravity;
import android.view.ViewGroup;
import android.widget.FrameLayout;
@@ -14,14 +15,16 @@ import com.chwl.app.ui.widget.magicindicator.buildins.UIUtil;
import com.chwl.app.ui.widget.magicindicator.buildins.commonnavigator.abs.CommonNavigatorAdapter;
import com.chwl.app.ui.widget.magicindicator.buildins.commonnavigator.abs.IPagerIndicator;
import com.chwl.app.ui.widget.magicindicator.buildins.commonnavigator.abs.IPagerTitleView;
import com.chwl.library.language.LanguageHelper;
import com.tencent.qgame.animplayer.mix.Resource;
import java.util.List;
public class ContactsIndicatorAdapter extends CommonNavigatorAdapter {
private final List<? extends CharSequence> mTitleList;
private int textSize = 16;
private float minScale = 1f;
private int textSize = 20;
private float minScale = 0.8f;
private boolean showIndicator = true;
private OnItemSelectListener mOnItemSelectListener;
@@ -37,10 +40,14 @@ public class ContactsIndicatorAdapter extends CommonNavigatorAdapter {
@Override
public IPagerTitleView getTitleView(Context context, final int i) {
ScaleTransitionPagerTitleView scaleTransitionPagerTitleView = new ScaleTransitionPagerTitleView(context, true);
scaleTransitionPagerTitleView.setNormalColor(ContextCompat.getColor(context, R.color.color_84868A));
scaleTransitionPagerTitleView.setSelectedColor(ContextCompat.getColor(context, R.color.color_1E1E1F));
scaleTransitionPagerTitleView.setNormalColor(ContextCompat.getColor(context, R.color.color_313131));
scaleTransitionPagerTitleView.setSelectedColor(ContextCompat.getColor(context, R.color.color_313131));
scaleTransitionPagerTitleView.setMinScale(minScale);
scaleTransitionPagerTitleView.setTextSize(textSize);
if (LanguageHelper.INSTANCE.getCurrentLanguageType().equals("EN")) {
scaleTransitionPagerTitleView.setTextSize(textSize);
} else {
scaleTransitionPagerTitleView.setTextSize(textSize-2);
}
int padding = UIUtil.dip2px(context, 16);
scaleTransitionPagerTitleView.setPadding(padding, 0, padding, 0);
scaleTransitionPagerTitleView.setText(mTitleList.get(i));

View File

@@ -6,11 +6,58 @@ import com.chad.library.adapter.base.BaseViewHolder
import com.chwl.app.R
import com.chwl.app.ui.utils.load
import com.chwl.core.user.bean.MedalBean
import com.chwl.library.download.DownloadManager
import com.chwl.library.download.DownloadRequest
import com.chwl.library.download.DownloadTask
import com.chwl.library.download.FileDownloadListener
import com.chwl.library.utils.PathHelper
import com.tencent.qgame.animplayer.AnimConfig
import com.tencent.qgame.animplayer.AnimView
import com.tencent.qgame.animplayer.inter.IAnimListener
import com.tencent.qgame.animplayer.util.ScaleType
import java.io.File
class UserInfoMedalAdapter :
BaseQuickAdapter<MedalBean, BaseViewHolder>(R.layout.user_info_item_medal) {
override fun convert(helper: BaseViewHolder, item: MedalBean) {
val imageView = helper.getView<ImageView>(R.id.iv_image)
imageView.load(item.picUrl)
item.picUrl?.let {
if (it.replace("\n", "").lowercase().endsWith("mp4")) {
val mp4View = helper.getView<AnimView>(R.id.iv_mp4)
mp4View.setScaleType(ScaleType.FIT_XY)
mp4View.setLoop(Int.MAX_VALUE)
mp4View.setAnimListener(object : IAnimListener {
override fun onFailed(errorType: Int, errorMsg: String?) {
}
override fun onVideoComplete() {
}
override fun onVideoDestroy() {
}
override fun onVideoRender(frameIndex: Int, config: AnimConfig?) {
}
override fun onVideoStart() {
}
})
val filePath = PathHelper.generateResourcesFilePath(it)
val request = DownloadRequest.build(it, filePath, "", null, 600000L)
DownloadManager.download(request, object : FileDownloadListener() {
override fun onDownloadCompleted(task: DownloadTask) {
val path = task.getRequest().getPath()
mp4View.startPlay(File(path))
}
})
} else {
val imageView = helper.getView<ImageView>(R.id.iv_image)
imageView.load(item.picUrl)
}
}
}
}

View File

@@ -26,7 +26,9 @@ class UserInfoViewModel : BaseViewModel() {
val userInfoData: LiveData<UserInfo> = _userInfoData
private val _userInfoDetailData = MutableLiveData<UserDetailInfo.DataBean>()
private val _userInfoDetailError = MutableLiveData<String>()
val userInfoDetailData: LiveData<UserDetailInfo.DataBean> = _userInfoDetailData
val userInfoDetailError: LiveData<String> = _userInfoDetailError
val userClanData = MutableLiveData<UserClanInfo>()
@@ -55,6 +57,7 @@ class UserInfoViewModel : BaseViewModel() {
.subscribe(object : BeanObserver<UserDetailInfo?>() {
override fun onErrorMsg(error: String) {
error.toast()
_userInfoDetailError.postValue(error)
}
override fun onSuccess(info: UserDetailInfo) {

View File

@@ -1,5 +1,13 @@
package com.chwl.app.ui.widget;
import static com.chwl.app.ui.widget.magicindicator.GiftIndicator.TYPE_COUNTRY;
import static com.chwl.app.ui.widget.magicindicator.GiftIndicator.TYPE_LUCKY;
import static com.chwl.app.ui.widget.magicindicator.GiftIndicator.TYPE_NOBLE;
import static com.chwl.app.ui.widget.magicindicator.GiftIndicator.TYPE_NORMAL;
import static com.chwl.app.ui.widget.magicindicator.GiftIndicator.TYPE_SING_ROOM;
import static com.chwl.app.ui.widget.magicindicator.GiftIndicator.TYPE_SUPER_LUCKY;
import static com.chwl.app.ui.widget.magicindicator.GiftIndicator.TYPE_WEEK;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Context;
@@ -35,9 +43,12 @@ import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.chwl.app.ui.adapter.StarWeekAdapter;
import com.chwl.app.ui.webview.DialogWebViewActivity;
import com.chwl.app.vip.VipCenterActivity;
import com.chwl.core.UriProvider;
import com.chwl.core.gift.bean.LuckyBagNoticeInfo;
import com.chwl.core.gift.bean.SimpleUserInfo;
import com.chwl.core.gift.bean.TagsInfo;
import com.chwl.core.home.bean.TabInfo;
import com.chwl.core.room.anotherroompk.ShowUserInfoDialogEvent;
import com.chwl.core.utils.extension.StringExtensionKt;
import com.example.lib_utils.UiUtils;
@@ -64,7 +75,6 @@ import com.chwl.app.ui.widget.magicindicator.buildins.UIUtil;
import com.chwl.app.ui.widget.recyclerview.decoration.VerticalDecoration;
import com.chwl.app.utils.RegexUtil;
import com.chwl.app.utils.SpannableBuilder;
import com.chwl.app.vip.VipMainActivity;
import com.chwl.core.auth.AuthModel;
import com.chwl.core.bean.RoomQueueInfo;
import com.chwl.core.gift.GiftModel;
@@ -438,13 +448,16 @@ public class GiftDialog extends BottomSheetDialog implements View.OnClickListene
sendGiftButton.setOnClickListener(this);
giftNumLayout = root.findViewById(R.id.gift_number_layout);
giftNumLayout.setOnClickListener(this);
List<GiftTab> tabInfoList = new ArrayList<>();
tabInfoList.add(new GiftTab(GiftIndicator.TYPE_NORMAL, ResUtil.getString(R.string.ui_widget_giftdialog_01), ResUtil.getString(R.string.ui_widget_giftdialog_02)));
tabInfoList.add(new GiftTab(GiftIndicator.TYPE_LUCKY, ResUtil.getString(R.string.ui_widget_giftdialog_03), ResUtil.getString(R.string.ui_widget_giftdialog_04)));
tabInfoList.add(new GiftTab(GiftIndicator.TYPE_NOBLE, ResUtil.getString(R.string.ui_widget_giftdialog_05), ResUtil.getString(R.string.ui_widget_giftdialog_06)));
tabInfoList.add(new GiftTab(GiftIndicator.TYPE_WEEK, ResUtil.getString(R.string.ui_widget_giftdialog_07), ResUtil.getString(R.string.ui_widget_giftdialog_08)));
List<GiftTab> tabInfoList = updateTabs();
// MARK: 获取到新 API 数据后tab 按这里的方式更新
// List<GiftTab> tabInfoList = new ArrayList<>();
// tabInfoList.add(new GiftTab(GiftIndicator.TYPE_NORMAL, ResUtil.getString(R.string.ui_widget_giftdialog_01), ResUtil.getString(R.string.ui_widget_giftdialog_02)));
// tabInfoList.add(new GiftTab(GiftIndicator.TYPE_LUCKY, ResUtil.getString(R.string.ui_widget_giftdialog_03), ResUtil.getString(R.string.ui_widget_giftdialog_04)));
// tabInfoList.add(new GiftTab(GiftIndicator.TYPE_NOBLE, ResUtil.getString(R.string.ui_widget_giftdialog_05), ResUtil.getString(R.string.ui_widget_giftdialog_06)));
// tabInfoList.add(new GiftTab(GiftIndicator.TYPE_WEEK, ResUtil.getString(R.string.ui_widget_giftdialog_07), ResUtil.getString(R.string.ui_widget_giftdialog_08)));
// tabInfoList.add(new GiftTab(GiftIndicator.TYPE_DRAW_GIFT, ResUtil.getString(R.string.ui_widget_giftdialog_09), ResUtil.getString(R.string.ui_widget_giftdialog_010)));
tabInfoList.add(new GiftTab(GiftIndicator.TYPE_SING_ROOM, ResUtil.getString(R.string.ui_widget_giftdialog_hot), ResUtil.getString(R.string.ui_widget_giftdialog_hot)));
// tabInfoList.add(new GiftTab(GiftIndicator.TYPE_SING_ROOM, ResUtil.getString(R.string.ui_widget_giftdialog_hot), ResUtil.getString(R.string.ui_widget_giftdialog_hot)));
// tabInfoList.add(new GiftTab(GiftIndicator.TYPE_KNAP, ResUtil.getString(R.string.ui_widget_giftdialog_011), ResUtil.getString(R.string.ui_widget_giftdialog_012)));
giftIndicator = root.findViewById(R.id.gift_indicator);
giftIndicator.initTab(
@@ -503,24 +516,30 @@ public class GiftDialog extends BottomSheetDialog implements View.OnClickListene
if (giftId == 0) {
// 更新所有礼物
giftIndicator.setPosition(GiftIndicator.TYPE_NORMAL);
giftIndicator.setPosition(TYPE_NORMAL);
updateGiftView(giftIndicator.getCurrrentType());
} else {
int indicatorType = GiftIndicator.TYPE_NORMAL;
int indicatorType = TYPE_NORMAL;
GiftInfo giftInfo = GiftModel.get().findGiftInfoById(giftId);
if (giftInfo != null) {
switch (giftInfo.getGiftType()) {
case GiftType.GIFT_TYPE_NORMAL:
indicatorType = GiftIndicator.TYPE_NORMAL;
indicatorType = TYPE_NORMAL;
break;
case GiftType.GIFT_TYPE_LUCKY:
indicatorType = GiftIndicator.TYPE_LUCKY;
break;
case GiftType.GIFT_TYPE_SUPER_LUCKY:
indicatorType = TYPE_SUPER_LUCKY;
break;
case GiftType.GIFT_TYPE_VIP:
indicatorType = GiftIndicator.TYPE_NOBLE;
indicatorType = TYPE_NOBLE;
break;
case GiftType.GIFT_TYPE_COUNTRY:
indicatorType = TYPE_COUNTRY;
break;
case GiftType.GIFT_TYPE_WEEK_STAR:
indicatorType = GiftIndicator.TYPE_WEEK;
indicatorType = TYPE_WEEK;
break;
}
}
@@ -581,6 +600,34 @@ public class GiftDialog extends BottomSheetDialog implements View.OnClickListene
});
}
private List<GiftTab> updateTabs() {
List<GiftTab> tabInfoList = new ArrayList<>();
for (TagsInfo info: GiftModel.get().getTabList()) {
tabInfoList.add(new GiftTab(swithGiftTypeToTabType(info), info.tagName(), info.tagName()));
}
return tabInfoList;
}
private int swithGiftTypeToTabType(TagsInfo info) {
switch (info.tagGiftType()) {
case GiftType.GIFT_TYPE_NORMAL:
return TYPE_NORMAL;
case GiftType.GIFT_TYPE_LUCKY:
return TYPE_LUCKY;
case GiftType.GIFT_TYPE_SUPER_LUCKY:
return TYPE_SUPER_LUCKY;
case GiftType.GIFT_TYPE_VIP:
return TYPE_NOBLE;
case GiftType.GIFT_TYPE_WEEK_STAR:
return TYPE_WEEK;
case GiftType.GIFT_TYPE_COUNTRY:
return TYPE_COUNTRY;
case GiftType.GIFT_TYPE_SINGLE_ROOM:
return TYPE_SING_ROOM;
}
return TYPE_NORMAL;
}
private void showLoadingAnimation() {
Animation rotateAnimation = new RotateAnimation(0, 360,
Animation.RELATIVE_TO_SELF, 0.5f,
@@ -656,31 +703,35 @@ public class GiftDialog extends BottomSheetDialog implements View.OnClickListene
List<GiftInfo> nobleGiftInfos = getNobleGiftInfos();
if (position == GiftIndicator.TYPE_KNAP) {
currentGiftInfoList = GiftModel.get().getKnapList();
} else if (position == GiftIndicator.TYPE_NOBLE) {
} else if (position == TYPE_NOBLE) {
currentGiftInfoList = nobleGiftInfos;
} else if (position == GiftIndicator.TYPE_NORMAL) {
} else if (position == TYPE_NORMAL) {
currentGiftInfoList = getNormalGiftInfos();
} else if (position == GiftIndicator.TYPE_LUCKY) {
currentGiftInfoList = getLuckyGiftInfos();
} else if (position == GiftIndicator.TYPE_WEEK) {
} else if (position == TYPE_WEEK) {
currentGiftInfoList = getWeekStarGiftInfos();
} else if (position == GiftIndicator.TYPE_DRAW_GIFT) {
currentGiftInfoList = getDrawGiftInfos();
} else if (position == GiftIndicator.TYPE_SING_ROOM) {
currentGiftInfoList = getSingleRoomGiftInfos();
} else if (position == TYPE_SUPER_LUCKY) {
currentGiftInfoList = getSuperLuckyGiftInfos();
} else if (position == TYPE_COUNTRY) {
currentGiftInfoList = getCountryGiftInfos();
}
// 有贵族礼物才显示贵族礼物的tab
if (ListUtils.isListEmpty(nobleGiftInfos)) {
giftIndicator.hidePosition(GiftIndicator.TYPE_NOBLE);
giftIndicator.hidePosition(TYPE_NOBLE);
} else {
giftIndicator.showPosition(GiftIndicator.TYPE_NOBLE);
giftIndicator.showPosition(TYPE_NOBLE);
}
// 有塗鴉礼物才显示塗鴉礼物的tab
if (ListUtils.isListEmpty(getDrawGiftInfos())) {
giftIndicator.hidePosition(GiftIndicator.TYPE_DRAW_GIFT);
} else {
giftIndicator.showPosition(GiftIndicator.TYPE_DRAW_GIFT);
}
// if (ListUtils.isListEmpty(getDrawGiftInfos())) {
// giftIndicator.hidePosition(GiftIndicator.TYPE_DRAW_GIFT);
// } else {
// giftIndicator.showPosition(GiftIndicator.TYPE_DRAW_GIFT);
// }
//是否背包礼物
final boolean isKnap = (position == GiftIndicator.TYPE_KNAP);
initEasyPop(isKnap);
@@ -690,9 +741,11 @@ public class GiftDialog extends BottomSheetDialog implements View.OnClickListene
// tvGiftValue.setVisibility(View.VISIBLE);
showEmptyView();
} else if (position == GiftIndicator.TYPE_LUCKY ||
position == GiftIndicator.TYPE_WEEK ||
position == TYPE_SUPER_LUCKY ||
position == TYPE_WEEK ||
position == GiftIndicator.TYPE_SING_ROOM ||
position == GiftIndicator.TYPE_DRAW_GIFT) {
position == GiftIndicator.TYPE_DRAW_GIFT ||
position == TYPE_COUNTRY) {
showEmptyView();
updateWeekStarDesc();
isShowDrawGiftModel = false;
@@ -707,7 +760,7 @@ public class GiftDialog extends BottomSheetDialog implements View.OnClickListene
if (currentGiftInfo.isSendMsg()) {
etSendMessage.setVisibility(View.VISIBLE);
}
pagerList = beanTransformVm(context, currentGiftInfoList, isKnap, position == GiftIndicator.TYPE_WEEK ? 4 : 8, currentGiftInfo);
pagerList = beanTransformVm(context, currentGiftInfoList, isKnap, position == TYPE_WEEK ? 4 : 8, currentGiftInfo);
setGridViewData(pagerList);
if (isKnap) {
// tvGiftValue.setVisibility(View.VISIBLE);
@@ -723,10 +776,13 @@ public class GiftDialog extends BottomSheetDialog implements View.OnClickListene
updateWeekStarDesc();
updateDrawGift();
giftIndicator.post(() -> {
if (position < GiftIndicator.TYPE_WEEK) {
giftIndicator.fullScroll(View.FOCUS_LEFT);
boolean isRTL = UiUtils.INSTANCE.isRtl(getContext());
// if (position < TYPE_WEEK) { GiftModel.get().getTabList().size()/2;
int centerIndex = GiftModel.get().getTabList().size()/2;
if (position < centerIndex) {
giftIndicator.fullScroll(isRTL ? View.FOCUS_RIGHT : View.FOCUS_LEFT);
} else {
giftIndicator.fullScroll(View.FOCUS_RIGHT);
giftIndicator.fullScroll(isRTL ? View.FOCUS_LEFT : View.FOCUS_RIGHT);
}
});
}
@@ -797,7 +853,7 @@ public class GiftDialog extends BottomSheetDialog implements View.OnClickListene
private void updateWeekStarDesc() {
if (giftIndicator.getCurrrentType() == GiftIndicator.TYPE_WEEK) {
if (giftIndicator.getCurrrentType() == TYPE_WEEK) {
flLuckyDesc.setVisibility(View.GONE);
llStarWeek.setVisibility(View.GONE);
mStarWeekBanner.setVisibility(View.VISIBLE);
@@ -1116,6 +1172,11 @@ public class GiftDialog extends BottomSheetDialog implements View.OnClickListene
return giftInfos;
}
private List<TagsInfo> getAllTabsAndGiftInfos() {
List<TagsInfo> tagsInfos = null;
return tagsInfos;
}
private List<GiftInfo> getNormalGiftInfos() {
List<GiftInfo> giftInfos = loadGiftInfoList();
List<GiftInfo> infos = new ArrayList<>();
@@ -1152,6 +1213,18 @@ public class GiftDialog extends BottomSheetDialog implements View.OnClickListene
GiftType.GIFT_TYPE_SINGLE_ROOM);
}
private List<GiftInfo> getSuperLuckyGiftInfos() {
return GiftModel.get().getGiftInfosByType(
String.valueOf(AvRoomDataManager.get().getRoomUid()),
GiftType.GIFT_TYPE_SUPER_LUCKY);
}
private List<GiftInfo> getCountryGiftInfos() {
return GiftModel.get().getGiftInfosByType(
String.valueOf(AvRoomDataManager.get().getRoomUid()),
GiftType.GIFT_TYPE_COUNTRY);
}
private List<GiftInfo> getNobleGiftInfos() {
return GiftModel.get().getGiftInfoList(GiftType.GIFT_TYPE_VIP);
}
@@ -1394,7 +1467,7 @@ public class GiftDialog extends BottomSheetDialog implements View.OnClickListene
showEasyPopup();
break;
case R.id.iv_open_noble:
VipMainActivity.start(context);
VipCenterActivity.start(context);
//进入贵族中心埋点
HashMap<String, Object> map = new HashMap<>(5);
map.put(IReportConstants.PAYPAGE_TYPE, IReportConstants.THREE);
@@ -1449,10 +1522,10 @@ public class GiftDialog extends BottomSheetDialog implements View.OnClickListene
if (needShowLoading) showLoadingView();
int currentType = giftIndicator.getCurrrentType();
switch (currentType) {
case GiftIndicator.TYPE_NORMAL:
case TYPE_NORMAL:
case GiftIndicator.TYPE_LUCKY:
case GiftIndicator.TYPE_NOBLE:
case GiftIndicator.TYPE_WEEK:
case TYPE_NOBLE:
case TYPE_WEEK:
String roomUid = null;
if (isInRoom) {
if (AvRoomDataManager.get().getRoomUid() > 0) {

View File

@@ -4,13 +4,16 @@ import static com.chwl.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_DRAGON_BA
import static com.chwl.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_DRAGON_BAR_CANCEL;
import static com.chwl.core.manager.RoomEvent.DRAGON_BAR_CANCEL;
import static com.chwl.library.utils.ResUtil.getString;
import static com.netease.nim.uikit.common.util.log.LogUtil.log;
import android.annotation.SuppressLint;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
import android.media.Image;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
@@ -21,6 +24,8 @@ import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatDialog;
import androidx.appcompat.widget.AppCompatImageView;
import androidx.recyclerview.widget.GridLayoutManager;
@@ -28,6 +33,13 @@ import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.chwl.app.utils.AvatarHelper;
import com.chwl.core.vip.bean.UserVipInfo;
import com.chwl.library.download.DownloadException;
import com.chwl.library.download.DownloadManager;
import com.chwl.library.download.DownloadRequest;
import com.chwl.library.download.DownloadTask;
import com.chwl.library.download.FileDownloadListener;
import com.chwl.library.utils.PathHelper;
import com.chwl.library.widget.SVGAView;
import com.google.android.flexbox.FlexboxLayout;
import com.netease.nim.uikit.common.util.sys.ScreenUtil;
@@ -92,11 +104,16 @@ import com.chwl.library.net.rxnet.callback.CallBack;
import com.chwl.library.utils.ListUtils;
import com.chwl.library.utils.SingleToastUtil;
import com.chwl.library.utils.config.BasicConfig;
import com.tencent.qgame.animplayer.AnimConfig;
import com.tencent.qgame.animplayer.AnimView;
import com.tencent.qgame.animplayer.inter.IAnimListener;
import com.tencent.qgame.animplayer.util.ScaleType;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
@@ -141,6 +158,7 @@ public class UserInfoDialog extends AppCompatDialog implements View.OnClickListe
private AppCompatImageView mIvUserLevel;
private AppCompatImageView mIvUserCharm;
private ImageView ivUserCardWear;
private AnimView ivUserCardWearMP4;
private TextView tvFamilyNameLabel;
private TextView tvFamilyName;
private FlexboxLayout flexbox;
@@ -258,6 +276,42 @@ public class UserInfoDialog extends AppCompatDialog implements View.OnClickListe
mIvUserCharm = findViewById(R.id.iv_user_charm);
ivUserCardWear = findViewById(R.id.iv_user_card_wear);
ivUserCardWearMP4 = findViewById(R.id.iv_user_card_wear_mp4);
ivUserCardWearMP4.setScaleType(ScaleType.CENTER_CROP);
ivUserCardWearMP4.setLoop(Integer.MAX_VALUE);
ivUserCardWearMP4.setAnimListener(new IAnimListener() {
@Override
public boolean onVideoConfigReady(@NonNull AnimConfig animConfig) {
return true;
}
@Override
public void onVideoStart() {
log( "onVideoStart: ");
}
@Override
public void onVideoRender(int i, @Nullable AnimConfig animConfig) {
}
@Override
public void onVideoComplete() {
log( "onVideoComplete: ");
}
@Override
public void onVideoDestroy() {
}
@Override
public void onFailed(int i, @Nullable String s) {
}
});
tvFamilyNameLabel = (TextView) findViewById(R.id.tv_family_name_label);
tvFamilyName = (TextView) findViewById(R.id.tv_family_name);
tvSelectHim = findViewById(R.id.tv_select_him);
@@ -543,9 +597,11 @@ public class UserInfoDialog extends AppCompatDialog implements View.OnClickListe
//资料卡装扮
if (!TextUtils.isEmpty(userInfo.getUserInfoCardPic())) {
ImageLoadUtils.loadImage(context, userInfo.getUserInfoCardPic(), ivUserCardWear);
drawVAPEffect(userInfo.getUserInfoCardPic());
// drawVAPEffect("https://image.pekolive.com/v7.mp4");
} else {
ivUserCardWear.setImageDrawable(null);
ivUserCardWearMP4.setVisibility(View.GONE);
}
if (null != findHimView) {
@@ -602,6 +658,23 @@ public class UserInfoDialog extends AppCompatDialog implements View.OnClickListe
}
}
private void drawVAPEffect(String url) {
String filePath = PathHelper.INSTANCE.generateResourcesFilePath(url);
DownloadRequest request = DownloadRequest.Companion.build(url, filePath, "gift_effect_download", null, 60000L);
DownloadManager.INSTANCE.download(request, new FileDownloadListener() {
@Override
public void onDownloadCompleted(@NonNull DownloadTask task) {
String path = task.getRequest().getPath();
ivUserCardWearMP4.startPlay(new File(path));
}
@Override
public void onDownloadError(@NonNull DownloadException exception) {
ImageLoadUtils.loadImage(context, userInfo.getUserInfoCardPic(), ivUserCardWear);
}
});
}
private void copyName() {
try {
ClipboardManager cm = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
@@ -677,7 +750,8 @@ public class UserInfoDialog extends AppCompatDialog implements View.OnClickListe
private void updateNobleView() {
// 防止访问数据库和网络同时刷新出现图标跳动
NobleInfo nobleInfo = userInfo.getNobleInfo();
// NobleInfo nobleInfo = userInfo.getNobleInfo();
UserVipInfo vipInfo = userInfo.getUserVipInfoVO();
HeadWearInfo userHeadwear = userInfo.getUserHeadwear();
boolean havaHead = false;
// 设置普通人
@@ -688,31 +762,46 @@ public class UserInfoDialog extends AppCompatDialog implements View.OnClickListe
AvatarHelper.loadAvatarFrame(ivAvatarHeadWear, avatarFrame, userHeadwear.getType());
}
}
if (nobleInfo == null || TextUtils.isEmpty(nobleInfo.getCardBg())) {
//如果没贵族信息,就加载头像作为背景
if (vipInfo != null && !vipInfo.getUserCardBG().isEmpty()) {
// findViewById(R.id.transition_mask).setVisibility(View.GONE);
ivAvatarBg.setScaleType(ImageView.ScaleType.MATRIX);
ImageLoadUtils.loadImage(
context,
vipInfo.getUserCardBG().replace("\n",""),
ivAvatarBg,
R.drawable.default_avatar
);
} else {
if (avatarBg == null || !avatarBg.equals(userInfo.getAvatar())) {
avatarBg = userInfo.getAvatar();
ImageLoadUtils.loadImageWithBlur(context, userInfo.getAvatar(), ivAvatarBg, 10, 1);
}
return;
}
// 卡片背景
if (!TextUtils.isEmpty(nobleInfo.getCardBg()) && !topBg.equals(nobleInfo.getCardBg())) {
topBg = nobleInfo.getCardBg();
NobleUtil.loadResource(nobleInfo.getCardBg(), ivAvatarBg, R.drawable.bg_user_info_dialog_top);
}
if (!TextUtils.isEmpty(nobleInfo.getHeadWear())) {
// 头饰
if (!havaHead) {
NobleUtil.loadResource(nobleInfo.getHeadWear(), ivAvatarHeadWear);
}
}
if (!TextUtils.isEmpty(nobleInfo.getBadge())) {
// 勋章
ivBadge.setVisibility(View.VISIBLE);
NobleUtil.loadResource(nobleInfo.getBadge(), ivBadge);
}
// if (nobleInfo == null || TextUtils.isEmpty(nobleInfo.getCardBg())) {
// //如果没贵族信息,就加载头像作为背景
// if (avatarBg == null || !avatarBg.equals(userInfo.getAvatar())) {
// avatarBg = userInfo.getAvatar();
// ImageLoadUtils.loadImageWithBlur(context, userInfo.getAvatar(), ivAvatarBg, 10, 1);
// }
// return;
// }
// // 卡片背景
// if (!TextUtils.isEmpty(nobleInfo.getCardBg()) && !topBg.equals(nobleInfo.getCardBg())) {
// topBg = nobleInfo.getCardBg();
// NobleUtil.loadResource(nobleInfo.getCardBg(), ivAvatarBg, R.drawable.bg_user_info_dialog_top);
// }
// if (!TextUtils.isEmpty(nobleInfo.getHeadWear())) {
// // 头饰
// if (!havaHead) {
// NobleUtil.loadResource(nobleInfo.getHeadWear(), ivAvatarHeadWear);
// }
// }
// if (!TextUtils.isEmpty(nobleInfo.getBadge())) {
// // 勋章
// ivBadge.setVisibility(View.VISIBLE);
// NobleUtil.loadResource(nobleInfo.getBadge(), ivBadge);
// }
}

View File

@@ -16,12 +16,12 @@ import android.widget.TextView;
import androidx.viewpager.widget.PagerAdapter;
import androidx.viewpager.widget.ViewPager;
import com.chwl.app.vip.VipCenterActivity;
import com.google.android.material.bottomsheet.BottomSheetBehavior;
import com.google.android.material.bottomsheet.BottomSheetDialog;
import com.chwl.app.R;
import com.chwl.library.common.util.Utils;
import com.chwl.app.common.widget.dialog.DialogManager;
import com.chwl.app.vip.VipMainActivity;
import com.chwl.core.market_verify.MarketVerifyModel;
import com.chwl.core.room.event.FaceIsReadyEvent;
import com.chwl.core.room.face.DynamicFaceModel;
@@ -309,7 +309,7 @@ public class DynamicFaceDialog extends BottomSheetDialog
tvNormalTab.setSelected(true);
}
} else if (v.getId() == R.id.iv_open_noble) {
VipMainActivity.start(context);
VipCenterActivity.start(context);
}
}

View File

@@ -67,6 +67,16 @@ public class GiftIndicator extends LinearLayout {
*/
public static final int TYPE_SING_ROOM = 6;
/**
* 国家礼物
*/
public static final int TYPE_COUNTRY = 7;
/**
* 超级幸运礼物
*/
public static final int TYPE_SUPER_LUCKY = 8;
private List<GiftTab> tabList = new ArrayList<>();
@Getter

View File

@@ -16,7 +16,7 @@ import com.chwl.app.ui.widget.magicindicator.buildins.commonnavigator.abs.IMeasu
* 博客: http://hackware.lucode.net
* Created by hackware on 2016/6/26.
*/
public class SimplePagerTitleView extends TextView implements IMeasurablePagerTitleView {
public class SimplePagerTitleView extends androidx.appcompat.widget.AppCompatTextView implements IMeasurablePagerTitleView {
protected int mSelectedColor;
protected int mNormalColor;

View File

@@ -0,0 +1,502 @@
package com.chwl.app.vip
import android.annotation.SuppressLint
import android.content.Context
import android.content.Intent
import android.util.Log
import android.view.View
import android.widget.TextView
import androidx.activity.viewModels
import androidx.core.view.isVisible
import androidx.lifecycle.lifecycleScope
import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.chwl.app.R
import com.chwl.app.base.BaseViewBindingActivity
import com.chwl.app.base.TitleBar
import com.chwl.app.common.EmptyViewHelper
import com.chwl.app.databinding.ActivityVipCenterBinding
import com.chwl.app.ui.pay.ChargeActivity
import com.chwl.app.ui.utils.RVDelegate
import com.chwl.app.ui.webview.CommonWebViewActivity
import com.chwl.app.vip.adapter.OnItemClickListener
import com.chwl.app.vip.adapter.VipAuthAdapter
import com.chwl.app.vip.adapter.VipCenterBannerAdapter
import com.chwl.app.vip.adapter.VipCenterIdentificationsAdapter
import com.chwl.app.vip.adapter.VipMagicIndicatorAdapter
import com.chwl.app.vip.adapter.VipRebateAdapter
import com.chwl.app.vip.dialog.SelectPayTypeDialog
import com.chwl.app.vip.dialog.VipAuthDetailsDialog
import com.chwl.core.UriProvider
import com.chwl.core.pay.PayModel
import com.chwl.core.pay.bean.ChargeBean
import com.chwl.core.utils.extension.toast
import com.chwl.core.vip.bean.VipAuthInfo
import com.chwl.core.vip.bean.VipInfo
import com.example.lib_utils.AppUtils
import com.example.lib_utils.UiUtils
import com.example.matisse.internal.utils.UIUtils
import com.example.module_base.support.billing.IBillingService
import com.example.module_base.support.billing.IProductDetails
import com.example.module_base.support.billing.IPurchase
import com.netease.nim.uikit.StatusBarUtil
import com.youth.banner.Banner
import com.youth.banner.adapter.BannerImageAdapter
import com.youth.banner.holder.BannerImageHolder
import com.youth.banner.indicator.CircleIndicator
import com.youth.banner.transformer.AlphaPageTransformer
import com.youth.banner.transformer.DepthPageTransformer
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import org.greenrobot.eventbus.EventBus
import com.youth.banner.listener.OnPageChangeListener
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.delay
import java.text.SimpleDateFormat
import java.time.LocalDateTime
import java.time.format.DateTimeFormatter
import java.util.Calendar
import java.util.Locale
class VipCenterActivity : BaseViewBindingActivity<ActivityVipCenterBinding>(),
VipMagicIndicatorAdapter.OnItemSelectListener, OnItemClickListener, IBillingService.Listener {
private val authAdapter = VipAuthAdapter() // 用户权限
private val vipViewModel: VipViewModel by viewModels()
private var chargeList: List<ChargeBean>? = null
private var authInfoList: List<VipAuthInfo>? = null
private val rebateAdapter = VipRebateAdapter()
private var currentChargeInfo: ChargeBean? = null
private lateinit var rvDelegate: RVDelegate<VipAuthInfo>
private lateinit var banner:Banner<VipInfo, VipCenterBannerAdapter>
private lateinit var recyclerView: RecyclerView
private lateinit var vipIdentificationsAdapter: VipCenterIdentificationsAdapter
private var currentIndex = 0
companion object {
@JvmStatic
fun start(context: Context) {
val starter = Intent(context, VipCenterActivity::class.java)
context.startActivity(starter)
}
private const val BIND_CODE_GOLD = 200
private const val TAG = "VipCenterActivity"
}
@SuppressLint("SetTextI18N")
override fun init() {
EventBus.getDefault().register(this)
initVipCenterBar(getString(R.string.vip_center))
updateVipCenterBar()
initView()
initObserve()
rvDelegate = RVDelegate.Builder<VipAuthInfo>()
.setLayoutManager(GridLayoutManager(this, 3))
.setRecyclerView(binding.recyclerViewBottom)
.setEmptyView(
EmptyViewHelper.createEmptyTextView(
context,
getString(R.string.me_no_search_results)
)
)
.setAdapter(authAdapter)
.build()
handleAuthAdapter()
handleViewModel()
handleBinding()
requestChargeList{
loadChargeList(it)
}
}
private fun initView() {
banner = findViewById(R.id.banner_view)
banner.setBannerGalleryEffect(20, 20, 15)
banner.addOnPageChangeListener(object : OnPageChangeListener {
override fun onPageScrolled(position: Int, positionOffset: Float, positionOffsetPixels: Int) {
// 页面滑动中
}
override fun onPageSelected(position: Int) {
// 页面被选中position 已更新
currentIndex = position
vipViewModel.onItemSelect(position)
refreshBottomArea()
}
override fun onPageScrollStateChanged(state: Int) {
// 页面滚动状态改变
}
})
recyclerView = findViewById(R.id.recycler_view)
recyclerView.layoutManager = GridLayoutManager(this, 2)
}
private fun updateVipCenterBar() {
mTitleBar = findViewById(R.id.title_bar)
// if (mTitleBar != null) {
// mTitleBar.addAction(object : TitleBar.ImageAction(R.drawable.vip_center_help_button) {
// override fun performAction(view: View) {
// CommonWebViewActivity.start(
// this@VipCenterActivity,
// UriProvider.getVipHelpUrl())
// }
// })
// }
}
private fun handleAuthAdapter() {
authAdapter.setOnItemClickListener { _, _, position ->
authAdapter.getItem(position)?.let {
VipAuthDetailsDialog.newInstance(it.descPic, it.authName, it.authIntro).show(this)
}
}
}
private fun handleBinding() {
binding.layoutOpenVip.setOnClickListener {
checkBuyVip {
buyVip()
}
}
binding.recyclerViewBottom.isNestedScrollingEnabled = false
}
@SuppressLint("NotifyDataSetChanged")
private fun handleViewModel() {
vipViewModel.getVipPageInfo()
vipViewModel.loadingLiveData.observe(this) {
if (it == true) {
dialogManager.showProgressDialog(this)
} else {
dialogManager.dismissDialog()
}
}
vipViewModel.authInfosLiveData.observe(this) {
// ArrayList[VipAuthInfo] // 全部特权列表
it?.let {
val filteredList = it.filter { authInfo ->
authInfo.authType == 4 || authInfo.authType == 6 || authInfo.authType == 10 || authInfo.authType == 14 || authInfo.authType == 15 || authInfo.authType == 12 || authInfo.authType == 13
}
authInfoList = filteredList
authAdapter.setNewData(filteredList)
vipIdentificationsAdapter = VipCenterIdentificationsAdapter(this, it, this)
recyclerView.adapter = vipIdentificationsAdapter
}
// authAdapter.setNewData(it)
// it?.let {
// vipIdentificationsAdapter = VipCenterIdentificationsAdapter(this, it, this)
// recyclerView.adapter = vipIdentificationsAdapter
// }
}
vipViewModel.pageLiveData.observe(this) {
it?.let { // 当前显示的 index
// TODO 处理轮播组件 index 更新
currentIndex = it
}
}
vipViewModel.vipInfosLiveData.observe(this) {
it?.let { // ArrayList[VipInfo] 每个等级的 VIP 内容
// TODO 初始化轮播组件
}
}
vipViewModel.myVipInfoLiveData.observe(this) {
val adapter = vipViewModel.vipInfosLiveData.value?.let { it1 ->
VipCenterBannerAdapter(this,
it1, it)
}
banner.setAdapter(adapter, false)
it?.let {
// lifecycleScope.launch {
// delay(500)
banner.setCurrentItem(it.vipLevel-1)
// }
if (it.ownAuthTypes?.contains(13) == true && mTitleBar.actionCount == 1) {
mTitleBar.addAction(object : TitleBar.ImageAction(R.drawable.ic_vip_setting) {
override fun performAction(view: View?) {
VipSettingActivity.start(this@VipCenterActivity)
}
}, 0)
}
} ?: run {
// binding.layoutLevelInfo.isVisible = false
// binding.layoutLevelProgress.isVisible = false
binding.slAuth.isVisible = true
// binding.tvNotOpen.text = getString(R.string.me_no_aristocracy_yet)
}
}
vipViewModel.currVipInfoLiveData.observe(this) {
it?.let { // VipInfo
if (it.comingSoon == 2) {
/// 处理敬请期待情况, 补充显示 SVGA
binding.slAuth.isVisible = false
// binding.bannerView.isVisible = false
binding.layoutBottomPanel.isVisible = false
} else {
val myVipInfo = vipViewModel.myVipInfoLiveData.value
// TODO 根据当前显示的 VIP 信息更新 UI
authAdapter.setVipInfo(it)
authAdapter.notifyDataSetChanged()
handleIdentificationAreaContent(it)
vipIdentificationsAdapter.setVipInfo(it)
refreshBottomArea()
}
} ?: run {
getString(R.string.me_failed_to_get_aristocrat_data).toast()
}
}
}
override fun onItemClick(position: Int) {
authAdapter.getItem(position)?.let {
VipAuthDetailsDialog.newInstance(it.descPic, it.authName, it.authIntro).show(this)
}
}
private fun handleIdentificationAreaContent(vipInfo: VipInfo) {
val exclusivePrivilegesTitle = findViewById<TextView>(R.id.center_title_2)
var count = 0
authInfoList?.map { info ->
if (vipInfo?.ownAuthTypes?.contains(info.authType) == true) {
count ++
}
}
"${getString(R.string.vip_center_4)}\n(${count}/${authInfoList?.size})".also {
binding.centerTitle2.text = it
}
// exclusivePrivilegesTitle.text = R.string.vip_center_4.toString()
}
@SuppressLint("CheckResult")
private fun requestChargeList(call: (List<ChargeBean>) -> Unit) {
PayModel.get().vipList
.compose(bindToLifecycle())
.subscribe(
{
call.invoke(it)
}, {
it.printStackTrace()
}
)
}
private fun initObserve(){
lifecycleScope.launch(Dispatchers.Main) {
vipViewModel.getVipRebateSuccessFlow.collect {
rebateAdapter.notifyItemRangeChanged(0, rebateAdapter.itemCount, true)
}
}
}
private fun loadChargeList(list: List<ChargeBean>) {
this.chargeList = list
refreshBottomArea()
}
private fun checkBuyVip(block: () -> Unit) {
val myVipInfo = vipViewModel.myVipInfoLiveData.value
val currentVipInfo = vipViewModel.vipInfosLiveData.value?.get(currentIndex)
if (currentVipInfo != null &&
myVipInfo != null &&
currentVipInfo.vipLevel > myVipInfo.vipLevel) {
val message = context.getString(R.string.vip_buy_tips).format(
myVipInfo.vipName,currentVipInfo.vipName
)
dialogManager.showOkCancelDialog(message,
context.getString(R.string.miniworld_activity_mwteamroommessageact_07),
context.getString(R.string.miniworld_activity_mwteamroommessageact_08),
true
) { block.invoke() }
} else {
block.invoke()
}
}
private fun buyVip() {
val currentVipInfo = vipViewModel.vipInfosLiveData.value?.get(currentIndex)
currentVipInfo?.let {
val googleUnavailable = ((currentChargeInfo?.productDetails?.getOneTimePurchaseOfferDetails()
?.getPriceAmountMicros()
?: "0") == "0")
var text =
currentChargeInfo?.productDetails?.getOneTimePurchaseOfferDetails()?.getFormattedPrice()
if (text.isNullOrEmpty()) {
text = it.buyAmount.toString()
}
SelectPayTypeDialog.newInstance(
text,
!googleUnavailable,
it.buyAmount
)
.apply {
setOnDiamondChargeClick {
vipViewModel.openVipWithDiamond(
currentChargeInfo?.getProdDesc()?.toIntOrNull() ?: -1
)
}
setOnGoogleChargeClick {
if (googleUnavailable) {
toast(getString(R.string.Recharge_failure))
return@setOnGoogleChargeClick
}
currentChargeInfo?.let { charge ->
buyProduct(charge.productDetails)
}
}
setOnChargeClick {
ChargeActivity.start(this@VipCenterActivity)
}
}
.show(context)
}
}
/*购买商品*/
@SuppressLint("CheckResult")
fun buyProduct(productDetails: IProductDetails?) {
if (productDetails != null) {
Log.d(VipCenterActivity.TAG, "BuyProduct:" + productDetails.getProductId())
// PayModel.get().placeOrder(productDetails.getProductId())
// .compose(bindToLifecycle())
// .subscribe(
// { recordId: PayRecordId ->
// billingManager?.initiatePurchaseFlow(
// productDetails,
// recordId.recordId
// )
// }
// ) { throwable: Throwable ->
// SingleToastUtil.showToast(
// throwable.message
// )
// }
} else {
Log.w(VipCenterActivity.TAG, "skuDetails ==null")
}
}
private fun refreshBottomArea() {
val currentPageVipInfo = vipViewModel.vipInfosLiveData.value?.get(currentIndex)
currentPageVipInfo?.let {
currentChargeInfo = chargeList?.firstOrNull {
it.prodDesc?.toIntOrNull() == currentPageVipInfo.vipLevel
}
if (it.buyAmount == 0) {
binding.tvNoticeText.visibility = View.VISIBLE
binding.tvAdditionalText.visibility = View.GONE
binding.tvOpenVip.visibility = View.GONE
binding.layoutOpenVip.visibility = View.GONE
binding.tvIcon.visibility = View.GONE
getString(R.string.vip_center_9).format(
currentPageVipInfo.vipLevel
).also { binding.tvNoticeText.text = it }
} else {
var myVipIsHighLevel = false
val myVipInfo = vipViewModel.myVipInfoLiveData.value
myVipInfo?.let {
myVipIsHighLevel = myVipInfo.vipLevel >= currentPageVipInfo.vipLevel
}
binding.tvNoticeText.visibility = View.GONE
binding.tvAdditionalText.visibility = View.VISIBLE
binding.tvOpenVip.visibility = View.VISIBLE
binding.layoutOpenVip.visibility = View.VISIBLE
binding.tvIcon.visibility = View.VISIBLE
"${it.buyAmount} ${
getString(R.string.vip_center_5).format(
" / 30"
)
}".also { binding.tvOpenVip.text = it }
val calendar = Calendar.getInstance()
calendar.add(Calendar.DAY_OF_YEAR, 30)
val dateFormat = SimpleDateFormat("yyyy/MM/dd 00:00", Locale.getDefault())
val formattedDate = dateFormat.format(calendar.time)
val result = "$formattedDate ${getString(R.string.vip_center_6)}"
binding.tvAdditionalText.text = result
}
}
}
private fun refreshOpenVipState() {
val currentVipInfo = vipViewModel.currVipInfoLiveData.value
val myVipInfo = vipViewModel.myVipInfoLiveData.value
if (currentVipInfo != null) {
currentChargeInfo = chargeList?.firstOrNull {
it.prodDesc?.toIntOrNull() == currentVipInfo.vipLevel
}
if (currentChargeInfo != null){
"${vipViewModel.myVipInfoLiveData.value?.buyAmount} ${
getString(R.string.vip_center_5).format(
" / 30"
)
}".also { binding.tvOpenVip.text = it }
}
val calendar = Calendar.getInstance()
calendar.add(Calendar.DAY_OF_YEAR, 30)
val dateFormat = SimpleDateFormat("yyyy/MM/dd 00:00", Locale.getDefault())
val formattedDate = dateFormat.format(calendar.time)
val result = "$formattedDate ${getString(R.string.vip_center_6)}"
binding.tvAdditionalText.text = result
} else {
currentChargeInfo = null
// binding.layoutOpenVip.isVisible = false
}
// if (binding.layoutOpenVip.isVisible && binding.layoutLevelProgress.isVisible) {
// binding.layoutBottomPanel.setBackgroundDrawable(binding.layoutLevelProgress.background)
// } else {
// binding.layoutBottomPanel.setBackgroundDrawable(null)
// }
}
override fun onItemSelect(position: Int, view: TextView?) {
TODO("Not yet implemented")
}
override fun onBillingClientSetupFinished() {
TODO("Not yet implemented")
}
override fun onPurchasesUpdated(purchases: List<IPurchase>) {
TODO("Not yet implemented")
}
override fun onConsumeFinished(token: String?, result: Int) {
TODO("Not yet implemented")
}
override fun onFailedHandle(result: Int) {
TODO("Not yet implemented")
}
override fun needSteepStateBar() = true
override fun setStatusBar() {
super.setStatusBar()
StatusBarUtil.transparencyBar(this)
}
}

View File

@@ -1,622 +0,0 @@
package com.chwl.app.vip
import android.annotation.SuppressLint
import android.content.Context
import android.content.Intent
import android.util.Log
import android.view.View
import android.widget.LinearLayout
import android.widget.TextView
import androidx.activity.viewModels
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.core.view.children
import androidx.core.view.isInvisible
import androidx.core.view.isVisible
import androidx.lifecycle.lifecycleScope
import androidx.recyclerview.widget.GridLayoutManager
import com.example.module_base.support.billing.IBillingResult
import com.example.module_base.support.billing.IBillingService
import com.example.module_base.support.billing.IProductDetails
import com.example.module_base.support.billing.IPurchase
import com.example.module_base.support.google.IGoogleService
import com.netease.nim.uikit.StatusBarUtil
import com.netease.nim.uikit.common.util.sys.TimeUtil
import com.opensource.svgaplayer.SVGADrawable
import com.opensource.svgaplayer.SVGAImageView
import com.opensource.svgaplayer.SVGAParser
import com.opensource.svgaplayer.SVGAVideoEntity
import com.chwl.app.R
import com.chwl.app.base.BaseViewBindingActivity
import com.chwl.app.base.TitleBar
import com.chwl.app.common.EmptyViewHelper
import com.chwl.app.databinding.ActivityVipMainBinding
import com.chwl.app.ui.pay.ChargeActivity
import com.chwl.app.ui.setting.ModifyPwdActivity
import com.chwl.app.ui.utils.RVDelegate
import com.chwl.app.ui.webview.CommonWebViewActivity
import com.chwl.app.ui.widget.magicindicator.buildins.commonnavigator.CommonNavigator
import com.chwl.app.vip.adapter.VipAuthAdapter
import com.chwl.app.vip.adapter.VipMagicIndicatorAdapter
import com.chwl.app.vip.adapter.VipRebateAdapter
import com.chwl.app.vip.dialog.SelectPayTypeDialog
import com.chwl.app.vip.dialog.VipAuthDetailsDialog
import com.chwl.app.vip.dialog.VipRemainTimeDialog
import com.chwl.core.UriProvider
import com.chwl.core.pay.PayModel
import com.chwl.core.pay.bean.ChargeBean
import com.chwl.core.pay.bean.PayRecordId
import com.chwl.core.utils.net.IgnoreException
import com.chwl.core.vip.bean.VipAuthInfo
import com.chwl.core.vip.bean.VipInfo
import com.chwl.core.utils.extension.toast
import com.chwl.core.vip.VipOpenEvent
import com.chwl.library.utils.SingleToastUtil
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import org.greenrobot.eventbus.EventBus
import org.greenrobot.eventbus.Subscribe
import org.greenrobot.eventbus.ThreadMode
import java.net.MalformedURLException
import java.net.URL
class VipMainActivity : BaseViewBindingActivity<ActivityVipMainBinding>(),
VipMagicIndicatorAdapter.OnItemSelectListener, IBillingService.Listener {
companion object {
@JvmStatic
fun start(context: Context) {
val starter = Intent(context, VipMainActivity::class.java)
context.startActivity(starter)
}
private const val BIND_CODE_GOLD = 200
private const val TAG = "VipMainActivity"
}
private val authAdapter = VipAuthAdapter()
private lateinit var rvDelegate: RVDelegate<VipAuthInfo>
private val vipViewModel: VipViewModel by viewModels()
private var billingManager: IBillingService? = null
private var currentChargeInfo: ChargeBean? = null
private var chargeList: List<ChargeBean>? = null
private val rebateAdapter = VipRebateAdapter()
@SuppressLint("SetTextI18n")
override fun init() {
EventBus.getDefault().register(this)
initWhiteTitleBar(getString(R.string.vip_center))
mTitleBar.addAction(object : TitleBar.ImageAction(R.drawable.ic_vip_help) {
override fun performAction(view: View) {
CommonWebViewActivity.start(this@VipMainActivity, UriProvider.getVipHelpUrl())
}
})
initView()
initObserve()
binding.ivRankList.setOnClickListener {
CommonWebViewActivity.start(this@VipMainActivity, UriProvider.getRankListUrl())
}
binding.ivTimeHelp.setOnClickListener {
VipRemainTimeDialog.newInstance().show(this)
}
rvDelegate = RVDelegate.Builder<VipAuthInfo>()
.setLayoutManager(GridLayoutManager(this, 3))
.setRecyclerView(binding.recyclerView)
.setEmptyView(
EmptyViewHelper.createEmptyTextView(
context,
getString(R.string.me_no_search_results)
)
)
.setAdapter(authAdapter)
.build()
binding.recyclerView.isNestedScrollingEnabled = false
authAdapter.setOnItemClickListener { _, _, position ->
authAdapter.getItem(position)?.let {
VipAuthDetailsDialog.newInstance(it.descPic, it.authName, it.authIntro).show(this)
}
}
vipViewModel.getVipPageInfo()
vipViewModel.loadingLiveData.observe(this) {
if (it == true) {
dialogManager.showProgressDialog(this)
} else {
dialogManager.dismissDialog()
}
}
vipViewModel.authInfosLiveData.observe(this) {
authAdapter.setNewData(it)
}
vipViewModel.vipInfosLiveData.observe(this) {
it?.let {
initTitleTab(it)
}
}
vipViewModel.myVipInfoLiveData.observe(this) {
it?.let {
binding.layoutLevelInfo.isVisible = true
binding.layoutLevelProgress.isVisible = true
binding.tvNotOpen.text =
"${getString(R.string.me_current_power_value)}${it.currScore}"
binding.tvCurrValue.text = "${getString(R.string.me_current)}${it.currScore}"
binding.tvCurrLevelName.text = it.vipName
binding.tvKeepValue.text = "${getString(R.string.me_grading)}${it.levelKeepScore}"
if (it.isMaxLevel) {
binding.llNextLevelDesc.isVisible = false
binding.tvMaxLevelHint.isVisible = true
binding.tvUpValue.isVisible = false
} else {
binding.llNextLevelDesc.isVisible = true
binding.tvMaxLevelHint.isVisible = false
binding.tvUpValue.isVisible = true
binding.tvNextLevelName.text = it.nextVipName
binding.tvUpValue.text = "${getString(R.string.me_upgrade)}${it.levelUpScore}"
binding.tvUpgradeValue.text = "${it.levelUpScore - it.currScore}"
}
binding.tvResidueTime.text = TimeUtil.getElapseTimeForVip(it.remainSeconds)
binding.seekBar.max = it.levelUpScore
binding.seekBar.progress = Math.min(it.currScore, it.levelUpScore)
val currValueParams =
binding.tvCurrValue.layoutParams as ConstraintLayout.LayoutParams
currValueParams.horizontalBias =
Math.min(it.currScore.toFloat() / it.levelUpScore, 1f)
binding.tvCurrValue.layoutParams = currValueParams
val keepParams =
binding.ivKeepIndicator.layoutParams as ConstraintLayout.LayoutParams
keepParams.horizontalBias = it.levelKeepScore.toFloat() / it.levelUpScore
binding.ivKeepIndicator.layoutParams = keepParams
if (it.ownAuthTypes?.contains(13) == true && mTitleBar.actionCount == 1) {
mTitleBar.addAction(object : TitleBar.ImageAction(R.drawable.ic_vip_setting) {
override fun performAction(view: View) {
VipSettingActivity.start(this@VipMainActivity)
}
}, 0)
}
} ?: run {
binding.layoutLevelInfo.isVisible = false
binding.layoutLevelProgress.isVisible = false
binding.slAuth.isVisible = true
binding.tvNotOpen.text = getString(R.string.me_no_aristocracy_yet)
}
}
vipViewModel.currVipInfoLiveData.observe(this) {
it?.let {
if (it.comingSoon == 2) {
binding.llNotOpen.isVisible = true
binding.slAuth.isVisible = false
binding.layoutBottomPanel.isVisible = false
loadSVGA(binding.ivNotOpenIcon, it.vipLogo)
} else {
binding.slAuth.isVisible = true
binding.llNotOpen.isVisible = false
binding.layoutBottomPanel.isVisible = true
val myVipInfo = vipViewModel.myVipInfoLiveData.value
binding.ivMyLevel.isInvisible = it.vipLevel != myVipInfo?.vipLevel
binding.tvNotOpen.isInvisible =
!(it.vipLevel == myVipInfo?.vipLevel || myVipInfo == null)
loadSVGA(binding.ivVipIcon, it.vipLogo)
binding.tvAuthNum.text =
"${it.ownAuthTypes?.size ?: 0}/${vipViewModel.authInfosLiveData.value?.size ?: 0}"
authAdapter.setVipInfo(it)
authAdapter.notifyDataSetChanged()
loadRebateData(it)
refreshOpenVipState()
}
} ?: run {
getString(R.string.me_failed_to_get_aristocrat_data).toast()
binding.llNotOpen.isVisible = false
binding.slAuth.isVisible = false
}
}
vipViewModel.pageLiveData.observe(this) {
it?.let {
binding.magicIndicator.onPageSelected(it)
}
}
binding.layoutOpenVip.setOnClickListener {
checkBuyVip {
buyVip()
}
}
requestChargeList{
loadChargeList(it)
}
initBilling()
}
private fun initBilling() {
billingManager = IGoogleService.newBillingService(this,this)
}
override fun initWhiteTitleBar(title: String?) {
mTitleBar = findViewById(R.id.title_bar)
if (mTitleBar != null) {
mTitleBar.setTitle(title)
mTitleBar.setImmersive(false)
mTitleBar.setTitleColor(resources.getColor(R.color.white))
mTitleBar.setLeftImageResource(R.drawable.arrow_left_white)
mTitleBar.setBackgroundResource(R.color.transparent)
mTitleBar.setLeftClickListener { onLeftClickListener() }
}
}
/**
* 初始化推荐和派对tab
*/
private fun initTitleTab(vipInfos: List<VipInfo>) {
val commonNavigator = CommonNavigator(context)
commonNavigator.isEnablePivotScroll = true
commonNavigator.isFollowTouch = false
val magicIndicatorAdapter =
VipMagicIndicatorAdapter(
context,
vipInfos
)
magicIndicatorAdapter.setOnItemSelectListener(this)
commonNavigator.adapter = magicIndicatorAdapter
binding.magicIndicator.navigator = commonNavigator
commonNavigator.titleContainer.showDividers = LinearLayout.SHOW_DIVIDER_MIDDLE
}
private fun loadSVGA(svgaImageView: SVGAImageView, svgaUrl: String) {
try {
SVGAParser.shareParser()
.decodeFromURL(URL(svgaUrl), object : SVGAParser.ParseCompletion {
override fun onComplete(videoItem: SVGAVideoEntity) {
val drawable = SVGADrawable(videoItem)
svgaImageView.setImageDrawable(drawable)
svgaImageView.startAnimation()
}
override fun onError() {
}
})
} catch (e: MalformedURLException) {
}
}
@SuppressLint("SetTextI18n")
override fun onItemSelect(position: Int, view: TextView?) {
vipViewModel.onItemSelect(position)
}
@Subscribe(threadMode = ThreadMode.MAIN)
fun onVipOpenEvent(vipOpenEvent: VipOpenEvent) {
getString(R.string.me_opening_of_the_aristocracy_successful).toast()
vipViewModel.getVipPageInfo()
}
override fun needSteepStateBar() = true
override fun setStatusBar() {
super.setStatusBar()
StatusBarUtil.transparencyBar(this)
}
/*客户端设置成功回调*/
@SuppressLint("CheckResult", "SetTextI18n")
override fun onBillingClientSetupFinished() {
Log.i(TAG, "onBillingClientSetupFinished")
val call: ((List<ChargeBean>) -> Unit) = { list ->
loadChargeList(list)
val productKeys = ArrayList<String>()
list.forEach {
productKeys.add(it.getChargeProdId())
}
billingManager?.querySkuDetailsAsync(productKeys,
object : IBillingService.ProductDetailsResponseListener {
override fun onProductDetailsResponse(
billingResult: IBillingResult,
productDetails: List<IProductDetails>
) {
if (!billingResult.isResponseOk()) {
Log.w(
TAG,
"Unsuccessful query for Error code: " + billingResult.getResponseCode()
)
} else if (productDetails.isNotEmpty()) {
for (item in list) {
for (skuDetails in productDetails) {
if (skuDetails.getProductId() == item.getChargeProdId()) {
item.productDetails = skuDetails
break
}
}
}
loadChargeList(list)
}
}
})
}
val list = chargeList
if (list.isNullOrEmpty()) {
requestChargeList{
call.invoke(it)
}
} else {
call.invoke(list)
}
}
@SuppressLint("CheckResult")
private fun requestChargeList(call: (List<ChargeBean>) -> Unit) {
PayModel.get().vipList
.compose(bindToLifecycle())
.subscribe(
{
call.invoke(it)
}, {
it.printStackTrace()
}
)
}
/*商品更新回调*/
@SuppressLint("CheckResult")
override fun onPurchasesUpdated(purchases: List<IPurchase>) {
for (purchase in purchases) {
if (purchase.isPurchasedState() &&
purchase.getAccountIdentifiers() != null
) {
PayModel.get().verifyOrder(
purchase.getAccountIdentifiers()!!.getObfuscatedAccountId(),
purchase.getProducts().firstOrNull(),
purchase.getPackageName(),
purchase.getPurchaseToken()
)
.compose(bindToLifecycle())
.subscribe(
{ token: String ->
//L.i("token=" + token);
billingManager?.consumeAsync(token)
// var skuDetails: IProductDetails? = null
// if (googleChargeBean?.getChargeProdId() == purchase.getProducts()
// .firstOrNull()
// ) {
// skuDetails = googleChargeBean?.productDetails
// }
// if (skuDetails != null) {
// val eventValue: MutableMap<String, Any> =
// HashMap()
// eventValue[AFInAppEventParameterName.CONTENT_TYPE] = "Gold"
// eventValue[AFInAppEventParameterName.QUANTITY] = 1
// eventValue[AFInAppEventParameterName.CONTENT_ID] =
// purchase.getOrderId()!!
// if (skuDetails.getOneTimePurchaseOfferDetails() != null) {
// eventValue[AFInAppEventParameterName.REVENUE] =
// skuDetails.getOneTimePurchaseOfferDetails()
// ?.getPriceAmountMicros()!! / 1000000f
// eventValue["Price"] =
// skuDetails.getOneTimePurchaseOfferDetails()
// ?.getFormattedPrice()!!
// eventValue[AFInAppEventParameterName.CURRENCY] =
// skuDetails.getOneTimePurchaseOfferDetails()
// ?.getPriceCurrencyCode()!!
// }
// AppsFlyerLib.getInstance().logEvent(
// applicationContext,
// AFInAppEventType.PURCHASE,
// eventValue
// )
// }
}
) { throwable: Throwable ->
if (throwable !is IgnoreException) {
SingleToastUtil.showToast(throwable.message)
}
}
}
}
Log.i(TAG, "onPurchasesUpdated")
}
override fun onConsumeFinished(token: String?, result: Int) {
}
override fun onFailedHandle(result: Int) {
}
/*购买商品*/
@SuppressLint("CheckResult")
fun buyProduct(productDetails: IProductDetails?) {
if (productDetails != null) {
Log.d(TAG, "BuyProduct:" + productDetails.getProductId())
PayModel.get().placeOrder(productDetails.getProductId())
.compose(bindToLifecycle())
.subscribe(
{ recordId: PayRecordId ->
billingManager?.initiatePurchaseFlow(
productDetails,
recordId.recordId
)
}
) { throwable: Throwable ->
SingleToastUtil.showToast(
throwable.message
)
}
} else {
Log.w(TAG, "skuDetails ==null")
}
}
override fun onResume() {
super.onResume()
if (billingManager?.isServiceConnected() == true) {
billingManager?.onQueryPurchases()
}
}
override fun onDestroy() {
super.onDestroy()
EventBus.getDefault().unregister(this)
billingManager?.destroy()
currentChargeInfo = null
}
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
dialogManager.dismissDialog()
if (resultCode != RESULT_OK) {
return
}
if (requestCode == BIND_CODE_GOLD) {
ModifyPwdActivity.start(this, ModifyPwdActivity.FOGERT_PAY_PWD)
}
}
private fun initView() {
binding.tvTabPrivilege.setOnClickListener {
showPrivilegeTab()
}
binding.tvTabRebate.setOnClickListener {
showRebateTab()
}
rebateAdapter.onGetListener = {
vipViewModel.getVipRebate(it)
}
binding.rvRebate.isNestedScrollingEnabled = false
binding.rvRebate.adapter = rebateAdapter
}
private fun initObserve(){
lifecycleScope.launch(Dispatchers.Main) {
vipViewModel.getVipRebateSuccessFlow.collect {
rebateAdapter.notifyItemRangeChanged(0, rebateAdapter.itemCount, true)
}
}
}
private fun showPrivilegeTab() {
binding.layoutRebate.isInvisible = true
binding.groupPrivilege.isInvisible = false
binding.tvTabPrivilege.setBackgroundResource(R.drawable.vip_bg_tab_selected)
binding.tvTabRebate.setBackgroundResource(R.drawable.vip_bg_tab_unselected)
}
private fun showRebateTab() {
binding.groupPrivilege.isInvisible = true
binding.layoutRebate.isInvisible = false
binding.tvTabPrivilege.setBackgroundResource(R.drawable.vip_bg_tab_unselected)
binding.tvTabRebate.setBackgroundResource(R.drawable.vip_bg_tab_selected)
}
private fun loadChargeList(list: List<ChargeBean>) {
this.chargeList = list
refreshOpenVipState()
}
private fun loadRebateData(info: VipInfo) {
binding.tvTableLevelName.text = info.vipName
binding.tvRebateTips1.text =
context.getString(R.string.vip_buy_tips_format).format(info.vipName)
rebateAdapter.setNewData(info.returnProfits)
val isNormalStatus = info.isRebate()
binding.layoutRebate.children.forEach {
if(it == binding.tvRebateDisableStatus){
it.isVisible = !isNormalStatus
}else{
it.isVisible = isNormalStatus
}
}
}
private fun refreshOpenVipState() {
val currentVipInfo = vipViewModel.currVipInfoLiveData.value
val myVipInfo = vipViewModel.myVipInfoLiveData.value
if (currentVipInfo != null) {
currentChargeInfo = chargeList?.firstOrNull {
it.prodDesc?.toIntOrNull() == currentVipInfo.vipLevel
}
if (currentChargeInfo != null && (myVipInfo == null || myVipInfo.vipLevel < currentVipInfo.vipLevel)) {
binding.tvOpenVip.text =
"${currentChargeInfo?.getMoney()} ${
getString(R.string.vip_buy_format).format(
currentVipInfo.vipName
)
}"
binding.layoutOpenVip.isVisible = true
} else {
binding.layoutOpenVip.isVisible = false
}
} else {
currentChargeInfo = null
binding.layoutOpenVip.isVisible = false
}
if (binding.layoutOpenVip.isVisible && binding.layoutLevelProgress.isVisible) {
binding.layoutBottomPanel.setBackgroundDrawable(binding.layoutLevelProgress.background)
} else {
binding.layoutBottomPanel.setBackgroundDrawable(null)
}
}
private fun checkBuyVip(block: () -> Unit) {
val myVipInfo = vipViewModel.myVipInfoLiveData.value
val currentVipInfo = vipViewModel.currVipInfoLiveData.value
if (currentVipInfo != null && myVipInfo != null && currentVipInfo.vipLevel > myVipInfo.vipLevel) {
val message = context.getString(R.string.vip_buy_tips).format(
myVipInfo.vipName,currentVipInfo.vipName
)
dialogManager.showOkCancelDialog(message,
context.getString(R.string.miniworld_activity_mwteamroommessageact_07),
context.getString(R.string.miniworld_activity_mwteamroommessageact_08),
true
) { block.invoke() }
} else {
block.invoke()
}
}
private fun buyVip() {
val googleUnavailable = ((currentChargeInfo?.productDetails?.getOneTimePurchaseOfferDetails()
?.getPriceAmountMicros()
?: "0") == "0")
var text =
currentChargeInfo?.productDetails?.getOneTimePurchaseOfferDetails()?.getFormattedPrice()
if (text.isNullOrEmpty()) {
text = ((currentChargeInfo?.money ?: 0.0) * 1000).toInt().toString()
}
SelectPayTypeDialog.newInstance(
text,
!googleUnavailable,
currentChargeInfo?.getMoney() ?: 0.0
)
.apply {
setOnDiamondChargeClick {
vipViewModel.openVipWithDiamond(
currentChargeInfo?.getProdDesc()?.toIntOrNull() ?: -1
)
}
setOnGoogleChargeClick {
if (googleUnavailable) {
toast(getString(R.string.Recharge_failure))
return@setOnGoogleChargeClick
}
currentChargeInfo?.let { charge ->
buyProduct(charge.productDetails)
}
}
setOnChargeClick {
ChargeActivity.start(this@VipMainActivity)
}
}
.show(context)
}
}

View File

@@ -22,6 +22,6 @@ class VipAuthAdapter :
helper.setText(R.id.tv_auth_name, item.authName)
helper.getView<ImageView>(R.id.iv_auth_icon).load(item.authIcon)
helper.itemView.alpha =
if (vipInfo?.ownAuthTypes?.contains(item.authType) == true) 1f else 0.5f
if (vipInfo?.ownAuthTypes?.contains(item.authType) == true) 1f else 0.7f
}
}

View File

@@ -0,0 +1,151 @@
package com.chwl.app.vip.adapter
import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import com.chwl.app.R
import com.chwl.app.ui.utils.loadAnim
import com.chwl.core.vip.bean.VipInfo
import com.chwl.library.download.DownloadException
import com.chwl.library.download.DownloadManager.download
import com.chwl.library.download.DownloadRequest.Companion.build
import com.chwl.library.download.DownloadTask
import com.chwl.library.download.FileDownloadListener
import com.chwl.library.utils.PathHelper.generateResourcesFilePath
import com.chwl.library.utils.ResUtil.getString
import com.tencent.qgame.animplayer.AnimConfig
import com.tencent.qgame.animplayer.AnimView
import com.tencent.qgame.animplayer.inter.IAnimListener
import com.tencent.qgame.animplayer.util.ScaleType
import com.youth.banner.adapter.BannerAdapter
import java.io.File
import java.text.SimpleDateFormat
import java.util.Calendar
import java.util.Locale
class VipCenterBannerAdapter(
private val context: Context,
private val vipInfos: List<VipInfo>,
private val myVipInfo: VipInfo?
) : BannerAdapter<VipInfo, VipCenterBannerAdapter.BannerViewHolder>(vipInfos) {
private val DOWNLOAD_TAG = "gift_effect_download"
override fun onCreateHolder(parent: ViewGroup, viewType: Int): BannerViewHolder {
val view = LayoutInflater.from(context).inflate(
R.layout.banner_vip_center_custom,
parent,
false)
return BannerViewHolder(view)
}
override fun onBindView(holder: BannerViewHolder, data: VipInfo, position: Int, size: Int) {
holder.dueText.visibility = View.GONE
myVipInfo?.let {
if (it.vipLevel == data.vipLevel) {
val calendar = Calendar.getInstance()
calendar.add(Calendar.SECOND, it.remainSeconds)
val dateFormat = SimpleDateFormat("yyyy-MM-dd", Locale.getDefault())
val formattedDate = dateFormat.format(calendar.time)
val result = "${getString(R.string.vip_center_2)}$formattedDate"
holder.dueText.text = result
holder.dueText.visibility = View.VISIBLE
} else if (it.vipLevel < data.vipLevel) {
holder.dueText.text = getString(R.string.vip_center_8)
holder.dueText.visibility = View.VISIBLE
} else {
holder.dueText.visibility = View.GONE
}
}
when(position) {
0-> {
holder.dueText.setTextColor(context.resources.getColor(R.color.color_3A4D14))
holder.imgBackground.setImageResource(R.drawable.vip_center_level_1)
}
1-> {
holder.dueText.setTextColor(context.resources.getColor(R.color.color_4D143A))
holder.imgBackground.setImageResource(R.drawable.vip_center_level_2)
}
2-> {
holder.dueText.setTextColor(context.resources.getColor(R.color.color_4D2C14))
holder.imgBackground.setImageResource(R.drawable.vip_center_level_3)
}
3-> {
holder.dueText.setTextColor(context.resources.getColor(R.color.color_44144D))
holder.imgBackground.setImageResource(R.drawable.vip_center_level_4)
}
4-> {
holder.dueText.setTextColor(context.resources.getColor(R.color.color_1C344D))
holder.imgBackground.setImageResource(R.drawable.vip_center_level_5)
}
5-> {
holder.dueText.setTextColor(context.resources.getColor(R.color.color_1C4D35))
holder.imgBackground.setImageResource(R.drawable.vip_center_level_6)
}
6-> {
holder.dueText.setTextColor(context.resources.getColor(R.color.color_44144D))
holder.imgBackground.setImageResource(R.drawable.vip_center_level_7)
}
7-> {
holder.dueText.setTextColor(context.resources.getColor(R.color.color_4D371C))
holder.imgBackground.setImageResource(R.drawable.vip_center_level_8)
}
8-> {
holder.dueText.setTextColor(context.resources.getColor(R.color.color_4D1C1C))
holder.imgBackground.setImageResource(R.drawable.vip_center_level_9)
}
}
holder.vapAnimView.setScaleType(ScaleType.FIT_XY)
holder.vapAnimView.setLoop(Int.MAX_VALUE)
holder.vapAnimView.setAnimListener(object : IAnimListener {
override fun onFailed(errorType: Int, errorMsg: String?) {
println(errorMsg)
}
override fun onVideoComplete() {
println("complete")
}
override fun onVideoDestroy() {
println("destory")
}
override fun onVideoRender(frameIndex: Int, config: AnimConfig?) {
println("rendering")
}
override fun onVideoStart() {
println("start")
}
})
val filePath = generateResourcesFilePath(data.vipLogo)
val request = build(data.vipLogo, filePath, DOWNLOAD_TAG, null, 60000L)
download(request, object : FileDownloadListener() {
override fun onDownloadCompleted(task: DownloadTask) {
val path = task.getRequest().getPath()
holder.vapAnimView.startPlay(File(path))
}
override fun onDownloadError(exception: DownloadException) {
exception.printStackTrace()
}
})
}
inner class BannerViewHolder(view: View) : RecyclerView.ViewHolder(view) {
val imgBackground: ImageView = view.findViewById(R.id.img_background)
// val svgaImage: SVGAImageView = view.findViewById(R.id.iv_vip_icon)
val vapAnimView: AnimView = view.findViewById(R.id.vap_anim_view)
val dueText: TextView = view.findViewById(R.id.due_date_textview)
}
}

View File

@@ -0,0 +1,156 @@
package com.chwl.app.vip.adapter
import android.annotation.SuppressLint
import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import com.chwl.app.R
import com.chwl.core.vip.bean.VipAuthInfo
import com.chwl.core.vip.bean.VipInfo
interface OnItemClickListener {
fun onItemClick(position: Int)
}
class VipCenterIdentificationsAdapter(
private val context: Context,
private val items: List<VipAuthInfo>,
private val listener: OnItemClickListener
) : RecyclerView.Adapter<VipCenterIdentificationsAdapter.ItemViewHolder>() {
private var vipInfo: VipInfo? = null
override fun onCreateViewHolder(
parent: ViewGroup,
viewType: Int
): VipCenterIdentificationsAdapter.ItemViewHolder {
val view = LayoutInflater.from(context).inflate(R.layout.vip_center_idnetifications_layout, parent, false)
return ItemViewHolder(view)
}
override fun onBindViewHolder(
holder: VipCenterIdentificationsAdapter.ItemViewHolder,
position: Int
) {
val filteredList = items.filter {
it.authType == 1 || it.authType == 5 || it.authType == 8 || it.authType ==
11 || it.authType == 12
}
val item = filteredList[position]
vipInfo?.let {
holder.titleTextView.text = item.authName
// val lv = it.vipLevel
// var resourceName = "null"
when (position) {
0 -> {
when (it.vipLevel) {
1 -> holder.contentImageView.setImageResource(R.drawable.vip_center_identification_vipidentity_lv1)
2 -> holder.contentImageView.setImageResource(R.drawable.vip_center_identification_vipidentity_lv2)
3 -> holder.contentImageView.setImageResource(R.drawable.vip_center_identification_vipidentity_lv3)
4 -> holder.contentImageView.setImageResource(R.drawable.vip_center_identification_vipidentity_lv4)
5 -> holder.contentImageView.setImageResource(R.drawable.vip_center_identification_vipidentity_lv5)
6 -> holder.contentImageView.setImageResource(R.drawable.vip_center_identification_vipidentity_lv6)
7 -> holder.contentImageView.setImageResource(R.drawable.vip_center_identification_vipidentity_lv7)
8 -> holder.contentImageView.setImageResource(R.drawable.vip_center_identification_vipidentity_lv8)
9 -> holder.contentImageView.setImageResource(R.drawable.vip_center_identification_vipidentity_lv9)
}
// resourceName = "vip_center_identification_vipidentity_lv$lv"
}
1 -> {
// resourceName = "vip_center_identification_roomcard_lv$lv"
when (it.vipLevel) {
1 -> holder.contentImageView.setImageResource(R.drawable.vip_center_identification_roomcard_lv1)
2 -> holder.contentImageView.setImageResource(R.drawable.vip_center_identification_roomcard_lv2)
3 -> holder.contentImageView.setImageResource(R.drawable.vip_center_identification_roomcard_lv3)
4 -> holder.contentImageView.setImageResource(R.drawable.vip_center_identification_roomcard_lv4)
5 -> holder.contentImageView.setImageResource(R.drawable.vip_center_identification_roomcard_lv5)
6 -> holder.contentImageView.setImageResource(R.drawable.vip_center_identification_roomcard_lv6)
7 -> holder.contentImageView.setImageResource(R.drawable.vip_center_identification_roomcard_lv7)
8 -> holder.contentImageView.setImageResource(R.drawable.vip_center_identification_roomcard_lv8)
9 -> holder.contentImageView.setImageResource(R.drawable.vip_center_identification_roomcard_lv9)
}
}
2 -> {
// resourceName = "vip_center_identification_mic_lv$lv"
when (it.vipLevel) {
3 -> holder.contentImageView.setImageResource(R.drawable.vip_center_identification_mic_lv3)
4 -> holder.contentImageView.setImageResource(R.drawable.vip_center_identification_mic_lv4)
5 -> holder.contentImageView.setImageResource(R.drawable.vip_center_identification_mic_lv5)
6 -> holder.contentImageView.setImageResource(R.drawable.vip_center_identification_mic_lv6)
7 -> holder.contentImageView.setImageResource(R.drawable.vip_center_identification_mic_lv7)
8 -> holder.contentImageView.setImageResource(R.drawable.vip_center_identification_mic_lv8)
9 -> holder.contentImageView.setImageResource(R.drawable.vip_center_identification_mic_lv9)
}
}
3 -> {
// resourceName = "vip_center_identification_bubble_lv$lv"
when (it.vipLevel) {
4 -> holder.contentImageView.setImageResource(R.drawable.vip_center_identification_bubble_lv4)
5 -> holder.contentImageView.setImageResource(R.drawable.vip_center_identification_bubble_lv5)
6 -> holder.contentImageView.setImageResource(R.drawable.vip_center_identification_bubble_lv6)
7 -> holder.contentImageView.setImageResource(R.drawable.vip_center_identification_bubble_lv7)
8 -> holder.contentImageView.setImageResource(R.drawable.vip_center_identification_bubble_lv8)
9 -> holder.contentImageView.setImageResource(R.drawable.vip_center_identification_bubble_lv9)
}
}
4 -> {
// resourceName = "vip_center_identification_entry_lv$lv"
when (it.vipLevel) {
4 -> holder.contentImageView.setImageResource(R.drawable.vip_center_identification_entry_lv4)
5 -> holder.contentImageView.setImageResource(R.drawable.vip_center_identification_entry_lv5)
6 -> holder.contentImageView.setImageResource(R.drawable.vip_center_identification_entry_lv6)
7 -> holder.contentImageView.setImageResource(R.drawable.vip_center_identification_entry_lv7)
8 -> holder.contentImageView.setImageResource(R.drawable.vip_center_identification_entry_lv8)
9 -> holder.contentImageView.setImageResource(R.drawable.vip_center_identification_entry_lv9)
}
}
}
// val resourceId = context.resources
// .getIdentifier(resourceName, "drawable", context.packageName)
// holder.contentImageView.setImageResource(resourceId)
}
val screenWidth = context.resources.displayMetrics.widthPixels
val itemWidth = (screenWidth * 160)/375
val layoutParams = holder.itemView.layoutParams
layoutParams.width = itemWidth
holder.itemView.layoutParams = layoutParams
// holder.itemView.setOnClickListener {
// listener.onItemClick(position)
// }
}
override fun getItemCount(): Int {
return vipInfo?.let {
when (it.vipLevel) {
1, 2 -> 2
3 -> 3
else -> 5
}
} ?: 0 // items.size
}
@SuppressLint("NotifyDataSetChanged")
fun setVipInfo(vipInfo: VipInfo?) {
this.vipInfo = vipInfo
this.notifyDataSetChanged()
}
inner class ItemViewHolder(view: View) : RecyclerView.ViewHolder(view) {
val contentImageView: ImageView = view.findViewById(R.id.item_image)
val titleTextView: TextView = view.findViewById(R.id.item_title)
}
}

View File

@@ -51,9 +51,9 @@ class SelectPayTypeDialog : BaseDialogFragment<DialogSelectPayTypeBinding>() {
fun newInstance(
descText: String,
showGoogleCharge: Boolean = false,
money: Double = 0.0
money: Int = 0
): SelectPayTypeDialog {
return newInstance(descText, (money * 1000).toLong(), showGoogleCharge)
return newInstance(descText, money.toLong(), showGoogleCharge)
}

View File

@@ -12,6 +12,14 @@ import com.chwl.app.base.BaseDialogFragment
import com.chwl.app.databinding.DialogVipUpgradeBinding
import com.chwl.app.vip.VipViewModel
import com.chwl.core.vip.bean.VipInfo
import com.chwl.library.download.DownloadException
import com.chwl.library.download.DownloadManager.download
import com.chwl.library.download.DownloadRequest
import com.chwl.library.download.DownloadRequest.Companion
import com.chwl.library.download.DownloadTask
import com.chwl.library.download.FileDownloadListener
import com.chwl.library.utils.PathHelper.generateResourcesFilePath
import java.io.File
import java.net.MalformedURLException
import java.net.URL
@@ -53,23 +61,38 @@ class VipUpgradeDialog : BaseDialogFragment<DialogVipUpgradeBinding>() {
}
binding?.tvVipUplevel?.setOnClickListener { dismissAllowingStateLoss() }
binding?.tvVipOrigin?.setOnClickListener { vm.saveOriginDisguise() }
try {
SVGAParser.shareParser()
.decodeFromURL(URL(vipInfo.vipLogo), object : SVGAParser.ParseCompletion {
override fun onComplete(videoItem: SVGAVideoEntity) {
val drawable = SVGADrawable(videoItem)
if (isViewLoaded) {
_binding?.ivVipIcon?.setImageDrawable(drawable)
_binding?.ivVipIcon?.startAnimation()
}
}
binding?.ivVipIconMp4?.setLoop(Int.MAX_VALUE)
override fun onError() {
}
})
} catch (e: MalformedURLException) {
val filePath = generateResourcesFilePath(vipInfo.vipLogo)
val request = DownloadRequest.build(vipInfo.vipLogo, filePath, "gift_effect_download", null, 60000L)
download(request, object : FileDownloadListener() {
override fun onDownloadCompleted(task: DownloadTask) {
val path = task.getRequest().getPath()
binding?.ivVipIconMp4?.startPlay(File(path))
}
}
override fun onDownloadError(exception: DownloadException) {
exception.printStackTrace()
}
})
// try {
// SVGAParser.shareParser()
// .decodeFromURL(URL(vipInfo.vipLogo), object : SVGAParser.ParseCompletion {
// override fun onComplete(videoItem: SVGAVideoEntity) {
// val drawable = SVGADrawable(videoItem)
// if (isViewLoaded) {
// _binding?.ivVipIcon?.setImageDrawable(drawable)
// _binding?.ivVipIcon?.startAnimation()
// }
// }
//
// override fun onError() {
// }
// })
// } catch (e: MalformedURLException) {
//
// }
binding?.tvLevelDesc?.text = getString(R.string.level_up_wear_dress_tips_format).format(vipInfo.vipName)
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 487 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 946 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 78 KiB

After

Width:  |  Height:  |  Size: 404 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 KiB

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 KiB

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

After

Width:  |  Height:  |  Size: 65 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 42 KiB

After

Width:  |  Height:  |  Size: 108 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 267 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 248 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 54 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 105 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 48 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 104 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 104 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 642 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 59 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 59 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 61 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 70 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 71 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 78 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 81 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 86 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 85 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 90 KiB

Some files were not shown because too many files have changed in this diff Show More