feat:初步搭建游戏房框架(待完善)
feat:完成游戏首页UI与部分接口联调 feat:完成游戏房部分UI
@@ -116,6 +116,7 @@ android {
|
||||
'src/module_album/java',
|
||||
'src/module_treasure_box/java',
|
||||
'src/module_public_chat/java',
|
||||
'src/module_game/java',
|
||||
|
||||
]
|
||||
|
||||
@@ -131,6 +132,7 @@ android {
|
||||
'src/module_album/res',
|
||||
'src/module_treasure_box/res',
|
||||
'src/module_public_chat/res',
|
||||
'src/module_game/res',
|
||||
|
||||
]
|
||||
|
||||
|
@@ -922,6 +922,12 @@
|
||||
android:name=".pay.activity.GiveGoldSearchActivity"
|
||||
android:screenOrientation="portrait"
|
||||
android:windowSoftInputMode="stateHidden|adjustResize" />
|
||||
<activity
|
||||
android:name=".game.ui.game.GameActivity"
|
||||
android:hardwareAccelerated="true"
|
||||
android:launchMode="singleTask"
|
||||
android:screenOrientation="portrait"
|
||||
android:windowSoftInputMode="adjustPan" />
|
||||
</application>
|
||||
|
||||
</manifest>
|
@@ -24,6 +24,7 @@ import androidx.fragment.app.FragmentTransaction;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
|
||||
import com.chwl.app.base.GlobalViewModelOwner;
|
||||
import com.chwl.app.game.ui.home.GameHomeFragment;
|
||||
import com.chwl.app.star.StarFragment;
|
||||
import com.chwl.app.support.PreloadResourceViewModel;
|
||||
import com.chwl.app.ui.login.LoginPasswordActivity;
|
||||
@@ -163,6 +164,7 @@ public class MainActivity extends BaseMvpActivity<IMainView, MainPresenter>
|
||||
|
||||
{
|
||||
fragmentArray.put(MainTabType.TAB_TYPE_STAR, new StarFragment());
|
||||
fragmentArray.put(MainTabType.TAB_TYPE_GAME, new GameHomeFragment());
|
||||
fragmentArray.put(MainTabType.TAB_TYPE_HOME, new HomeFragment());
|
||||
fragmentArray.put(MainTabType.TAB_TYPE_MSG, new ContactsListFragment());
|
||||
fragmentArray.put(MainTabType.TAB_TYPE_ME, new MeFragment());
|
||||
|
@@ -42,6 +42,7 @@ import com.chwl.app.ui.webview.baishun.BaiShunGameWebFragment;
|
||||
import com.chwl.app.ui.webview.baishun.IBaiShunGameListener;
|
||||
import com.chwl.core.monsterhunting.bean.MonsterDataBean;
|
||||
import com.chwl.core.room.game.bean.BaiShunGameConfig;
|
||||
import com.chwl.core.support.room.AudioRoomContext;
|
||||
import com.chwl.core.support.room.RoomWidget;
|
||||
import com.netease.nim.uikit.StatusBarUtil;
|
||||
import com.netease.nimlib.sdk.NIMSDK;
|
||||
@@ -1359,7 +1360,7 @@ public class AVRoomActivity extends BaseMvpActivity<IAvRoomView, AvRoomPresenter
|
||||
@Nullable
|
||||
@Override
|
||||
public RoomContext getRoomContext() {
|
||||
return RoomContext.Companion.get();
|
||||
return AudioRoomContext.Companion.get();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@@ -1374,6 +1375,7 @@ public class AVRoomActivity extends BaseMvpActivity<IAvRoomView, AvRoomPresenter
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
private static class GiftBroadcastObserver implements Observer<BroadcastMessage> {
|
||||
private WeakReference<AVRoomActivity> mReference;
|
||||
|
||||
|
@@ -1,16 +0,0 @@
|
||||
package com.chwl.app.avroom.core
|
||||
|
||||
import com.chwl.core.support.room.RoomAbility
|
||||
import com.chwl.core.support.room.RoomContext
|
||||
|
||||
/**
|
||||
* Created by Max on 2023/10/26 15:41
|
||||
* Desc:语音房
|
||||
* @param roomId roomUid
|
||||
**/
|
||||
class AudioRoomContext(roomId: Long) : RoomContext(roomId) {
|
||||
|
||||
override fun loadAbility(list: MutableMap<String, RoomAbility>) {
|
||||
super.loadAbility(list)
|
||||
}
|
||||
}
|
@@ -18,6 +18,7 @@ import com.chwl.core.room.bean.RoomIcon
|
||||
import com.chwl.core.room.core.RoomDataService
|
||||
import com.chwl.core.room.game.bean.BaiShunGameConfig
|
||||
import com.chwl.core.room.model.AvRoomModel
|
||||
import com.chwl.core.support.room.AudioRoomContext
|
||||
import com.chwl.core.support.room.RoomContext
|
||||
import com.chwl.library.utils.SingleToastUtil
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
|
||||
@@ -68,7 +69,7 @@ class RoomGameplayDialog :
|
||||
|
||||
private fun requestData() {
|
||||
val dataService =
|
||||
RoomContext.get()?.findAbility<RoomDataService>(RoomDataService::class.java.simpleName)
|
||||
AudioRoomContext.get()?.findAbility<RoomDataService>(RoomDataService::class.java.simpleName)
|
||||
val cacheKey = "gameplay_list#${parentFragment.hashCode()}"
|
||||
val list = dataService?.getData(cacheKey) as? List<RoomIcon>
|
||||
if (!list.isNullOrEmpty()) {
|
||||
|
@@ -106,6 +106,8 @@ import com.chwl.core.share.bean.SessionType
|
||||
import com.chwl.core.super_admin.SaConstant
|
||||
import com.chwl.core.super_admin.model.SuperAdminModel
|
||||
import com.chwl.core.super_admin.util.SuperAdminUtil
|
||||
import com.chwl.core.support.room.AudioRoomContext
|
||||
import com.chwl.core.support.room.RoomContext
|
||||
import com.chwl.core.support.room.RoomView
|
||||
import com.chwl.core.support.room.RoomWidget
|
||||
import com.chwl.core.user.UserModel
|
||||
@@ -1462,6 +1464,10 @@ open class BaseRoomFragment<V : IBaseRoomView?, P1 : BaseRoomPresenter<V>?> :
|
||||
return widgets[name]
|
||||
}
|
||||
|
||||
override fun getRoomContext(): RoomContext? {
|
||||
return AudioRoomContext.get()
|
||||
}
|
||||
|
||||
open fun initWidget() {
|
||||
publicChatMessageWidget?.let {
|
||||
registerWidget(PublicChatRoomMessageWidget::class.java.simpleName, it)
|
||||
|
@@ -9,6 +9,7 @@ import android.util.SparseArray;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.chwl.core.support.room.AudioRoomContext;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
@@ -20,8 +21,6 @@ import com.netease.nimlib.sdk.chatroom.model.EnterChatRoomResultData;
|
||||
import com.netease.nimlib.sdk.util.Entry;
|
||||
import com.chwl.app.R;
|
||||
import com.chwl.app.avroom.activity.AVRoomActivity;
|
||||
import com.chwl.app.avroom.core.AudioRoomContext;
|
||||
import com.chwl.core.support.room.RoomContext;
|
||||
import com.chwl.app.avroom.view.IAvRoomView;
|
||||
import com.chwl.app.base.BaseMvpPresenter;
|
||||
import com.chwl.core.Constants;
|
||||
|
@@ -142,6 +142,9 @@ public class MainRedPointTab extends RelativeLayout {
|
||||
case MainTabType.TAB_TYPE_STAR:
|
||||
resId = select ? R.drawable.ic_main_tab_star_pressed : R.drawable.ic_main_tab_star;
|
||||
break;
|
||||
case MainTabType.TAB_TYPE_GAME:
|
||||
resId = select ? R.drawable.ic_main_tab_game_pressed : R.drawable.ic_main_tab_game;
|
||||
break;
|
||||
case MainTabType.TAB_TYPE_MSG:
|
||||
resId = select ? R.drawable.ic_main_tab_msg_pressed : R.drawable.ic_main_tab_msg;
|
||||
break;
|
||||
|
@@ -26,6 +26,7 @@ public class MainTabLayout extends LinearLayout implements View.OnClickListener
|
||||
private final List<MainRedPointTab> tabViewList = new ArrayList<>(4);
|
||||
private MainRedPointTab homeTab;
|
||||
private MainRedPointTab starTab;
|
||||
private MainRedPointTab gameTab;
|
||||
private MainRedPointTab msgTab;
|
||||
private MainRedPointTab meTab;
|
||||
private int mLastPosition = -1;
|
||||
@@ -57,15 +58,18 @@ public class MainTabLayout extends LinearLayout implements View.OnClickListener
|
||||
|
||||
msgTab = findViewById(R.id.main_msg_tab);
|
||||
starTab = findViewById(R.id.main_star_tab);
|
||||
gameTab = findViewById(R.id.main_game_tab);
|
||||
homeTab = findViewById(R.id.main_home_tab);
|
||||
meTab = findViewById(R.id.main_me_tab);
|
||||
|
||||
homeTab.setOnClickListener(this);
|
||||
meTab.setOnClickListener(this);
|
||||
starTab.setOnClickListener(this);
|
||||
gameTab.setOnClickListener(this);
|
||||
msgTab.setOnClickListener(this);
|
||||
|
||||
tabViewList.add(starTab);
|
||||
tabViewList.add(gameTab);
|
||||
tabViewList.add(homeTab);
|
||||
tabViewList.add(msgTab);
|
||||
tabViewList.add(meTab);
|
||||
@@ -105,6 +109,9 @@ public class MainTabLayout extends LinearLayout implements View.OnClickListener
|
||||
case R.id.main_star_tab:
|
||||
select(MainTabType.TAB_TYPE_STAR);
|
||||
break;
|
||||
case R.id.main_game_tab:
|
||||
select(MainTabType.TAB_TYPE_GAME);
|
||||
break;
|
||||
case R.id.main_msg_tab:
|
||||
select(MainTabType.TAB_TYPE_MSG);
|
||||
break;
|
||||
@@ -115,10 +122,11 @@ public class MainTabLayout extends LinearLayout implements View.OnClickListener
|
||||
}
|
||||
|
||||
private void select(int tabType) {
|
||||
if (tabType == 0) tabType = MainTabType.TAB_TYPE_HOME;
|
||||
if (tabType == 0) tabType = MainTabType.TAB_TYPE_STAR;
|
||||
if (mLastPosition == tabType) return;
|
||||
msgTab.select(tabType == MainTabType.TAB_TYPE_MSG);
|
||||
starTab.select(tabType == MainTabType.TAB_TYPE_STAR);
|
||||
gameTab.select(tabType == MainTabType.TAB_TYPE_GAME);
|
||||
homeTab.select(tabType == MainTabType.TAB_TYPE_HOME);
|
||||
meTab.select(tabType == MainTabType.TAB_TYPE_ME);
|
||||
if (mOnTabClickListener != null) {
|
||||
|
@@ -7,6 +7,8 @@ import androidx.recyclerview.widget.GridLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import androidx.recyclerview.widget.StaggeredGridLayoutManager;
|
||||
|
||||
import com.example.lib_utils.UiUtils;
|
||||
|
||||
/**
|
||||
* User: wukai
|
||||
* Date: 2017/03/26
|
||||
@@ -18,6 +20,7 @@ public class GridSpacingItemNewDecoration extends RecyclerView.ItemDecoration {
|
||||
private int mHorSpacing;
|
||||
private boolean mIncludeEdge;
|
||||
private boolean mHasHeaderView;
|
||||
private Boolean isRTL;
|
||||
|
||||
public GridSpacingItemNewDecoration(int spacing, boolean includeEdge) {
|
||||
this(spacing, spacing, includeEdge);
|
||||
@@ -59,6 +62,9 @@ public class GridSpacingItemNewDecoration extends RecyclerView.ItemDecoration {
|
||||
|
||||
@Override
|
||||
public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
|
||||
if (isRTL == null) {
|
||||
isRTL = UiUtils.INSTANCE.isRtl(parent.getContext());
|
||||
}
|
||||
int spanCount = getSpanCount(parent);
|
||||
int position = parent.getChildAdapterPosition(view); // item position
|
||||
int spanIndex = getSpanIndex(view, parent);
|
||||
@@ -83,6 +89,11 @@ public class GridSpacingItemNewDecoration extends RecyclerView.ItemDecoration {
|
||||
outRect.top = mVerSpacing; // item top
|
||||
}
|
||||
}
|
||||
if (isRTL) {
|
||||
int right = outRect.right;
|
||||
outRect.right = outRect.left;
|
||||
outRect.left = right;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
BIN
app/src/main/res/drawable-xxhdpi/ic_main_tab_game.png
Normal file
After Width: | Height: | Size: 8.1 KiB |
BIN
app/src/main/res/drawable-xxhdpi/ic_main_tab_game_pressed.png
Normal file
After Width: | Height: | Size: 12 KiB |
@@ -13,6 +13,13 @@
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_weight="1" />
|
||||
|
||||
<com.chwl.app.ui.widget.MainRedPointTab
|
||||
android:id="@+id/main_game_tab"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_weight="1" />
|
||||
|
||||
<com.chwl.app.ui.widget.MainRedPointTab
|
||||
android:id="@+id/main_home_tab"
|
||||
android:layout_width="0dp"
|
||||
|
@@ -0,0 +1,14 @@
|
||||
package com.chwl.app.game.core
|
||||
|
||||
import com.chwl.core.support.room.RoomAbility
|
||||
import com.chwl.core.support.room.RoomContext
|
||||
|
||||
class GameContext(roomId: Long) : RoomContext(roomId) {
|
||||
|
||||
override fun loadAbility(list: MutableMap<String, RoomAbility>) {
|
||||
super.loadAbility(list)
|
||||
list.put(GameIMEngineAbility::class.java.simpleName, GameIMEngineAbility())
|
||||
list.put(GameQueueAbility::class.java.simpleName, GameQueueAbility())
|
||||
list.put(GameMessageAbility::class.java.simpleName, GameMessageAbility())
|
||||
}
|
||||
}
|
@@ -0,0 +1,53 @@
|
||||
package com.chwl.app.game.core
|
||||
|
||||
import com.chwl.app.public_chat.core.ChatRoomClient
|
||||
import com.chwl.app.public_chat.core.ChatRoomClientManager
|
||||
import com.chwl.core.support.room.RoomAbility
|
||||
import com.netease.nimlib.sdk.chatroom.model.ChatRoomMessage
|
||||
import com.netease.nimlib.sdk.msg.constant.MsgTypeEnum
|
||||
import com.netease.nimlib.sdk.msg.model.QueryDirectionEnum
|
||||
|
||||
class GameIMEngineAbility : RoomAbility() {
|
||||
|
||||
private var client: ChatRoomClient? = null
|
||||
|
||||
fun enterRoom(sessionId: String) {
|
||||
client = ChatRoomClientManager.getClient(sessionId)
|
||||
client?.let {
|
||||
addDisposable(it.enterChatRoom().subscribe({
|
||||
|
||||
}, {
|
||||
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
||||
fun sendMessage(message: ChatRoomMessage) {
|
||||
client?.let {
|
||||
addDisposable(it.sendMessage(message).subscribe({
|
||||
|
||||
}, {
|
||||
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
||||
private fun requestHistory(chatRoomClient: ChatRoomClient) {
|
||||
val typeEnums = arrayOf(MsgTypeEnum.text)
|
||||
addDisposable(
|
||||
chatRoomClient.requestRemoteMessageType(
|
||||
0,
|
||||
50,
|
||||
QueryDirectionEnum.QUERY_OLD,
|
||||
typeEnums
|
||||
).subscribe({
|
||||
}, {
|
||||
it.printStackTrace()
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
interface Listener {
|
||||
fun onStateChange()
|
||||
}
|
||||
}
|
@@ -0,0 +1,29 @@
|
||||
package com.chwl.app.game.core
|
||||
|
||||
import com.chwl.core.support.listener.ListenerOwner
|
||||
import com.chwl.core.support.listener.ListenerStore
|
||||
import com.chwl.core.support.listener.SafeListenerOwner
|
||||
import com.chwl.core.support.room.RoomAbility
|
||||
|
||||
class GameMessageAbility(private val listenerOwner: ListenerOwner<GameMessageAbility.Listener> = SafeListenerOwner()) :
|
||||
RoomAbility(), ListenerStore<GameMessageAbility.Listener> by listenerOwner {
|
||||
|
||||
private val dataList = ArrayList<Any>()
|
||||
|
||||
fun getMessageList(): List<Any> {
|
||||
return dataList
|
||||
}
|
||||
|
||||
fun addMessage(message: Any) {
|
||||
dataList.add(message)
|
||||
listenerOwner.postEvent {
|
||||
it.onAddMessage(message)
|
||||
}
|
||||
}
|
||||
|
||||
interface Listener {
|
||||
fun onAddMessage(message: Any)
|
||||
|
||||
fun onReplaceMessageList(list: List<Any>)
|
||||
}
|
||||
}
|
@@ -0,0 +1,7 @@
|
||||
package com.chwl.app.game.core
|
||||
|
||||
import com.chwl.core.support.room.RoomAbility
|
||||
|
||||
class GameQueueAbility : RoomAbility() {
|
||||
|
||||
}
|
@@ -0,0 +1,16 @@
|
||||
package com.chwl.app.game.core
|
||||
|
||||
import com.chwl.app.game.data.GameModel
|
||||
import com.chwl.core.support.room.RoomAbility
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
|
||||
class GameStateAbility : RoomAbility() {
|
||||
|
||||
val gameState: MutableStateFlow<Int> = MutableStateFlow(0)
|
||||
|
||||
fun requestRoomInfo() {
|
||||
safeLaunch {
|
||||
val info = GameModel.getGameRoomInfo()
|
||||
}
|
||||
}
|
||||
}
|
42
app/src/module_game/java/com/chwl/app/game/data/GameModel.kt
Normal file
@@ -0,0 +1,42 @@
|
||||
package com.chwl.app.game.data
|
||||
|
||||
import com.chwl.app.game.data.bean.GameConfigBean
|
||||
import com.chwl.app.game.data.bean.GameRoomInfo
|
||||
import com.chwl.core.base.BaseModel
|
||||
import com.chwl.core.bean.response.ServiceResult
|
||||
import com.chwl.core.home.bean.*
|
||||
import com.chwl.core.utils.net.launchRequest
|
||||
import com.chwl.library.net.rxnet.RxNet
|
||||
import retrofit2.http.GET
|
||||
|
||||
object GameModel : BaseModel() {
|
||||
|
||||
private val api = RxNet.create(Api::class.java)
|
||||
|
||||
suspend fun getHomeGameConfig(): GameConfigBean? =
|
||||
launchRequest {
|
||||
api.getHomeGameConfig()
|
||||
}
|
||||
|
||||
suspend fun getGameRoomInfo(): GameRoomInfo? =
|
||||
launchRequest {
|
||||
api.getGameRoomInfo()
|
||||
}
|
||||
|
||||
private interface Api {
|
||||
/**
|
||||
* 游戏房信息
|
||||
*
|
||||
* @return -
|
||||
*/
|
||||
@GET("resource/")
|
||||
suspend fun getGameRoomInfo(): ServiceResult<GameRoomInfo>
|
||||
|
||||
/**
|
||||
* 首页游戏配置
|
||||
*/
|
||||
@GET("miniGame/nav/config")
|
||||
suspend fun getHomeGameConfig(): ServiceResult<GameConfigBean>
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,12 @@
|
||||
package com.chwl.app.game.data.bean
|
||||
|
||||
import androidx.annotation.Keep
|
||||
|
||||
@Keep
|
||||
class GameConfigBean {
|
||||
val mgId: Long? = null
|
||||
val mgIdStr: String? = null
|
||||
val name: String? = null
|
||||
val pic: String? = null
|
||||
val gameModes: List<GameModeBean>? = null
|
||||
}
|
@@ -0,0 +1,12 @@
|
||||
package com.chwl.app.game.data.bean
|
||||
|
||||
import androidx.annotation.Keep
|
||||
import java.io.Serializable
|
||||
|
||||
@Keep
|
||||
class GameModeBean : Serializable {
|
||||
val ticket: Long? = null
|
||||
val modeIcon: String? = null
|
||||
val gameMode: Int? = null
|
||||
val scores: List<Int>? = null
|
||||
}
|
@@ -0,0 +1,8 @@
|
||||
package com.chwl.app.game.data.bean
|
||||
|
||||
import androidx.annotation.Keep
|
||||
import java.io.Serializable
|
||||
|
||||
@Keep
|
||||
class GameRoomInfo : Serializable {
|
||||
}
|
@@ -0,0 +1,9 @@
|
||||
package com.chwl.app.game.ui.buy
|
||||
|
||||
import com.chwl.app.databinding.GameBuyDialogBinding
|
||||
import com.chwl.library.common.base.BaseDialogFragment
|
||||
|
||||
class GameBuyDialog : BaseDialogFragment<GameBuyDialogBinding>() {
|
||||
|
||||
|
||||
}
|
@@ -0,0 +1,64 @@
|
||||
package com.chwl.app.game.ui.game
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import androidx.activity.viewModels
|
||||
import com.chwl.app.R
|
||||
import com.chwl.app.base.BaseViewBindingActivity
|
||||
import com.chwl.app.databinding.GameActivityBinding
|
||||
import com.example.lib_utils.ktx.singleClick
|
||||
import com.netease.nim.uikit.StatusBarUtil
|
||||
|
||||
class GameActivity : BaseViewBindingActivity<GameActivityBinding>() {
|
||||
|
||||
private val viewModel: GameViewModel by viewModels()
|
||||
private val gameViewModel: GameEngineViewModel by viewModels()
|
||||
|
||||
companion object {
|
||||
fun start(context: Context, intent: GameIntent) {
|
||||
context.startActivity(Intent(context, GameActivity::class.java).apply {
|
||||
putExtra("intent", intent)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
override fun init() {
|
||||
val intentData = intent.getSerializableExtra("intent") as? GameIntent
|
||||
if (intentData == null) {
|
||||
toast(R.string.utils_net_beanobserver_05)
|
||||
finish()
|
||||
return
|
||||
}
|
||||
initView()
|
||||
initEvent()
|
||||
initObserver()
|
||||
viewModel.init(intentData)
|
||||
}
|
||||
|
||||
private fun initView() {
|
||||
|
||||
}
|
||||
|
||||
private fun initEvent() {
|
||||
binding.ivClose.singleClick {
|
||||
toast("close")
|
||||
finish()
|
||||
}
|
||||
}
|
||||
|
||||
private fun initObserver() {
|
||||
gameViewModel.gameViewLiveData.observe(this) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
override fun needSteepStateBar(): Boolean {
|
||||
return true
|
||||
}
|
||||
|
||||
override fun setStatusBar() {
|
||||
super.setStatusBar()
|
||||
StatusBarUtil.transparencyBar(this)
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,10 @@
|
||||
package com.chwl.app.game.ui.game
|
||||
|
||||
import android.view.View
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import com.chwl.app.base.BaseViewModel
|
||||
|
||||
class GameEngineViewModel : BaseViewModel() {
|
||||
|
||||
val gameViewLiveData = MutableLiveData<View?>()
|
||||
}
|
@@ -0,0 +1,8 @@
|
||||
package com.chwl.app.game.ui.game
|
||||
|
||||
import androidx.annotation.Keep
|
||||
import java.io.Serializable
|
||||
|
||||
@Keep
|
||||
data class GameIntent(val roomId: Long, val gameId: String, val gameMode: String) : Serializable {
|
||||
}
|
@@ -0,0 +1,13 @@
|
||||
package com.chwl.app.game.ui.game
|
||||
|
||||
import com.chwl.app.base.BaseViewModel
|
||||
import com.chwl.app.game.core.GameContext
|
||||
|
||||
class GameViewModel : BaseViewModel() {
|
||||
|
||||
private var roomContext: GameContext? = null
|
||||
|
||||
fun init(intent: GameIntent) {
|
||||
roomContext = GameContext(intent.roomId)
|
||||
}
|
||||
}
|
@@ -0,0 +1,34 @@
|
||||
package com.chwl.app.game.ui.game.widgets.message
|
||||
|
||||
import android.view.LayoutInflater
|
||||
import android.view.ViewGroup
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import androidx.recyclerview.widget.RecyclerView.ViewHolder
|
||||
import com.chwl.app.R
|
||||
|
||||
class GameMessageAdapter<T>(val dataList: MutableList<T>) :
|
||||
RecyclerView.Adapter<RecyclerView.ViewHolder>() {
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): GameMessageNormalViewHolder {
|
||||
return GameMessageNormalViewHolder(
|
||||
LayoutInflater.from(parent.context)
|
||||
.inflate(R.layout.game_message_widget_item_text, parent, false)
|
||||
)
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
|
||||
val message = getItem(position)
|
||||
}
|
||||
|
||||
fun getItem(position: Int): T? {
|
||||
return dataList.get(position)
|
||||
}
|
||||
|
||||
override fun getItemCount(): Int {
|
||||
return dataList.size
|
||||
}
|
||||
|
||||
protected open fun convert(holder: GameMessageNormalViewHolder, item: T){
|
||||
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,16 @@
|
||||
package com.chwl.app.game.ui.game.widgets.message
|
||||
|
||||
import android.view.View
|
||||
import android.widget.TextView
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.chwl.app.R
|
||||
|
||||
class GameMessageNormalViewHolder(val itemView: View) : RecyclerView.ViewHolder(itemView) {
|
||||
|
||||
var textView: TextView? = null
|
||||
|
||||
init {
|
||||
textView = itemView.findViewById(R.id.tv_content)
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,66 @@
|
||||
package com.chwl.app.game.ui.game.widgets.message
|
||||
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import android.view.ViewGroup
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.chwl.app.R
|
||||
import com.chwl.app.ui.widget.DividerItemDecoration
|
||||
import com.chwl.app.ui.widget.MyItemAnimator
|
||||
import com.chwl.app.ui.widget.RecyclerViewNoViewpagerScroll
|
||||
import com.chwl.core.support.room.FrameLayoutRoomWidget
|
||||
import com.netease.nimlib.sdk.chatroom.model.ChatRoomMessage
|
||||
|
||||
class GameMessageWidget : FrameLayoutRoomWidget {
|
||||
|
||||
private val recyclerView = RecyclerViewNoViewpagerScroll(context)
|
||||
private val adapter = GameMessageAdapter<ChatRoomMessage>(ArrayList())
|
||||
|
||||
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 {
|
||||
initListView()
|
||||
}
|
||||
|
||||
private fun initListView() {
|
||||
recyclerView.layoutParams =
|
||||
ViewGroup.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)
|
||||
recyclerView.setFadingEdgeLength(60)
|
||||
recyclerView.isVerticalFadingEdgeEnabled = true
|
||||
recyclerView.overScrollMode = OVER_SCROLL_NEVER
|
||||
recyclerView.isHorizontalScrollBarEnabled = false
|
||||
addView(recyclerView)
|
||||
val layoutManger = LinearLayoutManager(context, RecyclerView.VERTICAL, false)
|
||||
recyclerView.layoutManager = layoutManger
|
||||
recyclerView.addItemDecoration(
|
||||
DividerItemDecoration(
|
||||
context,
|
||||
layoutManger.orientation,
|
||||
16,
|
||||
R.color.transparent
|
||||
)
|
||||
)
|
||||
recyclerView.itemAnimator = MyItemAnimator().apply {
|
||||
this.supportsChangeAnimations = false
|
||||
this.addDuration = 0
|
||||
this.changeDuration = 0
|
||||
this.moveDuration = 0
|
||||
this.removeDuration = 0
|
||||
}
|
||||
recyclerView.adapter = adapter
|
||||
}
|
||||
}
|
@@ -0,0 +1,42 @@
|
||||
package com.chwl.app.game.ui.game.widgets.queue
|
||||
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import android.view.LayoutInflater
|
||||
import androidx.databinding.DataBindingUtil
|
||||
import com.chwl.app.R
|
||||
import com.chwl.app.databinding.GameQueueWidgetBinding
|
||||
import com.chwl.core.support.room.FrameLayoutRoomWidget
|
||||
|
||||
class GameQueueWidget : FrameLayoutRoomWidget {
|
||||
|
||||
private val binding: GameQueueWidgetBinding =
|
||||
DataBindingUtil.inflate(
|
||||
LayoutInflater.from(
|
||||
context
|
||||
), R.layout.game_queue_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.tvState.setText("AAAA")
|
||||
}
|
||||
|
||||
private fun updateState() {
|
||||
|
||||
}
|
||||
}
|
@@ -0,0 +1,14 @@
|
||||
package com.chwl.app.game.ui.home
|
||||
|
||||
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.game.data.bean.GameModeBean
|
||||
import com.chwl.app.ui.utils.load
|
||||
|
||||
class GameHomeAdapter : BaseQuickAdapter<GameModeBean, BaseViewHolder>(R.layout.game_home_item) {
|
||||
override fun convert(helper: BaseViewHolder, item: GameModeBean?) {
|
||||
helper.getView<ImageView>(R.id.iv_game).load(item?.modeIcon)
|
||||
}
|
||||
}
|
@@ -0,0 +1,106 @@
|
||||
package com.chwl.app.game.ui.home
|
||||
|
||||
import androidx.fragment.app.activityViewModels
|
||||
import com.chwl.app.MainTabContentView
|
||||
import com.chwl.app.base.BaseViewBindingFragment
|
||||
import com.chwl.app.databinding.GameHomeFragmentBinding
|
||||
import com.chwl.app.game.data.bean.GameConfigBean
|
||||
import com.chwl.app.game.ui.buy.GameBuyDialog
|
||||
import com.chwl.app.game.ui.game.GameActivity
|
||||
import com.chwl.app.game.ui.game.GameIntent
|
||||
import com.chwl.app.ui.pay.ChargeActivity
|
||||
import com.chwl.app.ui.utils.load
|
||||
import com.chwl.app.ui.utils.loadAvatar
|
||||
import com.chwl.app.ui.widget.recyclerview.decoration.GridSpacingItemNewDecoration
|
||||
import com.chwl.core.pay.PayModel
|
||||
import com.chwl.core.pay.event.GetWalletInfoEvent
|
||||
import com.chwl.core.pay.event.UpdateWalletInfoEvent
|
||||
import com.chwl.core.user.UserModel
|
||||
import com.chwl.core.user.event.LoginUserInfoUpdateEvent
|
||||
import com.chwl.core.utils.CoreTextUtils
|
||||
import com.chwl.library.utils.FormatUtils
|
||||
import com.example.lib_utils.UiUtils
|
||||
import com.example.lib_utils.ktx.singleClick
|
||||
import org.greenrobot.eventbus.Subscribe
|
||||
import org.greenrobot.eventbus.ThreadMode
|
||||
|
||||
|
||||
class GameHomeFragment : BaseViewBindingFragment<GameHomeFragmentBinding>(), MainTabContentView {
|
||||
private val adapter = GameHomeAdapter()
|
||||
private val viewModel: GameHomeViewModel by activityViewModels()
|
||||
override fun init() {
|
||||
initView()
|
||||
initEvent()
|
||||
initObserver()
|
||||
PayModel.get().refreshWalletInfo(true)
|
||||
refreshWalletInfo()
|
||||
refreshUserInfo()
|
||||
}
|
||||
|
||||
private fun initView() {
|
||||
binding.recyclerView.addItemDecoration(
|
||||
GridSpacingItemNewDecoration(
|
||||
UiUtils.dip2px(10f),
|
||||
UiUtils.dip2px(18.5f),
|
||||
false
|
||||
)
|
||||
)
|
||||
binding.recyclerView.adapter = adapter
|
||||
}
|
||||
|
||||
private fun initEvent() {
|
||||
binding.layoutWallet.singleClick {
|
||||
ChargeActivity.start(context)
|
||||
}
|
||||
binding.ivRank.singleClick {
|
||||
toast("RANK")
|
||||
GameActivity.start(requireContext(), GameIntent(111,"2","2"))
|
||||
}
|
||||
adapter.setOnItemClickListener { adapter, view, position ->
|
||||
toast("$position")
|
||||
GameBuyDialog().show(childFragmentManager,"GAME_BUY")
|
||||
}
|
||||
}
|
||||
|
||||
private fun initObserver() {
|
||||
viewModel.gameConfigLiveData.observe(this) {
|
||||
val configData = it.data
|
||||
if (it.isSuccess && configData != null) {
|
||||
loadGameInfo(configData)
|
||||
} else {
|
||||
toast(it.message)
|
||||
}
|
||||
}
|
||||
viewModel.getGameList()
|
||||
}
|
||||
|
||||
private fun loadGameInfo(config: GameConfigBean) {
|
||||
binding.ivGameLogo.load(config.pic)
|
||||
adapter.setNewData(config.gameModes)
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
fun onWalletInfoUpdate(event: UpdateWalletInfoEvent?) {
|
||||
refreshWalletInfo()
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
fun onGetWalletInfoEvent(event: GetWalletInfoEvent?) {
|
||||
refreshWalletInfo()
|
||||
}
|
||||
|
||||
private fun refreshWalletInfo() {
|
||||
binding.tvWalletValue.text =
|
||||
FormatUtils.formatBigInteger(PayModel.get().currentWalletInfo?.diamondNum ?: 0.0)
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
fun onLoginUserInfoUpdateEvent(event: LoginUserInfoUpdateEvent?) {
|
||||
refreshUserInfo()
|
||||
}
|
||||
|
||||
private fun refreshUserInfo() {
|
||||
val userInfo = UserModel.get().cacheLoginUserInfo
|
||||
binding.ivAvatar.loadAvatar(if (CoreTextUtils.isEmptyText(userInfo?.newAvatar)) userInfo?.avatar else userInfo?.newAvatar)
|
||||
}
|
||||
}
|
@@ -0,0 +1,20 @@
|
||||
package com.chwl.app.game.ui.home
|
||||
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import com.chwl.app.base.BaseViewModel
|
||||
import com.chwl.app.game.data.GameModel
|
||||
import com.chwl.app.game.data.bean.GameConfigBean
|
||||
import com.chwl.core.bean.response.BeanResult
|
||||
|
||||
class GameHomeViewModel : BaseViewModel() {
|
||||
val gameConfigLiveData = MutableLiveData<BeanResult<GameConfigBean>>()
|
||||
|
||||
fun getGameList() {
|
||||
safeLaunch(onError = {
|
||||
gameConfigLiveData.postValue(BeanResult.Companion.failed(it))
|
||||
}) {
|
||||
val configBean = GameModel.getHomeGameConfig()
|
||||
gameConfigLiveData.postValue(BeanResult.success(configBean))
|
||||
}
|
||||
}
|
||||
}
|
BIN
app/src/module_game/res/drawable-xxhdpi/game_bg.webp
Normal file
After Width: | Height: | Size: 124 KiB |
BIN
app/src/module_game/res/drawable-xxhdpi/game_buy_bg.webp
Normal file
After Width: | Height: | Size: 4.8 KiB |
BIN
app/src/module_game/res/drawable-xxhdpi/game_buy_bg_body.webp
Normal file
After Width: | Height: | Size: 4.3 KiB |
BIN
app/src/module_game/res/drawable-xxhdpi/game_buy_btn.webp
Normal file
After Width: | Height: | Size: 2.3 KiB |
BIN
app/src/module_game/res/drawable-xxhdpi/game_buy_ic_help.webp
Normal file
After Width: | Height: | Size: 3.7 KiB |
BIN
app/src/module_game/res/drawable-xxhdpi/game_home_ic_add.webp
Normal file
After Width: | Height: | Size: 4.1 KiB |
After Width: | Height: | Size: 2.1 KiB |
BIN
app/src/module_game/res/drawable-xxhdpi/game_home_ic_rank.webp
Normal file
After Width: | Height: | Size: 10 KiB |
BIN
app/src/module_game/res/drawable-xxhdpi/game_ic_close.webp
Normal file
After Width: | Height: | Size: 856 B |
BIN
app/src/module_game/res/drawable-xxhdpi/game_ic_coins.webp
Normal file
After Width: | Height: | Size: 8.1 KiB |
BIN
app/src/module_game/res/drawable-xxhdpi/game_ic_link.webp
Normal file
After Width: | Height: | Size: 68 KiB |
After Width: | Height: | Size: 14 KiB |
BIN
app/src/module_game/res/drawable-xxhdpi/game_ic_vs.webp
Normal file
After Width: | Height: | Size: 75 KiB |
9
app/src/module_game/res/drawable/game_bg_award.xml
Normal file
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<corners android:radius="@dimen/dp_25" />
|
||||
<solid android:color="#66FFFFFF" />
|
||||
<stroke
|
||||
android:width="@dimen/dp_0_5"
|
||||
android:color="#36C0C8" />
|
||||
</shape>
|
12
app/src/module_game/res/drawable/game_bg_bottom.xml
Normal file
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
|
||||
<solid android:color="#33ffffff" />
|
||||
<corners
|
||||
android:bottomLeftRadius="0dp"
|
||||
android:bottomRightRadius="0dp"
|
||||
android:topLeftRadius="@dimen/dp_23"
|
||||
android:topRightRadius="@dimen/dp_23" />
|
||||
|
||||
</shape>
|
9
app/src/module_game/res/drawable/game_home_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">
|
||||
<gradient
|
||||
android:angle="270"
|
||||
android:centerColor="#BEFFEB"
|
||||
android:endColor="#F9FFFD"
|
||||
android:startColor="#FAFEFD" />
|
||||
</shape>
|
9
app/src/module_game/res/drawable/game_home_bg_wallet.xml
Normal file
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<corners android:radius="@dimen/dp_18" />
|
||||
<solid android:color="#BFFCFF" />
|
||||
<stroke
|
||||
android:width="@dimen/dp_0_5"
|
||||
android:color="#6EF2F9" />
|
||||
</shape>
|
133
app/src/module_game/res/layout/game_activity.xml
Normal file
@@ -0,0 +1,133 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_bg"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:scaleType="centerCrop"
|
||||
android:src="@drawable/game_bg" />
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/layout_game"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
|
||||
<Space
|
||||
android:id="@+id/space_title_bar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/dp_44"
|
||||
android:layout_marginTop="@dimen/dp_44"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<ImageView
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginStart="@dimen/dp_11"
|
||||
app:layout_constraintBottom_toBottomOf="@id/space_title_bar"
|
||||
app:layout_constraintDimensionRatio="90:80"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="@id/space_title_bar"
|
||||
app:layout_constraintWidth_percent="0.24" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_close"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="@dimen/dp_21"
|
||||
android:scaleType="fitCenter"
|
||||
android:src="@drawable/game_ic_close"
|
||||
app:layout_constraintBottom_toBottomOf="@id/space_title_bar"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="@id/space_title_bar" />
|
||||
|
||||
<com.chwl.app.game.ui.game.widgets.queue.GameQueueWidget
|
||||
android:id="@+id/queue_widget"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintTop_toBottomOf="@id/space_title_bar" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_award_tips"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="-5dp"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="@dimen/dp_14"
|
||||
app:layout_constraintBottom_toBottomOf="@id/queue_widget"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
tools:text="@string/game_award_tips_format" />
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/layout_award"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="@dimen/dp_21"
|
||||
android:layout_marginTop="@dimen/dp_22"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/tv_award_tips">
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="@dimen/dp_25"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:background="@drawable/game_bg_award">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_award_value"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="@dimen/dp_25"
|
||||
android:layout_marginStart="@dimen/dp_26"
|
||||
android:gravity="center"
|
||||
android:minWidth="@dimen/dp_56"
|
||||
android:paddingStart="@dimen/dp_10"
|
||||
android:paddingEnd="@dimen/dp_10"
|
||||
android:text="0"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="@dimen/dp_17" />
|
||||
</FrameLayout>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_award"
|
||||
android:layout_width="@dimen/dp_26"
|
||||
android:layout_height="@dimen/dp_26"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:src="@drawable/game_ic_coins" />
|
||||
</FrameLayout>
|
||||
|
||||
|
||||
<com.chwl.app.game.ui.game.widgets.message.GameMessageWidget
|
||||
android:id="@+id/message_widget"
|
||||
app:layout_constraintBottom_toTopOf="@id/layout_bottom"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintStart_toStartOf="parent" />
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/layout_bottom"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/dp_61"
|
||||
android:background="@drawable/game_bg_bottom"
|
||||
app:layout_constraintBottom_toBottomOf="parent">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_input"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/dp_28"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginHorizontal="@dimen/dp_39"
|
||||
android:background="@drawable/base_shape_190b032d_14dp"
|
||||
android:gravity="center_vertical|start"
|
||||
android:paddingHorizontal="@dimen/dp_21"
|
||||
android:text="@string/room_say_something"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="@dimen/dp_10" />
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
109
app/src/module_game/res/layout/game_buy_dialog.xml
Normal file
@@ -0,0 +1,109 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layout xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/game_buy_bg"
|
||||
app:layout_constraintDimensionRatio="375:252"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:includeFontPadding="false"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="@dimen/dp_18"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintVertical_bias="0.13"
|
||||
tools:text="Name" />
|
||||
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="@dimen/dp_32"
|
||||
android:src="@drawable/game_buy_ic_help"
|
||||
app:layout_constraintBottom_toBottomOf="@id/tv_title"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="@id/tv_title" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_body"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:src="@drawable/game_buy_bg_body"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintDimensionRatio="348.5:162.5"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintVertical_bias="0.77"
|
||||
app:layout_constraintWidth_percent="0.929" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_coins_bg"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:background="@drawable/base_shape_00757b_8dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintDimensionRatio="297:44"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintWidth_percent="0.792" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_coins"
|
||||
android:layout_width="@dimen/dp_22"
|
||||
android:layout_height="@dimen/dp_22"
|
||||
android:layout_marginEnd="@dimen/dp_6"
|
||||
android:src="@drawable/game_ic_coins"
|
||||
app:layout_constraintBottom_toBottomOf="@id/iv_coins_bg"
|
||||
app:layout_constraintEnd_toStartOf="@id/tv_coins"
|
||||
app:layout_constraintHorizontal_chainStyle="packed"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="@id/iv_coins_bg" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_coins"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="#F2EF25"
|
||||
android:textSize="@dimen/dp_18"
|
||||
app:layout_constraintBottom_toBottomOf="@id/iv_coins_bg"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@id/iv_coins"
|
||||
app:layout_constraintTop_toTopOf="@id/iv_coins_bg"
|
||||
tools:text="0" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/game_buy_btn"
|
||||
android:gravity="center"
|
||||
android:maxLines="1"
|
||||
android:paddingHorizontal="@dimen/dp_5"
|
||||
android:text="@string/start"
|
||||
android:textColor="#A75906"
|
||||
android:textSize="@dimen/dp_20"
|
||||
app:autoSizeMaxTextSize="@dimen/dp_20"
|
||||
app:autoSizeMinTextSize="@dimen/dp_12"
|
||||
app:autoSizeStepGranularity="1px"
|
||||
app:autoSizeTextType="uniform"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintVertical_bias="0.809" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
</layout>
|
137
app/src/module_game/res/layout/game_home_fragment.xml
Normal file
@@ -0,0 +1,137 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@drawable/game_home_bg">
|
||||
|
||||
<Space
|
||||
android:id="@+id/space_title_bar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/dp_44"
|
||||
android:layout_marginTop="@dimen/dp_44"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<com.google.android.material.imageview.ShapeableImageView
|
||||
android:id="@+id/iv_avatar"
|
||||
android:layout_width="@dimen/dp_34"
|
||||
android:layout_height="@dimen/dp_34"
|
||||
android:layout_marginStart="@dimen/dp_20"
|
||||
android:src="@drawable/default_avatar"
|
||||
app:layout_constraintBottom_toBottomOf="@id/space_title_bar"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="@id/space_title_bar"
|
||||
app:shapeAppearance="@style/shape_circle" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_avatar_border"
|
||||
android:layout_width="@dimen/dp_37"
|
||||
android:layout_height="@dimen/dp_37"
|
||||
android:src="@drawable/game_home_ic_avatar_border"
|
||||
app:layout_constraintBottom_toBottomOf="@id/iv_avatar"
|
||||
app:layout_constraintEnd_toEndOf="@id/iv_avatar"
|
||||
app:layout_constraintStart_toStartOf="@id/iv_avatar"
|
||||
app:layout_constraintTop_toTopOf="@id/iv_avatar" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/layout_wallet"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="@dimen/dp_36"
|
||||
android:layout_marginStart="@dimen/dp_13"
|
||||
android:background="@drawable/game_home_bg_wallet"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingEnd="@dimen/dp_41"
|
||||
app:layout_constraintBottom_toBottomOf="@id/space_title_bar"
|
||||
app:layout_constraintStart_toEndOf="@id/iv_avatar"
|
||||
app:layout_constraintTop_toTopOf="@id/space_title_bar">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_wallet_icon"
|
||||
android:layout_width="@dimen/dp_22"
|
||||
android:layout_height="@dimen/dp_22"
|
||||
android:layout_marginStart="@dimen/dp_6"
|
||||
android:src="@drawable/game_ic_coins" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_wallet_value"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="@dimen/dp_2"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="1"
|
||||
android:text=" "
|
||||
android:textColor="#273132"
|
||||
android:textSize="@dimen/dp_17"
|
||||
tools:text="123" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<ImageView
|
||||
android:layout_width="@dimen/dp_37"
|
||||
android:layout_height="@dimen/dp_37"
|
||||
android:src="@drawable/game_home_ic_add"
|
||||
app:layout_constraintBottom_toBottomOf="@id/layout_wallet"
|
||||
app:layout_constraintEnd_toEndOf="@id/layout_wallet"
|
||||
app:layout_constraintTop_toTopOf="@id/layout_wallet" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_rank"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="@dimen/dp_44"
|
||||
android:layout_marginEnd="@dimen/dp_21"
|
||||
android:src="@drawable/game_home_ic_rank"
|
||||
app:layout_constraintBottom_toBottomOf="@id/space_title_bar"
|
||||
app:layout_constraintEnd_toEndOf="@id/space_title_bar"
|
||||
app:layout_constraintTop_toTopOf="@id/space_title_bar" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_rank"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginHorizontal="@dimen/dp_3"
|
||||
android:gravity="center"
|
||||
android:includeFontPadding="false"
|
||||
android:maxLines="1"
|
||||
android:text="@string/main_ranking"
|
||||
android:textColor="#FFEB6F"
|
||||
android:textSize="@dimen/dp_9"
|
||||
app:autoSizeMaxTextSize="@dimen/dp_9"
|
||||
app:autoSizeMinTextSize="@dimen/dp_6"
|
||||
app:autoSizeStepGranularity="1px"
|
||||
app:autoSizeTextType="uniform"
|
||||
app:layout_constraintBottom_toBottomOf="@id/iv_rank"
|
||||
app:layout_constraintEnd_toEndOf="@id/iv_rank"
|
||||
app:layout_constraintStart_toStartOf="@id/iv_rank" />
|
||||
|
||||
<androidx.constraintlayout.widget.Guideline
|
||||
android:id="@+id/line_logo_top"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
app:layout_constraintGuide_percent="0.184" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_game_logo"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:scaleType="centerCrop"
|
||||
app:layout_constraintDimensionRatio="141.5:113"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="@id/line_logo_top"
|
||||
app:layout_constraintWidth_percent="0.377" />
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/recycler_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginTop="@dimen/dp_10"
|
||||
android:orientation="vertical"
|
||||
app:layoutManager="androidx.recyclerview.widget.GridLayoutManager"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/iv_game_logo"
|
||||
app:spanCount="2"
|
||||
tools:listitem="@layout/game_home_item" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
17
app/src/module_game/res/layout/game_home_item.xml
Normal file
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_game"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:scaleType="centerCrop"
|
||||
android:src="@drawable/default_cover"
|
||||
app:layout_constraintDimensionRatio="177.5:247"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
@@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
tools:background="#ff0">
|
||||
|
||||
<com.chwl.app.avroom.widget.FixRoomTitleTextView
|
||||
android:id="@+id/tv_content"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="4dp"
|
||||
android:background="@drawable/shape_room_message_bg"
|
||||
android:gravity="start|center_vertical"
|
||||
android:textColor="@android:color/white"
|
||||
android:textSize="12dp"
|
||||
tools:text="@string/layout_list_item_chatrrom_msg_01"
|
||||
tools:textColor="#000" />
|
||||
|
||||
</FrameLayout>
|
82
app/src/module_game/res/layout/game_queue_widget.xml
Normal file
@@ -0,0 +1,82 @@
|
||||
<?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="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_state"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="@dimen/dp_18"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:text="@string/matchmaking" />
|
||||
|
||||
<com.google.android.material.imageview.ShapeableImageView
|
||||
android:id="@+id/iv_queue1"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:layout_margin="@dimen/dp_2"
|
||||
android:src="@drawable/default_avatar"
|
||||
app:layout_constraintBottom_toBottomOf="@id/iv_queue1_border"
|
||||
app:layout_constraintEnd_toEndOf="@id/iv_queue1_border"
|
||||
app:layout_constraintStart_toStartOf="@id/iv_queue1_border"
|
||||
app:layout_constraintTop_toTopOf="@id/iv_queue1_border" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_queue1_border"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginTop="@dimen/dp_30"
|
||||
android:src="@drawable/game_ic_queue_avatar_border"
|
||||
app:layout_constraintDimensionRatio="1:1"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.194"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintWidth_percent="0.213" />
|
||||
|
||||
<com.google.android.material.imageview.ShapeableImageView
|
||||
android:id="@+id/iv_queue2"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:layout_margin="@dimen/dp_2"
|
||||
android:src="@drawable/default_avatar"
|
||||
app:layout_constraintBottom_toBottomOf="@id/iv_queue2_border"
|
||||
app:layout_constraintEnd_toEndOf="@id/iv_queue2_border"
|
||||
app:layout_constraintStart_toStartOf="@id/iv_queue2_border"
|
||||
app:layout_constraintTop_toTopOf="@id/iv_queue2_border" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_queue2_border"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:src="@drawable/game_ic_queue_avatar_border"
|
||||
app:layout_constraintDimensionRatio="1:1"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.805"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="@id/iv_queue1_border"
|
||||
app:layout_constraintWidth_percent="0.213" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_state_link"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:scaleType="fitCenter"
|
||||
android:src="@drawable/game_ic_link"
|
||||
app:layout_constraintBottom_toBottomOf="@id/iv_queue1_border"
|
||||
app:layout_constraintEnd_toStartOf="@id/iv_queue2_border"
|
||||
app:layout_constraintStart_toEndOf="@id/iv_queue1_border"
|
||||
app:layout_constraintTop_toTopOf="@id/iv_queue1_border"
|
||||
tools:src="@drawable/game_ic_vs" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
</layout>
|
6
app/src/module_game/res/values-ar/strings.xml
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="matchmaking">匹配中</string>
|
||||
<string name="game_award_tips_format">獲勝獎勵%s金幣</string>
|
||||
<string name="start">开始</string>
|
||||
</resources>
|
7
app/src/module_game/res/values-zh-rTW/strings.xml
Normal file
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
|
||||
<string name="matchmaking">匹配中</string>
|
||||
<string name="game_award_tips_format">獲勝獎勵%s金幣</string>
|
||||
<string name="start">开始</string>
|
||||
</resources>
|
3
app/src/module_game/res/values/colors.xml
Normal file
@@ -0,0 +1,3 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
</resources>
|
6
app/src/module_game/res/values/strings.xml
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="matchmaking">匹配中</string>
|
||||
<string name="game_award_tips_format">獲勝獎勵%s金幣</string>
|
||||
<string name="start">开始</string>
|
||||
</resources>
|