功能恢复:恢复寻爱玩法
@@ -114,6 +114,7 @@ android {
|
||||
'src/module_bank_card/java',
|
||||
'src/module_super_admin/java',
|
||||
'src/module_album/java',
|
||||
'src/module_treasure_box/java',
|
||||
|
||||
]
|
||||
|
||||
@@ -127,6 +128,7 @@ android {
|
||||
'src/module_bank_card/res',
|
||||
'src/module_super_admin/res',
|
||||
'src/module_album/res',
|
||||
'src/module_treasure_box/res',
|
||||
|
||||
]
|
||||
|
||||
|
@@ -466,6 +466,15 @@
|
||||
android:name=".team.view.UpdateTeamNameActivity"
|
||||
android:screenOrientation="portrait"
|
||||
android:windowSoftInputMode="stateHidden|adjustResize" />
|
||||
<activity
|
||||
android:name=".treasure_box.activity.TreasureBoxActivity"
|
||||
android:theme="@style/transparent_activity" />
|
||||
<activity
|
||||
android:name=".treasure_box.activity.BoxRankingActivity"
|
||||
android:theme="@style/room_message_activity" />
|
||||
<activity
|
||||
android:name=".treasure_box.activity.TreasureBoxHonourActivity"
|
||||
android:theme="@style/dialog_web_view_activity" />
|
||||
<activity android:name=".ui.setting.VerifyPhoneActivity" />
|
||||
<activity android:name=".ui.setting.ModifyPwdActivity" />
|
||||
<activity
|
||||
@@ -657,7 +666,12 @@
|
||||
<activity
|
||||
android:name=".ui.webview.DialogWebViewActivity"
|
||||
android:theme="@style/dialog_web_view_activity"
|
||||
android:windowSoftInputMode="adjustPan" /> <!-- 隐私政策 -->
|
||||
android:windowSoftInputMode="adjustPan" />
|
||||
<activity
|
||||
android:name=".ui.webview.room_banner.RoomWebDialogActivity"
|
||||
android:theme="@style/room_dialog_web_view_activity"
|
||||
android:windowSoftInputMode="adjustPan" />
|
||||
<!-- 隐私政策 -->
|
||||
<activity
|
||||
android:name=".ui.webview.DatingRuleWebViewActivity"
|
||||
android:theme="@style/dialog_web_view_activity" />
|
||||
|
@@ -44,6 +44,7 @@ import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.chwl.app.notify.room.RoomNotify;
|
||||
import com.chwl.core.monsterhunting.bean.MonsterDataBean;
|
||||
import com.chwl.core.support.room.RoomWidget;
|
||||
import com.netease.nim.uikit.StatusBarUtil;
|
||||
import com.netease.nimlib.sdk.NIMSDK;
|
||||
import com.netease.nimlib.sdk.Observer;
|
||||
@@ -1370,6 +1371,12 @@ public class AVRoomActivity extends BaseMvpActivity<IAvRoomView, AvRoomPresenter
|
||||
return this;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public RoomWidget findWidget(@NonNull String name) {
|
||||
return null;
|
||||
}
|
||||
|
||||
private static class GiftBroadcastObserver implements Observer<BroadcastMessage> {
|
||||
private WeakReference<AVRoomActivity> mReference;
|
||||
|
||||
|
@@ -1228,6 +1228,10 @@ open class BaseRoomFragment<V : IBaseRoomView?, P : BaseRoomPresenter<V>?> :
|
||||
return this
|
||||
}
|
||||
|
||||
override fun findWidget(name: String): RoomWidget? {
|
||||
return widgets[name]
|
||||
}
|
||||
|
||||
open fun initWidget() {
|
||||
|
||||
}
|
||||
|
@@ -8,6 +8,8 @@ import android.view.View;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.databinding.DataBindingUtil;
|
||||
|
||||
import com.chwl.app.avroom.gameplay.RoomGameplayListWidget;
|
||||
import com.chwl.app.avroom.gameplay.RoomGameplayWidget;
|
||||
import com.chwl.app.music.widget.MusicPlayerView;
|
||||
import com.netease.nim.uikit.common.util.log.LogUtil;
|
||||
import com.trello.rxlifecycle3.android.FragmentEvent;
|
||||
@@ -131,6 +133,8 @@ public class HomePartyRoomFragment extends BaseRoomFragment<IHomePartyView, Home
|
||||
@Override
|
||||
public void initWidget() {
|
||||
super.initWidget();
|
||||
registerWidget(RoomGameplayListWidget.class.getSimpleName(), gameBinding.gameplayListWidget);
|
||||
registerWidget(RoomGameplayWidget.class.getSimpleName(), gameBinding.gameplayWidget);
|
||||
}
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
|
@@ -6,13 +6,13 @@ import androidx.constraintlayout.widget.ConstraintLayout
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.core.view.updateLayoutParams
|
||||
import androidx.databinding.DataBindingUtil
|
||||
import com.chwl.library.base.factory.CreatePresenter
|
||||
import com.netease.nim.uikit.common.util.sys.ScreenUtil
|
||||
import com.chwl.app.R
|
||||
import com.chwl.app.avroom.adapter.OnMicroItemClickListener
|
||||
import com.chwl.app.avroom.adapter.SingleAnchorMicroViewAdapter
|
||||
import com.chwl.app.avroom.adapter.SingleRoomPKMicroViewAdapter
|
||||
import com.chwl.app.avroom.dialog.RequestUpMicDialog
|
||||
import com.chwl.app.avroom.gameplay.RoomGameplayListWidget
|
||||
import com.chwl.app.avroom.gameplay.RoomGameplayWidget
|
||||
import com.chwl.app.avroom.presenter.SingleRoomPresenter
|
||||
import com.chwl.app.avroom.singleroompk.SingleRoomPkFinishDialog
|
||||
import com.chwl.app.avroom.singleroompk.SingleRoomPkForceFinishDialog
|
||||
@@ -25,6 +25,8 @@ import com.chwl.core.im.custom.bean.RoomPKAttachment
|
||||
import com.chwl.core.manager.AvRoomDataManager
|
||||
import com.chwl.core.manager.RoomEvent
|
||||
import com.chwl.core.user.bean.UserInfo
|
||||
import com.chwl.library.base.factory.CreatePresenter
|
||||
import com.netease.nim.uikit.common.util.sys.ScreenUtil
|
||||
|
||||
/**
|
||||
* 個播房間
|
||||
@@ -133,6 +135,11 @@ class SingleRoomFragment : BaseRoomFragment<ISingleRoomView?, SingleRoomPresente
|
||||
|
||||
override fun initWidget() {
|
||||
super.initWidget()
|
||||
registerWidget(
|
||||
RoomGameplayListWidget::class.java.simpleName,
|
||||
gameBinding.gameplayListWidget
|
||||
)
|
||||
registerWidget(RoomGameplayWidget::class.java.simpleName, gameBinding.gameplayWidget)
|
||||
}
|
||||
|
||||
override fun onInitMusicPlayerView(view: MusicPlayerView) {
|
||||
|
@@ -0,0 +1,22 @@
|
||||
package com.chwl.app.avroom.gameplay
|
||||
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import android.view.MotionEvent
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
|
||||
|
||||
class GameplayRecyclerView : RecyclerView {
|
||||
constructor(context: Context) : super(context)
|
||||
constructor(context: Context, attrs: AttributeSet?) : super(context, attrs)
|
||||
constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : super(
|
||||
context,
|
||||
attrs,
|
||||
defStyleAttr
|
||||
)
|
||||
|
||||
override fun onInterceptTouchEvent(e: MotionEvent?): Boolean {
|
||||
parent.requestDisallowInterceptTouchEvent(true)
|
||||
return super.onInterceptTouchEvent(e)
|
||||
}
|
||||
}
|
@@ -0,0 +1,66 @@
|
||||
package com.chwl.app.avroom.gameplay
|
||||
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import android.view.LayoutInflater
|
||||
import android.view.ViewConfiguration
|
||||
import androidx.databinding.DataBindingUtil
|
||||
import com.chwl.core.support.room.FrameLayoutRoomWidget
|
||||
import com.chwl.app.R
|
||||
import com.chwl.app.databinding.RoomGameplayListWidgetBinding
|
||||
import com.chwl.core.room.bean.RoomIcon
|
||||
|
||||
class RoomGameplayListWidget : FrameLayoutRoomWidget {
|
||||
private val adapter = RoomPlayListAdapter()
|
||||
private val binding: RoomGameplayListWidgetBinding =
|
||||
DataBindingUtil.inflate(
|
||||
LayoutInflater.from(
|
||||
context
|
||||
), R.layout.room_gameplay_list_widget, this, true
|
||||
)
|
||||
|
||||
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 {
|
||||
binding.recyclerView.adapter = adapter
|
||||
binding.ivSwitch.setOnClickListener {
|
||||
getGameplayIconWidget()?.switchUI(false)
|
||||
}
|
||||
adapter.setOnItemClickListener { adapter, view, position ->
|
||||
(adapter.getItem(position) as? RoomIcon)?.let {
|
||||
getGameplayIconWidget()?.jump(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun getGameplayIconWidget(): RoomGameplayWidget? {
|
||||
return roomView?.findWidget(
|
||||
RoomGameplayWidget::class.simpleName ?: ""
|
||||
) as? RoomGameplayWidget
|
||||
}
|
||||
|
||||
fun loadData(list: List<RoomIcon>) {
|
||||
adapter.setNewData(list)
|
||||
if (list.size > 6) {
|
||||
binding.recyclerView.isScrollbarFadingEnabled = false
|
||||
binding.recyclerView.scrollBarFadeDuration = 0
|
||||
} else {
|
||||
binding.recyclerView.isScrollbarFadingEnabled = true
|
||||
binding.recyclerView.scrollBarFadeDuration =
|
||||
ViewConfiguration.getScrollBarFadeDuration()
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,119 @@
|
||||
package com.chwl.app.avroom.gameplay
|
||||
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.databinding.DataBindingUtil
|
||||
import com.chwl.app.R
|
||||
import com.chwl.app.databinding.RoomGameplayWidgetBinding
|
||||
import com.chwl.app.treasure_box.widget.GoldBoxHelper
|
||||
import com.chwl.app.ui.utils.load
|
||||
import com.chwl.app.ui.webview.CommonWebViewActivity
|
||||
import com.chwl.app.ui.webview.room_banner.RoomWebDialogActivity
|
||||
import com.chwl.app.utils.CommonJumpHelper
|
||||
import com.chwl.core.room.bean.RoomIcon
|
||||
import com.chwl.core.room.model.AvRoomModel
|
||||
import com.chwl.core.support.room.FrameLayoutRoomWidget
|
||||
import com.chwl.core.support.room.RoomContext
|
||||
import com.chwl.core.support.room.RoomView
|
||||
import com.example.lib_utils.ktx.singleClick
|
||||
|
||||
|
||||
class RoomGameplayWidget : FrameLayoutRoomWidget {
|
||||
private val binding: RoomGameplayWidgetBinding =
|
||||
DataBindingUtil.inflate(
|
||||
LayoutInflater.from(
|
||||
context
|
||||
), R.layout.room_gameplay_widget, this, true
|
||||
)
|
||||
|
||||
private var isOpened = false
|
||||
|
||||
private var list: List<RoomIcon>? = 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 {
|
||||
binding.ivSwitch.setOnClickListener {
|
||||
switchUI(!isOpened)
|
||||
}
|
||||
binding.ivIcon.singleClick {
|
||||
list?.getOrNull(0)?.let {
|
||||
jump(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onInitialize(roomView: RoomView, roomContext: RoomContext) {
|
||||
super.onInitialize(roomView, roomContext)
|
||||
refreshData()
|
||||
}
|
||||
|
||||
private fun refreshData() {
|
||||
val disposable = AvRoomModel.get().roomGamePlayList
|
||||
.subscribe { list: List<RoomIcon> ->
|
||||
loadData(list)
|
||||
}
|
||||
getCompositeDisposable().add(disposable)
|
||||
}
|
||||
|
||||
fun switchUI(openListWidget: Boolean) {
|
||||
this.isOpened = openListWidget
|
||||
if (openListWidget) {
|
||||
this.visibility = View.INVISIBLE
|
||||
getGameplayListWidget()?.visibility = View.VISIBLE
|
||||
} else {
|
||||
this.visibility = View.VISIBLE
|
||||
getGameplayListWidget()?.visibility = View.GONE
|
||||
}
|
||||
}
|
||||
|
||||
private fun loadData(list: List<RoomIcon>) {
|
||||
this.list = list
|
||||
this.isVisible = list.isNotEmpty()
|
||||
val listWidget = getGameplayListWidget()
|
||||
if (list.isEmpty()) {
|
||||
listWidget?.isVisible = false
|
||||
}
|
||||
listWidget?.loadData(list)
|
||||
binding.ivIcon.load(list.firstOrNull()?.icon)
|
||||
}
|
||||
|
||||
fun jump(data: RoomIcon) {
|
||||
if (data.isFindLove()) {
|
||||
GoldBoxHelper.handleBoxClick(context)
|
||||
} else {
|
||||
val url = data.skipContent
|
||||
if (data.skipType == 3 && !url.isNullOrEmpty()) {
|
||||
if (data.showType == 2) {
|
||||
RoomWebDialogActivity.start(context, url, false)
|
||||
} else {
|
||||
CommonWebViewActivity.start(context, url)
|
||||
}
|
||||
} else {
|
||||
CommonJumpHelper.bannerJump(context, data)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun getGameplayListWidget(): RoomGameplayListWidget? {
|
||||
return roomView?.findWidget(
|
||||
RoomGameplayListWidget::class.simpleName ?: ""
|
||||
) as? RoomGameplayListWidget
|
||||
}
|
||||
}
|
@@ -0,0 +1,16 @@
|
||||
package com.chwl.app.avroom.gameplay
|
||||
|
||||
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.load
|
||||
import com.chwl.core.room.bean.RoomIcon
|
||||
|
||||
|
||||
class RoomPlayListAdapter :
|
||||
BaseQuickAdapter<RoomIcon, BaseViewHolder>(R.layout.room_gameplay_item) {
|
||||
override fun convert(helper: BaseViewHolder, item: RoomIcon?) {
|
||||
helper.getView<ImageView>(R.id.iv_icon).load(item?.icon)
|
||||
}
|
||||
}
|
@@ -38,7 +38,7 @@ public class DialogWebViewActivity extends CommonWebViewActivity {
|
||||
View topView = findViewById(R.id.v_top);
|
||||
topView.setOnClickListener(v -> finish());
|
||||
ViewGroup.LayoutParams params = topView.getLayoutParams();
|
||||
params.height = ScreenUtil.screenHeight / 3;
|
||||
params.height = getTopMargin();
|
||||
topView.setLayoutParams(params);
|
||||
showTitleBar = getIntent().getBooleanExtra("showTitleBar", true);
|
||||
if (!showTitleBar) {
|
||||
@@ -50,4 +50,8 @@ public class DialogWebViewActivity extends CommonWebViewActivity {
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_dialog_web_view;
|
||||
}
|
||||
|
||||
protected int getTopMargin() {
|
||||
return ScreenUtil.screenHeight / 3;
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,26 @@
|
||||
package com.chwl.app.ui.webview.room_banner
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import com.chwl.app.ui.webview.DialogWebViewActivity
|
||||
import com.chwl.app.ui.widget.rollviewpager.Util
|
||||
|
||||
/**
|
||||
* Created by Max on 2024/2/20 17:47
|
||||
* Desc:房间半屏Web弹窗
|
||||
**/
|
||||
class RoomWebDialogActivity : DialogWebViewActivity() {
|
||||
|
||||
companion object {
|
||||
fun start(context: Context, url: String, showTitleBar: Boolean) {
|
||||
val intent = Intent(context, RoomWebDialogActivity::class.java)
|
||||
intent.putExtra("url", url)
|
||||
intent.putExtra("showTitleBar", showTitleBar)
|
||||
context.startActivity(intent)
|
||||
}
|
||||
}
|
||||
|
||||
override fun getTopMargin(): Int {
|
||||
return Util.dip2px(this, 168f)
|
||||
}
|
||||
}
|
@@ -13,8 +13,8 @@ import android.text.TextUtils;
|
||||
import com.chwl.app.avroom.activity.AVRoomActivity;
|
||||
import com.chwl.app.ui.im.RouterHandler;
|
||||
import com.chwl.app.ui.webview.CommonWebViewActivity;
|
||||
import com.chwl.core.home.bean.IRouterData;
|
||||
import com.chwl.library.utils.JavaUtil;
|
||||
import com.nnbc123.core.home.bean.IRouterData;
|
||||
|
||||
/**
|
||||
* 用于banner做通用跳转
|
||||
|
@@ -0,0 +1,14 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="14dp"
|
||||
android:height="14dp"
|
||||
android:viewportWidth="14"
|
||||
android:viewportHeight="14">
|
||||
<path
|
||||
android:pathData="M9.852,7.389C10.049,7.174 10.049,6.826 9.852,6.611L4.861,1.161C4.664,0.946 4.345,0.946 4.148,1.161C3.951,1.376 3.951,1.725 4.148,1.94L8.783,7L4.148,12.06C3.951,12.275 3.951,12.624 4.148,12.839C4.345,13.054 4.664,13.054 4.861,12.839L9.852,7.389Z"
|
||||
android:strokeAlpha="0.90000004"
|
||||
android:strokeWidth="0.4"
|
||||
android:fillColor="#FFFFFF"
|
||||
android:strokeColor="#FFFFFF"
|
||||
android:fillType="evenOdd"
|
||||
android:fillAlpha="0.90000004"/>
|
||||
</vector>
|
@@ -0,0 +1,14 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="14dp"
|
||||
android:height="14dp"
|
||||
android:viewportWidth="14"
|
||||
android:viewportHeight="14">
|
||||
<path
|
||||
android:pathData="M4.148,7.389C3.951,7.174 3.951,6.826 4.148,6.611L9.139,1.161C9.336,0.946 9.655,0.946 9.852,1.161C10.049,1.376 10.049,1.725 9.852,1.94L5.217,7L9.852,12.06C10.049,12.275 10.049,12.624 9.852,12.839C9.655,13.054 9.336,13.054 9.139,12.839L4.148,7.389Z"
|
||||
android:strokeAlpha="0.90000004"
|
||||
android:strokeWidth="0.4"
|
||||
android:fillColor="#FFFFFF"
|
||||
android:strokeColor="#FFFFFF"
|
||||
android:fillType="evenOdd"
|
||||
android:fillAlpha="0.90000004"/>
|
||||
</vector>
|
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
|
||||
<item android:state_pressed="true" android:drawable="@drawable/auto_open_honour_box_pressed"/>
|
||||
<item android:state_focused="true" android:drawable="@drawable/auto_open_honour_box_pressed"/>
|
||||
<item android:drawable="@drawable/auto_open_honour_box_normal"/>
|
||||
</selector>
|
9
app/src/main/res/drawable/room_gameplay_bg.xml
Normal file
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
|
||||
<stroke
|
||||
android:width="2px"
|
||||
android:color="#CCFFFFFF" />
|
||||
<corners android:radius="@dimen/dp_12" />
|
||||
</shape>
|
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
<solid android:color="#4D4D4D" />
|
||||
<corners android:radius="8dp" />
|
||||
</shape>
|
14
app/src/main/res/drawable/room_gameplay_ic_arrow_left.xml
Normal file
@@ -0,0 +1,14 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="14dp"
|
||||
android:height="14dp"
|
||||
android:viewportWidth="14"
|
||||
android:viewportHeight="14">
|
||||
<path
|
||||
android:pathData="M4.148,7.389C3.951,7.174 3.951,6.826 4.148,6.611L9.139,1.161C9.336,0.946 9.655,0.946 9.852,1.161C10.049,1.376 10.049,1.725 9.852,1.94L5.217,7L9.852,12.06C10.049,12.275 10.049,12.624 9.852,12.839C9.655,13.054 9.336,13.054 9.139,12.839L4.148,7.389Z"
|
||||
android:strokeAlpha="0.90000004"
|
||||
android:strokeWidth="0.4"
|
||||
android:fillColor="#FFFFFF"
|
||||
android:strokeColor="#FFFFFF"
|
||||
android:fillType="evenOdd"
|
||||
android:fillAlpha="0.90000004"/>
|
||||
</vector>
|
14
app/src/main/res/drawable/room_gameplay_ic_arrow_right.xml
Normal file
@@ -0,0 +1,14 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="14dp"
|
||||
android:height="14dp"
|
||||
android:viewportWidth="14"
|
||||
android:viewportHeight="14">
|
||||
<path
|
||||
android:pathData="M9.852,7.389C10.049,7.174 10.049,6.826 9.852,6.611L4.861,1.161C4.664,0.946 4.345,0.946 4.148,1.161C3.951,1.376 3.951,1.725 4.148,1.94L8.783,7L4.148,12.06C3.951,12.275 3.951,12.624 4.148,12.839C4.345,13.054 4.664,13.054 4.861,12.839L9.852,7.389Z"
|
||||
android:strokeAlpha="0.90000004"
|
||||
android:strokeWidth="0.4"
|
||||
android:fillColor="#FFFFFF"
|
||||
android:strokeColor="#FFFFFF"
|
||||
android:fillType="evenOdd"
|
||||
android:fillAlpha="0.90000004"/>
|
||||
</vector>
|
5
app/src/main/res/drawable/selector_choose_box_bg.xml
Normal file
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:drawable="@drawable/choose_box_bg_disable" android:state_enabled="false" />
|
||||
<item android:drawable="@drawable/choose_box_bg" android:state_enabled="true" />
|
||||
</selector>
|
7
app/src/main/res/drawable/shape_99727272_7dp.xml
Normal file
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
|
||||
<solid android:color="#99727272" />
|
||||
<corners android:radius="@dimen/dp_7" />
|
||||
</shape>
|
78
app/src/main/res/layout/box_ranking_list_item.xml
Normal file
@@ -0,0 +1,78 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/dp_60"
|
||||
android:orientation="horizontal"
|
||||
android:paddingStart="@dimen/dp_0"
|
||||
android:paddingEnd="@dimen/dp_15">
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="center"
|
||||
android:layout_weight="0.3"
|
||||
android:paddingStart="@dimen/dp_8"
|
||||
android:paddingEnd="@dimen/dp_0">
|
||||
|
||||
<androidx.appcompat.widget.AppCompatImageView
|
||||
android:id="@+id/iv_position"
|
||||
android:layout_width="@dimen/dp_20"
|
||||
android:layout_height="@dimen/dp_20"
|
||||
android:layout_gravity="center" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:id="@+id/tv_position"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:gravity="center"
|
||||
android:textColor="@color/color_white"
|
||||
android:textSize="@dimen/sp_18"
|
||||
android:textStyle="bold"
|
||||
tools:text="100" />
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
<com.chwl.app.ui.widget.NobleAvatarView
|
||||
android:id="@+id/noble_avatar_view"
|
||||
android:layout_width="50dp"
|
||||
android:layout_height="50dp"
|
||||
android:layout_gravity="center_vertical" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginStart="@dimen/dp_14"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="vertical">
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:id="@+id/tv_userName"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:ellipsize="end"
|
||||
android:lines="1"
|
||||
android:textColor="@color/color_white"
|
||||
android:textSize="@dimen/sp_14"
|
||||
app:layout_flexShrink="1"
|
||||
tools:text="@string/layout_box_ranking_list_item_01" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:id="@+id/tv_amount"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_weight="0.7"
|
||||
android:drawablePadding="5dp"
|
||||
android:gravity="end"
|
||||
android:textColor="@color/color_F8FF7B"
|
||||
android:textSize="@dimen/sp_15"
|
||||
tools:text="1236843"
|
||||
app:drawableEndCompat="@drawable/treasure_box_diamond" />
|
||||
|
||||
</LinearLayout>
|
@@ -119,7 +119,7 @@
|
||||
android:id="@+id/message_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_above="@+id/bottom_view"
|
||||
android:layout_above="@id/bottom_view"
|
||||
android:layout_below="@id/micro_view"
|
||||
android:layout_marginStart="12dp"
|
||||
android:layout_marginTop="@dimen/dp_5"
|
||||
@@ -162,6 +162,26 @@
|
||||
tools:contentDescription="@string/layout_fragment_av_room_game_05"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<com.chwl.app.avroom.gameplay.RoomGameplayWidget
|
||||
android:id="@+id/gameplay_widget"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_above="@id/bottom_view"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_marginEnd="6dp"
|
||||
android:layout_marginBottom="10dp"
|
||||
android:visibility="gone"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<com.chwl.app.avroom.gameplay.RoomGameplayListWidget
|
||||
android:id="@+id/gameplay_list_widget"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignEnd="@id/gameplay_widget"
|
||||
android:layout_alignBottom="@id/gameplay_widget"
|
||||
android:visibility="gone"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
19
app/src/main/res/layout/fragment_newbie_list.xml
Normal file
@@ -0,0 +1,19 @@
|
||||
<com.chwl.app.common.widget.StatusLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/status_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
||||
android:id="@+id/swipe_refresh"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:paddingTop="2dp"
|
||||
android:id="@+id/recycler_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
|
||||
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
|
||||
|
||||
</com.chwl.app.common.widget.StatusLayout>
|
@@ -2,7 +2,7 @@
|
||||
<layout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
tools:context="com.yizhuan.erban.avroom.fragment.SingleRoomFragment">
|
||||
tools:context="com.chwl.app.avroom.fragment.SingleRoomFragment">
|
||||
|
||||
<data>
|
||||
|
||||
@@ -85,6 +85,26 @@
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/barrier_micro" />
|
||||
|
||||
<com.chwl.app.avroom.gameplay.RoomGameplayWidget
|
||||
android:id="@+id/gameplay_widget"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="6dp"
|
||||
android:layout_marginBottom="6dp"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintBottom_toTopOf="@id/bottom_view"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<com.chwl.app.avroom.gameplay.RoomGameplayListWidget
|
||||
android:id="@+id/gameplay_list_widget"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintBottom_toBottomOf="@id/gameplay_widget"
|
||||
app:layout_constraintEnd_toEndOf="@id/gameplay_widget"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/input_layout"
|
||||
android:layout_width="0dp"
|
||||
|
18
app/src/main/res/layout/room_gameplay_item.xml
Normal file
@@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="@dimen/dp_4"
|
||||
android:background="@drawable/shape_99727272_7dp">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_icon"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:scaleType="centerCrop"
|
||||
app:layout_constraintDimensionRatio="1:1"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
68
app/src/main/res/layout/room_gameplay_list_widget.xml
Normal file
@@ -0,0 +1,68 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layout>
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
tools:background="@color/black">
|
||||
|
||||
<androidx.cardview.widget.CardView
|
||||
android:id="@+id/layout_content"
|
||||
android:layout_width="@dimen/dp_180"
|
||||
android:layout_height="@dimen/dp_124"
|
||||
app:cardBackgroundColor="@color/transparent"
|
||||
app:cardCornerRadius="@dimen/dp_12"
|
||||
app:cardElevation="0px"
|
||||
app:cardMaxElevation="0px"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<com.github.mmin18.widget.RealtimeBlurView
|
||||
android:id="@+id/blur_view_icon"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:realtimeBlurRadius="15dp"
|
||||
app:realtimeDownsampleFactor="4"
|
||||
app:realtimeOverlayColor="#50000000" />
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@drawable/room_gameplay_bg" />
|
||||
|
||||
<com.chwl.app.avroom.gameplay.GameplayRecyclerView
|
||||
android:id="@+id/recyclerView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginVertical="@dimen/dp_4"
|
||||
android:orientation="vertical"
|
||||
android:paddingHorizontal="@dimen/dp_4"
|
||||
android:fadeScrollbars="false"
|
||||
android:scrollbarSize="3dp"
|
||||
android:scrollbarStyle="outsideOverlay"
|
||||
android:scrollbarThumbVertical="@drawable/room_gameplay_bg_scrollbar_thumb"
|
||||
android:scrollbars="vertical"
|
||||
app:layoutManager="androidx.recyclerview.widget.GridLayoutManager"
|
||||
app:spanCount="3" />
|
||||
|
||||
</androidx.cardview.widget.CardView>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_switch"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="-5dp"
|
||||
android:paddingVertical="@dimen/dp_15"
|
||||
android:paddingStart="@dimen/dp_15"
|
||||
android:paddingEnd="6dp"
|
||||
android:scaleType="centerInside"
|
||||
android:src="@drawable/room_gameplay_ic_arrow_right"
|
||||
app:layout_constraintBottom_toBottomOf="@id/layout_content"
|
||||
app:layout_constraintEnd_toStartOf="@id/layout_content"
|
||||
app:layout_constraintTop_toTopOf="@id/layout_content" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
</layout>
|
61
app/src/main/res/layout/room_gameplay_widget.xml
Normal file
@@ -0,0 +1,61 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layout>
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
tools:background="@color/black">
|
||||
|
||||
<androidx.cardview.widget.CardView
|
||||
android:id="@+id/layout_content"
|
||||
android:layout_width="@dimen/dp_66"
|
||||
android:layout_height="@dimen/dp_66"
|
||||
app:cardBackgroundColor="@color/transparent"
|
||||
app:cardCornerRadius="@dimen/dp_12"
|
||||
app:cardElevation="0px"
|
||||
app:cardMaxElevation="0px"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent">
|
||||
|
||||
<com.github.mmin18.widget.RealtimeBlurView
|
||||
android:id="@+id/blur_view_icon"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:realtimeBlurRadius="25dp"
|
||||
app:realtimeDownsampleFactor="4"
|
||||
app:realtimeOverlayColor="#80000000" />
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@drawable/room_gameplay_bg" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_icon"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_margin="@dimen/dp_4"
|
||||
android:scaleType="centerCrop"
|
||||
tools:src="@drawable/default_cover" />
|
||||
|
||||
</androidx.cardview.widget.CardView>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_switch"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="-5dp"
|
||||
android:paddingVertical="@dimen/dp_15"
|
||||
android:paddingStart="@dimen/dp_15"
|
||||
android:paddingEnd="6dp"
|
||||
android:scaleType="centerInside"
|
||||
android:src="@drawable/room_gameplay_ic_arrow_left"
|
||||
app:layout_constraintBottom_toBottomOf="@id/layout_content"
|
||||
app:layout_constraintEnd_toStartOf="@id/layout_content"
|
||||
app:layout_constraintTop_toTopOf="@id/layout_content" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
</layout>
|
@@ -206,6 +206,9 @@
|
||||
|
||||
</style>
|
||||
|
||||
<style name="room_dialog_web_view_activity" parent="dialog_web_view_activity">
|
||||
<item name="android:backgroundDimEnabled">false</item>
|
||||
</style>
|
||||
|
||||
<style name="FullScreenDialog" parent="@android:style/Theme.Dialog">
|
||||
<!--<item name="android:windowBackground">@drawable/filled_activity_bg</item>-->
|
||||
|
@@ -16,6 +16,7 @@
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<ImageView
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
android:id="@+id/iv_back"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
@@ -38,6 +39,7 @@
|
||||
app:tl_textsize="@dimen/dp_18" />
|
||||
|
||||
<ImageView
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
android:id="@+id/iv_more"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
@@ -0,0 +1,52 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/root_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:background="@color/color_666666">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="360dp"
|
||||
android:layout_gravity="bottom"
|
||||
android:background="@drawable/bg_treasure_box_20"
|
||||
android:orientation="vertical">
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<com.flyco.tablayout.SlidingTabLayout
|
||||
android:id="@+id/view_indicator"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="46dp"
|
||||
app:tl_indicator_color="@color/color_white"
|
||||
app:tl_indicator_corner_radius="2dp"
|
||||
app:tl_indicator_height="@dimen/dp_4"
|
||||
app:tl_indicator_width="@dimen/dp_13"
|
||||
app:tl_tab_space_equal="true"
|
||||
app:tl_textSelectColor="@color/color_white"
|
||||
app:tl_textUnselectColor="@color/white_transparent_50"
|
||||
app:tl_textsize="@dimen/sp_16" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_refresh"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="end"
|
||||
android:paddingStart="@dimen/dp_15"
|
||||
android:paddingEnd="@dimen/dp_15"
|
||||
android:src="@drawable/ic_refresh" />
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
<androidx.viewpager.widget.ViewPager
|
||||
android:id="@+id/viewpager"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</FrameLayout>
|
@@ -0,0 +1,100 @@
|
||||
package com.chwl.app.treasure_box.activity;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import com.chwl.app.R;
|
||||
import com.chwl.app.base.BaseViewBindingActivity;
|
||||
import com.chwl.app.common.ViewPagerAdapter;
|
||||
import com.chwl.app.databinding.ActivityRoomBoxRankingBinding;
|
||||
import com.chwl.app.decoration.view.widgets.CarMagicIndicator;
|
||||
import com.chwl.app.room_chat.event.ClickRootViewEvent;
|
||||
import com.chwl.app.treasure_box.fragment.BoxRankingFragment;
|
||||
import com.chwl.core.home.bean.TabInfo;
|
||||
import com.chwl.core.manager.IMNetEaseManager;
|
||||
import com.chwl.core.manager.RoomEvent;
|
||||
import com.chwl.core.room.treasure_box.event.RefreshBoxRankingEvent;
|
||||
import com.chwl.library.utils.ResUtil;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class BoxRankingActivity extends BaseViewBindingActivity<ActivityRoomBoxRankingBinding>
|
||||
implements CarMagicIndicator.OnItemSelectListener, View.OnClickListener {
|
||||
|
||||
private final String[] titles = {ResUtil.getString(R.string.treasure_box_activity_boxrankingactivity_01), ResUtil.getString(R.string.treasure_box_activity_boxrankingactivity_02)};
|
||||
public static final int TYPE_TODAY = 1;//今日
|
||||
public static final int TYPE_YESTERDAY = 2;//今日
|
||||
|
||||
|
||||
public static void start(Context context) {
|
||||
Intent starter = new Intent(context, BoxRankingActivity.class);
|
||||
context.startActivity(starter);
|
||||
}
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
public void init() {
|
||||
EventBus.getDefault().register(this);
|
||||
|
||||
binding.rootView.setOnClickListener(this);
|
||||
|
||||
List<TabInfo> tabInfoList = new ArrayList<>(2);
|
||||
for (int i = 0; i < titles.length; i++) {
|
||||
tabInfoList.add(new TabInfo(i, titles[i]));
|
||||
}
|
||||
binding.viewpager.setOffscreenPageLimit(2);
|
||||
binding.viewpager.setAdapter(new ViewPagerAdapter(getSupportFragmentManager(), getFragment(), titles));
|
||||
binding.viewIndicator.setViewPager(binding.viewpager, titles, this, getFragment());
|
||||
|
||||
IMNetEaseManager.get().getChatRoomEventObservable()
|
||||
.compose(bindToLifecycle())
|
||||
.filter(roomEvent -> roomEvent.getEvent() == RoomEvent.KICK_OUT_ROOM)
|
||||
.subscribe(roomEvent -> finish());
|
||||
|
||||
binding.ivRefresh.setOnClickListener(v -> EventBus.getDefault().post(new RefreshBoxRankingEvent()));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean needSteepStateBar() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
EventBus.getDefault().unregister(this);
|
||||
}
|
||||
|
||||
private ArrayList<Fragment> getFragment() {
|
||||
ArrayList<Fragment> list = new ArrayList<>();
|
||||
list.add(BoxRankingFragment.newInstance(TYPE_TODAY));
|
||||
list.add(BoxRankingFragment.newInstance(TYPE_YESTERDAY));
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onItemSelect(int position) {
|
||||
binding.viewpager.setCurrentItem(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if(view.getId() == R.id.root_view){
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onRootViewClicked(ClickRootViewEvent event) {
|
||||
finish();
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,539 @@
|
||||
package com.chwl.app.treasure_box.activity;
|
||||
|
||||
import static com.chwl.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_BOX;
|
||||
import static com.chwl.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_LUCKY_GIFT;
|
||||
import static com.chwl.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_LUCKY_GIFT_SERVER_ALL;
|
||||
import static com.chwl.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_LUCKY_GIFT_SERVER_NOTIFY;
|
||||
import static com.chwl.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_LUCKY_SEA;
|
||||
import static com.chwl.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_LUCKY_SEA_GIFT_SERVER_ALL;
|
||||
import static com.chwl.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_BOX_ALL_ROOM_NOTIFY_BY_SVGA;
|
||||
import static com.chwl.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_TEMPLATE_NOTIFY;
|
||||
import static com.chwl.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_TEMPLATE_NOTIFY_ALL;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.animation.AnimatorListenerAdapter;
|
||||
import android.animation.ObjectAnimator;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.text.Editable;
|
||||
import android.text.TextUtils;
|
||||
import android.text.TextWatcher;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.WindowManager;
|
||||
import android.view.animation.AccelerateDecelerateInterpolator;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.google.gson.Gson;
|
||||
import com.hjq.toast.ToastUtils;
|
||||
import com.netease.nim.uikit.StatusBarUtil;
|
||||
import com.netease.nim.uikit.common.util.sys.ScreenUtil;
|
||||
import com.netease.nimlib.sdk.chatroom.ChatRoomMessageBuilder;
|
||||
import com.netease.nimlib.sdk.chatroom.model.ChatRoomMessage;
|
||||
import com.chwl.app.R;
|
||||
import com.chwl.app.base.BaseBindingActivity;
|
||||
import com.chwl.app.databinding.ActivityTreasureBoxBinding;
|
||||
import com.chwl.app.treasure_box.widget.dialog.BoxLoveLackDialog;
|
||||
import com.chwl.app.treasure_box.widget.dialog.BoxMoreDialog;
|
||||
import com.chwl.app.treasure_box.widget.dialog.BuyLoveDialog;
|
||||
import com.chwl.app.treasure_box.widget.dialog.TreasureBoxDialog;
|
||||
import com.chwl.app.ui.utils.ImageLoadUtils;
|
||||
import com.chwl.app.utils.KeyBoardUtils;
|
||||
import com.chwl.app.utils.UserUtils;
|
||||
import com.chwl.core.treasure_box.bean.PrizeNewInfo;
|
||||
import com.chwl.core.treasure_box.bean.UserTicketInfo;
|
||||
import com.chwl.core.treasure_box.model.BoxModel;
|
||||
import com.chwl.core.DemoCache;
|
||||
import com.chwl.core.auth.AuthModel;
|
||||
import com.chwl.core.bean.BaseProtocol;
|
||||
import com.chwl.core.exception.FailReasonException;
|
||||
import com.chwl.core.gift.bean.LuckyBagNoticeInfo;
|
||||
import com.chwl.core.im.custom.bean.RoomBoxPrizeAttachment;
|
||||
import com.chwl.core.im.custom.bean.RoomBoxPrizeInfo;
|
||||
import com.chwl.core.im.custom.bean.RoomLuckySeaAttachment;
|
||||
import com.chwl.core.im.custom.bean.RoomLuckySeaMsgBean;
|
||||
import com.chwl.core.im.custom.bean.RoomReceivedLuckyGiftAttachment;
|
||||
import com.chwl.core.im.custom.bean.RoomTemplateNotifyAttachment;
|
||||
import com.chwl.core.im.custom.bean.RoomTemplateNotifyMsgBean;
|
||||
import com.chwl.core.manager.AvRoomDataManager;
|
||||
import com.chwl.core.manager.IMNetEaseManager;
|
||||
import com.chwl.core.manager.RoomEvent;
|
||||
import com.chwl.core.pay.PayModel;
|
||||
import com.chwl.core.pay.bean.WalletInfo;
|
||||
import com.chwl.core.room.bean.FindLoveSwitchVo;
|
||||
import com.chwl.library.annatation.ActLayoutRes;
|
||||
import com.chwl.library.common.SpConstants;
|
||||
import com.chwl.library.common.util.SPUtils;
|
||||
import com.chwl.library.utils.FormatUtils;
|
||||
import com.chwl.library.utils.ResUtil;
|
||||
import com.chwl.library.utils.SingleToastUtil;
|
||||
import com.chwl.library.utils.TimeUtils;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
|
||||
@ActLayoutRes(R.layout.activity_treasure_box)
|
||||
public class TreasureBoxActivity extends BaseBindingActivity<ActivityTreasureBoxBinding> implements View.OnClickListener {
|
||||
|
||||
public static final int MAX_BUY_QUANTITY_LIMIT = 99999;
|
||||
|
||||
private final Runnable removeRunnable = () -> mBinding.llPrizeHint.removeAllViews();
|
||||
private ArrayList<PrizeNewInfo> cacheList = new ArrayList<>();
|
||||
private ArrayList<PrizeNewInfo> hintPrizeCacheList = new ArrayList<>();
|
||||
private ObjectAnimator translationXAnimator;
|
||||
private ObjectAnimator translationYAnimator;
|
||||
private int height;
|
||||
private int sendMessageSwitchLevel;
|
||||
|
||||
private int mNum = -1;
|
||||
|
||||
private UserTicketInfo userTicketInfo;
|
||||
|
||||
public static void start(Context context) {
|
||||
Intent starter = new Intent(context, TreasureBoxActivity.class);
|
||||
context.startActivity(starter);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
//这里的height用MATCH_PARENT状态栏会被顶上去,不知道什么鬼
|
||||
height = ScreenUtil.screenHeight - ScreenUtil.getStatusBarHeight(context);
|
||||
getWindow().setLayout(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT);
|
||||
getWindow().setGravity(Gravity.BOTTOM);
|
||||
subscribeEvent();
|
||||
EventBus.getDefault().register(this);
|
||||
}
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
@Override
|
||||
protected void init() {
|
||||
mBinding.setClick(this);
|
||||
translationXAnimator = ObjectAnimator.ofFloat(mBinding.ivGiftAnim, "translationX", 0,
|
||||
ScreenUtil.screenWidth / 2f - ScreenUtil.dip2px(15 + 19)).setDuration(100);
|
||||
translationXAnimator.setInterpolator(new AccelerateDecelerateInterpolator());
|
||||
translationXAnimator.addListener(new AnimatorListenerAdapter() {
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
mBinding.ivGiftAnim.setVisibility(View.GONE);
|
||||
}
|
||||
});
|
||||
mBinding.ivBox.post(() -> {
|
||||
translationYAnimator = ObjectAnimator.ofFloat(mBinding.ivGiftAnim, "translationY", 0,
|
||||
height - (mBinding.ivBox.getBottom() + mBinding.ivBox.getTop()) / 2f - ScreenUtil.dip2px(10 + 19)).setDuration(100);
|
||||
translationYAnimator.setInterpolator(new AccelerateDecelerateInterpolator());
|
||||
});
|
||||
WalletInfo walletInfo = PayModel.get().getCurrentWalletInfo();
|
||||
if (walletInfo != null) {
|
||||
mBinding.tvDiamondNum.setText(FormatUtils.formatBigInteger(walletInfo.getDiamondNum()));
|
||||
}
|
||||
|
||||
mBinding.view1.setOnClickListener(v -> setBoxPriceSelect(1));
|
||||
mBinding.view2.setOnClickListener(v -> setBoxPriceSelect(2));
|
||||
mBinding.view3.setOnClickListener(v -> setBoxPriceSelect(3));
|
||||
|
||||
mBinding.edInputNum.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
try {
|
||||
mNum = Integer.parseInt(s.toString());
|
||||
if (mNum > MAX_BUY_QUANTITY_LIMIT) {
|
||||
mNum = MAX_BUY_QUANTITY_LIMIT;
|
||||
mBinding.edInputNum.setText(String.valueOf(mNum));
|
||||
mBinding.edInputNum.setSelection(mBinding.edInputNum.getText().length());
|
||||
SingleToastUtil.showToast(getString(R.string.treasure_box_activity_treasureboxactivity_01, MAX_BUY_QUANTITY_LIMIT));
|
||||
}
|
||||
setBoxPriceSelect(0);
|
||||
} catch (NumberFormatException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
mBinding.tvBuy.setOnClickListener(v -> {
|
||||
if (userTicketInfo == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (mNum == -1) {
|
||||
toast(getString(R.string.please_select_or_enter_the_quantity_of_hearts_purchased));
|
||||
return;
|
||||
}
|
||||
|
||||
long date = SPUtils.getLong(SpConstants.BOX_BUY_LOVE, 0L);
|
||||
if (date != 0L) {
|
||||
if (TimeUtils.isToday(date)) {
|
||||
BoxModel.get()
|
||||
.buyTicket(mNum)
|
||||
.compose(bindToLifecycle())
|
||||
.doOnError(throwable -> toast(throwable.getMessage()))
|
||||
.subscribe(userTicketInfo -> {
|
||||
ToastUtils.show("購買成功");
|
||||
onTickerInfoUpdated(userTicketInfo);
|
||||
});
|
||||
} else {
|
||||
BuyLoveDialog.Companion.newInstance(mNum, (int) userTicketInfo.getTicketPrice() * mNum).show(this);
|
||||
}
|
||||
} else {
|
||||
BuyLoveDialog.Companion.newInstance(mNum, (int) userTicketInfo.getTicketPrice() * mNum).show(this);
|
||||
}
|
||||
});
|
||||
|
||||
loadUserTicket();
|
||||
loadKeyInfo();
|
||||
looperPrize();
|
||||
looperHintPrize();
|
||||
|
||||
}
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
private void loadUserTicket() {
|
||||
BoxModel.get()
|
||||
.getUserTicket()
|
||||
.compose(bindToLifecycle())
|
||||
.subscribe(userTicketInfo -> onTickerInfoUpdated(userTicketInfo));
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onTickerInfoUpdated(UserTicketInfo userTicketInfo) {
|
||||
this.userTicketInfo = userTicketInfo;
|
||||
mBinding.tvBoxNum.setText(String.valueOf(userTicketInfo.getTicketNum()));
|
||||
}
|
||||
|
||||
private void setBoxPriceSelect(int pos) {
|
||||
if (pos == 0) {
|
||||
mBinding.view1.setSelected(false);
|
||||
mBinding.view2.setSelected(false);
|
||||
mBinding.view3.setSelected(false);
|
||||
mBinding.tv1.setAlpha(0.4f);
|
||||
mBinding.tv2.setAlpha(0.4f);
|
||||
mBinding.tv3.setAlpha(0.4f);
|
||||
return;
|
||||
}
|
||||
|
||||
mBinding.edInputNum.setText(null);
|
||||
KeyBoardUtils.hideKeyBoard(this, mBinding.edInputNum);
|
||||
mBinding.edInputNum.clearFocus();
|
||||
|
||||
if (pos == 1) {
|
||||
mNum = 1;
|
||||
mBinding.view1.setSelected(true);
|
||||
mBinding.view2.setSelected(false);
|
||||
mBinding.view3.setSelected(false);
|
||||
mBinding.tv1.setAlpha(1f);
|
||||
mBinding.tv2.setAlpha(0.4f);
|
||||
mBinding.tv3.setAlpha(0.4f);
|
||||
} else if (pos == 2) {
|
||||
mNum = 10;
|
||||
mBinding.view1.setSelected(false);
|
||||
mBinding.view2.setSelected(true);
|
||||
mBinding.view3.setSelected(false);
|
||||
mBinding.tv1.setAlpha(0.4f);
|
||||
mBinding.tv2.setAlpha(1f);
|
||||
mBinding.tv3.setAlpha(0.4f);
|
||||
} else if (pos == 3) {
|
||||
mNum = 100;
|
||||
mBinding.view1.setSelected(false);
|
||||
mBinding.view2.setSelected(false);
|
||||
mBinding.view3.setSelected(true);
|
||||
mBinding.tv1.setAlpha(0.4f);
|
||||
mBinding.tv2.setAlpha(0.4f);
|
||||
mBinding.tv3.setAlpha(1f);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint({"CheckResult", "ClickableViewAccessibility"})
|
||||
private void loadKeyInfo() {
|
||||
FindLoveSwitchVo findLoveSwitchVo = AvRoomDataManager.get().mFindLoveSwitchVo;
|
||||
if (findLoveSwitchVo == null) {
|
||||
return;
|
||||
}
|
||||
sendMessageSwitchLevel = findLoveSwitchVo.getSendMsgLevel();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
switch (v.getId()) {
|
||||
case R.id.root_view:
|
||||
finish();
|
||||
break;
|
||||
case R.id.iv_more:
|
||||
new BoxMoreDialog(context, sendMessageSwitchLevel).openDialog();
|
||||
break;
|
||||
case R.id.tv_rank:
|
||||
BoxRankingActivity.start(this);
|
||||
break;
|
||||
case R.id.iv_box_1:
|
||||
openBox(1);
|
||||
break;
|
||||
case R.id.iv_box_2:
|
||||
openBox(10);
|
||||
break;
|
||||
case R.id.iv_box_3:
|
||||
openBox(100);
|
||||
break;
|
||||
case R.id.view_bg:
|
||||
case R.id.iv_title:
|
||||
//do nothing
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
private void openBox(int count) {
|
||||
if (count == 0) {
|
||||
SingleToastUtil.showToast(ResUtil.getString(R.string.treasure_box_activity_treasureboxactivity_03));
|
||||
return;
|
||||
}
|
||||
if (count > Integer.parseInt(mBinding.tvBoxNum.getText().toString())) {
|
||||
if (userTicketInfo != null) {
|
||||
BoxLoveLackDialog.Companion.newInstance(count, (int) userTicketInfo.getTicketPrice()).show(context);
|
||||
}
|
||||
return;
|
||||
}
|
||||
boolean sendMessage = (sendMessageSwitchLevel != 0 && UserUtils.getExpLevel() < sendMessageSwitchLevel) || DemoCache.readNeedBoxMsg();
|
||||
setBoxEnable(false);
|
||||
mBinding.ivBoxOpen.startAnimation();
|
||||
long startTime = System.currentTimeMillis();
|
||||
BoxModel.get().openBoxDraw(count, sendMessage)
|
||||
.compose(bindToLifecycle())
|
||||
.doOnError(throwable -> {
|
||||
setBoxEnable(true);
|
||||
if (throwable instanceof FailReasonException) {
|
||||
FailReasonException failReasonException = (FailReasonException) throwable;
|
||||
if (failReasonException.getCode() == BoxModel.ERROR_CODE_DIAMOND) {
|
||||
TreasureBoxDialog.newInstance().show(this);
|
||||
} else {
|
||||
SingleToastUtil.showToast(throwable.getMessage());
|
||||
}
|
||||
} else {
|
||||
SingleToastUtil.showToast(throwable.getMessage());
|
||||
}
|
||||
})
|
||||
.toObservable()
|
||||
.delay(startTime - System.currentTimeMillis() + 300, TimeUnit.MILLISECONDS)
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.flatMap(openBoxResult -> {
|
||||
setBoxEnable(true);
|
||||
cacheList.addAll(openBoxResult);
|
||||
|
||||
if (userTicketInfo != null) {
|
||||
userTicketInfo.setTicketNum(userTicketInfo.getTicketNum() - count);
|
||||
mBinding.tvBoxNum.setText(String.valueOf(userTicketInfo.getTicketNum()));
|
||||
}
|
||||
loadUserTicket();
|
||||
|
||||
return Observable.fromIterable(openBoxResult);
|
||||
})
|
||||
.filter(prizeInfo -> prizeInfo.getLevel() > 2)
|
||||
.subscribe(prizeInfo -> {
|
||||
hintPrizeCacheList.add(prizeInfo);
|
||||
});
|
||||
}
|
||||
|
||||
private void setBoxEnable(boolean status) {
|
||||
mBinding.ivBox1.setEnabled(status);
|
||||
mBinding.ivBox2.setEnabled(status);
|
||||
mBinding.ivBox3.setEnabled(status);
|
||||
}
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
private void looperPrize() {
|
||||
Observable.interval(0, 100, TimeUnit.MILLISECONDS)
|
||||
.compose(bindToLifecycle())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.filter(aLong -> cacheList.size() > 0)
|
||||
.subscribe(aLong -> {
|
||||
PrizeNewInfo prizeInfo = cacheList.get(0);
|
||||
String url = prizeInfo.getPicUrl();
|
||||
if (cacheList.size() > 0) cacheList.remove(0);
|
||||
if (!TextUtils.isEmpty(url)) {
|
||||
if (translationXAnimator != null) translationXAnimator.start();
|
||||
if (translationYAnimator != null) translationYAnimator.start();
|
||||
mBinding.ivGiftAnim.setVisibility(View.VISIBLE);
|
||||
mBinding.svgaGiftBg.startAnimation();
|
||||
ImageLoadUtils.loadImage(context, url, mBinding.ivGiftAnim);
|
||||
}
|
||||
}
|
||||
, e -> looperPrize());//出错了继续looper......
|
||||
|
||||
}
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
private void looperHintPrize() {
|
||||
Observable.interval(0, 250, TimeUnit.MILLISECONDS)
|
||||
.compose(bindToLifecycle())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.filter(aLong -> hintPrizeCacheList.size() > 0)
|
||||
.subscribe(aLong -> addPrizeHintView(hintPrizeCacheList.remove(0))
|
||||
, e -> looperHintPrize());//出错了继续looper......
|
||||
}
|
||||
|
||||
private void addPrizeHintView(PrizeNewInfo prizeInfo) {
|
||||
mBinding.llPrizeHint.removeCallbacks(removeRunnable);
|
||||
mBinding.llPrizeHint.postDelayed(removeRunnable, 3000);
|
||||
LinearLayout linearLayout = (LinearLayout) LayoutInflater.from(this).inflate(R.layout.item_box_prize_hint, null);
|
||||
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ScreenUtil.dip2px(21));
|
||||
layoutParams.setMargins(0, 0, 0, ScreenUtil.dip2px(5));
|
||||
linearLayout.setLayoutParams(layoutParams);
|
||||
linearLayout.setPadding(ScreenUtil.dip2px(10), 0, ScreenUtil.dip2px(10), 0);
|
||||
mBinding.llPrizeHint.addView(linearLayout);
|
||||
if (mBinding.llPrizeHint.getChildCount() > 6) {
|
||||
mBinding.llPrizeHint.removeViewAt(0);
|
||||
}
|
||||
for (int i = 0; i < mBinding.llPrizeHint.getChildCount(); i++) {
|
||||
ObjectAnimator.ofFloat(mBinding.llPrizeHint.getChildAt(i), "translationY", ScreenUtil.dip2px(21), 0)
|
||||
.setDuration(200)
|
||||
.start();
|
||||
}
|
||||
|
||||
ImageLoadUtils.loadAvatar(prizeInfo.getPicUrl(), linearLayout.findViewById(R.id.iv_icon));
|
||||
((TextView) linearLayout.findViewById(R.id.tv_prize_name)).setText(prizeInfo.getRewardName());
|
||||
((TextView) linearLayout.findViewById(R.id.tv_diamond)).setText(String.valueOf(prizeInfo.getDiamonds()));
|
||||
((TextView) linearLayout.findViewById(R.id.tv_prize_num)).setText("x" + prizeInfo.getNum());
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新钱包
|
||||
*
|
||||
* @param g
|
||||
*/
|
||||
private void setGold(double g) {
|
||||
mBinding.tvDiamondNum.setText(FormatUtils.formatBigInteger(g));
|
||||
PayModel.get().getCurrentWalletInfo().setDiamondNum(g);
|
||||
}
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
private void subscribeEvent() {
|
||||
//更新钻石数量和被踢出房间退出
|
||||
IMNetEaseManager.get().getChatRoomEventObservable()
|
||||
.compose(bindToLifecycle())
|
||||
.subscribe(roomEvent -> {
|
||||
switch (roomEvent.getEvent()) {
|
||||
case RoomEvent.WALLET_UPDATE:
|
||||
loadKeyInfo();
|
||||
setGold(roomEvent.getWalletInfo().getDiamondNum());
|
||||
break;
|
||||
case RoomEvent.KICK_OUT_ROOM:
|
||||
finish();
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 接收到全局广播信息
|
||||
*
|
||||
* @param body 信息实体
|
||||
*/
|
||||
protected void onReceivedNimBroadcastMessage(String body) {
|
||||
BaseProtocol baseProtocol;
|
||||
try {
|
||||
baseProtocol = JSON.parseObject(body, BaseProtocol.class);
|
||||
} catch (Exception e) {
|
||||
baseProtocol = null;
|
||||
}
|
||||
if (baseProtocol == null) return;
|
||||
switch (baseProtocol.getFirst()) {
|
||||
case CUSTOM_MSG_BOX://寻爱之旅
|
||||
if (baseProtocol.getSecond() == CUSTOM_MSG_SUB_BOX_ALL_ROOM_NOTIFY_BY_SVGA) {
|
||||
RoomBoxPrizeAttachment roomBoxPrizeAttachment = new RoomBoxPrizeAttachment(CUSTOM_MSG_BOX, CUSTOM_MSG_SUB_BOX_ALL_ROOM_NOTIFY_BY_SVGA);
|
||||
RoomBoxPrizeInfo roomBoxPrizeBean = JSON.parseObject(String.valueOf(baseProtocol.getData()), RoomBoxPrizeInfo.class);
|
||||
roomBoxPrizeAttachment.setUid(roomBoxPrizeBean.getUid());
|
||||
roomBoxPrizeAttachment.setPrizeName(roomBoxPrizeBean.getPrizeName());
|
||||
roomBoxPrizeAttachment.setNick(roomBoxPrizeBean.getNick());
|
||||
roomBoxPrizeAttachment.setBoxTypeStr(roomBoxPrizeBean.getBoxTypeStr());
|
||||
roomBoxPrizeAttachment.setRoomUid(roomBoxPrizeBean.getRoomUid());
|
||||
roomBoxPrizeAttachment.setPrizeNum(roomBoxPrizeBean.getPrizeNum());
|
||||
roomBoxPrizeAttachment.setUserLevelLimit(roomBoxPrizeBean.getUserLevelLimit());
|
||||
if (AvRoomDataManager.get().isOpenPureMode()) {
|
||||
// 純凈模式打開後,僅能看跟自己相關的砸蛋消息
|
||||
if (Objects.equals(roomBoxPrizeAttachment.getUid(), AuthModel.get().getCurrentUid())) {
|
||||
ChatRoomMessage message = ChatRoomMessageBuilder.createChatRoomCustomMessage(String.valueOf(AvRoomDataManager.get().getRoomId()), roomBoxPrizeAttachment);
|
||||
IMNetEaseManager.get().addMessages(message);
|
||||
}
|
||||
} else {
|
||||
ChatRoomMessage message = ChatRoomMessageBuilder.createChatRoomCustomMessage(String.valueOf(AvRoomDataManager.get().getRoomId()), roomBoxPrizeAttachment);
|
||||
IMNetEaseManager.get().addMessages(message);
|
||||
IMNetEaseManager.get().getChatRoomEventObservable()
|
||||
.onNext(new RoomEvent()
|
||||
.setEvent(RoomEvent.BOX_NOTIFY_SVGA)
|
||||
.setChatRoomMessage(message));
|
||||
}
|
||||
}
|
||||
break;
|
||||
case CUSTOM_MSG_LUCKY_SEA://星级厨房
|
||||
if (baseProtocol.getSecond() == CUSTOM_MSG_LUCKY_SEA_GIFT_SERVER_ALL) {
|
||||
RoomLuckySeaAttachment attachment = new RoomLuckySeaAttachment(CUSTOM_MSG_LUCKY_SEA, CUSTOM_MSG_LUCKY_SEA_GIFT_SERVER_ALL);
|
||||
attachment.setRoomLuckySeaMsgBean(JSON.parseObject(String.valueOf(baseProtocol.getData()), RoomLuckySeaMsgBean.class));
|
||||
ChatRoomMessage message = ChatRoomMessageBuilder.createChatRoomCustomMessage(String.valueOf(AvRoomDataManager.get().getRoomId()), attachment);
|
||||
IMNetEaseManager.get().addMessages(message);
|
||||
IMNetEaseManager.get().noticeRoomEvent(message, RoomEvent.LUCKY_SEA_GIFT_SERVER_NOTIFY);
|
||||
}
|
||||
break;
|
||||
case CUSTOM_MSG_TEMPLATE_NOTIFY://通用飘屏
|
||||
if (baseProtocol.getSecond() == CUSTOM_MSG_TEMPLATE_NOTIFY_ALL) {
|
||||
RoomTemplateNotifyAttachment attachment = new RoomTemplateNotifyAttachment(CUSTOM_MSG_TEMPLATE_NOTIFY, CUSTOM_MSG_TEMPLATE_NOTIFY_ALL);
|
||||
attachment.setMsgBean(new Gson().fromJson(String.valueOf(baseProtocol.getData()), RoomTemplateNotifyMsgBean.class));
|
||||
ChatRoomMessage message = ChatRoomMessageBuilder.createChatRoomCustomMessage(String.valueOf(AvRoomDataManager.get().getRoomId()), attachment);
|
||||
IMNetEaseManager.get().noticeRoomEvent(message, RoomEvent.TEMPLATE_NOTIFY);
|
||||
}
|
||||
break;
|
||||
case CUSTOM_MSG_LUCKY_GIFT://福袋
|
||||
if (baseProtocol.getSecond() == CUSTOM_MSG_LUCKY_GIFT_SERVER_NOTIFY || baseProtocol.getSecond() == CUSTOM_MSG_LUCKY_GIFT_SERVER_ALL) {
|
||||
RoomReceivedLuckyGiftAttachment attachment = new RoomReceivedLuckyGiftAttachment(CUSTOM_MSG_LUCKY_GIFT_SERVER_NOTIFY);
|
||||
attachment.setLuckyBagNoticeInfo(JSON.parseObject(String.valueOf(baseProtocol.getData()), LuckyBagNoticeInfo.class));
|
||||
ChatRoomMessage message = ChatRoomMessageBuilder.createChatRoomCustomMessage(String.valueOf(AvRoomDataManager.get().getRoomId()), attachment);
|
||||
IMNetEaseManager.get().noticeServiceLuckyBagNotice(message);
|
||||
IMNetEaseManager.get().addMessages(message);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean needSteepStateBar() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setStatusBar() {
|
||||
super.setStatusBar();
|
||||
StatusBarUtil.transparencyBar(this);
|
||||
StatusBarUtil.StatusBarLightMode(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
EventBus.getDefault().unregister(this);
|
||||
}
|
||||
}
|
@@ -0,0 +1,316 @@
|
||||
package com.chwl.app.treasure_box.activity;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.animation.AnimatorListenerAdapter;
|
||||
import android.animation.ObjectAnimator;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.text.Editable;
|
||||
import android.text.TextUtils;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.WindowManager;
|
||||
import android.view.animation.AccelerateDecelerateInterpolator;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.chwl.core.utils.StringFormatUtils;
|
||||
import com.netease.nim.uikit.StatusBarUtil;
|
||||
import com.netease.nim.uikit.common.util.sys.ScreenUtil;
|
||||
import com.chwl.app.R;
|
||||
import com.chwl.app.base.BaseBindingActivity;
|
||||
import com.chwl.app.databinding.ActivityTreasureBoxHonourBinding;
|
||||
import com.chwl.app.treasure_box.widget.dialog.BoxMoreDialog;
|
||||
import com.chwl.app.ui.utils.ImageLoadUtils;
|
||||
import com.chwl.app.ui.webview.DialogWebViewActivity;
|
||||
import com.chwl.core.treasure_box.bean.PrizeInfo;
|
||||
import com.chwl.core.treasure_box.model.BoxModel;
|
||||
import com.chwl.core.treasure_box.model.IBoxModel;
|
||||
import com.chwl.core.DemoCache;
|
||||
import com.chwl.core.UriProvider;
|
||||
import com.chwl.core.manager.IMNetEaseManager;
|
||||
import com.chwl.core.manager.RoomEvent;
|
||||
import com.chwl.core.pay.PayModel;
|
||||
import com.chwl.core.pay.bean.WalletInfo;
|
||||
import com.chwl.library.annatation.ActLayoutRes;
|
||||
import com.chwl.library.utils.FormatUtils;
|
||||
import com.chwl.library.utils.ResUtil;
|
||||
import com.chwl.library.utils.SingleToastUtil;
|
||||
import com.chwl.library.utils.TextWatcherWrapper;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
|
||||
@ActLayoutRes(R.layout.activity_treasure_box_honour)
|
||||
public class TreasureBoxHonourActivity extends BaseBindingActivity<ActivityTreasureBoxHonourBinding> {
|
||||
private final Runnable removeRunnable = () -> mBinding.llPrizeHint.removeAllViews();
|
||||
private int price = 20;
|
||||
private volatile int keyNum;
|
||||
private ArrayList<PrizeInfo> cacheList = new ArrayList<>();
|
||||
private ArrayList<PrizeInfo> hintPrizeCacheList = new ArrayList<>();
|
||||
private ObjectAnimator translationXAnimator;
|
||||
private ObjectAnimator translationYAnimator;
|
||||
private int boxType = IBoxModel.BOX_TYPE_HONOUR;
|
||||
private int height;
|
||||
private int sendMessageSwitchLevel;
|
||||
|
||||
public static void start(Context context) {
|
||||
Intent starter = new Intent(context, TreasureBoxHonourActivity.class);
|
||||
context.startActivity(starter);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
//这里的height用MATCH_PARENT状态栏会被顶上去,不知道什么鬼
|
||||
height = ScreenUtil.screenHeight - ScreenUtil.getStatusBarHeight(context);
|
||||
getWindow().setLayout(WindowManager.LayoutParams.MATCH_PARENT, ScreenUtil.screenHeight - ScreenUtil.getStatusBarHeight(context));
|
||||
getWindow().setGravity(Gravity.BOTTOM);
|
||||
subscribeEvent();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void init() {
|
||||
mBinding.setClick(this);
|
||||
translationXAnimator = ObjectAnimator.ofFloat(mBinding.ivGiftAnim, "translationX", 0,
|
||||
ScreenUtil.screenWidth / 2f - ScreenUtil.dip2px(15 + 19)).setDuration(100);
|
||||
translationXAnimator.setInterpolator(new AccelerateDecelerateInterpolator());
|
||||
translationXAnimator.addListener(new AnimatorListenerAdapter() {
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
mBinding.ivGiftAnim.setVisibility(View.GONE);
|
||||
}
|
||||
});
|
||||
mBinding.ivBox.post(() -> {
|
||||
translationYAnimator = ObjectAnimator.ofFloat(mBinding.ivGiftAnim, "translationY", 0,
|
||||
height - (mBinding.ivBox.getBottom() + mBinding.ivBox.getTop()) / 2f - ScreenUtil.dip2px(55)).setDuration(100);
|
||||
translationYAnimator.setInterpolator(new AccelerateDecelerateInterpolator());
|
||||
});
|
||||
WalletInfo walletInfo = PayModel.get().getCurrentWalletInfo();
|
||||
if (walletInfo != null) {
|
||||
mBinding.tvDiamondNum.setText(FormatUtils.formatBigInteger(walletInfo.getDiamondNum()));
|
||||
}
|
||||
|
||||
mBinding.editNum.addTextChangedListener(new TextWatcherWrapper() {
|
||||
@Override
|
||||
public void afterTextChanged(Editable editable) {
|
||||
int num = StringFormatUtils.toInt(mBinding.editNum.getText().toString(), 0);
|
||||
mBinding.tvContinuousNum.setText(ResUtil.getString(R.string.treasure_box_activity_treasureboxhonouractivity_01) + num * 10);
|
||||
}
|
||||
});
|
||||
loadKeyInfo();
|
||||
looperPrize();
|
||||
looperHintPrize();
|
||||
}
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
private void loadKeyInfo() {
|
||||
BoxModel.get()
|
||||
.getKeyInfo(boxType)
|
||||
.compose(bindToLifecycle())
|
||||
.subscribe(keyInfo -> {
|
||||
changeKeyNum(keyInfo.getKeyNum());
|
||||
price = keyInfo.getKeyPrice();
|
||||
sendMessageSwitchLevel = keyInfo.getSendMessageSwitchLevel();
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
switch (v.getId()) {
|
||||
case R.id.root_view:
|
||||
finish();
|
||||
break;
|
||||
case R.id.iv_open:
|
||||
openBox(StringFormatUtils.toInt(mBinding.editNum.getText().toString()));
|
||||
break;
|
||||
case R.id.iv_more:
|
||||
new BoxMoreDialog(context, sendMessageSwitchLevel).openDialog();
|
||||
break;
|
||||
case R.id.tv_rank:
|
||||
BoxRankingActivity.start(this);
|
||||
break;
|
||||
case R.id.iv_sub:
|
||||
mBinding.editNum.setText(String.valueOf(Math.max(StringFormatUtils.toInt(mBinding.editNum.getText().toString(), 0) - 1, 1)));
|
||||
break;
|
||||
case R.id.iv_add:
|
||||
mBinding.editNum.setText(String.valueOf(Math.min((StringFormatUtils.toInt(mBinding.editNum.getText().toString(), 0) + 1), 9999)));
|
||||
break;
|
||||
case R.id.view_bg:
|
||||
case R.id.iv_title:
|
||||
//do nothing
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查钥匙(锤子)数量
|
||||
*
|
||||
* @param count 想要使用的数量
|
||||
* @return true 表示数量不足,无法进行下一步操作
|
||||
* false 表示数量没问题,可以继续操作
|
||||
*/
|
||||
private boolean checkKeyNum(int count) {
|
||||
if (count == 0) {
|
||||
SingleToastUtil.showToast(ResUtil.getString(R.string.treasure_box_activity_treasureboxhonouractivity_02));
|
||||
return true;
|
||||
}
|
||||
if (keyNum < count) {
|
||||
getDialogManager().showOkCancelDialog(ResUtil.getString(R.string.treasure_box_activity_treasureboxhonouractivity_03), ResUtil.getString(R.string.treasure_box_activity_treasureboxhonouractivity_04),
|
||||
() -> DialogWebViewActivity.start(context, UriProvider.getBoxKey()));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
private void openBox(int count) {
|
||||
if (checkKeyNum(count)) {
|
||||
return;
|
||||
}
|
||||
mBinding.ivOpen.setEnabled(false);
|
||||
mBinding.svgaOpen.startAnimation();
|
||||
BoxModel.get()
|
||||
.openBox(boxType, count, DemoCache.readNeedBoxMsg())
|
||||
.compose(bindToLifecycle())
|
||||
.doOnError(throwable -> {
|
||||
mBinding.ivOpen.setEnabled(true);
|
||||
toast(throwable.getMessage());
|
||||
})
|
||||
.toObservable()
|
||||
.flatMap(openBoxResult -> {
|
||||
mBinding.ivOpen.setEnabled(true);
|
||||
changeKeyNum(openBoxResult.getRemainKeyNum());
|
||||
cacheList.addAll(openBoxResult.getPrizeItemList());
|
||||
return Observable.fromIterable(openBoxResult.getPrizeItemList());
|
||||
})
|
||||
.filter(prizeInfo -> prizeInfo.getPrizeLevel() > 2)
|
||||
.subscribe(prizeInfo -> hintPrizeCacheList.add(prizeInfo));
|
||||
}
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
private void looperPrize() {
|
||||
Observable.interval(0, 100, TimeUnit.MILLISECONDS)
|
||||
.compose(bindToLifecycle())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.filter(aLong -> cacheList.size() > 0)
|
||||
.subscribe(aLong -> {
|
||||
PrizeInfo prizeInfo = cacheList.get(0);
|
||||
String url = prizeInfo.getPrizeImgUrl();
|
||||
if (cacheList.size() > 0) cacheList.remove(0);
|
||||
if (!TextUtils.isEmpty(url)) {
|
||||
if (translationXAnimator != null) translationXAnimator.start();
|
||||
if (translationYAnimator != null) translationYAnimator.start();
|
||||
mBinding.ivGiftAnim.setVisibility(View.VISIBLE);
|
||||
mBinding.svgaGiftBg.startAnimation();
|
||||
ImageLoadUtils.loadImage(context, url, mBinding.ivGiftAnim);
|
||||
}
|
||||
}
|
||||
, e -> looperPrize());//出错了继续looper......
|
||||
|
||||
}
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
private void looperHintPrize() {
|
||||
Observable.interval(0, 250, TimeUnit.MILLISECONDS)
|
||||
.compose(bindToLifecycle())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.filter(aLong -> hintPrizeCacheList.size() > 0)
|
||||
.subscribe(aLong -> addPrizeHintView(hintPrizeCacheList.remove(0))
|
||||
, e -> looperHintPrize());//出错了继续looper......
|
||||
}
|
||||
|
||||
private void addPrizeHintView(PrizeInfo prizeInfo) {
|
||||
mBinding.llPrizeHint.removeCallbacks(removeRunnable);
|
||||
mBinding.llPrizeHint.postDelayed(removeRunnable, 3000);
|
||||
LinearLayout linearLayout = (LinearLayout) LayoutInflater.from(this).inflate(R.layout.item_box_prize_hint, null);
|
||||
ViewGroup.MarginLayoutParams layoutParams = new ViewGroup.MarginLayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ScreenUtil.dip2px(21));
|
||||
layoutParams.setMargins(0, 0, 0, ScreenUtil.dip2px(5));
|
||||
linearLayout.setLayoutParams(layoutParams);
|
||||
switch (prizeInfo.getPrizeLevel()) {
|
||||
case 3:
|
||||
default:
|
||||
linearLayout.setBackgroundResource(R.drawable.bg_box_prize_hint_v3);
|
||||
break;
|
||||
case 4:
|
||||
linearLayout.setBackgroundResource(R.drawable.bg_box_prize_hint_v4);
|
||||
break;
|
||||
case 5:
|
||||
linearLayout.setBackgroundResource(R.drawable.bg_box_prize_hint_v5);
|
||||
break;
|
||||
}
|
||||
mBinding.llPrizeHint.addView(linearLayout);
|
||||
if (mBinding.llPrizeHint.getChildCount() > 6) {
|
||||
mBinding.llPrizeHint.removeViewAt(0);
|
||||
}
|
||||
for (int i = 0; i < mBinding.llPrizeHint.getChildCount(); i++) {
|
||||
ObjectAnimator.ofFloat(mBinding.llPrizeHint.getChildAt(i), "translationY", ScreenUtil.dip2px(21), 0)
|
||||
.setDuration(200)
|
||||
.start();
|
||||
}
|
||||
|
||||
((TextView) linearLayout.findViewById(R.id.tv_prize_name)).setText(prizeInfo.getPrizeName());
|
||||
((TextView) linearLayout.findViewById(R.id.tv_prize_num)).setText("x" + prizeInfo.getPrizeNum());
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新钥匙(锤子)数量
|
||||
*
|
||||
* @param num
|
||||
*/
|
||||
private void changeKeyNum(int num) {
|
||||
keyNum = num;
|
||||
mBinding.tvKeyNum.setText(keyNum + "");
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新钱包
|
||||
*
|
||||
* @param g
|
||||
*/
|
||||
private void setGold(double g) {
|
||||
mBinding.tvDiamondNum.setText(FormatUtils.formatBigInteger(g));
|
||||
PayModel.get().getCurrentWalletInfo().setDiamondNum(g);
|
||||
}
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
private void subscribeEvent() {
|
||||
//更新钻石数量和被踢出房间退出
|
||||
IMNetEaseManager.get().getChatRoomEventObservable()
|
||||
.compose(bindToLifecycle())
|
||||
.subscribe(roomEvent -> {
|
||||
switch (roomEvent.getEvent()) {
|
||||
case RoomEvent.WALLET_UPDATE:
|
||||
loadKeyInfo();
|
||||
setGold(roomEvent.getWalletInfo().getDiamondNum());
|
||||
break;
|
||||
case RoomEvent.KICK_OUT_ROOM:
|
||||
finish();
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected boolean needSteepStateBar() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setStatusBar() {
|
||||
super.setStatusBar();
|
||||
StatusBarUtil.transparencyBar(this);
|
||||
StatusBarUtil.StatusBarLightMode(this);
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,66 @@
|
||||
package com.chwl.app.treasure_box.adapter;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
||||
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.ImageLoadKt;
|
||||
import com.chwl.core.room.treasure_box.bean.TreasureRankingInfo;
|
||||
|
||||
/**
|
||||
* @author jack
|
||||
* @Description
|
||||
* @Date 2018/4/16
|
||||
*/
|
||||
|
||||
public class BoxRankingListAdapter extends BaseQuickAdapter<TreasureRankingInfo, BaseViewHolder> {
|
||||
|
||||
private final Context mContext;
|
||||
|
||||
public BoxRankingListAdapter(Context context) {
|
||||
super(R.layout.box_ranking_list_item);
|
||||
this.mContext = context;
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
@Override
|
||||
protected void convert(@NonNull BaseViewHolder baseViewHolder, final TreasureRankingInfo rankVosBeans) {
|
||||
if (rankVosBeans == null) return;
|
||||
|
||||
baseViewHolder.setText(R.id.tv_userName, rankVosBeans.getNick()).setText(R.id.tv_amount, rankVosBeans.getDiamonds() + "");
|
||||
ImageLoadKt.loadAvatar(baseViewHolder.getView(R.id.iv_avatar), rankVosBeans.getAvatar());
|
||||
TextView tvPosition = baseViewHolder.getView(R.id.tv_position);
|
||||
ImageView ivPosition = baseViewHolder.getView(R.id.iv_position);
|
||||
switch (baseViewHolder.getLayoutPosition()) {
|
||||
case 0:
|
||||
tvPosition.setVisibility(View.GONE);
|
||||
ivPosition.setVisibility(View.VISIBLE);
|
||||
ivPosition.setImageDrawable(ContextCompat.getDrawable(mContext, R.drawable.ic_box_ranking_first));
|
||||
break;
|
||||
case 1:
|
||||
tvPosition.setVisibility(View.GONE);
|
||||
ivPosition.setVisibility(View.VISIBLE);
|
||||
ivPosition.setImageDrawable(ContextCompat.getDrawable(mContext, R.drawable.ic_box_ranking_second));
|
||||
break;
|
||||
case 2:
|
||||
tvPosition.setVisibility(View.GONE);
|
||||
ivPosition.setVisibility(View.VISIBLE);
|
||||
ivPosition.setImageDrawable(ContextCompat.getDrawable(mContext, R.drawable.ic_box_ranking_third));
|
||||
break;
|
||||
default:
|
||||
tvPosition.setVisibility(View.VISIBLE);
|
||||
ivPosition.setVisibility(View.GONE);
|
||||
tvPosition.setText(baseViewHolder.getLayoutPosition() + 1 + "");
|
||||
break;
|
||||
}
|
||||
baseViewHolder.addOnClickListener(R.id.iv_avatar);
|
||||
}
|
||||
}
|
@@ -0,0 +1,198 @@
|
||||
package com.chwl.app.treasure_box.fragment;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
||||
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter;
|
||||
import com.chwl.app.R;
|
||||
import com.chwl.app.base.BaseMvpFragment;
|
||||
import com.chwl.app.common.NoDataFragment;
|
||||
import com.chwl.app.treasure_box.adapter.BoxRankingListAdapter;
|
||||
import com.chwl.app.treasure_box.module.IBoxRankingView;
|
||||
import com.chwl.app.treasure_box.presenter.BoxRankingPresenter;
|
||||
import com.chwl.app.treasure_box.widget.BoxRankLoadMoreView;
|
||||
import com.chwl.app.ui.user.activity.UserInfoActivity;
|
||||
import com.chwl.app.ui.widget.magicindicator.buildins.UIUtil;
|
||||
import com.chwl.app.ui.widget.recyclerview.decoration.HorizontalDecoration;
|
||||
import com.chwl.core.room.treasure_box.bean.TreasureRankingInfo;
|
||||
import com.chwl.core.room.treasure_box.event.RefreshBoxRankingEvent;
|
||||
import com.chwl.library.base.factory.CreatePresenter;
|
||||
import com.chwl.library.utils.ListUtils;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 房间内寻爱排行榜
|
||||
*
|
||||
* @author MadisonRong RoomNewbieListFragment
|
||||
*/
|
||||
@CreatePresenter(BoxRankingPresenter.class)
|
||||
public class BoxRankingFragment extends BaseMvpFragment<IBoxRankingView, BoxRankingPresenter> implements IBoxRankingView, BaseQuickAdapter.RequestLoadMoreListener {
|
||||
private RecyclerView recyclerView;
|
||||
private SwipeRefreshLayout swipeRefresh;
|
||||
private BoxRankingListAdapter mAdapter;
|
||||
private int datetype;
|
||||
|
||||
public static BoxRankingFragment newInstance(int datetype) {
|
||||
Bundle args = new Bundle();
|
||||
args.putInt("datetype", datetype);
|
||||
BoxRankingFragment fragment = new BoxRankingFragment();
|
||||
fragment.setArguments(args);
|
||||
return fragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
EventBus.getDefault().register(this);
|
||||
if (getArguments() != null) {
|
||||
datetype = getArguments().getInt("datetype");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRootLayoutId() {
|
||||
return R.layout.fragment_newbie_list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFindViews() {
|
||||
recyclerView = mView.findViewById(R.id.recycler_view);
|
||||
swipeRefresh = mView.findViewById(R.id.swipe_refresh);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSetListener() {
|
||||
swipeRefresh.setOnRefreshListener(() -> {
|
||||
mAdapter.setEnableLoadMore(true);
|
||||
loadData(true, datetype);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initiate() {
|
||||
initRecyclerView();
|
||||
loadData(true, datetype);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 刷新数据
|
||||
*/
|
||||
private void loadData(boolean isRefresh, int datetype) {
|
||||
getMvpPresenter().loadData(isRefresh, datetype);
|
||||
}
|
||||
|
||||
@Override
|
||||
public View.OnClickListener getLoadMoreListener() {
|
||||
return super.getLoadMoreListener();
|
||||
}
|
||||
|
||||
private void initRecyclerView() {
|
||||
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
|
||||
recyclerView.setItemAnimator(null);
|
||||
recyclerView.addItemDecoration(new HorizontalDecoration(UIUtil.dip2px(mContext, 8), false, false));
|
||||
mAdapter = new BoxRankingListAdapter(mContext);
|
||||
mAdapter.setLoadMoreView(new BoxRankLoadMoreView());
|
||||
mAdapter.setOnLoadMoreListener(this, recyclerView);
|
||||
mAdapter.setOnItemChildClickListener((adapter, view, position) -> UserInfoActivity.Companion.start(mContext, mAdapter.getData().get(position).getUid()));
|
||||
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getContext());
|
||||
recyclerView.setLayoutManager(linearLayoutManager);
|
||||
recyclerView.setAdapter(mAdapter);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void getBoxRankingSuccess(List<TreasureRankingInfo> rankingInfo) {
|
||||
hideStatus();
|
||||
if (mAdapter != null) {
|
||||
int page = getMvpPresenter().getPage();
|
||||
if (page <= 1) {
|
||||
swipeRefresh.setRefreshing(false);
|
||||
|
||||
if (rankingInfo == null || rankingInfo.size() == 0) {
|
||||
showNoData(getString(R.string.empty_data));
|
||||
} else {
|
||||
mAdapter.setNewData(rankingInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showNoData(View view, int drawable, CharSequence charSequence) {
|
||||
if (!checkActivityValid())
|
||||
return;
|
||||
|
||||
if (view == null) {
|
||||
return;
|
||||
}
|
||||
View status = view.findViewById(R.id.status_layout);
|
||||
if (status == null || status.getId() == View.NO_ID) {
|
||||
return;
|
||||
}
|
||||
NoDataFragment fragment = NoDataFragment.newInstance(R.layout.fragment_box_rank_no_data, drawable, charSequence);
|
||||
fragment.setListener(getLoadListener());
|
||||
getChildFragmentManager().beginTransaction().replace(status.getId(), fragment, STATUS_TAG).commitAllowingStateLoss();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getBoxRankingFails(String error) {
|
||||
hideStatus();
|
||||
|
||||
int page = getMvpPresenter().getPage();
|
||||
if (page <= 1) {
|
||||
showNoData(getString(R.string.empty_data));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getBoxRankingLoadMoreSuccess(List<TreasureRankingInfo> rankingInfo) {
|
||||
if (ListUtils.isListEmpty(rankingInfo)) {
|
||||
mAdapter.loadMoreEnd();
|
||||
return;
|
||||
}
|
||||
mAdapter.addData(rankingInfo);
|
||||
mAdapter.loadMoreComplete();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getBoxRankingLoadMoreFails(String error) {
|
||||
hideStatus();
|
||||
int page = getMvpPresenter().getPage();
|
||||
if (page <= 1) {
|
||||
showNoData(getString(R.string.empty_data));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReloadData() {
|
||||
super.onReloadData();
|
||||
loadData(true, datetype);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadMoreRequested() {
|
||||
loadData(false, datetype);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
EventBus.getDefault().unregister(this);
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onRefreshRanking(RefreshBoxRankingEvent event) {
|
||||
loadData(true, datetype);
|
||||
}
|
||||
}
|
@@ -0,0 +1,120 @@
|
||||
package com.chwl.app.treasure_box.fragment;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.os.Bundle;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.Window;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
import androidx.fragment.app.DialogFragment;
|
||||
|
||||
import com.coorchice.library.utils.LogUtils;
|
||||
import com.chwl.app.R;
|
||||
import com.chwl.app.ui.webview.DialogWebViewActivity;
|
||||
import com.chwl.core.UriProvider;
|
||||
import com.chwl.library.utils.ResUtil;
|
||||
import com.chwl.library.utils.TimeUtils;
|
||||
|
||||
public class ChooseTreasureBoxDialogFragment extends DialogFragment implements View.OnClickListener {
|
||||
|
||||
private ConstraintLayout clBoxNormal, clBoxHonour;
|
||||
|
||||
private OnTreasureBoxChooseListener onTreasureBoxChooseListener;
|
||||
|
||||
private TextView tvOpenTime;
|
||||
|
||||
private String mOpenTime;
|
||||
|
||||
private TextView mTvOpenHonour;
|
||||
|
||||
public ChooseTreasureBoxDialogFragment(String openTime) {
|
||||
this.mOpenTime = openTime;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
View view = inflater.inflate(R.layout.fragment_choose_treasure_box_dialog, container);
|
||||
getDialog().requestWindowFeature(Window.FEATURE_NO_TITLE);// 去掉标题
|
||||
if (getDialog().getWindow() != null) {
|
||||
getDialog().getWindow().setBackgroundDrawableResource(android.R.color.transparent);// 透明
|
||||
}
|
||||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
clBoxNormal = view.findViewById(R.id.cl_box_normal);
|
||||
clBoxHonour = view.findViewById(R.id.cl_box_honour);
|
||||
tvOpenTime = view.findViewById(R.id.tv_open_time);
|
||||
mTvOpenHonour = view.findViewById(R.id.tv_open_honour);
|
||||
view.findViewById(R.id.iv_close).setOnClickListener(this);
|
||||
clBoxNormal.setOnClickListener(this);
|
||||
tvOpenTime.setText(ResUtil.getString(R.string.treasure_box_fragment_choosetreasureboxdialogfragment_01) + mOpenTime);
|
||||
// String mOpenTime = "11:10-02:00";
|
||||
int startTime = Integer.parseInt(mOpenTime.substring(0, mOpenTime.indexOf("-")).replace(":", ""));
|
||||
int endTime = Integer.parseInt(mOpenTime.substring(mOpenTime.indexOf("-") + 1).replace(":", ""));
|
||||
LogUtils.e("startTime" + startTime);
|
||||
LogUtils.e("endTime" + endTime);
|
||||
LogUtils.e(ResUtil.getString(R.string.treasure_box_fragment_choosetreasureboxdialogfragment_02) + TimeUtils.getTimeLimit(startTime, endTime));
|
||||
|
||||
mTvOpenHonour.setEnabled(TimeUtils.getTimeLimit(startTime, endTime));
|
||||
if (TimeUtils.getTimeLimit(startTime, endTime)) {
|
||||
clBoxHonour.setOnClickListener(this);
|
||||
}
|
||||
view.findViewById(R.id.ll_get_key).setOnClickListener(v -> DialogWebViewActivity.start(getContext(), UriProvider.getBoxKey()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
Dialog dialog = getDialog();
|
||||
if (dialog != null) {
|
||||
DisplayMetrics dm = new DisplayMetrics();
|
||||
if (getActivity() != null && getActivity().getWindowManager() != null
|
||||
&& dialog.getWindow() != null) {
|
||||
getActivity().getWindowManager().getDefaultDisplay().getMetrics(dm);
|
||||
dialog.getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||
dialog.getWindow().setGravity(Gravity.CENTER);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
int id = view.getId();
|
||||
if (id == R.id.iv_close) {
|
||||
dismiss();
|
||||
} else if (id == R.id.cl_box_normal) {
|
||||
if (onTreasureBoxChooseListener != null) {
|
||||
onTreasureBoxChooseListener.onBoxClick(0);
|
||||
}
|
||||
dismiss();
|
||||
} else if (id == R.id.cl_box_honour) {
|
||||
if (onTreasureBoxChooseListener != null) {
|
||||
onTreasureBoxChooseListener.onBoxClick(1);
|
||||
}
|
||||
dismiss();
|
||||
}
|
||||
}
|
||||
|
||||
public interface OnTreasureBoxChooseListener {
|
||||
/**
|
||||
* @param type 选择的宝箱类型 0 黄金(原始) 1 钻石
|
||||
*/
|
||||
void onBoxClick(int type);
|
||||
}
|
||||
|
||||
public void setOnTreasureBoxChooseListener(OnTreasureBoxChooseListener onTreasureBoxChooseListener) {
|
||||
this.onTreasureBoxChooseListener = onTreasureBoxChooseListener;
|
||||
}
|
||||
}
|
@@ -0,0 +1,59 @@
|
||||
package com.chwl.app.treasure_box.module;
|
||||
|
||||
import com.chwl.core.auth.AuthModel;
|
||||
import com.chwl.core.bean.response.ServiceResult;
|
||||
import com.chwl.core.community.CommunityConstant;
|
||||
import com.chwl.core.room.treasure_box.bean.TreasureRankingInfo;
|
||||
import com.chwl.core.utils.net.RxHelper;
|
||||
import com.chwl.library.net.rxnet.RxNet;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.Single;
|
||||
import retrofit2.http.GET;
|
||||
import retrofit2.http.Query;
|
||||
|
||||
public class BoxRankingModel {
|
||||
|
||||
private final Api api = RxNet.create(Api.class);
|
||||
|
||||
public Single<List<TreasureRankingInfo>> getBoxRankingList(int datetype,int page,int pageSize) {
|
||||
return api.apiNewbieList(String.valueOf(AuthModel.get().getCurrentUid()),
|
||||
CommunityConstant.VERSION_VALID_TYPE,
|
||||
AuthModel.get().getTicket(),
|
||||
datetype,
|
||||
page,
|
||||
pageSize)
|
||||
.compose(RxHelper.handleBeanData())
|
||||
.compose(RxHelper.handleSchedulers());
|
||||
}
|
||||
|
||||
|
||||
private static final class Helper {
|
||||
public static final BoxRankingModel INSTANCE = new BoxRankingModel();
|
||||
}
|
||||
|
||||
public static BoxRankingModel get() {
|
||||
return BoxRankingModel.Helper.INSTANCE;
|
||||
}
|
||||
|
||||
|
||||
private interface Api {
|
||||
|
||||
/**
|
||||
* 排行榜
|
||||
*
|
||||
* @return -
|
||||
*/
|
||||
@GET("/findLove/rank")
|
||||
Single<ServiceResult<List<TreasureRankingInfo>>> apiNewbieList(
|
||||
@Query("uid") String uid,
|
||||
@Query("types") String types,
|
||||
@Query("ticket") String ticket,
|
||||
@Query("type") int type,
|
||||
@Query("page") int page,
|
||||
@Query("pageSize") int pageSize);
|
||||
|
||||
|
||||
}
|
||||
}
|
@@ -0,0 +1,14 @@
|
||||
package com.chwl.app.treasure_box.module;
|
||||
|
||||
import com.chwl.core.room.treasure_box.bean.TreasureRankingInfo;
|
||||
import com.chwl.library.base.IMvpBaseView;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface IBoxRankingView extends IMvpBaseView {
|
||||
void getBoxRankingSuccess(List<TreasureRankingInfo> list);
|
||||
void getBoxRankingFails(String error);
|
||||
void getBoxRankingLoadMoreSuccess(List<TreasureRankingInfo> list);
|
||||
void getBoxRankingLoadMoreFails(String error);
|
||||
|
||||
}
|
@@ -0,0 +1,69 @@
|
||||
package com.chwl.app.treasure_box.presenter;
|
||||
|
||||
import com.chwl.app.R;
|
||||
import com.chwl.app.base.BaseMvpPresenter;
|
||||
import com.chwl.app.treasure_box.module.BoxRankingModel;
|
||||
import com.chwl.app.treasure_box.module.IBoxRankingView;
|
||||
import com.chwl.core.Constants;
|
||||
import com.chwl.core.room.treasure_box.bean.BoxRankingInfo;
|
||||
import com.chwl.core.room.treasure_box.bean.TreasureRankingInfo;
|
||||
import com.chwl.library.utils.ResUtil;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.SingleObserver;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
|
||||
public class BoxRankingPresenter extends BaseMvpPresenter<IBoxRankingView> {
|
||||
|
||||
private int page = 0;
|
||||
|
||||
public void loadData(boolean isRefresh,int datetype) {
|
||||
if (isRefresh) {
|
||||
page = 1;
|
||||
} else {
|
||||
page++;
|
||||
}
|
||||
|
||||
BoxRankingModel.get().getBoxRankingList(datetype,page, Constants.PAGE_SIZE)
|
||||
.compose(bindToLifecycle()).subscribe(new SingleObserver<List<TreasureRankingInfo>>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(List<TreasureRankingInfo> roomNewbieInfos) {
|
||||
if (roomNewbieInfos != null) {
|
||||
if (mMvpView != null) {
|
||||
if (isRefresh){
|
||||
mMvpView.getBoxRankingSuccess(roomNewbieInfos);
|
||||
}else {
|
||||
mMvpView.getBoxRankingLoadMoreSuccess(roomNewbieInfos);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (mMvpView != null) {
|
||||
if (isRefresh){
|
||||
mMvpView.getBoxRankingFails(ResUtil.getString(R.string.treasure_box_presenter_boxrankingpresenter_01));
|
||||
}else {
|
||||
mMvpView.getBoxRankingLoadMoreFails(ResUtil.getString(R.string.treasure_box_presenter_boxrankingpresenter_02));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
if (mMvpView != null) {
|
||||
mMvpView.getBoxRankingFails(e.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public int getPage() {
|
||||
return page;
|
||||
}
|
||||
}
|
@@ -0,0 +1,27 @@
|
||||
package com.chwl.app.treasure_box.widget;
|
||||
|
||||
import com.chad.library.adapter.base.loadmore.LoadMoreView;
|
||||
import com.chwl.app.R;
|
||||
|
||||
public final class BoxRankLoadMoreView extends LoadMoreView {
|
||||
|
||||
@Override
|
||||
public int getLayoutId() {
|
||||
return R.layout.box_rank_view_load_more;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getLoadingViewId() {
|
||||
return R.id.load_more_loading_view;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getLoadFailViewId() {
|
||||
return R.id.load_more_load_fail_view;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getLoadEndViewId() {
|
||||
return R.id.load_more_load_end_view;
|
||||
}
|
||||
}
|
@@ -0,0 +1,87 @@
|
||||
package com.chwl.app.treasure_box.widget;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
|
||||
import com.chwl.app.R;
|
||||
import com.chwl.app.treasure_box.activity.TreasureBoxActivity;
|
||||
import com.chwl.app.treasure_box.activity.TreasureBoxHonourActivity;
|
||||
import com.chwl.app.treasure_box.fragment.ChooseTreasureBoxDialogFragment;
|
||||
import com.chwl.core.initial.InitialModel;
|
||||
import com.chwl.core.initial.bean.FairyOpenInfo;
|
||||
import com.chwl.core.initial.bean.InitInfo;
|
||||
import com.chwl.core.manager.AvRoomDataManager;
|
||||
import com.chwl.core.user.UserModel;
|
||||
import com.chwl.core.user.bean.UserInfo;
|
||||
import com.chwl.library.utils.ResUtil;
|
||||
import com.chwl.library.utils.SingleToastUtil;
|
||||
import com.chwl.library.utils.TimeUtils;
|
||||
|
||||
|
||||
public class GoldBoxHelper {
|
||||
public static void handleBoxClick(Context context) {
|
||||
String openTime = GoldBoxHelper.getBoxOpenTime();
|
||||
if (openTime == null || openTime.isEmpty()) {
|
||||
SingleToastUtil.showToast(ResUtil.getString(R.string.treasure_box_widget_goldboxhelper_01));
|
||||
return;
|
||||
}
|
||||
int startTime = Integer.parseInt(openTime.substring(0, openTime.indexOf("-")).replace(":", ""));
|
||||
int endTime = Integer.parseInt(openTime.substring(openTime.indexOf("-") + 1).replace(":", ""));
|
||||
|
||||
if (startTime != endTime && TimeUtils.getTimeLimit(startTime, endTime)) {
|
||||
ChooseTreasureBoxDialogFragment chooseTreasureBoxDialogFragment = new ChooseTreasureBoxDialogFragment(openTime);
|
||||
chooseTreasureBoxDialogFragment.setOnTreasureBoxChooseListener(type -> {
|
||||
if (type == 0) {// 幸运许愿池(默认)
|
||||
TreasureBoxActivity.start(context);
|
||||
} else if (type == 1) {// 梦幻许愿池
|
||||
TreasureBoxHonourActivity.start(context);
|
||||
}
|
||||
});
|
||||
chooseTreasureBoxDialogFragment.show(((FragmentActivity) context).getSupportFragmentManager(), "chooseTreasureBoxDialogFragment");
|
||||
} else {
|
||||
TreasureBoxActivity.start(context);
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isShowDiamondBox() {
|
||||
return AvRoomDataManager.get().mBoxSwitchVo.isDiamondBoxSwitch();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static String getBoxIcon() {
|
||||
if (AvRoomDataManager.get().mBoxSwitchVo == null) return null;
|
||||
return AvRoomDataManager.get().mBoxSwitchVo.getOpenBoxIcon();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static String getBoxOpenTime() {
|
||||
if (AvRoomDataManager.get().mBoxSwitchVo == null) return null;
|
||||
return AvRoomDataManager.get().mBoxSwitchVo.getDiamondBoxOpenTime();
|
||||
}
|
||||
|
||||
public static boolean isShowRadish() {
|
||||
InitInfo initInfo = InitialModel.get().getCacheInitInfo();
|
||||
UserInfo userInfo = UserModel.get().getCacheLoginUserInfo();
|
||||
if (initInfo == null || userInfo == null) return false;
|
||||
return userInfo.getUserLevelVo().getExperLevelSeq() >= initInfo.getLinearlyPoolOpenLevel();
|
||||
}
|
||||
|
||||
/**
|
||||
* 屏幕宽高比小于2的机型房间活动入口和开箱入口整合,个播房不需要整合
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
|
||||
public static boolean needIntegrateBoxEntrance() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isShowFairy() {
|
||||
FairyOpenInfo fairyOpenInfo = InitialModel.get().getFairyOpenInfo();
|
||||
if (fairyOpenInfo == null) return false;
|
||||
return fairyOpenInfo.isOpen();
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,91 @@
|
||||
package com.chwl.app.treasure_box.widget.dialog;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.os.Bundle;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import androidx.appcompat.app.AppCompatDialog;
|
||||
import androidx.databinding.DataBindingUtil;
|
||||
import androidx.databinding.ViewDataBinding;
|
||||
|
||||
import com.netease.nim.uikit.common.util.sys.ScreenUtil;
|
||||
import com.chwl.library.annatation.ActLayoutRes;
|
||||
|
||||
/**
|
||||
* Created by huangmeng1 on 2018/4/12.
|
||||
*/
|
||||
|
||||
public abstract class BaseBindingDialog<T extends ViewDataBinding> extends AppCompatDialog {
|
||||
|
||||
|
||||
protected int width, height;
|
||||
protected Context context;
|
||||
protected int gravity;
|
||||
|
||||
public BaseBindingDialog(Context context) {
|
||||
this(context, 0);
|
||||
}
|
||||
|
||||
public BaseBindingDialog(Context context, int theme) {
|
||||
super(context, theme);
|
||||
this.context = context;
|
||||
width = ScreenUtil.getDialogWidth();
|
||||
height = WindowManager.LayoutParams.WRAP_CONTENT;
|
||||
gravity = Gravity.CENTER;
|
||||
}
|
||||
|
||||
protected T binding;
|
||||
|
||||
@Override
|
||||
protected void onStart() {
|
||||
super.onStart();
|
||||
Window window = getWindow();
|
||||
if (window != null) {
|
||||
window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
|
||||
WindowManager.LayoutParams windowParams = window.getAttributes();
|
||||
windowParams.width = width;
|
||||
windowParams.height = height;
|
||||
windowParams.dimAmount = 0.5f;
|
||||
windowParams.gravity = gravity;
|
||||
windowParams.x = 0;
|
||||
windowParams.y = 0;
|
||||
// window.addFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL);
|
||||
window.setAttributes(windowParams);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
View inflate = LayoutInflater.from(getContext()).inflate(getClass().getAnnotation(ActLayoutRes.class).value(), null);
|
||||
setContentView(inflate.getRootView());
|
||||
setCancelable(true);
|
||||
setCanceledOnTouchOutside(true);
|
||||
binding = DataBindingUtil.bind(inflate);
|
||||
init();
|
||||
}
|
||||
|
||||
protected abstract void init();
|
||||
|
||||
public void openDialog() {
|
||||
try {
|
||||
show();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void closeDialog() {
|
||||
try {
|
||||
dismiss();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,139 @@
|
||||
package com.chwl.app.treasure_box.widget.dialog
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.os.Bundle
|
||||
import android.text.Editable
|
||||
import android.view.Gravity
|
||||
import android.view.WindowManager
|
||||
import com.hjq.toast.ToastUtils
|
||||
import com.chwl.app.R
|
||||
import com.chwl.app.base.BaseDialog
|
||||
import com.chwl.app.databinding.TreasureBoxDialogLoveLackBinding
|
||||
import com.chwl.app.treasure_box.activity.TreasureBoxActivity.MAX_BUY_QUANTITY_LIMIT
|
||||
import com.chwl.app.treasure_box.widget.dialog.TreasureBoxDialog.Companion.newInstance
|
||||
import com.chwl.core.treasure_box.bean.UserTicketInfo
|
||||
import com.chwl.core.treasure_box.model.BoxModel
|
||||
import com.chwl.core.exception.FailReasonException
|
||||
import com.chwl.core.utils.StringFormatUtils
|
||||
import com.chwl.library.common.SpConstants
|
||||
import com.chwl.library.common.util.SPUtils
|
||||
import com.chwl.library.common.util.SoftKeyboardStateHelper
|
||||
import com.chwl.library.common.util.SoftKeyboardStateHelper.SoftKeyboardStateListener
|
||||
import com.chwl.library.utils.SingleToastUtil
|
||||
import com.chwl.library.utils.TextWatcherWrapper
|
||||
import com.chwl.library.utils.TimeUtils
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
|
||||
/**
|
||||
* 购买碎片
|
||||
*/
|
||||
class BoxLoveLackDialog : BaseDialog<TreasureBoxDialogLoveLackBinding>() {
|
||||
|
||||
override var width = WindowManager.LayoutParams.MATCH_PARENT
|
||||
override var height = WindowManager.LayoutParams.WRAP_CONTENT
|
||||
override var gravity = Gravity.CENTER
|
||||
|
||||
private var num: Int = 0
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun newInstance(num: Int, ticketPrice: Int): BoxLoveLackDialog {
|
||||
val args = Bundle()
|
||||
args.putInt("num", num)
|
||||
args.putInt("ticketPrice", ticketPrice)
|
||||
val fragment = BoxLoveLackDialog()
|
||||
fragment.arguments = args
|
||||
return fragment
|
||||
}
|
||||
}
|
||||
|
||||
private val ticketPrice by lazy { requireArguments().getInt("ticketPrice") }
|
||||
|
||||
@SuppressLint("CheckResult", "SetTextI18n")
|
||||
override fun init() {
|
||||
num = requireArguments().getInt("num")
|
||||
|
||||
binding.editNum.setText(num.toString())
|
||||
binding.tvPrizeName.text = (num * ticketPrice).toString()
|
||||
|
||||
binding.ivSub.setOnClickListener {
|
||||
val editNum =
|
||||
(StringFormatUtils.toInt(binding.editNum.text.toString(), 0) - 10).coerceAtLeast(1)
|
||||
binding.editNum.setText(editNum.toString())
|
||||
binding.tvPrizeName.text = (editNum * ticketPrice).toString()
|
||||
}
|
||||
|
||||
binding.ivAdd.setOnClickListener {
|
||||
val editNum =
|
||||
(StringFormatUtils.toInt(binding.editNum.text.toString(), 0) + 10).coerceAtMost(
|
||||
MAX_BUY_QUANTITY_LIMIT
|
||||
)
|
||||
binding.editNum.setText(editNum.toString())
|
||||
binding.tvPrizeName.text = (editNum * ticketPrice).toString()
|
||||
}
|
||||
|
||||
binding.ivClose.setOnClickListener {
|
||||
dismissAllowingStateLoss()
|
||||
}
|
||||
|
||||
binding.tvBuy.setOnClickListener {
|
||||
BoxModel.get()
|
||||
.buyTicket(num)
|
||||
.compose(bindToLifecycle())
|
||||
.doOnError { dealError(it) }
|
||||
.subscribe { userTicketInfo: UserTicketInfo ->
|
||||
EventBus.getDefault().post(userTicketInfo)
|
||||
dismissAllowingStateLoss()
|
||||
val date = SPUtils.getLong(SpConstants.BOX_BUY_SUCCESS, 0L)
|
||||
if (TimeUtils.isToday(date)) {
|
||||
ToastUtils.show("購買成功")
|
||||
return@subscribe
|
||||
}
|
||||
BuyLoveSuccessDialog.newInstance(num).show(context)
|
||||
}
|
||||
}
|
||||
|
||||
binding.editNum.addTextChangedListener(object : TextWatcherWrapper() {
|
||||
override fun afterTextChanged(editable: Editable) {
|
||||
var n = StringFormatUtils.toInt(binding.editNum.text.toString(), 0)
|
||||
if (n > MAX_BUY_QUANTITY_LIMIT) {
|
||||
n = MAX_BUY_QUANTITY_LIMIT
|
||||
binding.editNum.setText(n.toString())
|
||||
binding.editNum.setSelection(3)
|
||||
SingleToastUtil.showToast(
|
||||
getString(
|
||||
R.string.treasure_box_activity_treasureboxactivity_01,
|
||||
MAX_BUY_QUANTITY_LIMIT
|
||||
)
|
||||
)
|
||||
}
|
||||
binding.tvPrizeName.text = (n * ticketPrice).toString()
|
||||
num = n
|
||||
}
|
||||
})
|
||||
|
||||
SoftKeyboardStateHelper(binding.editNum).addSoftKeyboardStateListener(object :
|
||||
SoftKeyboardStateListener {
|
||||
override fun onSoftKeyboardOpened(keyboardHeightInPx: Int) {}
|
||||
override fun onSoftKeyboardClosed() {
|
||||
val num = StringFormatUtils.toInt(binding.editNum.text.toString(), 0)
|
||||
if (num == 0) {
|
||||
binding.editNum.setText("1")
|
||||
binding.editNum.setSelection(1)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
private fun dealError(error: Throwable) {
|
||||
if (error is FailReasonException) {
|
||||
if (error.code == BoxModel.ERROR_CODE_DIAMOND) {
|
||||
newInstance().show(context)
|
||||
} else {
|
||||
SingleToastUtil.showToast(error.message)
|
||||
}
|
||||
} else {
|
||||
SingleToastUtil.showToast(error.message)
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,71 @@
|
||||
package com.chwl.app.treasure_box.widget.dialog;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.Gravity;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import com.chwl.app.R;
|
||||
import com.chwl.app.databinding.DialogBoxMoreBinding;
|
||||
import com.chwl.app.ui.webview.DialogWebViewActivity;
|
||||
import com.chwl.app.utils.UserUtils;
|
||||
import com.chwl.core.DemoCache;
|
||||
import com.chwl.core.UriProvider;
|
||||
import com.chwl.library.annatation.ActLayoutRes;
|
||||
import com.chwl.library.utils.ResUtil;
|
||||
import com.chwl.library.utils.SingleToastUtil;
|
||||
|
||||
@ActLayoutRes(R.layout.dialog_box_more)
|
||||
public class BoxMoreDialog extends BaseBindingDialog<DialogBoxMoreBinding> {
|
||||
|
||||
private int sendMessageSwitchLevel;
|
||||
|
||||
public BoxMoreDialog(Context context, int sendMessageSwitchLevel) {
|
||||
super(context);
|
||||
width = WindowManager.LayoutParams.MATCH_PARENT;
|
||||
height = WindowManager.LayoutParams.WRAP_CONTENT;
|
||||
this.sendMessageSwitchLevel = sendMessageSwitchLevel;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStart() {
|
||||
super.onStart();
|
||||
Window window = getWindow();
|
||||
if (window != null) {
|
||||
WindowManager.LayoutParams windowParams = window.getAttributes();
|
||||
windowParams.gravity = Gravity.BOTTOM;
|
||||
window.setAttributes(windowParams);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void init() {
|
||||
binding.tvHistory.setOnClickListener(v -> {
|
||||
DialogWebViewActivity.start(context, UriProvider.getBoxHistory(), false);
|
||||
closeDialog();
|
||||
});
|
||||
binding.tvBoxRule.setOnClickListener(v -> {
|
||||
DialogWebViewActivity.start(context, UriProvider.getBoxHelp(), false);
|
||||
closeDialog();
|
||||
});
|
||||
|
||||
boolean canSwitch = sendMessageSwitchLevel != 0 && UserUtils.getExpLevel() >= sendMessageSwitchLevel;
|
||||
|
||||
updateMsgSwitch(canSwitch && DemoCache.readNeedBoxMsg());
|
||||
binding.ivSwitch.setOnClickListener(v -> {
|
||||
if (canSwitch) {
|
||||
boolean sendMsg = !DemoCache.readNeedBoxMsg();
|
||||
updateMsgSwitch(sendMsg);
|
||||
DemoCache.saveNeedBoxMsg(sendMsg);
|
||||
SingleToastUtil.showToast(ResUtil.getString(R.string.widget_dialog_boxmoredialog_01));
|
||||
} else {
|
||||
SingleToastUtil.showToast(ResUtil.getString(R.string.widget_dialog_boxmoredialog_02) + sendMessageSwitchLevel + ResUtil.getString(R.string.widget_dialog_boxmoredialog_03));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void updateMsgSwitch(boolean sendMsg) {
|
||||
binding.ivSwitch.setImageResource(sendMsg ?
|
||||
R.drawable.icon_room_set_lock_true : R.drawable.icon_room_set_lock_false);
|
||||
}
|
||||
}
|
@@ -0,0 +1,100 @@
|
||||
package com.chwl.app.treasure_box.widget.dialog
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.os.Bundle
|
||||
import android.view.Gravity
|
||||
import android.view.WindowManager
|
||||
import com.hjq.toast.ToastUtils
|
||||
import com.chwl.app.R
|
||||
import com.chwl.app.base.BaseDialog
|
||||
import com.chwl.app.databinding.TreasureBoxDialogBuyLoveBinding
|
||||
import com.chwl.core.treasure_box.bean.UserTicketInfo
|
||||
import com.chwl.core.treasure_box.model.BoxModel
|
||||
import com.chwl.core.exception.FailReasonException
|
||||
import com.chwl.library.common.SpConstants
|
||||
import com.chwl.library.common.util.SPUtils
|
||||
import com.chwl.library.utils.SingleToastUtil
|
||||
import com.chwl.library.utils.TimeUtils
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
|
||||
/**
|
||||
* 购买爱心
|
||||
*/
|
||||
class BuyLoveDialog : BaseDialog<TreasureBoxDialogBuyLoveBinding>() {
|
||||
|
||||
override var width = WindowManager.LayoutParams.MATCH_PARENT
|
||||
override var height = WindowManager.LayoutParams.WRAP_CONTENT
|
||||
override var gravity = Gravity.CENTER
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun newInstance(num: Int, ticketPrice: Int): BuyLoveDialog {
|
||||
val args = Bundle()
|
||||
args.putInt("num", num)
|
||||
args.putInt("ticketPrice", ticketPrice)
|
||||
val fragment = BuyLoveDialog()
|
||||
fragment.arguments = args
|
||||
return fragment
|
||||
}
|
||||
}
|
||||
|
||||
private val num by lazy { requireArguments().getInt("num") }
|
||||
private val ticketPrice by lazy { requireArguments().getInt("ticketPrice") }
|
||||
|
||||
@SuppressLint("CheckResult", "SetTextI18n")
|
||||
override fun init() {
|
||||
binding?.tvLackLove?.text = getString(R.string.buy_love_num, num)
|
||||
binding?.tvPrizeName?.text = ticketPrice.toString()
|
||||
|
||||
binding?.cbPay?.setOnCheckedChangeListener { _, isChecked ->
|
||||
if (isChecked) {
|
||||
SPUtils.putLong(SpConstants.BOX_BUY_LOVE, System.currentTimeMillis())
|
||||
} else {
|
||||
SPUtils.putLong(SpConstants.BOX_BUY_LOVE, 0L)
|
||||
}
|
||||
}
|
||||
|
||||
binding?.ivClose?.setOnClickListener {
|
||||
dismissAllowingStateLoss()
|
||||
}
|
||||
|
||||
binding?.tvBuy?.setOnClickListener {
|
||||
val date = SPUtils.getLong(SpConstants.BOX_BUY_SUCCESS, 0L)
|
||||
if (TimeUtils.isToday(date)) {
|
||||
BoxModel.get()
|
||||
.buyTicket(num)
|
||||
.compose(bindToLifecycle())
|
||||
.doOnError { dealError(it) }
|
||||
.subscribe { userTicketInfo: UserTicketInfo ->
|
||||
ToastUtils.show("購買成功")
|
||||
dismissAllowingStateLoss()
|
||||
EventBus.getDefault().post(userTicketInfo)
|
||||
}
|
||||
return@setOnClickListener
|
||||
}
|
||||
|
||||
BoxModel.get()
|
||||
.buyTicket(num)
|
||||
.compose(bindToLifecycle())
|
||||
.doOnError { dealError(it) }
|
||||
.subscribe { userTicketInfo: UserTicketInfo ->
|
||||
BuyLoveSuccessDialog.newInstance(num).show(context)
|
||||
dismissAllowingStateLoss()
|
||||
EventBus.getDefault().post(userTicketInfo)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun dealError(error: Throwable) {
|
||||
if (error is FailReasonException) {
|
||||
if (error.code == BoxModel.ERROR_CODE_DIAMOND) {
|
||||
TreasureBoxDialog.newInstance().show(context)
|
||||
} else {
|
||||
SingleToastUtil.showToast(error.message)
|
||||
}
|
||||
} else {
|
||||
SingleToastUtil.showToast(error.message)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,50 @@
|
||||
package com.chwl.app.treasure_box.widget.dialog
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.os.Bundle
|
||||
import android.view.Gravity
|
||||
import android.view.WindowManager
|
||||
import com.chwl.app.base.BaseDialog
|
||||
import com.chwl.app.databinding.TreasureBoxDialogBuyLoveSuccessBinding
|
||||
import com.chwl.library.common.SpConstants
|
||||
import com.chwl.library.common.util.SPUtils
|
||||
|
||||
/**
|
||||
* 购买爱心
|
||||
*/
|
||||
class BuyLoveSuccessDialog : BaseDialog<TreasureBoxDialogBuyLoveSuccessBinding>() {
|
||||
|
||||
override var width = WindowManager.LayoutParams.MATCH_PARENT
|
||||
override var height = WindowManager.LayoutParams.WRAP_CONTENT
|
||||
override var gravity = Gravity.CENTER
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun newInstance(num: Int): BuyLoveSuccessDialog {
|
||||
val args = Bundle()
|
||||
args.putInt("num", num)
|
||||
val fragment = BuyLoveSuccessDialog()
|
||||
fragment.arguments = args
|
||||
return fragment
|
||||
}
|
||||
}
|
||||
|
||||
private val num by lazy { requireArguments().getInt("num") }
|
||||
|
||||
@SuppressLint("CheckResult", "SetTextI18n")
|
||||
override fun init() {
|
||||
binding?.tvPrizeName?.text = "x${num}"
|
||||
|
||||
binding?.cbPay?.setOnCheckedChangeListener { _, isChecked ->
|
||||
if (isChecked) {
|
||||
SPUtils.putLong(SpConstants.BOX_BUY_SUCCESS, System.currentTimeMillis())
|
||||
} else {
|
||||
SPUtils.putLong(SpConstants.BOX_BUY_SUCCESS, 0L)
|
||||
}
|
||||
}
|
||||
|
||||
binding?.ivClose?.setOnClickListener {
|
||||
dismissAllowingStateLoss()
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,32 @@
|
||||
package com.chwl.app.treasure_box.widget.dialog
|
||||
|
||||
import com.chwl.app.base.BaseDialog
|
||||
import com.chwl.app.databinding.DialogTreasureBoxBinding
|
||||
import com.chwl.app.ui.pay.ChargeActivity
|
||||
import com.chwl.app.ui.webview.CommonWebViewActivity
|
||||
import com.chwl.core.Constants
|
||||
import com.chwl.core.UriProvider
|
||||
import com.chwl.library.common.util.DeviceUtil.getDeviceId
|
||||
import com.chwl.library.utils.AppMetaDataUtil
|
||||
|
||||
/**
|
||||
* author: wushaocheng
|
||||
* time: 2023/3/23
|
||||
* desc: 寻爱钻石不足提示
|
||||
*/
|
||||
class TreasureBoxDialog : BaseDialog<DialogTreasureBoxBinding>() {
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun newInstance(): TreasureBoxDialog {
|
||||
return TreasureBoxDialog()
|
||||
}
|
||||
}
|
||||
|
||||
override fun init() {
|
||||
binding?.tvCharge?.setOnClickListener {
|
||||
ChargeActivity.start(context)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
After Width: | Height: | Size: 11 KiB |
After Width: | Height: | Size: 9.0 KiB |
BIN
app/src/module_treasure_box/res/drawable-ar-xhdpi/ic_box_1.png
Normal file
After Width: | Height: | Size: 25 KiB |
BIN
app/src/module_treasure_box/res/drawable-ar-xhdpi/ic_box_10.png
Normal file
After Width: | Height: | Size: 26 KiB |
BIN
app/src/module_treasure_box/res/drawable-ar-xhdpi/ic_box_100.png
Normal file
After Width: | Height: | Size: 27 KiB |
After Width: | Height: | Size: 150 KiB |
After Width: | Height: | Size: 6.0 KiB |
After Width: | Height: | Size: 7.4 KiB |
After Width: | Height: | Size: 28 KiB |
After Width: | Height: | Size: 12 KiB |
After Width: | Height: | Size: 9.5 KiB |
BIN
app/src/module_treasure_box/res/drawable-en-xhdpi/ic_box_1.png
Normal file
After Width: | Height: | Size: 25 KiB |
BIN
app/src/module_treasure_box/res/drawable-en-xhdpi/ic_box_10.png
Normal file
After Width: | Height: | Size: 26 KiB |
BIN
app/src/module_treasure_box/res/drawable-en-xhdpi/ic_box_100.png
Normal file
After Width: | Height: | Size: 27 KiB |
After Width: | Height: | Size: 148 KiB |
After Width: | Height: | Size: 5.6 KiB |
After Width: | Height: | Size: 7.6 KiB |
After Width: | Height: | Size: 33 KiB |
After Width: | Height: | Size: 2.9 KiB |
After Width: | Height: | Size: 2.1 KiB |
After Width: | Height: | Size: 2.9 KiB |
After Width: | Height: | Size: 3.4 KiB |
After Width: | Height: | Size: 3.4 KiB |
BIN
app/src/module_treasure_box/res/drawable-xhdpi/choose_box_bg.png
Normal file
After Width: | Height: | Size: 2.1 KiB |
After Width: | Height: | Size: 2.4 KiB |
After Width: | Height: | Size: 2.2 KiB |
BIN
app/src/module_treasure_box/res/drawable-xhdpi/ic_box_1.png
Normal file
After Width: | Height: | Size: 22 KiB |
BIN
app/src/module_treasure_box/res/drawable-xhdpi/ic_box_10.png
Normal file
After Width: | Height: | Size: 23 KiB |
BIN
app/src/module_treasure_box/res/drawable-xhdpi/ic_box_100.png
Normal file
After Width: | Height: | Size: 24 KiB |
After Width: | Height: | Size: 1.6 KiB |
After Width: | Height: | Size: 1.6 KiB |
After Width: | Height: | Size: 1.7 KiB |
BIN
app/src/module_treasure_box/res/drawable-xhdpi/ic_box_temp.webp
Normal file
After Width: | Height: | Size: 86 KiB |
BIN
app/src/module_treasure_box/res/drawable-xhdpi/ic_love_token.png
Normal file
After Width: | Height: | Size: 37 KiB |
BIN
app/src/module_treasure_box/res/drawable-xhdpi/ic_refresh.webp
Normal file
After Width: | Height: | Size: 1.0 KiB |
After Width: | Height: | Size: 612 B |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 1.8 KiB |
After Width: | Height: | Size: 5.8 KiB |
After Width: | Height: | Size: 37 KiB |
After Width: | Height: | Size: 32 KiB |
After Width: | Height: | Size: 16 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 2.2 KiB |
After Width: | Height: | Size: 8.6 KiB |
After Width: | Height: | Size: 10 KiB |
After Width: | Height: | Size: 1.5 KiB |
After Width: | Height: | Size: 5.6 KiB |
After Width: | Height: | Size: 9.1 KiB |
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
<stroke
|
||||
android:width="0.5dp"
|
||||
android:color="#99ffcdfc" />
|
||||
<gradient
|
||||
android:angle="90"
|
||||
android:startColor="#ff934aee"
|
||||
android:endColor="#ff2e2b99"
|
||||
android:type="linear"
|
||||
android:useLevel="true" />
|
||||
<corners android:radius="10dp" />
|
||||
</shape>
|
338
app/src/module_treasure_box/res/layout/activity_treasure_box.xml
Normal file
@@ -0,0 +1,338 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<data>
|
||||
|
||||
<variable
|
||||
name="click"
|
||||
type="android.view.View.OnClickListener" />
|
||||
</data>
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/root_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:onClick="@{click}">
|
||||
|
||||
<View
|
||||
android:id="@+id/view_bg"
|
||||
android:layout_width="311dp"
|
||||
android:layout_height="474dp"
|
||||
android:layout_marginTop="20dp"
|
||||
android:background="@drawable/treasure_box_bg_normal"
|
||||
android:onClick="@{click}"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/tv_rank"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="15dp"
|
||||
android:layout_marginTop="44dp"
|
||||
android:onClick="@{click}"
|
||||
android:src="@drawable/treasure_box_rank"
|
||||
app:layout_constraintStart_toStartOf="@id/view_bg"
|
||||
app:layout_constraintTop_toTopOf="@id/view_bg" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_more"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="44dp"
|
||||
android:layout_marginEnd="18dp"
|
||||
android:gravity="center"
|
||||
android:onClick="@{click}"
|
||||
android:src="@drawable/icon_room_box_more_normal"
|
||||
app:layout_constraintEnd_toEndOf="@id/view_bg"
|
||||
app:layout_constraintTop_toTopOf="@id/view_bg" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_diamond_num"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="18dp"
|
||||
android:drawableTop="@drawable/treasure_box_diamond"
|
||||
android:gravity="center"
|
||||
android:textColor="#ffffffff"
|
||||
android:textSize="11sp"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintEnd_toEndOf="@id/iv_more"
|
||||
app:layout_constraintStart_toStartOf="@id/iv_more"
|
||||
app:layout_constraintTop_toBottomOf="@id/iv_more"
|
||||
tools:text="200" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_first_box"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="84dp"
|
||||
android:adjustViewBounds="true"
|
||||
android:src="@drawable/ic_box_temp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="@+id/view_bg" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatImageView
|
||||
android:id="@+id/iv_box_1"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="@dimen/dp_8"
|
||||
android:layout_marginBottom="@dimen/dp_8"
|
||||
android:onClick="@{click}"
|
||||
android:src="@drawable/ic_box_1"
|
||||
app:layout_constraintEnd_toStartOf="@id/iv_box_2"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/iv_first_box"
|
||||
app:layout_constraintHorizontal_weight="1"
|
||||
app:layout_constraintStart_toStartOf="@+id/iv_first_box" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatImageView
|
||||
android:id="@+id/iv_box_2"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="@dimen/dp_8"
|
||||
android:onClick="@{click}"
|
||||
android:src="@drawable/ic_box_10"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/iv_first_box"
|
||||
app:layout_constraintHorizontal_weight="1"
|
||||
app:layout_constraintEnd_toStartOf="@id/iv_box_3"
|
||||
app:layout_constraintStart_toEndOf="@+id/iv_box_1" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatImageView
|
||||
android:id="@+id/iv_box_3"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="@dimen/dp_8"
|
||||
android:layout_marginBottom="@dimen/dp_8"
|
||||
android:onClick="@{click}"
|
||||
android:src="@drawable/ic_box_100"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/iv_first_box"
|
||||
app:layout_constraintEnd_toEndOf="@+id/iv_first_box"
|
||||
app:layout_constraintHorizontal_weight="1"
|
||||
app:layout_constraintStart_toEndOf="@+id/iv_box_2" />
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/cs_bottom"
|
||||
android:layout_width="@dimen/dp_0"
|
||||
android:layout_height="@dimen/dp_28"
|
||||
android:layout_marginTop="@dimen/dp_12"
|
||||
android:background="@drawable/bg_8651e0_stroke_ffffff"
|
||||
app:layout_constraintEnd_toEndOf="@+id/iv_first_box"
|
||||
app:layout_constraintStart_toStartOf="@+id/iv_first_box"
|
||||
app:layout_constraintTop_toBottomOf="@+id/iv_first_box">
|
||||
|
||||
<com.coorchice.library.SuperTextView
|
||||
android:id="@+id/tv_box_num"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginStart="@dimen/dp_16"
|
||||
android:gravity="center"
|
||||
android:text="0"
|
||||
android:textColor="@color/color_white"
|
||||
android:textSize="@dimen/sp_10"
|
||||
app:corner="@dimen/dp_8"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintDimensionRatio="42:16"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintWidth_percent="0.145"
|
||||
app:solid="@color/color_7748C7" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatImageView
|
||||
android:layout_width="@dimen/dp_24"
|
||||
android:layout_height="@dimen/dp_24"
|
||||
android:layout_marginStart="@dimen/dp_4"
|
||||
android:src="@drawable/ic_token"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<View
|
||||
android:id="@+id/view_1"
|
||||
android:layout_width="@dimen/dp_0"
|
||||
android:layout_height="@dimen/dp_0"
|
||||
android:layout_marginStart="@dimen/dp_8"
|
||||
android:background="@drawable/selector_bg_box_price"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintDimensionRatio="30:16"
|
||||
app:layout_constraintStart_toEndOf="@+id/tv_box_num"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintWidth_percent="0.104" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:id="@+id/tv_1"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:alpha="0.4"
|
||||
android:text="1"
|
||||
android:textColor="@color/color_white"
|
||||
android:textSize="@dimen/sp_10"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/view_1"
|
||||
app:layout_constraintEnd_toEndOf="@+id/view_1"
|
||||
app:layout_constraintStart_toStartOf="@+id/view_1"
|
||||
app:layout_constraintTop_toTopOf="@+id/view_1" />
|
||||
|
||||
<View
|
||||
android:id="@+id/view_2"
|
||||
android:layout_width="@dimen/dp_0"
|
||||
android:layout_height="@dimen/dp_0"
|
||||
android:layout_marginStart="@dimen/dp_8"
|
||||
android:background="@drawable/selector_bg_box_price"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintDimensionRatio="30:16"
|
||||
app:layout_constraintStart_toEndOf="@+id/view_1"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintWidth_percent="0.104" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:id="@+id/tv_2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:alpha="0.4"
|
||||
android:text="10"
|
||||
android:textColor="@color/color_white"
|
||||
android:textSize="@dimen/sp_10"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/view_2"
|
||||
app:layout_constraintEnd_toEndOf="@+id/view_2"
|
||||
app:layout_constraintStart_toStartOf="@+id/view_2"
|
||||
app:layout_constraintTop_toTopOf="@+id/view_2" />
|
||||
|
||||
<View
|
||||
android:id="@+id/view_3"
|
||||
android:layout_width="@dimen/dp_0"
|
||||
android:layout_height="@dimen/dp_0"
|
||||
android:layout_marginStart="@dimen/dp_8"
|
||||
android:background="@drawable/selector_bg_box_price"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintDimensionRatio="30:16"
|
||||
app:layout_constraintStart_toEndOf="@+id/view_2"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintWidth_percent="0.104" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:id="@+id/tv_3"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:alpha="0.4"
|
||||
android:text="100"
|
||||
android:textColor="@color/color_white"
|
||||
android:textSize="@dimen/sp_10"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/view_3"
|
||||
app:layout_constraintEnd_toEndOf="@+id/view_3"
|
||||
app:layout_constraintStart_toStartOf="@+id/view_3"
|
||||
app:layout_constraintTop_toTopOf="@+id/view_3" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatEditText
|
||||
android:id="@+id/ed_input_num"
|
||||
android:layout_width="@dimen/dp_0"
|
||||
android:layout_height="@dimen/dp_18"
|
||||
android:layout_marginStart="@dimen/dp_6"
|
||||
android:layout_marginEnd="@dimen/dp_6"
|
||||
android:background="@drawable/bg_7748c7_r10"
|
||||
android:gravity="center"
|
||||
android:hint="@string/please_input_quantity"
|
||||
android:inputType="number"
|
||||
android:maxLines="1"
|
||||
android:textColor="@color/white"
|
||||
android:textColorHint="@color/white_tran_40"
|
||||
android:textSize="@dimen/sp_10"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@+id/tv_buy"
|
||||
app:layout_constraintStart_toEndOf="@+id/view_3"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<com.coorchice.library.SuperTextView
|
||||
android:id="@+id/tv_buy"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginEnd="@dimen/dp_4"
|
||||
android:background="@drawable/bg_box_buy"
|
||||
android:gravity="center"
|
||||
android:text="@string/buy"
|
||||
android:textColor="@color/color_white"
|
||||
android:textSize="@dimen/sp_10"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintDimensionRatio="52:22"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintWidth_percent="0.18" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<com.opensource.svgaplayer.SVGAImageView
|
||||
android:id="@+id/iv_box"
|
||||
android:layout_width="190dp"
|
||||
android:layout_height="242dp"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_marginTop="52dp"
|
||||
android:onClick="@{click}"
|
||||
android:visibility="invisible"
|
||||
app:autoPlay="true"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="@id/view_bg"
|
||||
app:loopCount="999999"
|
||||
app:source="svga/gold_box_bg.svga" />
|
||||
|
||||
<com.opensource.svgaplayer.SVGAImageView
|
||||
android:id="@+id/iv_box_open"
|
||||
android:layout_width="190dp"
|
||||
android:layout_height="242dp"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_marginTop="52dp"
|
||||
app:autoPlay="false"
|
||||
app:fillMode="Clear"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="@id/view_bg"
|
||||
app:loopCount="1"
|
||||
app:source="svga/gold_box_open.svga" />
|
||||
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_gift_anim"
|
||||
android:layout_width="50dp"
|
||||
android:layout_height="50dp"
|
||||
app:layout_constraintBottom_toBottomOf="@id/iv_box"
|
||||
app:layout_constraintEnd_toEndOf="@id/iv_box"
|
||||
app:layout_constraintStart_toStartOf="@id/iv_box"
|
||||
app:layout_constraintTop_toTopOf="@id/iv_box" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/ll_prize_hint"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="135dp"
|
||||
android:layout_marginStart="7dp"
|
||||
android:layout_marginBottom="110dp"
|
||||
android:gravity="bottom"
|
||||
android:orientation="vertical"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/view_bg"
|
||||
app:layout_constraintStart_toStartOf="@id/view_bg" />
|
||||
|
||||
<com.opensource.svgaplayer.SVGAImageView
|
||||
android:id="@+id/svga_gift_bg"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginStart="80dp"
|
||||
android:layout_marginTop="60dp"
|
||||
app:autoPlay="false"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="@id/iv_box"
|
||||
app:layout_constraintTop_toTopOf="@id/iv_box"
|
||||
app:loopCount="1"
|
||||
app:source="svga/bubble_tran_bg.svga"
|
||||
tools:background="@color/white"
|
||||
tools:visibility="gone" />
|
||||
|
||||
<com.chwl.app.avroom.widget.RoomEffectBoxView
|
||||
android:id="@+id/effect_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</layout>
|