Compare commits
75 Commits
molistar/g
...
dev/molist
Author | SHA1 | Date | |
---|---|---|---|
![]() |
e4d44155dc | ||
![]() |
06c974a6ed | ||
![]() |
4bfbd19b53 | ||
![]() |
61a26f0c4f | ||
![]() |
e8cfc8a13b | ||
![]() |
295de38074 | ||
![]() |
e3c5f10d02 | ||
![]() |
d949cfa7ff | ||
![]() |
e30f4fd15f | ||
![]() |
90ece5366b | ||
![]() |
555b81589c | ||
![]() |
e4cdc39ad8 | ||
![]() |
09411df1ff | ||
![]() |
9cbc6cf39f | ||
![]() |
444d043aa8 | ||
![]() |
f99d193598 | ||
![]() |
4a57bd50c5 | ||
![]() |
8a59f8a769 | ||
![]() |
2c1ecbb263 | ||
![]() |
aa2987cb0d | ||
![]() |
5e6864d87f | ||
![]() |
6aabeb3eb3 | ||
![]() |
9ff48bc500 | ||
![]() |
e9ba0b1929 | ||
![]() |
adf2adc173 | ||
![]() |
74b2d71821 | ||
![]() |
81a5c6ba65 | ||
![]() |
5f8a8113c6 | ||
![]() |
b0bf9ce98d | ||
![]() |
c3fcbc3942 | ||
![]() |
6e08f397ee | ||
![]() |
3d29568b3c | ||
![]() |
cb4dac8e81 | ||
![]() |
f58701a2d6 | ||
![]() |
654bc45c8c | ||
![]() |
87a36d796c | ||
![]() |
0bc1023c99 | ||
![]() |
154e688673 | ||
![]() |
a91dee592d | ||
![]() |
7ef78bc3e1 | ||
![]() |
b5bcd9cb5f | ||
![]() |
de7eb25045 | ||
![]() |
029b7fcf96 | ||
![]() |
23a3858a2c | ||
![]() |
67044ded6b | ||
![]() |
3e6d34a986 | ||
![]() |
e7ca237a3e | ||
![]() |
e26d548515 | ||
![]() |
539be23e47 | ||
![]() |
dcafb35e24 | ||
![]() |
8fa429aca6 | ||
![]() |
f08b6d4577 | ||
![]() |
3ea7aecd5c | ||
![]() |
178f4e24ef | ||
![]() |
e2861459fb | ||
![]() |
d704a44106 | ||
![]() |
da81a4e905 | ||
![]() |
6c081d9a38 | ||
![]() |
37d897035f | ||
![]() |
cea25c7497 | ||
![]() |
47d2bfd145 | ||
![]() |
047e1454bd | ||
![]() |
714d5baec6 | ||
![]() |
b20ee8064c | ||
![]() |
711135ae90 | ||
![]() |
ecf42e368e | ||
![]() |
205e1180e7 | ||
![]() |
bc48cc86a9 | ||
![]() |
e7b73a2961 | ||
![]() |
5070e21d16 | ||
![]() |
049006aa8b | ||
![]() |
86b498c00e | ||
![]() |
6df95cf11f | ||
![]() |
3b407c0bd6 | ||
![]() |
83af08076a |
@@ -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()) {
|
||||
|
@@ -82,7 +82,8 @@
|
||||
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
|
||||
<!-- 对于 Android 12.0 及以上设备,还需要添加如下权限: -->
|
||||
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
|
||||
|
||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK" />
|
||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_REMOTE_MESSAGING" />
|
||||
<application
|
||||
android:name=".application.App"
|
||||
android:allowBackup="false"
|
||||
@@ -732,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" /> <!-- 通知提醒设置 -->
|
||||
@@ -876,17 +877,22 @@
|
||||
|
||||
<service
|
||||
android:name="com.netease.nimlib.service.NimService"
|
||||
android:foregroundServiceType="remoteMessaging"
|
||||
android:process=":core" />
|
||||
<service
|
||||
android:name="com.netease.nimlib.service.NimService$Aux"
|
||||
android:foregroundServiceType="remoteMessaging"
|
||||
android:process=":core" />
|
||||
<service
|
||||
android:name="com.netease.nimlib.job.NIMJobService"
|
||||
android:foregroundServiceType="remoteMessaging"
|
||||
android:permission="android.permission.BIND_JOB_SERVICE"
|
||||
android:process=":core" />
|
||||
<service android:name="com.netease.nimlib.service.ResponseService" />
|
||||
<service android:name="com.netease.nimlib.service.ResponseService"
|
||||
android:foregroundServiceType="remoteMessaging"/>
|
||||
<service
|
||||
android:name=".service.DaemonService"
|
||||
android:foregroundServiceType="mediaPlayback"
|
||||
android:enabled="true" />
|
||||
|
||||
<activity android:name=".avroom.room_album.RoomAlbumActivity" />
|
||||
@@ -949,6 +955,8 @@
|
||||
android:screenOrientation="portrait" />
|
||||
<activity android:name=".ui.debug.DebugActivity"
|
||||
android:screenOrientation="portrait"/>
|
||||
<activity android:name=".ui.game_team.record.GameTeamRecordActivity"
|
||||
android:screenOrientation="portrait"/>
|
||||
</application>
|
||||
|
||||
</manifest>
|
BIN
app/src/main/assets/svga/Combo_Boom.svga
Normal file
BIN
app/src/main/assets/svga/Combo_Boom.svga
Normal file
Binary file not shown.
@@ -84,7 +84,6 @@ import com.chwl.library.common.file.FileHelper;
|
||||
import com.chwl.library.net.rxnet.RxNet;
|
||||
import com.chwl.library.net.rxnet.converter.GsonConverterPlugins;
|
||||
import com.chwl.library.utils.AppMetaDataUtil;
|
||||
import com.chwl.library.utils.AppUtils;
|
||||
import com.chwl.library.utils.DeviceUuidFactory;
|
||||
import com.chwl.library.utils.ResUtil;
|
||||
import com.chwl.library.utils.SingleToastUtil;
|
||||
@@ -417,7 +416,7 @@ public class App extends BaseApp {
|
||||
httpParams.put("netType", String.valueOf(SystemUtils.getNetworkType(context)));
|
||||
httpParams.put("model", SystemUtils.getPhoneModel());
|
||||
httpParams.put("appVersion", VersionUtil.getLocalName(context));
|
||||
httpParams.put("appVersionCode", String.valueOf(AppUtils.getVersionCode(context)));
|
||||
httpParams.put("appVersionCode", String.valueOf(VersionUtil.getVersionCode(context)));
|
||||
httpParams.put("deviceId", DeviceUuidFactory.getDeviceId(context));
|
||||
httpParams.put("androidId", MD5Utils.getMD5String(Settings.Secure.getString(context.getContentResolver(), Settings.Secure.ANDROID_ID)));
|
||||
httpParams.put("channel", AppMetaDataUtil.getChannelID());
|
||||
|
@@ -97,7 +97,7 @@ public class GlobalHandleManager {
|
||||
Activity activity = getActivity();
|
||||
if (activity == null) return;
|
||||
if (AvRoomDataManager.get().isSelfGamePlaying()) return;
|
||||
LevelUpDialog.start(activity, event.getLevelName(), true);
|
||||
// LevelUpDialog.start(activity, event.getLevelName(), true);
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
@@ -105,7 +105,7 @@ public class GlobalHandleManager {
|
||||
Activity activity = getActivity();
|
||||
if (activity == null) return;
|
||||
if (AvRoomDataManager.get().isSelfGamePlaying()) return;
|
||||
LevelUpDialog.start(activity, event.getLevelName(), false);
|
||||
// LevelUpDialog.start(activity, event.getLevelName(), false);
|
||||
}
|
||||
|
||||
private static final class Helper {
|
||||
|
@@ -47,8 +47,7 @@ public abstract class BottomViewListenerWrapper {
|
||||
|
||||
}
|
||||
|
||||
public void onRoomGameplayClick(){
|
||||
public void onRoomGameplayClick(boolean isOnlyPK){
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -4,13 +4,13 @@ import android.annotation.SuppressLint
|
||||
import android.os.Bundle
|
||||
import android.view.WindowManager
|
||||
import com.chwl.app.R
|
||||
import com.chwl.app.base.BaseDialog
|
||||
import com.chwl.app.base.BaseDialogFragment
|
||||
import com.chwl.app.databinding.DialogRoomPkFinishBinding
|
||||
import com.chwl.app.ui.utils.ImageLoadUtils
|
||||
import com.chwl.core.im.custom.bean.RoomPkBean
|
||||
import com.chwl.core.utils.extension.subAndReplaceDot
|
||||
|
||||
class RoomPkFinishDialog : BaseDialog<DialogRoomPkFinishBinding>() {
|
||||
class RoomPkFinishDialog : BaseDialogFragment<DialogRoomPkFinishBinding>() {
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
|
@@ -4,13 +4,13 @@ import android.annotation.SuppressLint
|
||||
import android.os.Bundle
|
||||
import android.view.WindowManager
|
||||
import com.chwl.app.R
|
||||
import com.chwl.app.base.BaseDialog
|
||||
import com.chwl.app.base.BaseDialogFragment
|
||||
import com.chwl.app.databinding.DialogRoomPkForceFinishBinding
|
||||
import com.chwl.app.ui.utils.ImageLoadUtils
|
||||
import com.chwl.core.im.custom.bean.RoomPkBean
|
||||
import com.chwl.core.utils.extension.subAndReplaceDot
|
||||
|
||||
class RoomPkForceFinishDialog : BaseDialog<DialogRoomPkForceFinishBinding>() {
|
||||
class RoomPkForceFinishDialog : BaseDialogFragment<DialogRoomPkForceFinishBinding>() {
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
|
@@ -4,7 +4,7 @@ import android.annotation.SuppressLint
|
||||
import android.os.Bundle
|
||||
import androidx.core.view.isVisible
|
||||
import com.chwl.app.R
|
||||
import com.chwl.app.base.BaseDialog
|
||||
import com.chwl.app.base.BaseDialogFragment
|
||||
import com.chwl.app.databinding.DialogRoomPkReceivedBinding
|
||||
import com.chwl.core.im.custom.bean.RoomPkBean
|
||||
import com.chwl.core.manager.AvRoomDataManager
|
||||
@@ -16,7 +16,7 @@ import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.disposables.Disposable
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
class RoomPkReceivedDialog : BaseDialog<DialogRoomPkReceivedBinding>() {
|
||||
class RoomPkReceivedDialog : BaseDialogFragment<DialogRoomPkReceivedBinding>() {
|
||||
|
||||
companion object {
|
||||
|
||||
|
@@ -1,9 +1,9 @@
|
||||
package com.chwl.app.avroom.anotherroompk
|
||||
|
||||
import com.chwl.app.base.BaseDialog
|
||||
import com.chwl.app.base.BaseDialogFragment
|
||||
import com.chwl.app.databinding.DialogRoomPkRuleBinding
|
||||
|
||||
class RoomPkRuleDialog : BaseDialog<DialogRoomPkRuleBinding>() {
|
||||
class RoomPkRuleDialog : BaseDialogFragment<DialogRoomPkRuleBinding>() {
|
||||
|
||||
companion object {
|
||||
|
||||
|
@@ -0,0 +1,126 @@
|
||||
package com.chwl.app.avroom.dialog
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.Color
|
||||
import android.graphics.drawable.ColorDrawable
|
||||
import android.os.Bundle
|
||||
import android.os.Handler
|
||||
import android.os.Looper
|
||||
import android.view.Gravity
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.view.Window
|
||||
import android.view.WindowManager
|
||||
import androidx.annotation.StyleRes
|
||||
import androidx.viewbinding.ViewBinding
|
||||
import com.chwl.app.R
|
||||
import com.chwl.app.avroom.widget.VDHLayout
|
||||
import com.chwl.app.ui.widget.dialog.BaseDialog
|
||||
|
||||
abstract class BaseRoomNotifyeBaseDialog<VB : ViewBinding>(context: Context, theme: Int = 0) : BaseDialog(context, theme) {
|
||||
|
||||
protected val handle = Handler(Looper.getMainLooper())
|
||||
protected lateinit var mBinding: VB
|
||||
|
||||
abstract fun createBinding(inflater: LayoutInflater): VB
|
||||
|
||||
abstract fun init()
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
mBinding = createBinding(LayoutInflater.from(context))
|
||||
setContentView(mBinding.root)
|
||||
setCancelable(true)
|
||||
setCanceledOnTouchOutside(false)
|
||||
window?.let {
|
||||
initWindow(it)
|
||||
}
|
||||
|
||||
init()
|
||||
|
||||
handle.postDelayed({
|
||||
dismissDialog()
|
||||
}, (getStaySecond()*1000).toLong())
|
||||
}
|
||||
|
||||
override fun onDetachedFromWindow() {
|
||||
handle.removeCallbacksAndMessages(null)
|
||||
super.onDetachedFromWindow()
|
||||
}
|
||||
|
||||
protected open fun initWindow(window: Window) {
|
||||
window.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT))
|
||||
val windowParams = window.attributes
|
||||
windowParams.width = WindowManager.LayoutParams.MATCH_PARENT
|
||||
windowParams.height = WindowManager.LayoutParams.WRAP_CONTENT
|
||||
windowParams.dimAmount = 0.0f
|
||||
windowParams.gravity = Gravity.TOP
|
||||
windowParams.x = 0
|
||||
windowParams.y = getTopOffset()
|
||||
window.clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND)
|
||||
window.addFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE or WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL)
|
||||
window.attributes = windowParams
|
||||
window.setWindowAnimations(getAnimations())
|
||||
}
|
||||
|
||||
protected open fun getStaySecond():Float{
|
||||
return 5f
|
||||
}
|
||||
|
||||
protected open fun getTopOffset():Int{
|
||||
return 0
|
||||
}
|
||||
|
||||
@StyleRes
|
||||
protected open fun getAnimations():Int{
|
||||
return R.style.anim_left
|
||||
}
|
||||
|
||||
override fun setContentView(view: View) {
|
||||
if (useSlipSlip()) {
|
||||
val vdhLayout = VDHLayout(context, null)
|
||||
vdhLayout.addView(view)
|
||||
vdhLayout.setListener { dismissDialog() }
|
||||
super.setContentView(vdhLayout)
|
||||
return
|
||||
}
|
||||
super.setContentView(view)
|
||||
}
|
||||
|
||||
override fun setContentView(layoutResID: Int) {
|
||||
if (useSlipSlip()) {
|
||||
val vdhLayout = VDHLayout(context, null)
|
||||
LayoutInflater.from(context).inflate(layoutResID, vdhLayout)
|
||||
vdhLayout.setListener { dismissDialog() }
|
||||
super.setContentView(vdhLayout)
|
||||
return
|
||||
}
|
||||
super.setContentView(layoutResID)
|
||||
}
|
||||
|
||||
override fun setContentView(view: View, params: ViewGroup.LayoutParams?) {
|
||||
if (useSlipSlip()) {
|
||||
val vdhLayout = VDHLayout(context, null)
|
||||
vdhLayout.addView(view)
|
||||
vdhLayout.setListener { dismissDialog() }
|
||||
super.setContentView(vdhLayout, params)
|
||||
return
|
||||
}
|
||||
super.setContentView(view, params)
|
||||
}
|
||||
|
||||
open fun dismissDialog(){
|
||||
try {
|
||||
dismiss()
|
||||
} catch (e: Exception) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否启动侧滑,左滑:删除,右滑:回到原位置
|
||||
*/
|
||||
protected open fun useSlipSlip(): Boolean {
|
||||
return true
|
||||
}
|
||||
}
|
@@ -0,0 +1,75 @@
|
||||
package com.chwl.app.avroom.dialog
|
||||
|
||||
import android.content.Context
|
||||
import android.view.LayoutInflater
|
||||
import com.chwl.app.R
|
||||
import com.chwl.app.avroom.activity.AVRoomActivity
|
||||
import com.chwl.app.common.widget.dialog.DialogManager
|
||||
import com.chwl.app.common.widget.dialog.DialogManager.OkCancelDialogListener
|
||||
import com.chwl.app.databinding.RoomNotifyLuckGiftDlgBinding
|
||||
import com.chwl.app.ui.utils.ImageLoadUtils
|
||||
import com.chwl.app.utils.NumberUtils
|
||||
import com.chwl.core.gift.bean.LuckyGiftMsgAllBean
|
||||
import com.chwl.core.manager.AvRoomDataManager
|
||||
import com.chwl.library.utils.ResUtil
|
||||
import com.example.lib_utils.UiUtils
|
||||
|
||||
/**
|
||||
* @Author Vance
|
||||
* 幸运礼物的飘屏,全服但是展示的时候限制只有房间才展示
|
||||
*/
|
||||
class BaseRoomNotifyeLuckGiftDialog(private val context: Context) : BaseRoomNotifyeBaseDialog<RoomNotifyLuckGiftDlgBinding>(context) {
|
||||
|
||||
override fun createBinding(inflater: LayoutInflater): RoomNotifyLuckGiftDlgBinding {
|
||||
return RoomNotifyLuckGiftDlgBinding.inflate(inflater)
|
||||
}
|
||||
|
||||
private var mDialogManager: DialogManager? = null
|
||||
var luckyGiftMsgBean: LuckyGiftMsgAllBean ? = null
|
||||
|
||||
override fun init() {
|
||||
|
||||
if (UiUtils.isRtl(context)) {
|
||||
mBinding.bg.scaleX = -1f
|
||||
}
|
||||
|
||||
ImageLoadUtils.loadImage(mBinding.avatar,luckyGiftMsgBean?.sender?.avatar?:"")
|
||||
mBinding.giftName.text = luckyGiftMsgBean?.giftNameMap?.getFirstText()
|
||||
mBinding.winNum.text = luckyGiftMsgBean?.times.toString()
|
||||
|
||||
val coinNum = NumberUtils.format(luckyGiftMsgBean?.coins?:0)
|
||||
mBinding.coinNum.text = coinNum
|
||||
|
||||
mBinding.clickArea.setOnClickListener {
|
||||
mDialogManager = DialogManager(context)
|
||||
mDialogManager?.showOkCancelDialog(ResUtil.getString(R.string.changeRoomTips), true, object : OkCancelDialogListener {
|
||||
override fun onCancel() {
|
||||
mDialogManager?.dismissDialog()
|
||||
}
|
||||
|
||||
override fun onOk() {
|
||||
mDialogManager?.dismissDialog()
|
||||
luckyGiftMsgBean?.roomUid?.let {
|
||||
if (AvRoomDataManager.get().roomUid != it) {
|
||||
AVRoomActivity.start(context, it)
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
var mCallBack : CallBack? = null
|
||||
interface CallBack{
|
||||
fun onHide();
|
||||
}
|
||||
|
||||
override fun dismissDialog() {
|
||||
super.dismissDialog()
|
||||
mCallBack?.onHide()
|
||||
}
|
||||
|
||||
|
||||
}
|
@@ -6,7 +6,7 @@ import android.view.WindowManager
|
||||
import androidx.recyclerview.widget.GridLayoutManager
|
||||
import com.chwl.app.avroom.adapter.CreateRoomGameGuideAdapter
|
||||
import com.chwl.app.base.BaseActivity
|
||||
import com.chwl.app.base.BaseDialog
|
||||
import com.chwl.app.base.BaseDialogFragment
|
||||
import com.chwl.app.databinding.DialogCreateGameRoomBinding
|
||||
import com.chwl.app.home.helper.OpenRoomHelper
|
||||
import com.chwl.app.ui.utils.RVDelegate
|
||||
@@ -14,7 +14,7 @@ import com.chwl.core.room.bean.RoomInfo
|
||||
import com.chwl.core.room.game.bean.GameInfo
|
||||
import com.chwl.core.room.game.GameModel
|
||||
|
||||
class CreateGameRoomDialog : BaseDialog<DialogCreateGameRoomBinding>() {
|
||||
class CreateGameRoomDialog : BaseDialogFragment<DialogCreateGameRoomBinding>() {
|
||||
|
||||
private lateinit var rvDelegate: RVDelegate<GameInfo>
|
||||
private val gameAdapter = CreateRoomGameGuideAdapter()
|
||||
|
@@ -9,7 +9,7 @@ import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import com.chwl.app.R
|
||||
import com.chwl.app.avroom.adapter.CreateRoomGameAdapter
|
||||
import com.chwl.app.base.BaseActivity
|
||||
import com.chwl.app.base.BaseDialog
|
||||
import com.chwl.app.base.BaseDialogFragment
|
||||
import com.chwl.app.databinding.DialogCreateRoomBinding
|
||||
import com.chwl.app.home.helper.OpenRoomHelper
|
||||
import com.chwl.app.ui.utils.RVDelegate
|
||||
@@ -19,7 +19,7 @@ import com.chwl.core.room.game.GameModel
|
||||
import com.chwl.core.utils.extension.toast
|
||||
import com.chwl.library.utils.ResUtil
|
||||
|
||||
class CreateRoomDialog : BaseDialog<DialogCreateRoomBinding>() {
|
||||
class CreateRoomDialog : BaseDialogFragment<DialogCreateRoomBinding>() {
|
||||
|
||||
private lateinit var rvDelegate: RVDelegate<GameInfo>
|
||||
private val gameAdapter = CreateRoomGameAdapter()
|
||||
|
@@ -1,12 +1,12 @@
|
||||
package com.chwl.app.avroom.dialog
|
||||
|
||||
import com.chwl.app.base.BaseDialog
|
||||
import com.chwl.app.base.BaseDialogFragment
|
||||
import com.chwl.app.databinding.DialogNewUserGiftBinding
|
||||
import com.chwl.app.ui.utils.load
|
||||
import com.chwl.core.gift.bean.GiftInfo
|
||||
|
||||
class NewUserGiftDialog(val giftInfo: GiftInfo) :
|
||||
BaseDialog<DialogNewUserGiftBinding>() {
|
||||
BaseDialogFragment<DialogNewUserGiftBinding>() {
|
||||
|
||||
override fun init() {
|
||||
binding?.ivClose?.setOnClickListener {
|
||||
|
@@ -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)
|
||||
|
@@ -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 ->
|
||||
|
@@ -77,6 +77,14 @@ public class RoomOperationDialog extends BottomSheetDialog {
|
||||
private Context context;
|
||||
private OptAdapter optAdapter;
|
||||
private OnActionListener onActionListener;
|
||||
private CallBack callBack;
|
||||
public void setCallBack(CallBack callBack) {
|
||||
this.callBack = callBack;
|
||||
}
|
||||
|
||||
public interface CallBack{
|
||||
void onCLick(int Type);
|
||||
}
|
||||
|
||||
public RoomOperationDialog(@NonNull Context context) {
|
||||
super(context, R.style.ErbanBottomSheetDialogDimFalse);
|
||||
@@ -133,6 +141,7 @@ public class RoomOperationDialog extends BottomSheetDialog {
|
||||
addSuperAdminAction(optAdapter);
|
||||
addShieldReportAction(optAdapter);
|
||||
addRoomTypeSwitchAction(optAdapter);
|
||||
//todo-- add pk btn
|
||||
rvOPtList.setAdapter(optAdapter);
|
||||
}
|
||||
|
||||
|
@@ -5,7 +5,7 @@ import android.view.WindowManager
|
||||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
import androidx.core.view.isVisible
|
||||
import com.chwl.app.R
|
||||
import com.chwl.app.base.BaseDialog
|
||||
import com.chwl.app.base.BaseDialogFragment
|
||||
import com.chwl.app.databinding.RoomTeamPkDialogBinding
|
||||
import com.chwl.app.ui.utils.loadAvatar
|
||||
import com.chwl.app.ui.widget.dialog.CommonTipDialog
|
||||
@@ -28,7 +28,7 @@ import org.greenrobot.eventbus.Subscribe
|
||||
import org.greenrobot.eventbus.ThreadMode
|
||||
import java.util.Locale
|
||||
|
||||
class RoomTeamPkDialog : BaseDialog<RoomTeamPkDialogBinding>() {
|
||||
class RoomTeamPkDialog : BaseDialogFragment<RoomTeamPkDialogBinding>() {
|
||||
|
||||
private var compositeDisposable: CompositeDisposable? = null
|
||||
|
||||
|
@@ -9,7 +9,7 @@ import android.view.WindowManager
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import com.chwl.app.avroom.adapter.SendBroadcastAdapter
|
||||
import com.chwl.app.base.BaseActivity
|
||||
import com.chwl.app.base.BaseDialog
|
||||
import com.chwl.app.base.BaseDialogFragment
|
||||
import com.chwl.app.databinding.DialogSendBroadcastBinding
|
||||
import com.chwl.app.ui.utils.RVDelegate
|
||||
import com.chwl.app.utils.SpannableBuilder
|
||||
@@ -24,7 +24,7 @@ import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.disposables.Disposable
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
class SendBroadcastDialog : BaseDialog<DialogSendBroadcastBinding>() {
|
||||
class SendBroadcastDialog : BaseDialogFragment<DialogSendBroadcastBinding>() {
|
||||
|
||||
private lateinit var rvDelegate: RVDelegate<String>
|
||||
private lateinit var adapter: SendBroadcastAdapter
|
||||
|
@@ -2,11 +2,11 @@ package com.chwl.app.avroom.dialog
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.view.WindowManager
|
||||
import com.chwl.app.base.BaseDialog
|
||||
import com.chwl.app.base.BaseDialogFragment
|
||||
import com.chwl.app.databinding.DialogSingleRoomTipBinding
|
||||
|
||||
class SingleRoomTipDialog :
|
||||
BaseDialog<DialogSingleRoomTipBinding>() {
|
||||
BaseDialogFragment<DialogSingleRoomTipBinding>() {
|
||||
@SuppressLint("ClickableViewAccessibility")
|
||||
override fun init() {
|
||||
binding?.root?.setOnClickListener {
|
||||
|
@@ -22,9 +22,7 @@ import android.widget.RelativeLayout
|
||||
import android.widget.TextView
|
||||
import androidx.annotation.CallSuper
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.fragment.app.FragmentManager
|
||||
import androidx.fragment.app.activityViewModels
|
||||
import androidx.lifecycle.LifecycleOwner
|
||||
import androidx.lifecycle.LiveData
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
@@ -48,7 +46,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
|
||||
@@ -60,16 +57,14 @@ import com.chwl.app.event.OpenRoomIntroEvent
|
||||
import com.chwl.app.friend.view.SelectFriendActivity
|
||||
import com.chwl.app.home.adapter.RoomActAdapter
|
||||
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
|
||||
import com.chwl.app.ui.widget.GiftDialog.OnGiftDialogBtnClickListener
|
||||
import com.chwl.app.ui.widget.GiftDialog.SenGiftCallback
|
||||
import com.chwl.app.ui.widget.UserInfoDialog
|
||||
import com.chwl.app.ui.widget.dialog.CommonTipDialog
|
||||
import com.chwl.app.ui.widget.dynamicface.DynamicFaceDialog
|
||||
import com.chwl.app.ui.widget.magicindicator.MagicIndicator
|
||||
import com.chwl.app.ui.widget.magicindicator.buildins.UIUtil
|
||||
@@ -78,13 +73,13 @@ import com.chwl.app.ui.widget.rollviewpager.RollPagerView
|
||||
import com.chwl.app.ui.widget.rollviewpager.Util
|
||||
import com.chwl.app.ui.widget.rollviewpager.hintview.ColorPointHintView
|
||||
import com.chwl.app.utils.KeyBoardUtils
|
||||
import com.chwl.app.vip.dialog.SelectPayTypeDialog
|
||||
import com.chwl.core.Constants
|
||||
import com.chwl.core.UriProvider
|
||||
import com.chwl.core.auth.AuthModel
|
||||
import com.chwl.core.bean.RoomMicInfo
|
||||
import com.chwl.core.gift.GiftModel
|
||||
import com.chwl.core.gift.bean.GiftInfo
|
||||
import com.chwl.core.gift.event.GiftComboEvent
|
||||
import com.chwl.core.gift.event.RoomFreeGiftEvent
|
||||
import com.chwl.core.helper.AtProxy
|
||||
import com.chwl.core.home.bean.BannerInfo
|
||||
@@ -98,6 +93,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
|
||||
@@ -116,12 +113,16 @@ import com.chwl.core.support.room.RoomWidget
|
||||
import com.chwl.core.user.UserModel
|
||||
import com.chwl.core.user.bean.BaseInfo
|
||||
import com.chwl.core.user.bean.UserInfo
|
||||
import com.chwl.core.utils.net.BalanceNotEnoughExeption
|
||||
import com.chwl.core.utils.net.VipLevelNotEnoughException
|
||||
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.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.UIUtils
|
||||
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
|
||||
@@ -132,7 +133,6 @@ import com.tbruyelle.rxpermissions2.RxPermissions
|
||||
import com.trello.rxlifecycle3.android.FragmentEvent
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.disposables.Disposable
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import org.greenrobot.eventbus.Subscribe
|
||||
@@ -153,12 +153,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 +198,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 +213,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 +235,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 +245,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 +300,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 +307,6 @@ open class BaseRoomFragment<V : IBaseRoomView?, P1 : BaseRoomPresenter<V>?> :
|
||||
false
|
||||
}
|
||||
|
||||
|
||||
messageView.setOnLongClickListener { _, account, name ->
|
||||
showInputLayout()
|
||||
if (atProxy == null) atProxy = AtProxy(inputEdit)
|
||||
@@ -374,44 +362,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 +615,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 +743,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 +812,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 +842,6 @@ open class BaseRoomFragment<V : IBaseRoomView?, P1 : BaseRoomPresenter<V>?> :
|
||||
return
|
||||
}
|
||||
mvpPresenter?.sendPublicChatTextMessage(message)
|
||||
publicChatMessageWidget?.getMessageView()?.setNeedAutoScroll(true) // 發送後自動滾動公屏列表
|
||||
inputEdit.setText("")
|
||||
}
|
||||
|
||||
@@ -907,6 +867,9 @@ open class BaseRoomFragment<V : IBaseRoomView?, P1 : BaseRoomPresenter<V>?> :
|
||||
for (i in micMemberInfos.indices) {
|
||||
targetUids.add(micMemberInfos[i].account.toLong())
|
||||
}
|
||||
|
||||
EventBus.getDefault().post(GiftComboEvent(GiftComboEvent.Action.ACT_GIFT_BEGIN))
|
||||
|
||||
GiftModel.get()
|
||||
.sendRoomGift(
|
||||
giftInfo.giftId,
|
||||
@@ -928,11 +891,16 @@ open class BaseRoomFragment<V : IBaseRoomView?, P1 : BaseRoomPresenter<V>?> :
|
||||
dialogManager.showOkDialog(message)
|
||||
}
|
||||
}
|
||||
.subscribe { _, throwable ->
|
||||
.subscribe { gift, throwable ->
|
||||
if (throwable != null) {
|
||||
toast(throwable.message)
|
||||
callback.onFail()
|
||||
EventBus.getDefault().post(GiftComboEvent(GiftComboEvent.Action.ACT_GIFT_CANCEL))
|
||||
} else {
|
||||
giftDialog?.hide()
|
||||
val giftComboEvent = GiftComboEvent(GiftComboEvent.Action.ACT_GIFT_END)
|
||||
giftComboEvent.giftNumber = gift.data.giftNum
|
||||
EventBus.getDefault().post(giftComboEvent)
|
||||
callback.onSuccess()
|
||||
}
|
||||
}
|
||||
@@ -1197,7 +1165,6 @@ open class BaseRoomFragment<V : IBaseRoomView?, P1 : BaseRoomPresenter<V>?> :
|
||||
}
|
||||
|
||||
override fun onSendPublicChatMsgSuccess(msg: ChatRoomMessage) {
|
||||
publicChatMessageWidget?.getMessageView()?.addMessages(msg)
|
||||
inputEdit.setText("")
|
||||
KeyBoardUtils.hideKeyBoard(activity, inputEdit)
|
||||
}
|
||||
@@ -1318,6 +1285,7 @@ open class BaseRoomFragment<V : IBaseRoomView?, P1 : BaseRoomPresenter<V>?> :
|
||||
giftDialog?.setOnDismissListener { giftDialog = null }
|
||||
}
|
||||
if (giftDialog?.isShowing != true && !requireActivity().isFinishing) {
|
||||
EventBus.getDefault().post(GiftComboEvent(GiftComboEvent.Action.ACT_GIFT_POINT))
|
||||
giftDialog?.show()
|
||||
}
|
||||
}
|
||||
@@ -1434,14 +1402,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 +1457,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 +1474,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)
|
||||
@@ -1520,6 +1489,26 @@ open class BaseRoomFragment<V : IBaseRoomView?, P1 : BaseRoomPresenter<V>?> :
|
||||
}
|
||||
|
||||
protected open fun onInitMusicPlayerView(view: MusicPlayerView) {
|
||||
|
||||
//todo-- 音乐按钮
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
fun onGiftComboEvent(event: GiftComboEvent) {
|
||||
when (event.action) {
|
||||
|
||||
GiftComboEvent.Action.ACT_GIFT_START-> {
|
||||
giftDialog?.sendGift()
|
||||
}
|
||||
|
||||
GiftComboEvent.Action.ACT_GIFT_SHOW-> {
|
||||
giftDialog?.show()
|
||||
}
|
||||
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -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) {
|
||||
|
@@ -6,7 +6,10 @@ import android.content.ClipboardManager;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewConfiguration;
|
||||
import android.view.ViewStub;
|
||||
@@ -19,9 +22,23 @@ import androidx.fragment.app.DialogFragment;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import com.chwl.app.avroom.activity.RoomTitleEditActivity;
|
||||
import com.chwl.app.avroom.dialog.BaseRoomNotifyeLuckGiftDialog;
|
||||
import com.chwl.app.databinding.LayoutRoomNotifyLuckyGiftTipBinding;
|
||||
import com.chwl.app.utils.GiftAnimUtil;
|
||||
import com.chwl.app.utils.NumberUtils;
|
||||
import com.chwl.app.utils.WeakPool;
|
||||
import com.chwl.core.auth.AuthModel;
|
||||
import com.chwl.core.gift.bean.LuckyGiftMsgAllBean;
|
||||
import com.chwl.core.gift.bean.LuckyGiftMsgSelfBean;
|
||||
import com.chwl.core.gift.bean.MsgSuperLuckyGift;
|
||||
import com.chwl.core.utils.ComboUtil;
|
||||
import com.chwl.app.ui.utils.ImageLoadUtilsV2;
|
||||
import com.chwl.app.ui.widget.BonsellaJoinAttackButtonView;
|
||||
import com.chwl.app.ui.widget.GiftDialog;
|
||||
import com.chwl.app.ui.widget.UserInfoDialog;
|
||||
import com.chwl.core.gift.event.GiftComboEvent;
|
||||
import com.chwl.core.gift.toolbox.GiftToolbox;
|
||||
import com.chwl.core.utils.LogUtils;
|
||||
import com.chwl.library.utils.JavaUtil;
|
||||
import com.example.lib_utils.UiUtils;
|
||||
import com.netease.nim.uikit.common.util.string.StringUtil;
|
||||
@@ -66,6 +83,7 @@ import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import io.reactivex.SingleObserver;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
@@ -101,6 +119,9 @@ public class HomePartyFragment extends BaseFragment implements View.OnClickListe
|
||||
//收藏房间
|
||||
private String FOLLOW_ROOM_TYPE = "";
|
||||
|
||||
//幸运礼物 飘屏队列
|
||||
private ArrayList<LuckyGiftMsgAllBean> mLuckyGiftList = new ArrayList<>();
|
||||
|
||||
public static HomePartyFragment newInstance() {
|
||||
HomePartyFragment homePartyFragment = new HomePartyFragment();
|
||||
Bundle bundle = new Bundle();
|
||||
@@ -243,7 +264,7 @@ public class HomePartyFragment extends BaseFragment implements View.OnClickListe
|
||||
case RoomEvent.ROOM_INFO_UPDATE:
|
||||
updateView(AvRoomDataManager.get().mCurrentRoomInfo);
|
||||
break;
|
||||
case RoomEvent.RECEIVE_NORMALE_GIFT:
|
||||
case RoomEvent.RECEIVE_NORMALE_GIFT://普通
|
||||
onReceiveGiftMsg(roomEvent.getGiftReceiveInfo());
|
||||
break;
|
||||
case RoomEvent.RECEIVE_MUTLT_NORMALEI_GIFT://普通多人
|
||||
@@ -267,12 +288,17 @@ public class HomePartyFragment extends BaseFragment implements View.OnClickListe
|
||||
case RoomEvent.FANS_TEAM_JOIN:
|
||||
onReceiveFansTeamJoinMsg(roomEvent.getChatRoomMessage());
|
||||
break;
|
||||
case RoomEvent.MSG_SUPER_LUCKY_GIFT:
|
||||
onLuckyGiftMsg(roomEvent);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 获取礼物飘屏是否展示
|
||||
*
|
||||
@@ -491,10 +517,16 @@ public class HomePartyFragment extends BaseFragment implements View.OnClickListe
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
|
||||
luckyGiftTipPool.clear();
|
||||
handler.removeCallbacksAndMessages(null);
|
||||
mLuckyGiftList.clear();
|
||||
|
||||
if (giftView != null) {
|
||||
giftView.release();
|
||||
}
|
||||
EventBus.getDefault().unregister(this);
|
||||
gameMainBinding.giftComboBtn.cancel();
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
@@ -508,10 +540,10 @@ public class HomePartyFragment extends BaseFragment implements View.OnClickListe
|
||||
updateOnlineNumberView(onlineNumber);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 普通多人
|
||||
*
|
||||
* @param giftMultiReceiverInfo
|
||||
*/
|
||||
private void onReceiveMultiGiftMsg(GiftMultiReceiverInfo giftMultiReceiverInfo) {
|
||||
if (giftMultiReceiverInfo == null || !isResumed()) return;
|
||||
@@ -519,12 +551,12 @@ public class HomePartyFragment extends BaseFragment implements View.OnClickListe
|
||||
giftView = (GiftV2View) mVsGift2View.inflate();
|
||||
}
|
||||
giftView.onReceiveGiftToMultiMsg(giftMultiReceiverInfo);
|
||||
giftMultiReceiverInfo.isMulti = true;
|
||||
gameMainBinding.giftComboLayout.onRoomCustomMsg(giftMultiReceiverInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 普通全麦
|
||||
*
|
||||
* @param multiGiftReceiveInfo
|
||||
*/
|
||||
private void onReceiveAllMicGiftMsg(MultiGiftReceiveInfo multiGiftReceiveInfo) {
|
||||
if (multiGiftReceiveInfo == null || !isResumed()) return;
|
||||
@@ -532,14 +564,20 @@ public class HomePartyFragment extends BaseFragment implements View.OnClickListe
|
||||
giftView = (GiftV2View) mVsGift2View.inflate();
|
||||
}
|
||||
giftView.onReceiveMultiGiftMsg(multiGiftReceiveInfo);
|
||||
gameMainBinding.giftComboLayout.onRoomCustomMsg(GiftToolbox.transformToGiftMultiReceiverInfo(multiGiftReceiveInfo));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 普通
|
||||
*/
|
||||
private void onReceiveGiftMsg(GiftReceiveInfo giftReceiveInfo) {
|
||||
if (giftReceiveInfo == null || !isResumed()) return;
|
||||
if (giftView == null) {
|
||||
giftView = (GiftV2View) mVsGift2View.inflate();
|
||||
}
|
||||
giftView.onReceiveGiftMsg(giftReceiveInfo);
|
||||
gameMainBinding.giftComboLayout.onRoomCustomMsg(GiftToolbox.transformToGiftMultiReceiverInfo(giftReceiveInfo));
|
||||
}
|
||||
|
||||
private void onReceiveMagicMsg(MagicReceivedInfo magicReceivedInfo) {
|
||||
@@ -611,4 +649,149 @@ public class HomePartyFragment extends BaseFragment implements View.OnClickListe
|
||||
dialogFragment.show(requireActivity().getSupportFragmentManager(), "roomTitle");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onGiftComboEvent(GiftComboEvent event) {
|
||||
if (event.getAction() == GiftComboEvent.Action.ACT_GIFT_BEGIN) {
|
||||
if (gameMainBinding.giftComboBtn.isInCombo()){
|
||||
gameMainBinding.giftComboBtn.waitStart();
|
||||
}
|
||||
} else if (event.getAction() == GiftComboEvent.Action.ACT_GIFT_END) {
|
||||
showComboBtn(event.getGiftNumber());
|
||||
}else if (event.getAction() == GiftComboEvent.Action.ACT_GIFT_CANCEL) {
|
||||
if (gameMainBinding.giftComboBtn.isInCombo()) {
|
||||
gameMainBinding.giftComboBtn.cancel();
|
||||
}
|
||||
}else if (event.getAction() == GiftComboEvent.Action.ACT_GIFT_POINT) {
|
||||
ComboUtil.INSTANCE.setPoint(gameMainBinding.giftComboBtn);
|
||||
}
|
||||
}
|
||||
|
||||
private void showComboBtn(int number) {
|
||||
if (gameMainBinding.giftComboBtn.getOnGiftComboEndListener() == null) {
|
||||
|
||||
gameMainBinding.giftComboBtn.setOnClickListener(v -> {
|
||||
ComboUtil.INSTANCE.setPoint(gameMainBinding.giftComboBtn);
|
||||
EventBus.getDefault().post(new GiftComboEvent(GiftComboEvent.Action.ACT_GIFT_START));
|
||||
gameMainBinding.giftComboBtn.onBtnDown();
|
||||
});
|
||||
|
||||
|
||||
gameMainBinding.giftComboBtn.setOnGiftComboEndListener(new BonsellaJoinAttackButtonView.OnGiftComboEndListener() {
|
||||
@Override
|
||||
public void onGiftComboEnd() {
|
||||
gameMainBinding.giftComboBtn.showView(false);
|
||||
EventBus.getDefault().post(new GiftComboEvent(GiftComboEvent.Action.ACT_GIFT_SHOW));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
gameMainBinding.giftComboBtn.showView(true);
|
||||
gameMainBinding.giftComboBtn.start();
|
||||
gameMainBinding.giftComboBtn.updateNumber(number);
|
||||
}
|
||||
|
||||
|
||||
private void onLuckyGiftMsg(RoomEvent roomEvent) {
|
||||
MsgSuperLuckyGift msgSuperLuckyGift = roomEvent.getMsgSuperLuckyGift();
|
||||
if (msgSuperLuckyGift != null) {
|
||||
if (msgSuperLuckyGift.luckyGiftMsgAllBean != null) {
|
||||
showLuckyGiftDlg(msgSuperLuckyGift.luckyGiftMsgAllBean);
|
||||
}
|
||||
|
||||
if (msgSuperLuckyGift.luckyGiftMsgSelfBean != null) {
|
||||
showLuckyGiftDlgNotify(msgSuperLuckyGift.luckyGiftMsgSelfBean);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
private Handler handler = new Handler(Looper.getMainLooper());
|
||||
private WeakPool<View> luckyGiftTipPool = new WeakPool<>(3);
|
||||
private void showLuckyGiftDlgNotify(LuckyGiftMsgSelfBean luckyGiftMsgBean) {
|
||||
if (luckyGiftMsgBean == null) return;
|
||||
if (luckyGiftMsgBean.getUid() != AuthModel.get().getCurrentUid()) return;
|
||||
if (luckyGiftMsgBean.getRoomId() != AvRoomDataManager.get().getRoomId()) return;
|
||||
if (luckyGiftMsgBean.getRoomUid() != AvRoomDataManager.get().getRoomUid()) return;
|
||||
|
||||
LogUtils.i(" showLuckyGiftDlgNotify = start");
|
||||
|
||||
View root = luckyGiftTipPool.acquire(() -> {
|
||||
return LayoutInflater.from(gameMainBinding.flLuckyGiftNotifyLayout.getContext()).inflate(R.layout.layout_room_notify_lucky_gift_tip, gameMainBinding.flLuckyGiftNotifyLayout, false);
|
||||
});
|
||||
LayoutRoomNotifyLuckyGiftTipBinding binding = LayoutRoomNotifyLuckyGiftTipBinding.bind(root);
|
||||
binding.coinNum.setText(NumberUtils.format(luckyGiftMsgBean.getCoins()));
|
||||
binding.winNum.setText(java.lang.String.valueOf(luckyGiftMsgBean.getTimes()));
|
||||
if (luckyGiftMsgBean.getLevel() > 1) {
|
||||
binding.rootView.setBackgroundResource(R.drawable.bg_lucky_gift_tip_2);
|
||||
}
|
||||
root.setAlpha(0f);
|
||||
root.setScaleX(0f);
|
||||
root.setScaleY(0f);
|
||||
gameMainBinding.flLuckyGiftNotifyLayout.addView(root);
|
||||
GiftAnimUtil.showAnimation(root);
|
||||
// GiftAnimUtil.expandAnimation(root);
|
||||
|
||||
handler.postDelayed(() -> {
|
||||
try {
|
||||
root.animate()
|
||||
.alpha(0f)
|
||||
.setDuration(500)
|
||||
.withEndAction(() -> {
|
||||
gameMainBinding.flLuckyGiftNotifyLayout.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
root.clearAnimation();
|
||||
gameMainBinding.flLuckyGiftNotifyLayout.removeView(root);
|
||||
luckyGiftTipPool.release(root);
|
||||
}
|
||||
});
|
||||
})
|
||||
.start();
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
}, 2300);
|
||||
}
|
||||
|
||||
BaseRoomNotifyeLuckGiftDialog allServiceLuckGiftDialog;
|
||||
private void showLuckyGiftDlg(LuckyGiftMsgAllBean luckyGiftMsgAllBean){
|
||||
LogUtils.d(" LuckyGiftDlg -- showLuckyGiftDlg() ");
|
||||
mLuckyGiftList.add(luckyGiftMsgAllBean);
|
||||
if (!(allServiceLuckGiftDialog != null && allServiceLuckGiftDialog.isShowing())) {
|
||||
LuckyGiftMsgAllBean data = mLuckyGiftList.remove(0);
|
||||
LogUtils.d(" LuckyGiftDlg -- showLuckyGiftDlg() -> showLuckyGiftDialog"+mLuckyGiftList.size());
|
||||
showLuckyGiftDialog(data);
|
||||
}
|
||||
}
|
||||
private void showLuckyGiftDialog(LuckyGiftMsgAllBean luckyGiftMsgAllBean){
|
||||
LogUtils.d(" LuckyGiftDlg -- showLuckyGiftDialog() ");
|
||||
allServiceLuckGiftDialog = new BaseRoomNotifyeLuckGiftDialog(requireContext());
|
||||
allServiceLuckGiftDialog.setLuckyGiftMsgBean(luckyGiftMsgAllBean);
|
||||
allServiceLuckGiftDialog.setMCallBack(new BaseRoomNotifyeLuckGiftDialog.CallBack() {
|
||||
@Override
|
||||
public void onHide() {
|
||||
LogUtils.d(" LuckyGiftDlg -- showLuckyGiftDialog() ->onHide");
|
||||
gameMainBinding.getRoot().postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
LogUtils.d(" LuckyGiftDlg -- showLuckyGiftDialog() ->onHide->postDelayed");
|
||||
if (!mLuckyGiftList.isEmpty()){
|
||||
LuckyGiftMsgAllBean data = mLuckyGiftList.remove(0);
|
||||
LogUtils.d(" LuckyGiftDlg -- showLuckyGiftDialog() ->onHide->postDelayed-> "+mLuckyGiftList.size());
|
||||
showLuckyGiftDialog(data);
|
||||
}
|
||||
}
|
||||
},100);
|
||||
}
|
||||
});
|
||||
allServiceLuckGiftDialog.show();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
@@ -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) {
|
||||
|
@@ -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
|
||||
|
@@ -93,8 +93,8 @@ class RoomHeadlineWidget : FrameLayoutRoomWidget {
|
||||
|
||||
private fun requestCurrentHeadline() {
|
||||
safeLaunch {
|
||||
val data = PublicChatModel.getCurrentHeadline()
|
||||
updateHeadline(data)
|
||||
// val data = PublicChatModel.getCurrentHeadline()
|
||||
// updateHeadline(data)
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -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
|
||||
}
|
||||
}
|
@@ -21,6 +21,7 @@ import com.example.lib_utils.ktx.singleClick
|
||||
|
||||
/**
|
||||
* 房间榜单入口
|
||||
* //todo-- 房间榜单入口
|
||||
*/
|
||||
class RoomRankNumberWidget : FrameLayoutRoomWidget, RoomWidget {
|
||||
|
||||
|
@@ -3,13 +3,13 @@ package com.chwl.app.avroom.room_album
|
||||
import android.annotation.SuppressLint
|
||||
import android.os.Bundle
|
||||
import com.hjq.toast.ToastUtils
|
||||
import com.chwl.app.base.BaseDialog
|
||||
import com.chwl.app.base.BaseDialogFragment
|
||||
import com.chwl.app.databinding.DialogLockRoomAlbumPhotoBinding
|
||||
import com.chwl.app.ui.utils.ImageLoadUtilsV2
|
||||
import com.chwl.core.gift.bean.GiftReceiveInfo
|
||||
import com.chwl.core.manager.AvRoomDataManager
|
||||
|
||||
class UnlockRoomAlbumPhotoDialog : BaseDialog<DialogLockRoomAlbumPhotoBinding>(){
|
||||
class UnlockRoomAlbumPhotoDialog : BaseDialogFragment<DialogLockRoomAlbumPhotoBinding>(){
|
||||
|
||||
var onUnlockRoomPhotoListener: OnUnlockRoomPhotoListener? = null
|
||||
|
||||
|
@@ -5,7 +5,7 @@ import android.os.Bundle
|
||||
import android.view.WindowManager
|
||||
import androidx.core.view.isVisible
|
||||
import com.chwl.app.R
|
||||
import com.chwl.app.base.BaseDialog
|
||||
import com.chwl.app.base.BaseDialogFragment
|
||||
import com.chwl.app.databinding.DialogSingleRoomPkFinishBinding
|
||||
import com.chwl.app.ui.utils.load
|
||||
import com.chwl.core.im.custom.bean.RoomPkBean
|
||||
@@ -14,7 +14,7 @@ import io.reactivex.Observable
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
class SingleRoomPkFinishDialog : BaseDialog<DialogSingleRoomPkFinishBinding>() {
|
||||
class SingleRoomPkFinishDialog : BaseDialogFragment<DialogSingleRoomPkFinishBinding>() {
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
|
@@ -4,13 +4,13 @@ import android.annotation.SuppressLint
|
||||
import android.os.Bundle
|
||||
import android.view.WindowManager
|
||||
import com.chwl.app.R
|
||||
import com.chwl.app.base.BaseDialog
|
||||
import com.chwl.app.base.BaseDialogFragment
|
||||
import com.chwl.app.databinding.DialogSingleRoomPkForceFinishBinding
|
||||
import com.chwl.app.ui.utils.ImageLoadUtils
|
||||
import com.chwl.core.im.custom.bean.RoomPkBean
|
||||
import com.chwl.core.utils.extension.subAndReplaceDot
|
||||
|
||||
class SingleRoomPkForceFinishDialog : BaseDialog<DialogSingleRoomPkForceFinishBinding>() {
|
||||
class SingleRoomPkForceFinishDialog : BaseDialogFragment<DialogSingleRoomPkForceFinishBinding>() {
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
|
@@ -4,7 +4,7 @@ import android.annotation.SuppressLint
|
||||
import android.os.Bundle
|
||||
import androidx.core.view.isVisible
|
||||
import com.chwl.app.R
|
||||
import com.chwl.app.base.BaseDialog
|
||||
import com.chwl.app.base.BaseDialogFragment
|
||||
import com.chwl.app.databinding.DialogSingleRoomPkReceivedBinding
|
||||
import com.chwl.core.im.custom.bean.RoomPkBean
|
||||
import com.chwl.core.manager.AvRoomDataManager
|
||||
@@ -17,7 +17,7 @@ import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.disposables.Disposable
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
class SingleRoomPkReceivedDialog : BaseDialog<DialogSingleRoomPkReceivedBinding>() {
|
||||
class SingleRoomPkReceivedDialog : BaseDialogFragment<DialogSingleRoomPkReceivedBinding>() {
|
||||
|
||||
companion object {
|
||||
|
||||
|
@@ -1,12 +1,12 @@
|
||||
package com.chwl.app.avroom.singleroompk
|
||||
|
||||
import android.text.method.ScrollingMovementMethod
|
||||
import com.chwl.app.base.BaseDialog
|
||||
import com.chwl.app.base.BaseDialogFragment
|
||||
import com.chwl.app.databinding.DialogSingleRoomPkRuleBinding
|
||||
import com.chwl.core.room.anotherroompk.SingleRoomPKModel
|
||||
import com.chwl.core.utils.extension.toast
|
||||
|
||||
class SingleRoomPkRuleDialog : BaseDialog<DialogSingleRoomPkRuleBinding>() {
|
||||
class SingleRoomPkRuleDialog : BaseDialogFragment<DialogSingleRoomPkRuleBinding>() {
|
||||
|
||||
companion object {
|
||||
|
||||
|
@@ -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,23 @@ public class BottomView extends LinearLayout implements View.OnClickListener {
|
||||
micLayout.setVisibility(VISIBLE);
|
||||
}
|
||||
|
||||
public void updateGameEntrance() {
|
||||
//todo-- game btn
|
||||
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 +376,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:
|
||||
|
@@ -23,6 +23,8 @@ import android.view.ViewGroup;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import com.chwl.core.utils.ComboUtil;
|
||||
import com.chwl.core.auth.AuthModel;
|
||||
import com.example.lib_utils.UiUtils;
|
||||
import com.netease.nim.uikit.common.util.log.LogUtil;
|
||||
import com.netease.nimlib.sdk.chatroom.model.ChatRoomMessage;
|
||||
@@ -89,6 +91,7 @@ public class GiftV2View extends FrameLayout implements GiftEffectView.GiftEffect
|
||||
private int mScreenWidth;
|
||||
private int mScreenHeight;
|
||||
private Keyframe[] keyScale;
|
||||
private Keyframe[] keyScaleCombo;
|
||||
private Keyframe[] keyTrans;
|
||||
private SvgaObjectPool mMagicViewPool;
|
||||
|
||||
@@ -126,6 +129,13 @@ public class GiftV2View extends FrameLayout implements GiftEffectView.GiftEffect
|
||||
keyScale[4] = (Keyframe.ofFloat(0.5f, 2f));
|
||||
keyScale[5] = (Keyframe.ofFloat(0.8f, 2f));
|
||||
keyScale[6] = (Keyframe.ofFloat(1f, 1f));
|
||||
|
||||
keyScaleCombo = new Keyframe[4];
|
||||
keyScaleCombo[0] = (Keyframe.ofFloat(0f, 0.25f));
|
||||
keyScaleCombo[1] = (Keyframe.ofFloat(0.25f, 0.5f));
|
||||
keyScaleCombo[2] = (Keyframe.ofFloat(0.5f, 0.75f));
|
||||
keyScaleCombo[3] = (Keyframe.ofFloat(1f, 1f));
|
||||
|
||||
keyTrans = new Keyframe[3];
|
||||
keyTrans[0] = (Keyframe.ofFloat(0f, 0));
|
||||
keyTrans[1] = (Keyframe.ofFloat(0.2f, 0));
|
||||
@@ -255,6 +265,14 @@ public class GiftV2View extends FrameLayout implements GiftEffectView.GiftEffect
|
||||
}
|
||||
Point senderPoint = micViewPoint.get(senderPosition);
|
||||
Point receivePoint = micViewPoint.get(receivePosition);
|
||||
|
||||
// 连击 特殊动画
|
||||
if (giftReceiveInfo.getUid() == AuthModel.get().getCurrentUid()){
|
||||
if (ComboUtil.INSTANCE.isChangePoint()) {
|
||||
senderPoint = ComboUtil.INSTANCE.getPoint();
|
||||
}
|
||||
}
|
||||
|
||||
//设置动画结束的位置
|
||||
if (receivePoint == null || isGameRoomMoreThan6People()) { //这种情况就是接收者已经不在麦上
|
||||
//礼物送到中间的位置
|
||||
@@ -627,6 +645,7 @@ public class GiftV2View extends FrameLayout implements GiftEffectView.GiftEffect
|
||||
return;
|
||||
}
|
||||
GiftInfo giftInfo = giftReceiveInfo.getGift();
|
||||
giftInfo.uid = giftReceiveInfo.getUid();
|
||||
if (giftInfo == null) {
|
||||
return;
|
||||
}
|
||||
@@ -668,8 +687,24 @@ public class GiftV2View extends FrameLayout implements GiftEffectView.GiftEffect
|
||||
PropertyValuesHolder p1 = PropertyValuesHolder.ofKeyframe("translationY", keyTrans[0], keyTrans[1], keyTrans[2], keyTransY3, keyTransY4, keyTransY5);
|
||||
PropertyValuesHolder p2 = PropertyValuesHolder.ofKeyframe("scaleX", keyScale);
|
||||
PropertyValuesHolder p3 = PropertyValuesHolder.ofKeyframe("scaleY", keyScale);
|
||||
ObjectAnimator objectAnimator = ObjectAnimator.ofPropertyValuesHolder(imageView, p2, p3, p1, p0);
|
||||
objectAnimator.setDuration(4000);
|
||||
|
||||
PropertyValuesHolder p0c = PropertyValuesHolder.ofKeyframe("translationX", keyTrans[0], keyTransX5);
|
||||
PropertyValuesHolder p1c = PropertyValuesHolder.ofKeyframe("translationY", keyTrans[0], keyTransY5);
|
||||
PropertyValuesHolder p2c = PropertyValuesHolder.ofKeyframe("scaleX", keyScaleCombo);
|
||||
PropertyValuesHolder p3c = PropertyValuesHolder.ofKeyframe("scaleY", keyScaleCombo);
|
||||
|
||||
long time;
|
||||
ObjectAnimator objectAnimator;
|
||||
// 连击 特殊动画
|
||||
if (ComboUtil.INSTANCE.isChangePoint() && giftInfo.uid == AuthModel.get().getCurrentUid()){
|
||||
objectAnimator = ObjectAnimator.ofPropertyValuesHolder(imageView, p2c, p3c, p1c, p0c);
|
||||
time = 600;
|
||||
}else {
|
||||
objectAnimator = ObjectAnimator.ofPropertyValuesHolder(imageView, p2, p3, p1, p0);
|
||||
time = 2000;
|
||||
}
|
||||
|
||||
objectAnimator.setDuration(time);
|
||||
objectAnimator.start();
|
||||
objectAnimator.addListener(new AnimatorListenerAdapter() {
|
||||
@Override
|
||||
|
@@ -2286,7 +2286,7 @@ public class MessageView extends FrameLayout {
|
||||
})
|
||||
.append(ResUtil.getString(R.string.gift_message_01), new ForegroundColorSpan(getResources().getColor(R.color.white)));
|
||||
|
||||
text.append(luckyGiftInfo.getGiftName() + ResUtil.getString(R.string.gift_message_02), new ForegroundColorSpan(getResources().getColor(R.color.white)))
|
||||
text.append(luckyGiftInfo.getFirstGiftName() + ResUtil.getString(R.string.gift_message_02), new ForegroundColorSpan(getResources().getColor(R.color.white)))
|
||||
.append(luckyGiftInfo.getUser().getNick(), new ForegroundColorSpan(roomTipNickColor), new OriginalDrawStatusClickSpan() {
|
||||
@Override
|
||||
public void onClick(@NonNull View widget) {
|
||||
@@ -2341,7 +2341,7 @@ public class MessageView extends FrameLayout {
|
||||
})
|
||||
.append(ResUtil.getString(R.string.gift_message_01), new ForegroundColorSpan(getResources().getColor(R.color.white)));
|
||||
|
||||
text.append(luckyGiftInfo.getGiftName() + ResUtil.getString(R.string.gift_message_02), new ForegroundColorSpan(getResources().getColor(R.color.white)))
|
||||
text.append(luckyGiftInfo.getFirstGiftName() + ResUtil.getString(R.string.gift_message_02), new ForegroundColorSpan(getResources().getColor(R.color.white)))
|
||||
.append(luckyGiftInfo.getUser().getNick(), new ForegroundColorSpan(roomTipNickColor), new OriginalDrawStatusClickSpan() {
|
||||
@Override
|
||||
public void onClick(@NonNull View widget) {
|
||||
|
@@ -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()
|
||||
|
118
app/src/main/java/com/chwl/app/avroom/widget/VDHLayout.java
Normal file
118
app/src/main/java/com/chwl/app/avroom/widget/VDHLayout.java
Normal file
@@ -0,0 +1,118 @@
|
||||
package com.chwl.app.avroom.widget;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.graphics.Point;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.widget.FrameLayout;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.core.view.ViewCompat;
|
||||
import androidx.customview.widget.ViewDragHelper;
|
||||
|
||||
import com.netease.nim.uikit.common.util.sys.ScreenUtil;
|
||||
|
||||
/**
|
||||
* 侧滑FrameLayout
|
||||
* 子View左滑删除,右滑弹起后复位
|
||||
*/
|
||||
public class VDHLayout extends FrameLayout {
|
||||
private final ViewDragHelper mDragHelper;
|
||||
|
||||
private final Point mAutoBackOriginPos = new Point();
|
||||
|
||||
private OnViewGoneListener listener;
|
||||
|
||||
public VDHLayout(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
mDragHelper = ViewDragHelper.create(this, 1.0f, new ViewDragHelper.Callback() {
|
||||
@Override
|
||||
public boolean tryCaptureView(@NonNull View child, int pointerId) {
|
||||
mAutoBackOriginPos.x = child.getLeft();
|
||||
mAutoBackOriginPos.y = child.getTop();
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* view的left
|
||||
*/
|
||||
@Override
|
||||
public int clampViewPositionHorizontal(@NonNull View child, int left, int dx) {
|
||||
return left;
|
||||
}
|
||||
|
||||
/**
|
||||
* view的top
|
||||
*/
|
||||
@Override
|
||||
public int clampViewPositionVertical(@NonNull View child, int top, int dy) {
|
||||
return child.getTop();
|
||||
}
|
||||
|
||||
|
||||
//手指释放的时候回调
|
||||
@Override
|
||||
public void onViewReleased(@NonNull View releasedChild, float xvel, float yvel) {
|
||||
//mAutoBackView手指释放时可以自动回去
|
||||
if (releasedChild.getLeft() < 0 && ((Math.abs(releasedChild.getLeft()) >= releasedChild.getMeasuredWidth() * 0.2))) {
|
||||
releasedChild.setEnabled(false);
|
||||
releasedChild.animate()
|
||||
.setDuration(100L)
|
||||
.translationX(-ScreenUtil.getDisplayWidth())
|
||||
.alpha(0F)
|
||||
.withEndAction(() -> {
|
||||
releasedChild.setVisibility(GONE);
|
||||
if(listener != null){
|
||||
listener.onViewGone();
|
||||
}
|
||||
}).start();
|
||||
} else {
|
||||
mDragHelper.settleCapturedViewAt(mAutoBackOriginPos.x, mAutoBackOriginPos.y);
|
||||
ViewCompat.postInvalidateOnAnimation(VDHLayout.this);
|
||||
}
|
||||
}
|
||||
|
||||
//在边界拖动时回调
|
||||
@Override
|
||||
public void onEdgeDragStarted(int edgeFlags, int pointerId) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getViewHorizontalDragRange(@NonNull View child) {
|
||||
return child.getMeasuredWidth();
|
||||
}
|
||||
|
||||
});
|
||||
mDragHelper.setEdgeTrackingEnabled(ViewDragHelper.EDGE_LEFT);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onInterceptTouchEvent(MotionEvent event) {
|
||||
return mDragHelper.shouldInterceptTouchEvent(event);
|
||||
}
|
||||
|
||||
@SuppressLint("ClickableViewAccessibility")
|
||||
@Override
|
||||
public boolean onTouchEvent(MotionEvent event) {
|
||||
mDragHelper.processTouchEvent(event);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void computeScroll() {
|
||||
if (mDragHelper.continueSettling(true)) {
|
||||
invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
public void setListener(OnViewGoneListener listener) {
|
||||
this.listener = listener;
|
||||
}
|
||||
|
||||
public interface OnViewGoneListener{
|
||||
void onViewGone();
|
||||
}
|
||||
}
|
@@ -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) {
|
||||
|
@@ -17,7 +17,7 @@ import com.trello.rxlifecycle3.components.support.RxDialogFragment
|
||||
import kotlinx.coroutines.launch
|
||||
import java.lang.reflect.ParameterizedType
|
||||
|
||||
abstract class BaseDialog<T : ViewBinding> : RxDialogFragment() {
|
||||
abstract class BaseDialogFragment<T : ViewBinding> : RxDialogFragment() {
|
||||
|
||||
val isViewLoaded: Boolean get() = _binding != null
|
||||
protected var _binding: T? = null
|
@@ -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);
|
||||
|
@@ -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) {
|
||||
|
@@ -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();
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -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 {
|
||||
//去掉小数凑整:不管小数是多少,都进一
|
||||
|
@@ -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()))
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -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);
|
||||
|
@@ -1,9 +1,13 @@
|
||||
package com.chwl.app.home.adapter
|
||||
|
||||
import android.graphics.Rect
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.ImageView
|
||||
import androidx.core.view.isInvisible
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import androidx.recyclerview.widget.RecyclerView.RecycledViewPool
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter
|
||||
import com.chad.library.adapter.base.BaseViewHolder
|
||||
import com.chwl.app.R
|
||||
@@ -11,14 +15,54 @@ import com.chwl.app.ui.utils.ImageLoadUtils
|
||||
import com.chwl.app.ui.utils.load
|
||||
import com.chwl.app.ui.utils.loadFromAssets
|
||||
import com.chwl.core.home.bean.HomeRoomInfo
|
||||
import com.example.lib_utils.AppUtils
|
||||
import com.example.lib_utils.UiUtils
|
||||
import com.opensource.svgaplayer.SVGADrawable
|
||||
import com.opensource.svgaplayer.SVGAImageView
|
||||
|
||||
/**
|
||||
* create by lvzebiao @2019/11/13
|
||||
*/
|
||||
class HomeRoomAdapter :
|
||||
BaseQuickAdapter<HomeRoomInfo, BaseViewHolder>(R.layout.home_item_room) {
|
||||
class HomeRoomAdapter : BaseQuickAdapter<HomeRoomInfo, BaseViewHolder>(R.layout.home_item_room) {
|
||||
private var micUserItemViewPool = RecycledViewPool().apply {
|
||||
setMaxRecycledViews(0, 50)
|
||||
}
|
||||
|
||||
private val isRTL = UiUtils.isRtl(AppUtils.getApp())
|
||||
|
||||
override fun onCreateDefViewHolder(parent: ViewGroup, viewType: Int): BaseViewHolder {
|
||||
return super.onCreateDefViewHolder(parent, viewType).apply {
|
||||
val micUserRecyclerView = this.getView<RecyclerView>(R.id.recycler_view_users)
|
||||
micUserRecyclerView.setOnTouchListener { v, event -> true }
|
||||
micUserRecyclerView.setRecycledViewPool(micUserItemViewPool)
|
||||
micUserRecyclerView.setHasFixedSize(true)
|
||||
micUserRecyclerView.layoutManager =
|
||||
LinearLayoutManager(parent.context, RecyclerView.HORIZONTAL, false).apply {
|
||||
this.recycleChildrenOnDetach = true
|
||||
this.isSmoothScrollbarEnabled
|
||||
}
|
||||
micUserRecyclerView.addItemDecoration(object : RecyclerView.ItemDecoration() {
|
||||
val offset = AppUtils.getApp().resources.getDimensionPixelOffset(R.dimen.dp_4) * -1
|
||||
override fun getItemOffsets(
|
||||
outRect: Rect,
|
||||
view: View,
|
||||
parent: RecyclerView,
|
||||
state: RecyclerView.State
|
||||
) {
|
||||
super.getItemOffsets(outRect, view, parent, state)
|
||||
val position = parent.getChildAdapterPosition(view)
|
||||
if (position != 0) {
|
||||
if (isRTL) {
|
||||
outRect.right = offset
|
||||
} else {
|
||||
outRect.left = offset
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
micUserRecyclerView.adapter = HomeRoomUserAdapter()
|
||||
}
|
||||
}
|
||||
|
||||
override fun convert(helper: BaseViewHolder, item: HomeRoomInfo) {
|
||||
helper.apply {
|
||||
@@ -28,18 +72,10 @@ class HomeRoomAdapter :
|
||||
setText(R.id.tv_desc, item.roomDesc)
|
||||
}
|
||||
|
||||
val avatars: Array<ImageView> = arrayOf(
|
||||
helper.getView(R.id.iv_avatar_0),
|
||||
helper.getView(R.id.iv_avatar_1),
|
||||
helper.getView(R.id.iv_avatar_2),
|
||||
helper.getView(R.id.iv_avatar_3),
|
||||
helper.getView(R.id.iv_avatar_4)
|
||||
)
|
||||
for (i in avatars.indices) {
|
||||
val avatarUrl = item.micUsers?.getOrNull(i)?.avatar
|
||||
avatars[i].isInvisible = avatarUrl.isNullOrBlank()
|
||||
avatars[i].load(avatarUrl)
|
||||
}
|
||||
val micUserRecyclerView = helper.getView<RecyclerView>(R.id.recycler_view_users)
|
||||
val userAdapter = micUserRecyclerView.adapter as HomeRoomUserAdapter
|
||||
userAdapter.setNewData(item.micUsers)
|
||||
|
||||
val topView = helper.getView<ImageView>(R.id.iv_top)
|
||||
if (item.isHourTop1 == 1) {
|
||||
topView.setImageResource(R.drawable.home_room_bg_hour_top)
|
||||
|
@@ -0,0 +1,16 @@
|
||||
package com.chwl.app.home.adapter
|
||||
|
||||
import android.widget.ImageView
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter
|
||||
import com.chad.library.adapter.base.BaseViewHolder
|
||||
import com.chwl.app.R
|
||||
import com.chwl.app.ui.utils.loadAvatar
|
||||
import com.chwl.core.home.bean.MicUsersBean
|
||||
|
||||
class HomeRoomUserAdapter :
|
||||
BaseQuickAdapter<MicUsersBean, BaseViewHolder>(R.layout.home_item_room_user) {
|
||||
override fun convert(helper: BaseViewHolder, item: MicUsersBean?) {
|
||||
val avatarView = helper.getView<ImageView>(R.id.iv_avatar)
|
||||
avatarView.loadAvatar(item?.avatar)
|
||||
}
|
||||
}
|
@@ -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]
|
||||
}
|
||||
|
||||
}
|
@@ -7,14 +7,14 @@ import android.view.WindowManager
|
||||
import android.widget.ImageView
|
||||
import androidx.core.view.isGone
|
||||
import com.chwl.app.R
|
||||
import com.chwl.app.base.BaseDialog
|
||||
import com.chwl.app.base.BaseDialogFragment
|
||||
import com.chwl.app.databinding.DialogHelloMessageBinding
|
||||
import com.chwl.app.ui.utils.load
|
||||
import com.chwl.app.room_chat.activity.RoomMsgActivity
|
||||
import com.chwl.core.channel_page.bean.HelloMessageInfo
|
||||
import com.chwl.library.utils.ResUtil
|
||||
|
||||
class HelloMessageDialog : BaseDialog<DialogHelloMessageBinding>() {
|
||||
class HelloMessageDialog : BaseDialogFragment<DialogHelloMessageBinding>() {
|
||||
|
||||
companion object {
|
||||
|
||||
|
@@ -4,13 +4,13 @@ import android.annotation.SuppressLint
|
||||
import android.os.Bundle
|
||||
import android.view.WindowManager
|
||||
import com.chwl.app.avroom.activity.AVRoomActivity
|
||||
import com.chwl.app.base.BaseDialog
|
||||
import com.chwl.app.base.BaseDialogFragment
|
||||
import com.chwl.app.databinding.DialogNewUserHelloBinding
|
||||
import com.chwl.app.ui.utils.load
|
||||
import com.chwl.core.channel_page.bean.NewUserHelloInfo
|
||||
import com.chwl.core.utils.extension.subAndReplaceDot
|
||||
|
||||
class NewUserHelloDialog : BaseDialog<DialogNewUserHelloBinding>() {
|
||||
class NewUserHelloDialog : BaseDialogFragment<DialogNewUserHelloBinding>() {
|
||||
|
||||
companion object {
|
||||
|
||||
|
@@ -3,12 +3,12 @@ package com.chwl.app.home.dialog
|
||||
import android.annotation.SuppressLint
|
||||
import android.os.Bundle
|
||||
import com.chwl.app.avroom.activity.AVRoomActivity
|
||||
import com.chwl.app.base.BaseDialog
|
||||
import com.chwl.app.base.BaseDialogFragment
|
||||
import com.chwl.app.databinding.DialogRecommendRoomBinding
|
||||
import com.chwl.app.ui.utils.ImageLoadUtils
|
||||
import com.chwl.core.home.bean.HomeRoomInfo
|
||||
|
||||
class RecommendRoomDialog : BaseDialog<DialogRecommendRoomBinding>() {
|
||||
class RecommendRoomDialog : BaseDialogFragment<DialogRecommendRoomBinding>() {
|
||||
|
||||
companion object {
|
||||
|
||||
|
@@ -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
|
||||
@@ -139,7 +138,7 @@ class ContactsListFragment : BaseViewBindingFragment<FragmentContactListBinding>
|
||||
}
|
||||
|
||||
override fun onScroll(
|
||||
e1: MotionEvent,
|
||||
e1: MotionEvent?,
|
||||
e2: MotionEvent,
|
||||
distanceX: Float,
|
||||
distanceY: Float
|
||||
@@ -151,7 +150,7 @@ class ContactsListFragment : BaseViewBindingFragment<FragmentContactListBinding>
|
||||
}
|
||||
|
||||
override fun onFling(
|
||||
e1: MotionEvent,
|
||||
e1: MotionEvent?,
|
||||
e2: MotionEvent,
|
||||
velocityX: Float,
|
||||
velocityY: Float
|
||||
@@ -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()
|
||||
// }
|
||||
}
|
||||
}
|
@@ -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
|
||||
|
@@ -198,7 +198,7 @@ class HomeRecommendFragment : BaseViewBindingFragment<FragmentHomeRecommendBindi
|
||||
override fun createFragment(position: Int): Fragment {
|
||||
val itemId = getItemId(position)
|
||||
return HomeTabRoomFragment.newInstance(itemId.toInt()).apply {
|
||||
autoRefreshOnVisible = true
|
||||
this.autoRefreshOnVisible = true
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -1,7 +1,6 @@
|
||||
package com.chwl.app.home.fragment
|
||||
|
||||
import android.os.Bundle
|
||||
import android.util.Log
|
||||
import android.view.View
|
||||
import androidx.fragment.app.viewModels
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
|
@@ -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)
|
||||
|
@@ -0,0 +1,202 @@
|
||||
package com.chwl.app.ui.game_team.invite
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.os.Bundle
|
||||
import android.view.Gravity
|
||||
import android.view.WindowManager
|
||||
import androidx.fragment.app.viewModels
|
||||
import androidx.lifecycle.Lifecycle
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import androidx.lifecycle.repeatOnLifecycle
|
||||
import com.chwl.app.R
|
||||
import com.chwl.app.base.BaseDialogFragment
|
||||
import com.chwl.app.common.widget.dialog.DialogManager
|
||||
import com.chwl.app.databinding.GameTeamInviteDialogBinding
|
||||
import com.chwl.app.ui.pay.ChargeActivity
|
||||
import com.chwl.app.ui.utils.load
|
||||
import com.chwl.core.game_team.UserGameTeamInfo
|
||||
import com.chwl.core.pay.PayModel
|
||||
import com.chwl.core.pay.bean.WalletInfo
|
||||
import com.chwl.core.utils.net.BalanceNotEnoughExeption
|
||||
import com.chwl.library.utils.ResUtil
|
||||
import com.chwl.library.utils.SingleToastUtil
|
||||
import com.example.lib_utils.ktx.singleClick
|
||||
import kotlinx.coroutines.flow.collectLatest
|
||||
import kotlinx.coroutines.launch
|
||||
import java.math.BigDecimal
|
||||
import java.math.RoundingMode
|
||||
|
||||
|
||||
class GameTeamInviteDialog : BaseDialogFragment<GameTeamInviteDialogBinding>() {
|
||||
|
||||
private val viewModel: GameTeamInviteViewModel by viewModels()
|
||||
|
||||
override var width = WindowManager.LayoutParams.MATCH_PARENT
|
||||
override var gravity = Gravity.CENTER
|
||||
|
||||
private var gameId: Long = 0
|
||||
private var gameUid: Long = 0
|
||||
private var gameBackground: String? = null
|
||||
private var gamePrice: Long = 0
|
||||
private var gameInning: Long = 1
|
||||
private var dialogManager: DialogManager? = null
|
||||
|
||||
var successListener: (() -> Unit)? = null
|
||||
|
||||
companion object {
|
||||
fun newInstance(info: UserGameTeamInfo): GameTeamInviteDialog {
|
||||
return newInstance(info.uid ?: 0, info.gameId ?: 0, info.pic, info.price ?: 0, 1)
|
||||
}
|
||||
|
||||
fun newInstance(
|
||||
targetUid: Long,
|
||||
gameId: Long,
|
||||
gameBackground: String?,
|
||||
gamePrice: Long,
|
||||
gameInning: Long,
|
||||
): GameTeamInviteDialog {
|
||||
return GameTeamInviteDialog().apply {
|
||||
arguments = Bundle().apply {
|
||||
putLong("targetUid", targetUid)
|
||||
putLong("gameId", gameId)
|
||||
putSerializable("gameBackground", gameBackground)
|
||||
putLong("gamePrice", gamePrice)
|
||||
putLong("gameInning", gameInning)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun init() {
|
||||
gameUid = arguments?.getLong("targetUid") ?: 0
|
||||
gameId = arguments?.getLong("gameId") ?: 0
|
||||
gameBackground = arguments?.getString("gameBackground")
|
||||
gamePrice = arguments?.getLong("gamePrice") ?: 0
|
||||
gameInning = arguments?.getLong("gameInning") ?: 1
|
||||
dialogManager = DialogManager(requireContext())
|
||||
initView()
|
||||
initEvent()
|
||||
initObserve()
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
updateBalance()
|
||||
}
|
||||
|
||||
private fun initView() {
|
||||
binding.ivGameImage.load(gameBackground)
|
||||
updateInning(0)
|
||||
requestBalance()
|
||||
}
|
||||
|
||||
private fun initEvent() {
|
||||
binding.ivClose.setOnClickListener {
|
||||
safeDismiss()
|
||||
}
|
||||
|
||||
binding.tvPay.singleClick {
|
||||
pay()
|
||||
}
|
||||
|
||||
binding.layoutRecharge.setOnClickListener {
|
||||
ChargeActivity.start(context)
|
||||
}
|
||||
|
||||
binding.ivCountAdd.setOnClickListener {
|
||||
updateInning(1)
|
||||
}
|
||||
|
||||
binding.ivCountSubtract.setOnClickListener {
|
||||
updateInning(-1)
|
||||
}
|
||||
}
|
||||
|
||||
private fun initObserve() {
|
||||
viewLifecycleOwner.lifecycleScope.launch {
|
||||
viewLifecycleOwner.lifecycle.repeatOnLifecycle(Lifecycle.State.STARTED) {
|
||||
viewModel.payResultFlow.collectLatest {
|
||||
dialogManager?.dismissDialog()
|
||||
if (it.isSuccess) {
|
||||
successListener?.invoke()
|
||||
SingleToastUtil.showToast(R.string.game_team_19)
|
||||
safeDismiss()
|
||||
} else if (it.code == BalanceNotEnoughExeption.code) {
|
||||
showBalanceNotEnoughDialog()
|
||||
} else {
|
||||
it.message?.let { msg ->
|
||||
SingleToastUtil.showToast(msg)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun showBalanceNotEnoughDialog() {
|
||||
dialogManager?.showOkCancelDialog(
|
||||
ResUtil.getString(R.string.widget_dialog_dialoguihelper_04),
|
||||
ResUtil.getString(R.string.treasure_to_charge)
|
||||
) {
|
||||
ChargeActivity.start(context)
|
||||
}
|
||||
}
|
||||
|
||||
private fun pay() {
|
||||
dialogManager?.showProgressDialog(requireContext())
|
||||
viewModel.pay(gameId, gameUid, gameInning)
|
||||
}
|
||||
|
||||
private fun updateInning(add: Int) {
|
||||
var newInning = gameInning + add
|
||||
if (newInning <= 0) {
|
||||
newInning = 1
|
||||
}
|
||||
gameInning = newInning
|
||||
if (gameInning <= 1L) {
|
||||
binding.ivCountSubtract.setImageResource(R.drawable.game_team_invite_ic_subtract_disabled)
|
||||
binding.ivCountSubtract.isEnabled = false
|
||||
} else {
|
||||
binding.ivCountSubtract.setImageResource(R.drawable.game_team_invite_ic_subtract)
|
||||
binding.ivCountSubtract.isEnabled = true
|
||||
}
|
||||
binding.tvCount.text = gameInning.toString()
|
||||
updateMoney()
|
||||
}
|
||||
|
||||
private fun updateMoney() {
|
||||
val total = gamePrice * gameInning
|
||||
binding.tvMoney.text = total.toString()
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
private fun updateBalance() {
|
||||
if (_binding == null) {
|
||||
return
|
||||
}
|
||||
val balanceTitle = getString(R.string.gift_wallet_overage)
|
||||
val balanceValue = PayModel.get().currentWalletInfo?.diamondNum ?: 0.0
|
||||
var balanceBigDecimal = BigDecimal.valueOf(balanceValue)
|
||||
balanceBigDecimal = balanceBigDecimal.setScale(0, RoundingMode.DOWN)
|
||||
binding.tvBalance.text = "$balanceTitle${balanceBigDecimal.toPlainString()}"
|
||||
}
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
private fun requestBalance() {
|
||||
PayModel.get().myRemoteWalletInfo.compose<WalletInfo>(bindToLifecycle())
|
||||
.subscribe { info: WalletInfo ->
|
||||
updateBalance()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onDestroyView() {
|
||||
super.onDestroyView()
|
||||
dialogManager?.dismissDialog()
|
||||
dialogManager = null
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
successListener = null
|
||||
}
|
||||
}
|
@@ -0,0 +1,22 @@
|
||||
package com.chwl.app.ui.game_team.invite
|
||||
|
||||
import com.chwl.app.base.BaseViewModel
|
||||
import com.chwl.core.auth.AuthModel
|
||||
import com.chwl.core.bean.response.BeanResult
|
||||
import com.chwl.core.room.game.GameModel
|
||||
import kotlinx.coroutines.flow.MutableSharedFlow
|
||||
|
||||
class GameTeamInviteViewModel : BaseViewModel() {
|
||||
|
||||
var payResultFlow = MutableSharedFlow<BeanResult<Any>>()
|
||||
|
||||
fun pay(gameId: Long, gameUid: Long, inning: Long) {
|
||||
safeLaunch(onError = {
|
||||
payResultFlow.emit(BeanResult.failed(it))
|
||||
}) {
|
||||
val result =
|
||||
GameModel.startGameTeam(gameId, gameUid, inning, AuthModel.get().currentUid)
|
||||
payResultFlow.emit(BeanResult.success(result))
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,63 @@
|
||||
package com.chwl.app.ui.game_team.record
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.widget.TextView
|
||||
import androidx.fragment.app.Fragment
|
||||
import com.chwl.app.R
|
||||
import com.chwl.app.avroom.adapter.CommonVPAdapter
|
||||
import com.chwl.app.base.BaseViewBindingActivity
|
||||
import com.chwl.app.databinding.GameTeamRecordActivityBinding
|
||||
import com.chwl.app.ui.widget.magicindicator.ViewPagerHelper
|
||||
import com.chwl.app.ui.widget.magicindicator.buildins.commonnavigator.CommonNavigator
|
||||
import com.chwl.library.utils.ResUtil
|
||||
import com.netease.nim.uikit.StatusBarUtil
|
||||
|
||||
class GameTeamRecordActivity : BaseViewBindingActivity<GameTeamRecordActivityBinding>() {
|
||||
|
||||
companion object {
|
||||
fun start(context: Context) {
|
||||
context.startActivity(Intent(context, GameTeamRecordActivity::class.java))
|
||||
}
|
||||
}
|
||||
|
||||
override fun init() {
|
||||
initWhiteTitleBar(ResUtil.getString(R.string.game_team_09))
|
||||
initTab()
|
||||
}
|
||||
|
||||
private fun initTab() {
|
||||
val fragmentList = ArrayList<Fragment>()
|
||||
fragmentList.add(GameTeamRecordFragment.newInstance(GameTeamRecordFragment.TYPE_INITIATOR))
|
||||
fragmentList.add(GameTeamRecordFragment.newInstance(GameTeamRecordFragment.TYPE_RECEIVER))
|
||||
val titleList = ArrayList<String>()
|
||||
titleList.add(getString(R.string.game_team_10))
|
||||
titleList.add(getString(R.string.game_team_11))
|
||||
val commonNavigator = CommonNavigator(context)
|
||||
commonNavigator.setTitleWrapContent(false)
|
||||
val magicIndicatorAdapter = GameTeamRecordIndicatorAdapter(context, titleList)
|
||||
magicIndicatorAdapter.setOnItemSelectListener { position: Int, view: TextView? ->
|
||||
binding.viewPager.currentItem = position
|
||||
}
|
||||
commonNavigator.adapter = magicIndicatorAdapter
|
||||
binding.magicIndicator.navigator = commonNavigator
|
||||
binding.viewPager.offscreenPageLimit = 2
|
||||
binding.viewPager.adapter = CommonVPAdapter(
|
||||
supportFragmentManager,
|
||||
lifecycle,
|
||||
fragmentList
|
||||
)
|
||||
binding.viewPager.isUserInputEnabled = false
|
||||
ViewPagerHelper.bind(binding.magicIndicator, binding.viewPager)
|
||||
}
|
||||
|
||||
override fun needSteepStateBar(): Boolean {
|
||||
return true
|
||||
}
|
||||
|
||||
override fun setStatusBar() {
|
||||
super.setStatusBar()
|
||||
StatusBarUtil.transparencyBar(this)
|
||||
StatusBarUtil.StatusBarLightMode(this)
|
||||
}
|
||||
}
|
@@ -0,0 +1,38 @@
|
||||
package com.chwl.app.ui.game_team.record
|
||||
|
||||
import android.view.View
|
||||
import android.widget.ImageView
|
||||
import androidx.core.view.isVisible
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter
|
||||
import com.chad.library.adapter.base.BaseViewHolder
|
||||
import com.chwl.app.R
|
||||
import com.chwl.app.ui.utils.load
|
||||
import com.chwl.app.ui.utils.loadAvatar
|
||||
import com.chwl.core.game_team.GameTeamRecordBean
|
||||
|
||||
class GameTeamRecordAdapter :
|
||||
BaseQuickAdapter<GameTeamRecordBean, BaseViewHolder>(R.layout.game_team_record_item) {
|
||||
|
||||
var isInitiator = false
|
||||
|
||||
override fun convert(helper: BaseViewHolder, item: GameTeamRecordBean?) {
|
||||
helper.addOnClickListener(R.id.tv_repurchase, R.id.tv_chat, R.id.iv_order_id_copy)
|
||||
val userAvatarView = helper.getView<ImageView>(R.id.iv_user_avatar)
|
||||
val repurchaseView = helper.getView<View>(R.id.tv_repurchase)
|
||||
if (isInitiator) {
|
||||
repurchaseView.isVisible = true
|
||||
helper.setText(R.id.tv_user_name, item?.toNick ?: "")
|
||||
helper.setText(R.id.tv_user_id, item?.toErBanNo?.toString() ?: "")
|
||||
userAvatarView.load(item?.toAvatar)
|
||||
} else {
|
||||
repurchaseView.isVisible = false
|
||||
helper.setText(R.id.tv_user_name, item?.fromNick ?: "")
|
||||
helper.setText(R.id.tv_user_id, item?.fromErBanNo?.toString() ?: "")
|
||||
userAvatarView.load(item?.fromAvatar)
|
||||
}
|
||||
helper.setText(R.id.tv_game_name, item?.gameName ?: "")
|
||||
helper.setText(R.id.tv_order_money, item?.amount?.toString())
|
||||
helper.setText(R.id.tv_order_time, item?.orderTime)
|
||||
helper.setText(R.id.tv_order_id, item?.orderNo)
|
||||
}
|
||||
}
|
@@ -0,0 +1,154 @@
|
||||
package com.chwl.app.ui.game_team.record
|
||||
|
||||
import android.os.Bundle
|
||||
import androidx.fragment.app.viewModels
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import com.chwl.app.R
|
||||
import com.chwl.app.base.BaseViewBindingFragment
|
||||
import com.chwl.app.common.EmptyViewHelper
|
||||
import com.chwl.app.databinding.GameTemaRecordFragmentBinding
|
||||
import com.chwl.app.ui.game_team.invite.GameTeamInviteDialog
|
||||
import com.chwl.app.ui.im.avtivity.NimP2PMessageActivity
|
||||
import com.chwl.app.ui.utils.RVDelegate
|
||||
import com.chwl.app.utils.ClipboardUtils
|
||||
import com.chwl.core.game_team.GameTeamRecordBean
|
||||
import com.chwl.library.utils.SingleToastUtil
|
||||
|
||||
class GameTeamRecordFragment : BaseViewBindingFragment<GameTemaRecordFragmentBinding>() {
|
||||
|
||||
companion object {
|
||||
const val TYPE_INITIATOR = 0
|
||||
const val TYPE_RECEIVER = 1
|
||||
fun newInstance(type: Int): GameTeamRecordFragment {
|
||||
return GameTeamRecordFragment().apply {
|
||||
arguments = Bundle().apply {
|
||||
putInt("type", type)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private val viewModel: GameTeamRecordViewModel by viewModels()
|
||||
private val adapter = GameTeamRecordAdapter()
|
||||
|
||||
private var type: Int = TYPE_INITIATOR
|
||||
|
||||
private var rvDelegate: RVDelegate<GameTeamRecordBean>? = null
|
||||
|
||||
private var pageNum = 1
|
||||
|
||||
private val pageSize = 20
|
||||
|
||||
override fun init() {
|
||||
type = arguments?.getInt("type", TYPE_INITIATOR) ?: TYPE_INITIATOR
|
||||
initView()
|
||||
initEvent()
|
||||
initObserve()
|
||||
binding.swipeRefresh.isRefreshing = true
|
||||
loadData(true)
|
||||
}
|
||||
|
||||
private fun initView() {
|
||||
adapter.isInitiator = type == TYPE_INITIATOR
|
||||
binding.recyclerView.adapter = adapter
|
||||
rvDelegate = RVDelegate.Builder<GameTeamRecordBean>()
|
||||
.setPageSize(pageSize)
|
||||
.setAdapter(adapter)
|
||||
.setRecyclerView(binding.recyclerView)
|
||||
.setEmptyView(
|
||||
EmptyViewHelper.createEmptyTextViewHeight(
|
||||
context,
|
||||
getString(R.string.data_empty)
|
||||
)
|
||||
)
|
||||
.setLayoutManager(LinearLayoutManager(mContext))
|
||||
.build()
|
||||
}
|
||||
|
||||
private fun initEvent() {
|
||||
adapter.setOnItemChildClickListener { adapter, view, position ->
|
||||
val item = (adapter.getItem(position) as? GameTeamRecordBean)
|
||||
?: return@setOnItemChildClickListener
|
||||
|
||||
when (view.id) {
|
||||
R.id.tv_repurchase -> {
|
||||
jumpRepurchase(item)
|
||||
}
|
||||
|
||||
R.id.tv_chat -> {
|
||||
jumpChat(item)
|
||||
}
|
||||
|
||||
R.id.iv_order_id_copy -> {
|
||||
ClipboardUtils.copyText(item.orderNo ?: "")
|
||||
toast(getString(R.string.have_copy))
|
||||
}
|
||||
}
|
||||
}
|
||||
binding.swipeRefresh.setOnRefreshListener {
|
||||
loadData(true)
|
||||
}
|
||||
adapter.setOnLoadMoreListener({
|
||||
loadData(false)
|
||||
}, binding.recyclerView)
|
||||
}
|
||||
|
||||
private fun initObserve() {
|
||||
viewModel.listLiveData.observe(this) {
|
||||
binding.swipeRefresh.isRefreshing = false
|
||||
rvDelegate?.loadData(it)
|
||||
if (!it.isSuccess && it.message != null) {
|
||||
toast(it.message)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun jumpRepurchase(item: GameTeamRecordBean) {
|
||||
val uid = getTargetUidByItem(item)
|
||||
val gameId = item.gameId
|
||||
val gameBackground = item.gamePic
|
||||
val gamePrice = item.price ?: 0
|
||||
val gameInning = item.inning ?: 1
|
||||
if (uid == null || gameId == null) {
|
||||
toast(R.string.data_parsing_exception)
|
||||
return
|
||||
}
|
||||
GameTeamInviteDialog.newInstance(
|
||||
targetUid = uid,
|
||||
gameId = gameId,
|
||||
gameBackground = gameBackground,
|
||||
gamePrice = gamePrice,
|
||||
gameInning = gameInning
|
||||
).apply {
|
||||
this.successListener = {
|
||||
loadData(true)
|
||||
}
|
||||
}.safeShow(requireActivity().supportFragmentManager, requireActivity())
|
||||
}
|
||||
|
||||
private fun jumpChat(item: GameTeamRecordBean) {
|
||||
val targetUid = getTargetUidByItem(item)?.toString()
|
||||
if (targetUid.isNullOrEmpty()) {
|
||||
return
|
||||
}
|
||||
NimP2PMessageActivity.start(requireContext(), targetUid)
|
||||
}
|
||||
|
||||
private fun getTargetUidByItem(item: GameTeamRecordBean): Long? {
|
||||
val targetUid = if (type == TYPE_INITIATOR) {
|
||||
item.toUid
|
||||
} else {
|
||||
item.fromUid
|
||||
}
|
||||
return targetUid
|
||||
}
|
||||
|
||||
private fun loadData(isRefresh: Boolean) {
|
||||
if (isRefresh) {
|
||||
pageNum = 1
|
||||
} else {
|
||||
pageNum++
|
||||
}
|
||||
viewModel.getRecordList(type, pageNum, pageSize)
|
||||
}
|
||||
}
|
@@ -0,0 +1,103 @@
|
||||
package com.chwl.app.ui.game_team.record;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
||||
import com.chwl.app.R;
|
||||
import com.chwl.app.ui.widget.XRecyclerView.ScaleTransitionPagerTitleView;
|
||||
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.app.ui.widget.magicindicator.buildins.commonnavigator.indicators.LinePagerIndicator;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class GameTeamRecordIndicatorAdapter extends CommonNavigatorAdapter {
|
||||
private final Context mContext;
|
||||
private final List<? extends CharSequence> mTitleList;
|
||||
|
||||
private int textSize = 14;
|
||||
private float minScale = 1f;
|
||||
private boolean showIndicator = true;
|
||||
private OnItemSelectListener mOnItemSelectListener;
|
||||
|
||||
public GameTeamRecordIndicatorAdapter(Context context, List<? extends CharSequence> charSequences) {
|
||||
this.mContext = context;
|
||||
this.mTitleList = charSequences;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return mTitleList == null ? 0 : mTitleList.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPagerTitleView getTitleView(Context context, final int i) {
|
||||
ScaleTransitionPagerTitleView scaleTransitionPagerTitleView = new ScaleTransitionPagerTitleView(context, true);
|
||||
scaleTransitionPagerTitleView.setNormalColor(ContextCompat.getColor(context, R.color.color_66000000));
|
||||
scaleTransitionPagerTitleView.setSelectedColor(ContextCompat.getColor(context, R.color.color_000000));
|
||||
scaleTransitionPagerTitleView.setMinScale(minScale);
|
||||
scaleTransitionPagerTitleView.setTextSize(textSize);
|
||||
int padding = UIUtil.dip2px(context, 13);
|
||||
scaleTransitionPagerTitleView.setPadding(padding, 0, padding, 0);
|
||||
scaleTransitionPagerTitleView.setText(mTitleList.get(i));
|
||||
scaleTransitionPagerTitleView.setOnClickListener(view -> {
|
||||
if (mOnItemSelectListener != null) {
|
||||
mOnItemSelectListener.onItemSelect(i, scaleTransitionPagerTitleView);
|
||||
}
|
||||
|
||||
});
|
||||
return scaleTransitionPagerTitleView;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPagerIndicator getIndicator(Context context) {
|
||||
LinePagerIndicator indicator = new LinePagerIndicator(context);
|
||||
indicator.setMode(LinePagerIndicator.MODE_EXACTLY);
|
||||
indicator.setLineHeight(context.getResources().getDimensionPixelOffset(R.dimen.dp_3));
|
||||
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_0FCA81));
|
||||
FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
|
||||
// lp.bottomMargin = mBottomMargin;
|
||||
indicator.setLayoutParams(lp);
|
||||
return indicator;
|
||||
}
|
||||
|
||||
public int getTextSize() {
|
||||
return textSize;
|
||||
}
|
||||
|
||||
public void setTextSize(int textSize) {
|
||||
this.textSize = textSize;
|
||||
}
|
||||
|
||||
public float getMinScale() {
|
||||
return minScale;
|
||||
}
|
||||
|
||||
public void setMinScale(float minScale) {
|
||||
this.minScale = minScale;
|
||||
}
|
||||
|
||||
public boolean isShowIndicator() {
|
||||
return showIndicator;
|
||||
}
|
||||
|
||||
public void setShowIndicator(boolean showIndicator) {
|
||||
this.showIndicator = showIndicator;
|
||||
}
|
||||
|
||||
public void setOnItemSelectListener(OnItemSelectListener onItemSelectListener) {
|
||||
mOnItemSelectListener = onItemSelectListener;
|
||||
}
|
||||
|
||||
public interface OnItemSelectListener {
|
||||
void onItemSelect(int position, TextView view);
|
||||
}
|
||||
}
|
@@ -0,0 +1,23 @@
|
||||
package com.chwl.app.ui.game_team.record
|
||||
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import com.chwl.app.base.BaseViewModel
|
||||
import com.chwl.core.auth.AuthModel
|
||||
import com.chwl.core.bean.response.ListResult
|
||||
import com.chwl.core.game_team.GameTeamRecordBean
|
||||
import com.chwl.core.room.game.GameModel
|
||||
|
||||
class GameTeamRecordViewModel : BaseViewModel() {
|
||||
|
||||
val listLiveData = MutableLiveData<ListResult<GameTeamRecordBean>>()
|
||||
|
||||
fun getRecordList(type: Int, pageNum: Int, pageSize: Int) {
|
||||
safeLaunch(onError = {
|
||||
listLiveData.postValue(ListResult.failed(pageNum, it))
|
||||
}) {
|
||||
val list =
|
||||
GameModel.getGameTeamRecordList(type, pageNum, pageSize, AuthModel.get().currentUid)
|
||||
listLiveData.postValue(ListResult.success(list, pageNum))
|
||||
}
|
||||
}
|
||||
}
|
@@ -71,6 +71,11 @@ public class GiftInfoVm extends BaseItem<GiftInfo> {
|
||||
*/
|
||||
public boolean isSuperLuckyGift;
|
||||
|
||||
/**
|
||||
* 礼物名称
|
||||
*/
|
||||
public String giftName;
|
||||
|
||||
public GiftInfoVm(Context context, GiftInfo data, boolean select, boolean isKnap) {
|
||||
super(context, data);
|
||||
this.isSelect.set(select);
|
||||
@@ -110,6 +115,7 @@ public class GiftInfoVm extends BaseItem<GiftInfo> {
|
||||
SimpleVipInfo vipInfo = data.getGiftVipInfo();
|
||||
isLocked = vipInfo != null && VipHelper.getMyVipLevel() < vipInfo.getVipLevel();
|
||||
vipIcon = vipInfo == null ? "" : vipInfo.getVipIcon();
|
||||
giftName = data.getFirstGiftName();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -5,8 +5,10 @@ import android.content.Context;
|
||||
import com.chwl.app.community.holder.DynamicSysHolder;
|
||||
import com.chwl.app.community.im.WorldDynamicShareViewHolder;
|
||||
import com.chwl.app.module_hall.im.msgholder.FamilyMsgViewHolder;
|
||||
import com.chwl.app.ui.im.chat.GameTeamInviteViewHolder;
|
||||
import com.chwl.core.community.attachment.DynamicSysAttachment;
|
||||
import com.chwl.core.community.im.WorldDynamicAttachment;
|
||||
import com.chwl.core.im.custom.bean.GameTeamInviteAttachment;
|
||||
import com.chwl.core.module_hall.im.FamilyAttachment;
|
||||
import com.netease.nim.uikit.api.NimUIKit;
|
||||
import com.netease.nim.uikit.api.model.contact.ContactEventListener;
|
||||
@@ -169,6 +171,9 @@ public class ImInitHelper {
|
||||
// 客服充值
|
||||
NimUIKit.registerMsgItemViewHolder(P2PContactRechargeAttachment.class, MsgViewHolderP2PContactRecharge.class);
|
||||
|
||||
// 游戏组队 - 邀请
|
||||
NimUIKit.registerMsgItemViewHolder(GameTeamInviteAttachment.class, GameTeamInviteViewHolder.class);
|
||||
|
||||
NimUIKit.setSessionListener(listener);
|
||||
NimUIKit.setContactEventListener(listener1);
|
||||
}
|
||||
|
@@ -8,6 +8,8 @@ import com.chwl.app.decoration.view.DecorationStoreActivity;
|
||||
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;
|
||||
@@ -37,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;
|
||||
@@ -215,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);
|
||||
@@ -293,6 +294,12 @@ public class RouterHandler {
|
||||
case RouterType.MY_DONATION:
|
||||
GiveGoldActivity.Companion.start(context);
|
||||
break;
|
||||
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;
|
||||
|
@@ -0,0 +1,118 @@
|
||||
package com.chwl.app.ui.im.chat
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.Color
|
||||
import android.widget.ImageView
|
||||
import android.widget.TextView
|
||||
import androidx.annotation.Keep
|
||||
import com.chwl.app.R
|
||||
import com.chwl.app.ui.utils.load
|
||||
import com.chwl.core.im.custom.bean.GameTeamInviteAttachment
|
||||
import com.example.lib_utils.AppUtils
|
||||
import com.example.lib_utils.UiUtils
|
||||
import com.google.android.material.imageview.ShapeableImageView
|
||||
import com.google.android.material.shape.CornerFamily
|
||||
import com.google.android.material.shape.ShapeAppearanceModel
|
||||
import com.netease.nim.uikit.business.session.viewholder.MsgViewHolderBase
|
||||
import com.netease.nim.uikit.common.ui.recyclerview.adapter.BaseMultiItemFetchLoadAdapter
|
||||
|
||||
@Keep
|
||||
class GameTeamInviteViewHolder(adapter: BaseMultiItemFetchLoadAdapter<*, *>) :
|
||||
MsgViewHolderBase(adapter) {
|
||||
|
||||
private val isRTL = UiUtils.isRtl(AppUtils.getApp())
|
||||
|
||||
private val leftShapeAppearance: ShapeAppearanceModel by lazy(LazyThreadSafetyMode.NONE) {
|
||||
buildBackgroundShapeAppearance(context ?: AppUtils.getApp(), true)
|
||||
}
|
||||
private val rightShapeAppearance: ShapeAppearanceModel by lazy(LazyThreadSafetyMode.NONE) {
|
||||
buildBackgroundShapeAppearance(context ?: AppUtils.getApp(), false)
|
||||
}
|
||||
|
||||
override fun getContentResId(): Int {
|
||||
return R.layout.layout_msg_view_holder_game_team_invite
|
||||
}
|
||||
|
||||
override fun inflateContentView() {
|
||||
}
|
||||
|
||||
override fun leftBackground(): Int {
|
||||
return R.color.transparent
|
||||
}
|
||||
|
||||
override fun rightBackground(): Int {
|
||||
return R.color.transparent
|
||||
}
|
||||
|
||||
override fun bindContentView() {
|
||||
val attachment = message?.attachment as? GameTeamInviteAttachment
|
||||
val data = attachment?.msgData
|
||||
val gameNameView = findViewById<TextView>(R.id.tv_game_name)
|
||||
val gameInningView = findViewById<TextView>(R.id.tv_game_inning)
|
||||
val gameIconView = findViewById<ImageView>(R.id.iv_icon)
|
||||
val gameBackgroundView = findViewById<ShapeableImageView>(R.id.iv_image)
|
||||
val gameBackgroundMaskView = findViewById<ShapeableImageView>(R.id.iv_image_mask)
|
||||
val shapeAppearance = getBackgroundShapeAppearance()
|
||||
gameBackgroundView.shapeAppearanceModel = shapeAppearance
|
||||
gameBackgroundMaskView.shapeAppearanceModel = shapeAppearance
|
||||
gameNameView.text = data?.gameName ?: ""
|
||||
gameInningView.text =
|
||||
context?.getString(R.string.game_team_18)?.format(data?.inning?.toString() ?: "0") ?: ""
|
||||
gameIconView.load(data?.gameLogo)
|
||||
gameBackgroundView.load(data?.gamePic, defaultRes = R.color.color_33000000)
|
||||
}
|
||||
|
||||
private fun getBackgroundShapeAppearance(): ShapeAppearanceModel {
|
||||
return if (isReceivedMessage) {
|
||||
if (isRTL) {
|
||||
rightShapeAppearance
|
||||
} else {
|
||||
leftShapeAppearance
|
||||
}
|
||||
} else {
|
||||
if (isRTL) {
|
||||
leftShapeAppearance
|
||||
} else {
|
||||
rightShapeAppearance
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun buildBackgroundShapeAppearance(
|
||||
context: Context,
|
||||
isLeft: Boolean
|
||||
): ShapeAppearanceModel {
|
||||
val cornerA = context.resources.getDimension(R.dimen.dp_12)
|
||||
val cornerB = context.resources.getDimension(R.dimen.dp_2)
|
||||
val topLeftCorner: Float
|
||||
val topRightCorner: Float
|
||||
if (isLeft) {
|
||||
topLeftCorner = cornerB
|
||||
topRightCorner = cornerA
|
||||
} else {
|
||||
topLeftCorner = cornerA
|
||||
topRightCorner = cornerB
|
||||
}
|
||||
return ShapeAppearanceModel.Builder().apply {
|
||||
this.setTopLeftCorner(
|
||||
CornerFamily.ROUNDED,
|
||||
topLeftCorner
|
||||
)
|
||||
|
||||
this.setTopRightCorner(
|
||||
CornerFamily.ROUNDED,
|
||||
topRightCorner
|
||||
)
|
||||
|
||||
this.setBottomLeftCorner(
|
||||
CornerFamily.ROUNDED,
|
||||
cornerA
|
||||
)
|
||||
|
||||
this.setBottomRightCorner(
|
||||
CornerFamily.ROUNDED,
|
||||
cornerA
|
||||
)
|
||||
}.build()
|
||||
}
|
||||
}
|
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -14,6 +14,7 @@ import com.chwl.app.common.widget.dialog.DialogManager.OkCancelDialogListener
|
||||
import com.chwl.app.databinding.ActivitySettingBinding
|
||||
import com.chwl.app.notify.RoomNotifyManager
|
||||
import com.chwl.app.ui.debug.DebugActivity
|
||||
import com.chwl.app.ui.game_team.record.GameTeamRecordActivity
|
||||
import com.chwl.app.ui.im.avtivity.BlackListManageActivity
|
||||
import com.chwl.app.ui.language.LanguageActivity
|
||||
import com.chwl.app.ui.login.BindPhoneActivity
|
||||
@@ -222,8 +223,8 @@ class SettingActivity : BaseViewBindingActivity<ActivitySettingBinding>(), View.
|
||||
}
|
||||
|
||||
private fun debug() {
|
||||
startActivity(Intent(this, DebugActivity::class.java))
|
||||
// CommonWebViewActivity.start(this,"https://api.molistar.xyz/molistar/activity/2024-invitationFission/index.html")
|
||||
startActivity(Intent(this, GameTeamRecordActivity::class.java))
|
||||
// CommonWebViewActivity.start(this,"http://beta.api.molistar.xyz/molistar/modules/order/index.html")
|
||||
// PublicChatRoomMessageActivity.start(this)
|
||||
// MyDecorationActivity.start(this,0)
|
||||
}
|
||||
|
@@ -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) {
|
||||
|
@@ -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));
|
||||
|
@@ -0,0 +1,31 @@
|
||||
package com.chwl.app.ui.user.adapter
|
||||
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.ImageView
|
||||
import androidx.core.view.isVisible
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter
|
||||
import com.chad.library.adapter.base.BaseViewHolder
|
||||
import com.chwl.app.R
|
||||
import com.chwl.app.ui.utils.load
|
||||
import com.chwl.core.game_team.UserGameTeamInfo
|
||||
|
||||
class UserInfoGameTeamAdapter(private val isMe: Boolean) :
|
||||
BaseQuickAdapter<UserGameTeamInfo, BaseViewHolder>(R.layout.user_info_item_game_team) {
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): BaseViewHolder {
|
||||
return super.onCreateViewHolder(parent, viewType).apply {
|
||||
addOnClickListener(R.id.layout_play)
|
||||
getView<View>(R.id.layout_play).isVisible = !isMe
|
||||
}
|
||||
}
|
||||
|
||||
override fun convert(helper: BaseViewHolder, item: UserGameTeamInfo) {
|
||||
helper.setText(R.id.tv_name, item.gameName)
|
||||
helper.setText(R.id.tv_level, item.proficiency)
|
||||
helper.setText(R.id.tv_price, item.price?.toString() ?: "")
|
||||
helper.getView<ImageView>(R.id.iv_icon).load(item.logo)
|
||||
helper.getView<ImageView>(R.id.iv_bg)
|
||||
.load(item.background, defaultRes = R.color.color_66000000)
|
||||
}
|
||||
}
|
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -3,7 +3,7 @@ package com.chwl.app.ui.user.dialog
|
||||
import android.os.Bundle
|
||||
import android.view.Gravity
|
||||
import android.view.WindowManager
|
||||
import com.chwl.app.base.BaseDialog
|
||||
import com.chwl.app.base.BaseDialogFragment
|
||||
import com.chwl.app.databinding.DialogUserAreaPickerBinding
|
||||
import com.chwl.app.ui.user.adapter.ArrayWheelAdapter
|
||||
import java.io.Serializable
|
||||
@@ -15,7 +15,7 @@ import java.io.Serializable
|
||||
* desc: 用户地区
|
||||
*/
|
||||
class UserAreaDialog :
|
||||
BaseDialog<DialogUserAreaPickerBinding>() {
|
||||
BaseDialogFragment<DialogUserAreaPickerBinding>() {
|
||||
|
||||
private var mOptionsItems: List<String>? = null
|
||||
|
||||
|
@@ -9,22 +9,26 @@ import com.chwl.app.R
|
||||
import com.chwl.app.base.BaseViewBindingFragment
|
||||
import com.chwl.app.databinding.UserInfoDataFragmentBinding
|
||||
import com.chwl.app.support.FragmentVisibleStateHelper
|
||||
import com.chwl.app.ui.game_team.invite.GameTeamInviteDialog
|
||||
import com.chwl.app.ui.user.activity.ShowPhotoActivity
|
||||
import com.chwl.app.ui.user.activity.UserInfoModifyActivity
|
||||
import com.chwl.app.ui.user.activity.UserModifyPhotosActivity
|
||||
import com.chwl.app.ui.user.adapter.UserInfoAlbumAdapter
|
||||
import com.chwl.app.ui.user.adapter.UserInfoGameTeamAdapter
|
||||
import com.chwl.app.ui.user.adapter.UserInfoGiftAdapter
|
||||
import com.chwl.app.ui.user.adapter.UserInfoMedalAdapter
|
||||
import com.chwl.app.ui.user.viewmodel.UserInfoViewModel
|
||||
import com.chwl.app.ui.widget.recyclerview.decoration.GridSpacingItemNewDecoration
|
||||
import com.chwl.app.ui.widget.recyclerview.decoration.SpacingDecoration
|
||||
import com.chwl.core.game_team.UserGameTeamInfo
|
||||
import com.chwl.core.user.bean.UserPhoto
|
||||
import com.example.lib_utils.UiUtils
|
||||
|
||||
class UserInfoDataFragment : BaseViewBindingFragment<UserInfoDataFragmentBinding>() {
|
||||
|
||||
private val viewModel: UserInfoViewModel by activityViewModels()
|
||||
|
||||
override fun init() {
|
||||
initGameTeam()
|
||||
initAlbum()
|
||||
initMedal()
|
||||
initGift()
|
||||
@@ -36,6 +40,29 @@ class UserInfoDataFragment : BaseViewBindingFragment<UserInfoDataFragmentBinding
|
||||
}
|
||||
}
|
||||
|
||||
private fun initGameTeam() {
|
||||
val adapter = UserInfoGameTeamAdapter(viewModel.isMe)
|
||||
binding.recyclerViewGameTeam.addItemDecoration(
|
||||
SpacingDecoration(
|
||||
0,
|
||||
resources.getDimensionPixelOffset(R.dimen.dp_10),
|
||||
false
|
||||
)
|
||||
)
|
||||
binding.recyclerViewGameTeam.adapter = adapter
|
||||
adapter.setOnItemChildClickListener { adapter, view, position ->
|
||||
activity?.let {
|
||||
val item = (adapter.getItem(position) as? UserGameTeamInfo)
|
||||
?: return@setOnItemChildClickListener
|
||||
GameTeamInviteDialog.newInstance(item).safeShow(it.supportFragmentManager, it)
|
||||
}
|
||||
}
|
||||
viewModel.userInfoDetailData.observe(this) {
|
||||
adapter.setNewData(it.userGamePartner ?: emptyList())
|
||||
binding.layoutGameTeam.isVisible = !it.userGamePartner.isNullOrEmpty()
|
||||
}
|
||||
}
|
||||
|
||||
private fun initAlbum() {
|
||||
val albumAdapter = UserInfoAlbumAdapter()
|
||||
binding.ivAlbumMore.isVisible = viewModel.isMe
|
||||
|
@@ -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) {
|
||||
|
62
app/src/main/java/com/chwl/app/ui/utils/SoftPool.kt
Normal file
62
app/src/main/java/com/chwl/app/ui/utils/SoftPool.kt
Normal file
@@ -0,0 +1,62 @@
|
||||
package com.chwl.app.ui.utils
|
||||
|
||||
import com.opensource.svgaplayer.utils.Pools
|
||||
import java.lang.ref.SoftReference
|
||||
import java.util.LinkedList
|
||||
|
||||
class SoftPool <T:Any> (private var max:Int) : Pools.Pool<T> {
|
||||
|
||||
init {
|
||||
if (max <= 0){
|
||||
max = 8
|
||||
}
|
||||
}
|
||||
|
||||
private var mPool = LinkedList<SoftReference<T>>()
|
||||
|
||||
fun acquire(getItemEmpty:()->T):T{
|
||||
return acquire()?:getItemEmpty()
|
||||
}
|
||||
|
||||
|
||||
override fun acquire(): T? {
|
||||
if (mPool.size == 0){
|
||||
return null
|
||||
}
|
||||
|
||||
while (true){
|
||||
val item = mPool.poll()?:return null
|
||||
if (item.get() != null) {
|
||||
return item.get()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
override fun release(instance: T): Boolean {
|
||||
if (mPool.size > max) {
|
||||
if (getRealSize() > max) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
mPool.addFirst(SoftReference(instance))
|
||||
return true
|
||||
}
|
||||
|
||||
|
||||
private fun getRealSize() : Int{
|
||||
val iterator = mPool.listIterator()
|
||||
while (iterator.hasNext()) {
|
||||
val item = iterator.next().get()
|
||||
if (item == null) iterator.remove()
|
||||
}
|
||||
return mPool.size
|
||||
}
|
||||
|
||||
fun clear(){
|
||||
mPool.clear()
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
@@ -0,0 +1,285 @@
|
||||
package com.chwl.app.ui.wallet.payment
|
||||
|
||||
import android.app.Activity
|
||||
import androidx.lifecycle.Lifecycle
|
||||
import androidx.lifecycle.LifecycleEventObserver
|
||||
import androidx.lifecycle.LifecycleOwner
|
||||
import com.chwl.app.R
|
||||
import com.chwl.app.common.widget.dialog.DialogManager
|
||||
import com.chwl.core.pay.PayModel
|
||||
import com.chwl.core.pay.bean.PayRecordId
|
||||
import com.chwl.library.utils.SingleToastUtil
|
||||
import com.example.lib_utils.log.ILog
|
||||
import com.example.module_base.support.billing.IBillingResult
|
||||
import com.example.module_base.support.billing.IBillingService2
|
||||
import com.example.module_base.support.billing.IProductDetails
|
||||
import com.example.module_base.support.billing.IPurchase
|
||||
import com.example.module_base.support.billing.OnBillingClientStateListener
|
||||
import com.example.module_base.support.billing.OnConsumeResponseListener
|
||||
import com.example.module_base.support.billing.OnProductDetailsResponseListener
|
||||
import com.example.module_base.support.billing.OnPurchasesResponseListener
|
||||
import com.example.module_base.support.google.IGoogleService
|
||||
import io.reactivex.disposables.CompositeDisposable
|
||||
import io.reactivex.disposables.Disposable
|
||||
|
||||
class GPaymentClient(val activity: Activity) : IPaymentClient, IBillingService2.Listener,
|
||||
OnProductDetailsResponseListener, LifecycleEventObserver, ILog, OnBillingClientStateListener {
|
||||
|
||||
private var compositeDisposable: CompositeDisposable? = null
|
||||
private var _billingService: IBillingService2? = null
|
||||
private val dialogManager = DialogManager(activity)
|
||||
|
||||
private var paymentIntent: PaymentIntent? = null
|
||||
private var productItem: IProductDetails? = null
|
||||
private var orderId: String? = null
|
||||
|
||||
init {
|
||||
dialogManager.setCanceledOnClickOutside(false)
|
||||
dialogManager.setCanceledOnClickBackKey(false)
|
||||
(activity as? LifecycleOwner)?.lifecycle?.addObserver(this)
|
||||
}
|
||||
|
||||
private fun getBillingService(): IBillingService2? {
|
||||
if (_billingService == null) {
|
||||
_billingService = IGoogleService.newBillingService2(activity, this)
|
||||
_billingService?.setLogEnabled(true)
|
||||
_billingService?.startConnection(this)
|
||||
}
|
||||
return _billingService
|
||||
}
|
||||
|
||||
override fun launchPayment(intent: PaymentIntent) {
|
||||
logD("launchPayment() intent:${intent.productId}")
|
||||
if (paymentIntent != null) {
|
||||
SingleToastUtil.showToast(R.string.avroom_activity_roomblacklistactivity_015)
|
||||
return
|
||||
}
|
||||
dialogManager.showProgressDialog(activity)
|
||||
this.paymentIntent = intent
|
||||
tryLaunch()
|
||||
}
|
||||
|
||||
private fun tryLaunch() {
|
||||
val billingService = getBillingService()
|
||||
if (billingService == null) {
|
||||
callFailed(
|
||||
IPaymentClient.CODE_NONSUPPORT,
|
||||
PaymentException(activity.getString(R.string.bean_response_serviceresult_015))
|
||||
)
|
||||
return
|
||||
}
|
||||
val productId = paymentIntent?.productId
|
||||
val productItem = productItem
|
||||
logD("tryLaunch() productId:$productId productItem:$productItem")
|
||||
if (productId == null) {
|
||||
return
|
||||
}
|
||||
if (getBillingService()?.isServiceConnected() != true) {
|
||||
logD("tryLaunch() isServiceConnected = false")
|
||||
return
|
||||
}
|
||||
if (productItem == null) {
|
||||
getBillingService()?.querySkuDetailsAsync(listOf(productId), this)
|
||||
} else {
|
||||
placeOrder(productItem)
|
||||
}
|
||||
}
|
||||
|
||||
private fun placeOrder(productItem: IProductDetails) {
|
||||
logD("placeOrder() productItem:${productItem.getProductId()}")
|
||||
addDisposable(PayModel.get().placeOrder(productItem.getProductId())
|
||||
.subscribe(
|
||||
{ recordId: PayRecordId ->
|
||||
if (paymentIntent?.productId == productItem.getProductId()) {
|
||||
orderId = recordId.recordId
|
||||
getBillingService()?.launchBillingFlow(
|
||||
productItem,
|
||||
recordId.recordId
|
||||
)
|
||||
} else {
|
||||
logE("placeOrder() 意图发生改变")
|
||||
}
|
||||
}
|
||||
) { throwable: Throwable ->
|
||||
callFailed(IPaymentClient.CODE_PLACE_ORDER_FAILED, throwable)
|
||||
})
|
||||
}
|
||||
|
||||
override fun onBillingSetupFinished(billingResult: IBillingResult) {
|
||||
if (billingResult.isResponseOk()) {
|
||||
logD("onBillingClientSetupFinished()")
|
||||
getBillingService()?.queryPurchases(object : OnPurchasesResponseListener {
|
||||
override fun onQueryPurchasesResponse(
|
||||
billingResult: IBillingResult,
|
||||
purchases: List<IPurchase>
|
||||
) {
|
||||
if (billingResult.isResponseOk() && purchases.isNotEmpty()) {
|
||||
purchases.forEach {
|
||||
handlePurchases(false, it)
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
tryLaunch()
|
||||
} else {
|
||||
callFailed(
|
||||
IPaymentClient.CODE_UNAVAILABLE, billingResult
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onPurchasesUpdated(billingResult: IBillingResult, purchases: List<IPurchase>?) {
|
||||
logD("onPurchasesUpdated() billingResult:${billingResult.getResponseCode()} purchases:${purchases?.size}")
|
||||
if (billingResult.isResponseOk() && !purchases.isNullOrEmpty()) {
|
||||
purchases.forEach {
|
||||
handlePurchases(true, it)
|
||||
}
|
||||
} else {
|
||||
callFailed(IPaymentClient.CODE_PURCHASE_FAILED, billingResult)
|
||||
}
|
||||
}
|
||||
|
||||
private fun handlePurchases(isCurrentPaying: Boolean, purchases: IPurchase) {
|
||||
logD("handlePurchases isCurrentPaying:${isCurrentPaying} state:${purchases.getPurchaseState()}")
|
||||
val identifiers = purchases.getAccountIdentifiers()
|
||||
if (purchases.isPurchasedState() && identifiers != null) {
|
||||
logD("handlePurchases() verifyOrder")
|
||||
addDisposable(
|
||||
PayModel.get().verifyOrder(
|
||||
identifiers.getObfuscatedAccountId(),
|
||||
purchases.getProducts().firstOrNull(),
|
||||
purchases.getPackageName(),
|
||||
purchases.getPurchaseToken()
|
||||
).subscribe({
|
||||
logD("handlePurchases() verifyOrder consumeAsync")
|
||||
consumeAsync(isCurrentPaying, it)
|
||||
}, {
|
||||
logD("handlePurchases() error:${it.message}")
|
||||
if (isCurrentPaying) {
|
||||
callFailed(IPaymentClient.CODE_VERIFY_ORDER_FAILED, it)
|
||||
}
|
||||
})
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private fun consumeAsync(isCurrentPaying: Boolean, token: String) {
|
||||
logD("consumeAsync() isCurrentPaying:${isCurrentPaying} token:$token")
|
||||
getBillingService()?.consumeAsync(token, object : OnConsumeResponseListener {
|
||||
override fun onConsumeResponse(billingResult: IBillingResult, purchaseToken: String) {
|
||||
logD("consumeAsync() onConsumeResponse billingResult:${billingResult} purchaseToken:$purchaseToken")
|
||||
if (isCurrentPaying) {
|
||||
if (billingResult.isResponseOk()) {
|
||||
val orderId = orderId
|
||||
if (orderId != null) {
|
||||
callSuccess(orderId)
|
||||
}
|
||||
} else {
|
||||
callFailed(IPaymentClient.CODE_CONSUME_ORDER_FAILED, billingResult)
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
override fun onProductDetailsResponse(
|
||||
billingResult: IBillingResult,
|
||||
productDetails: List<IProductDetails>
|
||||
) {
|
||||
logD("onProductDetailsResponse() billingResult:${billingResult.getResponseCode()} productDetails:${productDetails.size}")
|
||||
if (billingResult.isResponseOk()) {
|
||||
val item = productDetails.firstOrNull {
|
||||
it.getProductId() == paymentIntent?.productId
|
||||
}
|
||||
productItem = item
|
||||
if (item != null) {
|
||||
tryLaunch()
|
||||
} else {
|
||||
callFailed(IPaymentClient.CODE_PRODUCT_NOT_FOUND, billingResult)
|
||||
}
|
||||
} else {
|
||||
callFailed(IPaymentClient.CODE_PRODUCT_NOT_FOUND, billingResult)
|
||||
}
|
||||
}
|
||||
|
||||
private fun callSuccess(orderRecordId: String) {
|
||||
logD("callSuccess() orderRecordId:${orderRecordId} productId:${paymentIntent?.productId}")
|
||||
paymentIntent?.let {
|
||||
it.listener.onResponse(PaymentResult.PaymentSuccess(it.productId, orderRecordId))
|
||||
}
|
||||
paymentIntent = null
|
||||
dialogManager.dismissDialog()
|
||||
}
|
||||
|
||||
private fun callFailed(code: Int) {
|
||||
callFailed(
|
||||
code,
|
||||
PaymentException(
|
||||
code,
|
||||
message = activity.getString(R.string.common_operation_prompt_format).format(code)
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
private fun callFailed(code: Int, billingResult: IBillingResult) {
|
||||
callFailed(
|
||||
code,
|
||||
PaymentException(
|
||||
code,
|
||||
message = activity.getString(R.string.common_operation_prompt_format)
|
||||
.format("$code-${billingResult.getResponseCode()}")
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
private fun callFailed(code: Int, throwable: Throwable) {
|
||||
throwable.printStackTrace()
|
||||
logD("callFailed() code:${code} throwable:${throwable.message}")
|
||||
throwable.let {
|
||||
SingleToastUtil.showToast(
|
||||
it.message
|
||||
)
|
||||
}
|
||||
paymentIntent?.let {
|
||||
it.listener.onResponse(PaymentResult.PaymentFailed(it.productId, code, throwable))
|
||||
}
|
||||
paymentIntent = null
|
||||
dialogManager.dismissDialog()
|
||||
}
|
||||
|
||||
private fun getCompositeDisposable(): CompositeDisposable {
|
||||
var disposable = compositeDisposable
|
||||
if (disposable == null) {
|
||||
disposable = CompositeDisposable()
|
||||
compositeDisposable = disposable
|
||||
}
|
||||
return disposable
|
||||
}
|
||||
|
||||
private fun addDisposable(disposable: Disposable) {
|
||||
getCompositeDisposable().add(disposable)
|
||||
}
|
||||
|
||||
override fun onCleared() {
|
||||
logD("onCleared()")
|
||||
_billingService?.destroy()
|
||||
paymentIntent = null
|
||||
compositeDisposable?.dispose()
|
||||
compositeDisposable = null
|
||||
dialogManager.dismissDialog()
|
||||
}
|
||||
|
||||
override fun onStateChanged(source: LifecycleOwner, event: Lifecycle.Event) {
|
||||
logD("onStateChanged() event:$event")
|
||||
when (event) {
|
||||
Lifecycle.Event.ON_DESTROY -> {
|
||||
(activity as? LifecycleOwner)?.lifecycle?.removeObserver(this)
|
||||
onCleared()
|
||||
}
|
||||
|
||||
else -> {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,42 @@
|
||||
package com.chwl.app.ui.wallet.payment
|
||||
|
||||
import com.example.lib_utils.ICleared
|
||||
|
||||
interface IPaymentClient : ICleared {
|
||||
companion object {
|
||||
// 支付成功
|
||||
const val CODE_SUCCESS = 200
|
||||
|
||||
// 未知异常原因
|
||||
const val CODE_OTHER = 0
|
||||
|
||||
// 不支持该功能
|
||||
const val CODE_NONSUPPORT = 1
|
||||
|
||||
// 服务暂不可用
|
||||
const val CODE_UNAVAILABLE = 2
|
||||
|
||||
// 未查询到购买信息
|
||||
const val CODE_PRODUCT_NOT_FOUND = 3
|
||||
|
||||
// 预下单失败
|
||||
const val CODE_PLACE_ORDER_FAILED = 4
|
||||
|
||||
// 购买失败
|
||||
const val CODE_PURCHASE_FAILED = 5
|
||||
|
||||
// 验证订单失败
|
||||
const val CODE_VERIFY_ORDER_FAILED = 6
|
||||
|
||||
// 核消订单失败
|
||||
const val CODE_CONSUME_ORDER_FAILED = 7
|
||||
}
|
||||
|
||||
fun launchPayment(intent: PaymentIntent)
|
||||
|
||||
override fun onCleared()
|
||||
|
||||
interface Listener {
|
||||
fun onResponse(result: PaymentResult)
|
||||
}
|
||||
}
|
@@ -0,0 +1,13 @@
|
||||
package com.chwl.app.ui.wallet.payment
|
||||
|
||||
import androidx.annotation.Keep
|
||||
|
||||
@Keep
|
||||
class PaymentException : Exception {
|
||||
var code = 0
|
||||
|
||||
constructor(message: String) : super(message)
|
||||
constructor(code: Int, message: String) : super(message) {
|
||||
this.code = code
|
||||
}
|
||||
}
|
@@ -0,0 +1,4 @@
|
||||
package com.chwl.app.ui.wallet.payment
|
||||
|
||||
class PaymentIntent(val productId: String, val listener: IPaymentClient.Listener) {
|
||||
}
|
@@ -0,0 +1,12 @@
|
||||
package com.chwl.app.ui.wallet.payment
|
||||
|
||||
sealed class PaymentResult {
|
||||
|
||||
data class PaymentSuccess(val productId: String, val orderId: String) : PaymentResult()
|
||||
|
||||
data class PaymentFailed(
|
||||
val productId: String,
|
||||
val code: Int,
|
||||
val exception: Throwable? = null
|
||||
) : PaymentResult()
|
||||
}
|
@@ -91,6 +91,8 @@ public class CommonWebViewActivity extends BaseActivity {
|
||||
private static final String POSITION = "position";
|
||||
private int mPosition;
|
||||
|
||||
private JSInterface jsInterface;
|
||||
|
||||
public static void start(Context context, String url) {
|
||||
Intent intent = new Intent(context, CommonWebViewActivity.class);
|
||||
intent.putExtra("url", url);
|
||||
@@ -194,7 +196,7 @@ public class CommonWebViewActivity extends BaseActivity {
|
||||
webView.getSettings().setMixedContentMode(WebSettings.MIXED_CONTENT_COMPATIBILITY_MODE);
|
||||
}
|
||||
webView.getSettings().setTextZoom(100);
|
||||
JSInterface jsInterface = new JSInterface(webView, this);
|
||||
jsInterface = new JSInterface(webView, this);
|
||||
jsInterface.setPosition(mPosition);
|
||||
webView.addJavascriptInterface(jsInterface, "androidJsObj");
|
||||
webView.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
|
||||
@@ -441,6 +443,9 @@ public class CommonWebViewActivity extends BaseActivity {
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
if (jsInterface != null) {
|
||||
jsInterface.onCleared();
|
||||
}
|
||||
EventBus.getDefault().unregister(this);
|
||||
|
||||
if (webViewCallBack != null) {
|
||||
|
@@ -1,8 +1,6 @@
|
||||
package com.chwl.app.ui.webview;
|
||||
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.net.http.SslError;
|
||||
import android.os.Build;
|
||||
import android.text.TextUtils;
|
||||
@@ -16,7 +14,6 @@ import androidx.appcompat.app.AlertDialog;
|
||||
import com.orhanobut.logger.Logger;
|
||||
import com.chwl.app.R;
|
||||
import com.chwl.app.base.BaseBindingFragment;
|
||||
import com.chwl.app.common.widget.dialog.BaseAlertDialogBuilder;
|
||||
import com.chwl.app.databinding.FragmentCommonWebViewBinding;
|
||||
import com.chwl.library.annatation.ActLayoutRes;
|
||||
import com.chwl.library.utils.ResUtil;
|
||||
@@ -26,6 +23,7 @@ public class CommonWebViewFragment extends BaseBindingFragment<FragmentCommonWeb
|
||||
|
||||
private WebView webView;
|
||||
protected String url;
|
||||
private JSInterface jsInterface;
|
||||
|
||||
@Override
|
||||
public void initiate() {
|
||||
@@ -37,7 +35,7 @@ public class CommonWebViewFragment extends BaseBindingFragment<FragmentCommonWeb
|
||||
webView.getSettings().setMixedContentMode(WebSettings.MIXED_CONTENT_COMPATIBILITY_MODE);
|
||||
}
|
||||
webView.getSettings().setTextZoom(100);
|
||||
JSInterface jsInterface = new JSInterface(webView, getActivity());
|
||||
jsInterface = new JSInterface(webView, getActivity());
|
||||
webView.addJavascriptInterface(jsInterface, "androidJsObj");
|
||||
webView.setWebViewClient(new WebViewClient() {
|
||||
|
||||
@@ -113,4 +111,12 @@ public class CommonWebViewFragment extends BaseBindingFragment<FragmentCommonWeb
|
||||
ShowWebView(url);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
if (jsInterface != null) {
|
||||
jsInterface.onCleared();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -14,13 +14,21 @@ import android.util.Log;
|
||||
import android.webkit.JavascriptInterface;
|
||||
import android.webkit.WebView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.chwl.app.earn.activity.EarnRecordActivity;
|
||||
import com.chwl.app.ui.invite.InviteImageHelper;
|
||||
import com.chwl.app.ui.invite.ShareInviteDialog;
|
||||
import com.chwl.app.ui.invite.ShareInviteInfo;
|
||||
import com.chwl.app.ui.wallet.payment.GPaymentClient;
|
||||
import com.chwl.app.ui.wallet.payment.IPaymentClient;
|
||||
import com.chwl.app.ui.wallet.payment.PaymentIntent;
|
||||
import com.chwl.app.ui.wallet.payment.PaymentResult;
|
||||
import com.chwl.library.language.LanguageHelper;
|
||||
import com.chwl.library.utils.json.JsonUtils;
|
||||
import com.example.lib_utils.ICleared;
|
||||
import com.google.gson.Gson;
|
||||
import com.netease.nim.uikit.common.util.log.LogUtil;
|
||||
import com.orhanobut.logger.Logger;
|
||||
@@ -51,7 +59,6 @@ import com.chwl.library.record.AuditRecorderConfiguration;
|
||||
import com.chwl.library.record.ExtAudioRecorder;
|
||||
import com.chwl.library.rxbus.RxBus;
|
||||
import com.chwl.library.utils.AppMetaDataUtil;
|
||||
import com.chwl.library.utils.AppUtils;
|
||||
import com.chwl.library.utils.DeviceUuidFactory;
|
||||
import com.chwl.library.utils.SystemUtils;
|
||||
import com.chwl.library.utils.VersionUtil;
|
||||
@@ -66,7 +73,7 @@ import java.util.HashMap;
|
||||
* <p> html js 与webview 交互接口</p>
|
||||
* Created by ${user} on 2017/11/6.
|
||||
*/
|
||||
public class JSInterface {
|
||||
public class JSInterface implements ICleared {
|
||||
private static final String TAG = JSInterface.class.getSimpleName();
|
||||
private WebView mWebView;
|
||||
private CommonWebViewActivity mActivity;
|
||||
@@ -75,6 +82,7 @@ public class JSInterface {
|
||||
private MediaRecorder recorder;
|
||||
private File myRecAudioFile;
|
||||
private ExtAudioRecorder extAudioRecorder;
|
||||
private GPaymentClient paymentClient;
|
||||
|
||||
public JSInterface(WebView webView, CommonWebViewActivity activity) {
|
||||
mWebView = webView;
|
||||
@@ -87,6 +95,68 @@ public class JSInterface {
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
private void loadUrl(String url) {
|
||||
com.example.lib_utils.log.LogUtil.d("JSInterface", "loadUrl url:" + url, false);
|
||||
if (Looper.myLooper() == Looper.getMainLooper()) {
|
||||
if (mWebView != null) {
|
||||
mWebView.loadUrl(url);
|
||||
}
|
||||
} else {
|
||||
if (mActivity != null) {
|
||||
mActivity.runOnUiThread(() -> {
|
||||
if (mWebView != null) {
|
||||
mWebView.loadUrl(url);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void callJsWithJson(String name, Object params) {
|
||||
if (name == null) {
|
||||
return;
|
||||
}
|
||||
if (params != null) {
|
||||
String jsonStr = JsonUtils.toJson(params);
|
||||
loadUrl("javascript:" + name + "(" + jsonStr + ")");
|
||||
} else {
|
||||
loadUrl("javascript:" + name + "()");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 拉起本地支付
|
||||
*/
|
||||
@JavascriptInterface
|
||||
public void openPayment(String productId) {
|
||||
com.example.lib_utils.log.LogUtil.d("JSInterface", "openPayment productId:" + productId, false);
|
||||
if (mActivity == null || TextUtils.isEmpty(productId)) {
|
||||
return;
|
||||
}
|
||||
mActivity.runOnUiThread(() -> {
|
||||
if (paymentClient == null) {
|
||||
paymentClient = new GPaymentClient(mActivity);
|
||||
}
|
||||
PaymentIntent paymentIntent = new PaymentIntent(productId, new IPaymentClient.Listener() {
|
||||
@Override
|
||||
public void onResponse(@NonNull PaymentResult result) {
|
||||
HashMap<String, Object> map = new HashMap<>();
|
||||
if (result instanceof PaymentResult.PaymentSuccess) {
|
||||
map.put("orderId", ((PaymentResult.PaymentSuccess) result).getOrderId());
|
||||
map.put("productId", ((PaymentResult.PaymentSuccess) result).getProductId());
|
||||
map.put("code", 200);
|
||||
} else if (result instanceof PaymentResult.PaymentFailed) {
|
||||
map.put("code", ((PaymentResult.PaymentFailed) result).getCode());
|
||||
map.put("productId", ((PaymentResult.PaymentFailed) result).getProductId());
|
||||
}
|
||||
callJsWithJson("openPaymentCallback", map);
|
||||
}
|
||||
});
|
||||
paymentClient.launchPayment(paymentIntent);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 调转个人主页
|
||||
*
|
||||
@@ -122,7 +192,7 @@ public class JSInterface {
|
||||
map.put(IReportConstants.MODULE, IReportConstants.MOLISTAR_PAY);
|
||||
ReportManager.get().reportEvent(IReportConstants.PAYPAGE_SHOW, map);
|
||||
// if (AppMetaDataUtil.getChannelID().equals(Constants.GOOGLE)) {
|
||||
ChargeActivity.start(context);
|
||||
ChargeActivity.start(context);
|
||||
// } else {
|
||||
// CommonWebViewActivity.start(
|
||||
// context, UriProvider.getOfficialPay(
|
||||
@@ -175,7 +245,7 @@ public class JSInterface {
|
||||
if (activity == null) {
|
||||
return;
|
||||
}
|
||||
ShareInviteInfo info = new Gson().fromJson(json,ShareInviteInfo.class);
|
||||
ShareInviteInfo info = new Gson().fromJson(json, ShareInviteInfo.class);
|
||||
if (info.getType() != null) {
|
||||
if (info.getType() == 1) {
|
||||
activity.runOnUiThread(() -> {
|
||||
@@ -474,7 +544,7 @@ public class JSInterface {
|
||||
jsonObject.put("netType", String.valueOf(SystemUtils.getNetworkType(context)));
|
||||
jsonObject.put("model", SystemUtils.getPhoneModel());
|
||||
jsonObject.put("appVersion", VersionUtil.getLocalName(context));
|
||||
jsonObject.put("appVersionCode", String.valueOf(AppUtils.getVersionCode(context)));
|
||||
jsonObject.put("appVersionCode", String.valueOf(VersionUtil.getVersionCode(context)));
|
||||
jsonObject.put("deviceId", DeviceUtil.getDeviceId(context));
|
||||
jsonObject.put("channel", AppMetaDataUtil.getChannelID());
|
||||
jsonObject.put("Accept-Language", LanguageHelper.INSTANCE.getCurrentLanguageType());
|
||||
@@ -556,4 +626,11 @@ public class JSInterface {
|
||||
PraiseModel.get().praise(Long.parseLong(uid), true).subscribe();
|
||||
NimP2PMessageActivity.start(context, uid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCleared() {
|
||||
if (paymentClient != null) {
|
||||
paymentClient.onCleared();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -12,7 +12,6 @@ import com.tencent.vasdolly.helper.ChannelReaderUtil;
|
||||
import com.chwl.app.application.App;
|
||||
import com.chwl.core.XConstants;
|
||||
import com.chwl.core.Constants;
|
||||
import com.chwl.library.utils.AppUtils;
|
||||
import com.chwl.library.utils.VersionUtil;
|
||||
|
||||
/**
|
||||
@@ -108,7 +107,7 @@ public class SimpleJSInterface {
|
||||
jsonObject.put("os", "android");
|
||||
jsonObject.put("app", XConstants.APP_MARK);
|
||||
jsonObject.put("appVersion", VersionUtil.getLocalName(context));
|
||||
jsonObject.put("appVersionCode", String.valueOf(AppUtils.getVersionCode(context)));
|
||||
jsonObject.put("appVersionCode", String.valueOf(VersionUtil.getVersionCode(context)));
|
||||
jsonObject.put("channel", getChannel());
|
||||
Log.e(TAG, "getDeviceInfo: " + jsonObject);
|
||||
return jsonObject.toJSONString();
|
||||
|
@@ -0,0 +1,180 @@
|
||||
package com.chwl.app.ui.widget
|
||||
|
||||
import android.animation.ObjectAnimator
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.os.Build
|
||||
import android.os.VibrationEffect
|
||||
import android.os.Vibrator
|
||||
import android.os.VibratorManager
|
||||
import android.util.AttributeSet
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.widget.FrameLayout
|
||||
import androidx.core.view.isGone
|
||||
import com.chwl.app.databinding.ViewBonsellaJoinAttackButtonBinding
|
||||
import com.chwl.core.utils.ComboUtil
|
||||
|
||||
class BonsellaJoinAttackButtonView @JvmOverloads constructor(
|
||||
context: Context,
|
||||
attrs: AttributeSet? = null
|
||||
) : FrameLayout(context, attrs) {
|
||||
|
||||
var onGiftComboEndListener: OnGiftComboEndListener? = null
|
||||
private var comboNum = 0
|
||||
private var comboCount = 0
|
||||
|
||||
private val objectAnimator: ObjectAnimator by lazy {
|
||||
ObjectAnimator.ofFloat(mBinding.pvBg, "percent", 100F, 0F).apply {
|
||||
duration = DOWN_COUNT_TIME
|
||||
}
|
||||
}
|
||||
|
||||
private val mBinding = ViewBonsellaJoinAttackButtonBinding.inflate(LayoutInflater.from(context), this)
|
||||
|
||||
private val vibrator by lazy {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
||||
(context.getSystemService(Context.VIBRATOR_MANAGER_SERVICE) as VibratorManager).defaultVibrator
|
||||
} else {
|
||||
context.getSystemService(Context.VIBRATOR_SERVICE) as Vibrator
|
||||
}
|
||||
}
|
||||
|
||||
init {
|
||||
mBinding.ivBtn.isLongClickable = false
|
||||
mBinding.pvBg.setProgressChangeListener{
|
||||
if(it == 0f){
|
||||
isGone = true
|
||||
comboNum = 0
|
||||
comboCount = 0
|
||||
ComboUtil.comboCount = comboCount+1
|
||||
mBinding.tvNum.text = ""
|
||||
onGiftComboEndListener?.onGiftComboEnd()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun onBtnDown(){
|
||||
try {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
vibrator.vibrate(VibrationEffect.createOneShot(100L, VibrationEffect.DEFAULT_AMPLITUDE))
|
||||
}else{
|
||||
vibrator.vibrate(100)
|
||||
}
|
||||
} catch (_: Exception) { }
|
||||
|
||||
// mBinding.ivBtn.animate().cancel()
|
||||
// mBinding.ivBtn.animate()
|
||||
// .scaleX(0.875f)
|
||||
// .scaleY(0.875f)
|
||||
// .setDuration(50)
|
||||
// .withEndAction {
|
||||
// onBtnUp()
|
||||
// }
|
||||
// .start()
|
||||
// mBinding.pvBg.animate().cancel()
|
||||
// mBinding.pvBg.animate()
|
||||
// .scaleX(0.875f)
|
||||
// .scaleY(0.875f)
|
||||
// .setDuration(50)
|
||||
// .start()
|
||||
// mBinding.ivBg.animate().cancel()
|
||||
// mBinding.ivBg.alpha = 0f
|
||||
// mBinding.ivBg.scaleX = 1f
|
||||
// mBinding.ivBg.scaleY = 1f
|
||||
|
||||
mBinding.svga.stopAnimation()
|
||||
mBinding.svga.startAnimation()
|
||||
|
||||
|
||||
}
|
||||
|
||||
private fun onBtnUp(){
|
||||
mBinding.ivBtn.animate()
|
||||
.scaleX(1f)
|
||||
.scaleY(1f)
|
||||
.setDuration(50)
|
||||
.withEndAction { }
|
||||
.start()
|
||||
mBinding.pvBg.animate()
|
||||
.scaleX(1f)
|
||||
.scaleY(1f)
|
||||
.setDuration(50)
|
||||
.start()
|
||||
mBinding.ivBg.alpha = 1f
|
||||
mBinding.ivBg.animate()
|
||||
.alpha(0f)
|
||||
.scaleX(1.3f)
|
||||
.scaleY(1.3f)
|
||||
.start()
|
||||
}
|
||||
|
||||
fun getComboNum():Int{
|
||||
return comboNum
|
||||
}
|
||||
|
||||
|
||||
fun isInCombo():Boolean{
|
||||
return comboNum > 0
|
||||
}
|
||||
|
||||
fun cancel() {
|
||||
objectAnimator.cancel()
|
||||
mBinding.pvBg.percent = 0f
|
||||
}
|
||||
|
||||
fun start() {
|
||||
objectAnimator.start()
|
||||
}
|
||||
|
||||
fun waitStart() {
|
||||
mBinding.pvBg.percent = 100f
|
||||
objectAnimator.pause()
|
||||
}
|
||||
|
||||
override fun onDetachedFromWindow() {
|
||||
super.onDetachedFromWindow()
|
||||
cancel()
|
||||
mBinding.svga.clear()
|
||||
objectAnimator.removeAllListeners()
|
||||
objectAnimator.removeAllUpdateListeners()
|
||||
}
|
||||
|
||||
/**
|
||||
* 用于更新按钮上的文字
|
||||
*/
|
||||
@SuppressLint("SetTextI18n")
|
||||
fun updateNumber(num: Int) {
|
||||
comboNum += num
|
||||
comboCount++
|
||||
mBinding.tvNum.text = "x$comboCount"
|
||||
mBinding.tvNum.scaleX = 1.3f
|
||||
mBinding.tvNum.scaleY = 1.3f
|
||||
mBinding.tvNum.animate()
|
||||
.setDuration(100)
|
||||
.scaleX(1f)
|
||||
.scaleY(1f)
|
||||
.start()
|
||||
ComboUtil.comboCount = comboCount+1
|
||||
}
|
||||
|
||||
fun interface OnGiftComboEndListener {
|
||||
fun onGiftComboEnd()
|
||||
}
|
||||
|
||||
companion object {
|
||||
/**
|
||||
* 倒计时时间,毫秒为单位
|
||||
*/
|
||||
const val DOWN_COUNT_TIME = 5 * 1000L
|
||||
}
|
||||
|
||||
fun showView(isVis : Boolean){
|
||||
if (isVis) {
|
||||
if (visibility != View.VISIBLE) visibility = View.VISIBLE
|
||||
}else{
|
||||
if (visibility == View.VISIBLE) visibility = View.INVISIBLE
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@@ -0,0 +1,349 @@
|
||||
package com.chwl.app.ui.widget
|
||||
|
||||
import android.animation.ObjectAnimator
|
||||
import android.animation.PropertyValuesHolder
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.os.Handler
|
||||
import android.os.Looper
|
||||
import android.os.Message
|
||||
import android.util.AttributeSet
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.animation.Animation
|
||||
import android.view.animation.AnimationUtils
|
||||
import android.widget.ImageView
|
||||
import android.widget.LinearLayout
|
||||
import android.widget.TextView
|
||||
import androidx.appcompat.widget.AppCompatTextView
|
||||
import androidx.core.view.isGone
|
||||
import androidx.core.view.isVisible
|
||||
import com.chwl.app.R
|
||||
import com.chwl.app.ui.utils.ImageLoadUtils
|
||||
import com.chwl.app.ui.utils.SoftPool
|
||||
import com.chwl.core.gift.bean.BonsellaJoinAttack
|
||||
import com.chwl.core.gift.bean.GiftMultiReceiverInfo
|
||||
import com.chwl.core.utils.LogUtils
|
||||
import com.chwl.library.utils.ResUtil
|
||||
import com.example.lib_utils.UiUtils
|
||||
import java.util.LinkedList
|
||||
|
||||
class BonsellaJoinAttackLayout @JvmOverloads constructor(
|
||||
context: Context?,
|
||||
attrs: AttributeSet? = null,
|
||||
defStyleAttr: Int = 0,
|
||||
defStyleRes: Int = 0
|
||||
) : LinearLayout(context, attrs, defStyleAttr, defStyleRes){
|
||||
|
||||
private val showingList = LinkedList<BonsellaJoinAttack>()
|
||||
private val waitingList = LinkedList<BonsellaJoinAttack>()
|
||||
private val comboMap = linkedMapOf<BonsellaJoinAttack, View>()
|
||||
private val cacheView = SoftPool<View>(2)
|
||||
private val inflater = LayoutInflater.from(context)
|
||||
|
||||
private val handle = Handler(Looper.getMainLooper()) {
|
||||
if (it.what == 1) {
|
||||
viewOut(it.obj as? BonsellaJoinAttack, false)
|
||||
}
|
||||
true
|
||||
}
|
||||
|
||||
init {
|
||||
if(isInEditMode){
|
||||
inflater.inflate(R.layout.item_bonsella_join_attack_view, this, true)
|
||||
inflater.inflate(R.layout.item_bonsella_join_attack_view, this, true)
|
||||
}
|
||||
orientation = VERTICAL
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建
|
||||
*/
|
||||
private fun getComboChildView(): View {
|
||||
val view = cacheView.acquire {
|
||||
inflater.inflate(R.layout.item_bonsella_join_attack_view, this, false)
|
||||
}.apply {
|
||||
createViewHolder(this)
|
||||
isVisible = true
|
||||
}
|
||||
return view
|
||||
}
|
||||
|
||||
/**
|
||||
* add data
|
||||
*/
|
||||
fun add(bonsellaJoinAttack: BonsellaJoinAttack?) {
|
||||
//没有绑定之前不能添加
|
||||
if (!isAttachedToWindow) {
|
||||
return
|
||||
}
|
||||
if (bonsellaJoinAttack == null) {
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
var addToWaiting = true
|
||||
for (comboInfo in showingList) {
|
||||
if(comboInfo.sentUserid == bonsellaJoinAttack.sentUserid && comboInfo.giftId == bonsellaJoinAttack.giftId){
|
||||
comboInfo.giftNumber = bonsellaJoinAttack.giftNumber
|
||||
comboInfo.comboCount = bonsellaJoinAttack.comboCount
|
||||
comboInfo.receiverNumber = bonsellaJoinAttack.receiverNumber
|
||||
updateNum(comboInfo)
|
||||
addToWaiting = false
|
||||
}
|
||||
}
|
||||
|
||||
for (comboInfo in waitingList) {
|
||||
if(comboInfo.sentUserid == bonsellaJoinAttack.sentUserid && comboInfo.giftId == bonsellaJoinAttack.giftId){
|
||||
comboInfo.giftNumber = bonsellaJoinAttack.giftNumber
|
||||
comboInfo.comboCount = bonsellaJoinAttack.comboCount
|
||||
comboInfo.receiverNumber = bonsellaJoinAttack.receiverNumber
|
||||
addToWaiting = false
|
||||
}
|
||||
}
|
||||
|
||||
if(addToWaiting){
|
||||
waitingList.add(bonsellaJoinAttack)
|
||||
}
|
||||
|
||||
showNext()
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新数量
|
||||
*/
|
||||
private fun updateNum(bonsellaJoinAttack: BonsellaJoinAttack) {
|
||||
val view = comboMap[bonsellaJoinAttack] ?: return
|
||||
val viewHolder = getViewHolder(view)
|
||||
viewHolder?.refreshNum(bonsellaJoinAttack, true)
|
||||
handle.removeMessages(1, bonsellaJoinAttack)
|
||||
handle.sendMessageDelayed(Message.obtain(handle, 1, bonsellaJoinAttack), COMBO_STAY_TIME * 1000L)
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 显示下一个
|
||||
*/
|
||||
private fun showNext() {
|
||||
if(waitingList.isEmpty()){
|
||||
return
|
||||
}
|
||||
|
||||
val comboChildView = getComboChildView()
|
||||
addView(comboChildView,0)
|
||||
val giftComboInfo = waitingList.remove()
|
||||
showingList.add(giftComboInfo)
|
||||
|
||||
comboMap[giftComboInfo] = comboChildView
|
||||
val viewHolder = getViewHolder(comboChildView)
|
||||
viewHolder?.showUi(giftComboInfo)
|
||||
viewAnimationIn(comboChildView)
|
||||
|
||||
handle.sendMessageDelayed(Message.obtain(handle, 1, giftComboInfo), COMBO_STAY_TIME * 1000L)
|
||||
|
||||
if(showingList.size > MAX_SHOWING){
|
||||
handle.removeMessages(1, showingList[0])
|
||||
viewOut(showingList.remove(), true)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 移除动画
|
||||
*/
|
||||
private fun viewOut(bonsellaJoinAttack: BonsellaJoinAttack?, isDirectRemove: Boolean) {
|
||||
bonsellaJoinAttack ?: return
|
||||
val comboView = comboMap.remove(bonsellaJoinAttack) ?: return
|
||||
|
||||
val runnable = {
|
||||
val viewHolder = getViewHolder(comboView)
|
||||
viewHolder?.clear()
|
||||
if(!isDirectRemove){
|
||||
showingList.remove(bonsellaJoinAttack)
|
||||
}
|
||||
removeView(comboView)
|
||||
cacheView.release(comboView)
|
||||
showNext()
|
||||
}
|
||||
|
||||
if(isDirectRemove){
|
||||
comboView.isGone = true
|
||||
post(runnable)
|
||||
}else{
|
||||
val animOut = AnimationUtils.loadAnimation(context, R.anim.alpha_out)
|
||||
animOut.setAnimationListener(object : Animation.AnimationListener {
|
||||
override fun onAnimationStart(animation: Animation?) {
|
||||
}
|
||||
|
||||
override fun onAnimationEnd(animation: Animation?) {
|
||||
post(runnable)
|
||||
}
|
||||
|
||||
override fun onAnimationRepeat(animation: Animation?) {
|
||||
}
|
||||
})
|
||||
comboView.startAnimation(animOut)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 飞入动画
|
||||
*/
|
||||
private fun viewAnimationIn(view: View) {
|
||||
view.alpha = 1f
|
||||
val animIn = AnimationUtils.loadAnimation(context,if (UiUtils.isRtl(context)) R.anim.left_to_right else R.anim.right_to_left )
|
||||
// animIn.fillAfter = true
|
||||
// animIn.isFillEnabled = true
|
||||
view.startAnimation(animIn)
|
||||
}
|
||||
|
||||
override fun onAttachedToWindow() {
|
||||
super.onAttachedToWindow()
|
||||
if(isInEditMode) return
|
||||
// RoomMsgManager.addCustomMsgListener(this)
|
||||
}
|
||||
|
||||
|
||||
|
||||
fun onRoomCustomMsg(giftInfo: GiftMultiReceiverInfo?) {
|
||||
LogUtils.d(" GiftComboLayout onRoomCustomMsg " )
|
||||
if (giftInfo==null) return
|
||||
if (giftInfo.comboCount == 0) return
|
||||
val comboInfo = BonsellaJoinAttack().apply {
|
||||
giftId = giftInfo.giftId
|
||||
sentUserid = giftInfo.uid
|
||||
sentUserName = giftInfo.nick
|
||||
sentAvatar = giftInfo.avatar
|
||||
receiverUserName = giftInfo.targetUsers?.getOrNull(0)?.nick?:""
|
||||
receiverNumber = giftInfo.targetUsers?.size?: giftInfo.targetUids?.size?: 1
|
||||
giftNumber = giftInfo.giftNum
|
||||
giftImgUrl = giftInfo.gift?.giftUrl?:""
|
||||
comboCount = giftInfo.comboCount
|
||||
isMulti = giftInfo.isMulti
|
||||
}
|
||||
add(comboInfo)
|
||||
}
|
||||
|
||||
override fun onDetachedFromWindow() {
|
||||
super.onDetachedFromWindow()
|
||||
handle.removeCallbacksAndMessages(null)
|
||||
// RoomMsgManager.removeCustomMsgListener(this)
|
||||
}
|
||||
|
||||
private fun createViewHolder(view: View) {
|
||||
getViewHolder(view) ?: ViewHolder(view)
|
||||
}
|
||||
|
||||
private fun getViewHolder(view: View): ViewHolder? {
|
||||
return view.tag as? ViewHolder
|
||||
}
|
||||
|
||||
private inner class ViewHolder(view: View) {
|
||||
var tvNumber: AppCompatTextView = view.findViewById(R.id.giftComboNumber)
|
||||
var ivGift: ImageView = view.findViewById(R.id.giftImg)
|
||||
var tvNick: TextView = view.findViewById(R.id.sentUserName)
|
||||
var tvReceiverNick: TextView = view.findViewById(R.id.receiverUserName)
|
||||
var ivAvatar: ImageView = view.findViewById(R.id.sentUserAvatar)
|
||||
var ivLayoutBg: ImageView = view.findViewById(R.id.layoutBg)
|
||||
|
||||
init {
|
||||
view.tag = this
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
fun showUi(bonsellaJoinAttack: BonsellaJoinAttack) {
|
||||
if (UiUtils.isRtl(context)){
|
||||
ivLayoutBg.scaleX = -1f
|
||||
}
|
||||
|
||||
refreshNum(bonsellaJoinAttack)
|
||||
tvNick.text = bonsellaJoinAttack.sentUserName
|
||||
if (bonsellaJoinAttack.receiverNumber == 1) {
|
||||
tvReceiverNick.text = bonsellaJoinAttack.receiverUserName
|
||||
} else {
|
||||
if (bonsellaJoinAttack.isMulti) {
|
||||
tvReceiverNick.text = ResUtil.getString(R.string.Multiplayer)
|
||||
} else {
|
||||
tvReceiverNick.text = ResUtil.getString(R.string.All_mic)
|
||||
}
|
||||
}
|
||||
// tvNumber.text = "x${giftComboInfo.giftNumber * giftComboInfo.receiverNumber * giftComboInfo.comboCount}"
|
||||
ImageLoadUtils.loadImage(ivGift, bonsellaJoinAttack.giftImgUrl)
|
||||
ImageLoadUtils.loadImage(ivAvatar, bonsellaJoinAttack.sentAvatar)
|
||||
ivAvatar.tag = bonsellaJoinAttack
|
||||
}
|
||||
|
||||
/**
|
||||
* 用于刷新数量
|
||||
*/
|
||||
@SuppressLint("SetTextI18n")
|
||||
fun refreshNum(bonsellaJoinAttack: BonsellaJoinAttack, isAnim: Boolean = false) {
|
||||
val num = bonsellaJoinAttack.giftNumber * bonsellaJoinAttack.receiverNumber * bonsellaJoinAttack.comboCount
|
||||
if(num == 0){
|
||||
tvNumber.isVisible = false
|
||||
return
|
||||
}
|
||||
// val old = tvNumber.tag as? Int
|
||||
// //兼容上一个比下一个数还要大
|
||||
// if (old != null && old > num) {
|
||||
// return
|
||||
// }
|
||||
tvNumber.isVisible = true
|
||||
tvNumber.tag = num
|
||||
tvNumber.text = "x$num"
|
||||
if (isAnim) {
|
||||
tvNumber.animate().cancel()
|
||||
tvNumber.requestLayout()
|
||||
post {
|
||||
val scaleUp: ObjectAnimator = ObjectAnimator.ofPropertyValuesHolder(
|
||||
tvNumber,
|
||||
PropertyValuesHolder.ofFloat(SCALE_X, 1f, 1.3f, 1f),
|
||||
PropertyValuesHolder.ofFloat(SCALE_Y, 1f, 1.3f, 1f)
|
||||
)
|
||||
scaleUp.setDuration(100)
|
||||
scaleUp.start()
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 清空UI数据
|
||||
*/
|
||||
fun clear() {
|
||||
LogUtils.d(" ComboView clear -- clear ")
|
||||
tvNumber.animate().cancel()
|
||||
tvNumber.scaleX = 1f
|
||||
tvNumber.scaleY = 1f
|
||||
tvNumber.tag = 0
|
||||
ivAvatar.tag = null
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
/**
|
||||
* 最大显示个数
|
||||
*/
|
||||
const val MAX_SHOWING = 2
|
||||
|
||||
/**
|
||||
* 连击停留时间
|
||||
*/
|
||||
const val COMBO_STAY_TIME = 5
|
||||
}
|
||||
|
||||
// override fun onClick(v: View) {
|
||||
// val giftComboInfo = v.tag as? GiftComboInfo ?: return
|
||||
// val sendUid = giftComboInfo.senderUid
|
||||
// if (sendUid == 0L) {
|
||||
// return
|
||||
// }
|
||||
// RoomUserInfoDialog.show(sendUid)
|
||||
// }
|
||||
|
||||
}
|
@@ -0,0 +1,295 @@
|
||||
package com.chwl.app.ui.widget
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.Canvas
|
||||
import android.graphics.LinearGradient
|
||||
import android.graphics.Paint
|
||||
import android.graphics.RectF
|
||||
import android.graphics.Shader
|
||||
import android.util.AttributeSet
|
||||
import android.view.View
|
||||
import androidx.annotation.Keep
|
||||
import com.chwl.app.R
|
||||
import com.chwl.library.utils.SizeUtils
|
||||
|
||||
class ColorfulRingProgressView(context: Context, attrs: AttributeSet?) : View(context, attrs) {
|
||||
|
||||
private var mPercent = 0f
|
||||
|
||||
private var mStrokeWidth = 0f
|
||||
|
||||
private var mStartAngle = 0f
|
||||
|
||||
private var mFgColorStart = 0xffb900
|
||||
|
||||
private var mFgColorEnd = 0xffb900
|
||||
|
||||
private var widthDiff = 3
|
||||
|
||||
private var mBgColor = -0xa0a0b
|
||||
|
||||
private var mShader: LinearGradient? = null
|
||||
|
||||
private var mOval = RectF()
|
||||
|
||||
private val progressPaint = Paint()
|
||||
|
||||
private var mNegative = false //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>㵹<EFBFBD><E3B5B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>100-0<><30>
|
||||
|
||||
private val circlePaint = Paint()
|
||||
|
||||
|
||||
|
||||
private var progressChangeListener: OnProgressChangeListener? = null
|
||||
|
||||
|
||||
|
||||
init {
|
||||
|
||||
val a = context.theme.obtainStyledAttributes(attrs, R.styleable.ColorfulRingProgressView, 0, 0)
|
||||
|
||||
try {
|
||||
|
||||
mFgColorEnd = a.getColor(R.styleable.ColorfulRingProgressView_fgColorEnd, 0xffb900)
|
||||
|
||||
mFgColorStart = a.getColor(R.styleable.ColorfulRingProgressView_fgColorStart, 0xffb900)
|
||||
|
||||
mPercent = a.getFloat(R.styleable.ColorfulRingProgressView_currentPercent, 75f)
|
||||
|
||||
mStartAngle = a.getFloat(R.styleable.ColorfulRingProgressView_ringProgress_startAngle, 0f) + 270
|
||||
|
||||
mStrokeWidth = a.getDimensionPixelSize(R.styleable.ColorfulRingProgressView_circleStrokeWidth, 21).toFloat()
|
||||
|
||||
widthDiff = a.getDimensionPixelSize(R.styleable.ColorfulRingProgressView_circle_width_diff, 3)
|
||||
|
||||
mBgColor = a.getColor(R.styleable.ColorfulRingProgressView_circle_bg_color, -0xa0a0b)
|
||||
|
||||
mNegative = a.getBoolean(R.styleable.ColorfulRingProgressView_crp_negative, false)
|
||||
|
||||
} finally {
|
||||
|
||||
a.recycle()
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
progressPaint.isAntiAlias = true
|
||||
|
||||
progressPaint.style = Paint.Style.STROKE
|
||||
|
||||
progressPaint.strokeWidth = mStrokeWidth
|
||||
|
||||
progressPaint.strokeCap = Paint.Cap.ROUND
|
||||
|
||||
circlePaint.style = Paint.Style.STROKE
|
||||
|
||||
circlePaint.isAntiAlias = true
|
||||
|
||||
circlePaint.color = mBgColor
|
||||
|
||||
circlePaint.strokeWidth = mStrokeWidth + widthDiff
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
override fun onDraw(canvas: Canvas) {
|
||||
|
||||
super.onDraw(canvas)
|
||||
|
||||
|
||||
|
||||
canvas.drawCircle(
|
||||
|
||||
(mOval.right + mOval.left) / 2,
|
||||
|
||||
(mOval.bottom + mOval.top) / 2,
|
||||
|
||||
(mOval.bottom - mOval.top) / 2,
|
||||
|
||||
circlePaint
|
||||
|
||||
)
|
||||
|
||||
progressPaint.setShader(mShader)
|
||||
|
||||
if (mNegative) {
|
||||
|
||||
canvas.drawArc(mOval, mStartAngle + (100 - mPercent) * 3.6f, 360 - (100 - mPercent) * 3.6f, false, progressPaint)
|
||||
|
||||
} else {
|
||||
|
||||
canvas.drawArc(mOval, mStartAngle, mPercent * 3.6f, false, progressPaint)
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
override fun onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int) {
|
||||
|
||||
super.onSizeChanged(w, h, oldw, oldh)
|
||||
|
||||
updateOval()
|
||||
|
||||
mShader = LinearGradient(
|
||||
|
||||
mOval.left, mOval.top,
|
||||
|
||||
mOval.left, mOval.bottom, mFgColorStart, mFgColorEnd, Shader.TileMode.MIRROR
|
||||
|
||||
)
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@set:Keep
|
||||
var percent: Float
|
||||
get() = mPercent
|
||||
set(mPercent) {
|
||||
this.mPercent = mPercent
|
||||
postInvalidate()
|
||||
if (progressChangeListener != null) {
|
||||
progressChangeListener?.onProgressChange(mPercent)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
fun setProgressChangeListener(progressChangeListener: OnProgressChangeListener?) {
|
||||
|
||||
this.progressChangeListener = progressChangeListener
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
var strokeWidth: Float
|
||||
|
||||
get() = mStrokeWidth
|
||||
|
||||
set(mStrokeWidth) {
|
||||
|
||||
this.mStrokeWidth = mStrokeWidth
|
||||
|
||||
progressPaint.strokeWidth = mStrokeWidth
|
||||
|
||||
updateOval()
|
||||
|
||||
refreshTheLayout()
|
||||
|
||||
}
|
||||
private fun updateOval() {
|
||||
|
||||
val xp = paddingLeft + paddingRight
|
||||
|
||||
val yp = paddingBottom + paddingTop
|
||||
|
||||
mOval = RectF(
|
||||
|
||||
paddingLeft + mStrokeWidth, paddingTop + mStrokeWidth,
|
||||
|
||||
paddingLeft + (width - xp) - mStrokeWidth,
|
||||
|
||||
paddingTop + (height - yp) - mStrokeWidth
|
||||
|
||||
)
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
fun setStrokeWidthDp(dp: Float) {
|
||||
|
||||
this.mStrokeWidth = SizeUtils.dp2px(context,dp).toFloat()
|
||||
|
||||
progressPaint.strokeWidth = mStrokeWidth
|
||||
|
||||
updateOval()
|
||||
|
||||
refreshTheLayout()
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
private fun refreshTheLayout() {
|
||||
|
||||
invalidate()
|
||||
|
||||
requestLayout()
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
var fgColorStart: Int
|
||||
|
||||
get() = mFgColorStart
|
||||
|
||||
set(mFgColorStart) {
|
||||
|
||||
this.mFgColorStart = mFgColorStart
|
||||
|
||||
mShader = LinearGradient(
|
||||
|
||||
mOval.left, mOval.top,
|
||||
|
||||
mOval.left, mOval.bottom, mFgColorStart, mFgColorEnd, Shader.TileMode.MIRROR
|
||||
|
||||
)
|
||||
|
||||
refreshTheLayout()
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
var fgColorEnd: Int
|
||||
|
||||
get() = mFgColorEnd
|
||||
|
||||
set(mFgColorEnd) {
|
||||
|
||||
this.mFgColorEnd = mFgColorEnd
|
||||
|
||||
mShader = LinearGradient(
|
||||
|
||||
mOval.left, mOval.top,
|
||||
|
||||
mOval.left, mOval.bottom, mFgColorStart, mFgColorEnd, Shader.TileMode.MIRROR
|
||||
|
||||
)
|
||||
|
||||
refreshTheLayout()
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
var startAngle: Float
|
||||
|
||||
get() = mStartAngle
|
||||
|
||||
set(mStartAngle) {
|
||||
|
||||
this.mStartAngle = mStartAngle + 270
|
||||
|
||||
refreshTheLayout()
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
fun interface OnProgressChangeListener {
|
||||
|
||||
fun onProgressChange(mPercent: Float)
|
||||
|
||||
}
|
||||
|
||||
}
|
@@ -2,13 +2,13 @@ package com.chwl.app.ui.widget
|
||||
|
||||
import com.netease.nim.uikit.common.util.sys.ScreenUtil
|
||||
import com.chwl.app.R
|
||||
import com.chwl.app.base.BaseDialog
|
||||
import com.chwl.app.base.BaseDialogFragment
|
||||
import com.chwl.app.databinding.DialogDatingSelectBinding
|
||||
import com.chwl.core.room.event.DatingSelectUserEvent
|
||||
import com.chwl.library.utils.ResUtil
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
|
||||
class DatingSelectDialog(val position: Int, val uid: Long, private val myUid: Long, val roomUid: Long) : BaseDialog<DialogDatingSelectBinding>() {
|
||||
class DatingSelectDialog(val position: Int, val uid: Long, private val myUid: Long, val roomUid: Long) : BaseDialogFragment<DialogDatingSelectBinding>() {
|
||||
|
||||
override fun init() {
|
||||
width = ScreenUtil.dip2px(200f)
|
||||
|
@@ -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,36 @@ public class GiftDialog extends BottomSheetDialog implements View.OnClickListene
|
||||
});
|
||||
}
|
||||
|
||||
private List<GiftTab> updateTabs() {
|
||||
List<GiftTab> tabInfoList = new ArrayList<>();
|
||||
if (GiftModel.get().getTabList() != null) {
|
||||
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 +705,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 +743,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 +762,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 +778,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 +855,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 +1174,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 +1215,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 +1469,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 +1524,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) {
|
||||
@@ -1702,4 +1777,8 @@ public class GiftDialog extends BottomSheetDialog implements View.OnClickListene
|
||||
void onFail();
|
||||
}
|
||||
|
||||
public void sendGift(){
|
||||
sendGiftButton.performClick();
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -59,7 +59,7 @@ class SideBarView : View {
|
||||
this.textSizeFocus = focusTextSize
|
||||
}
|
||||
|
||||
override fun onDraw(canvas: Canvas?) {
|
||||
override fun onDraw(canvas: Canvas) {
|
||||
super.onDraw(canvas)
|
||||
paintText(canvas)
|
||||
}
|
||||
|
@@ -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);
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
|
@@ -51,8 +51,7 @@ class AllServiceGiftLevelDialog : BaseDialog {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
requestWindowFeature(Window.FEATURE_NO_TITLE)
|
||||
val inflate =
|
||||
LayoutInflater.from(context).inflate(R.layout.dialog_gift_all_service_level, null)
|
||||
val inflate = LayoutInflater.from(context).inflate(R.layout.dialog_gift_all_service_level, null)
|
||||
setContentView(inflate.rootView)
|
||||
setCancelable(true)
|
||||
setCanceledOnTouchOutside(true)
|
||||
|
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -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
|
||||
|
@@ -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;
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user