优化排队.

This commit is contained in:
18631081161 2024-12-20 22:23:45 +08:00
parent ebeb5a3fc1
commit 68f414c9f0
13 changed files with 50 additions and 39 deletions

View File

@ -1,7 +1,7 @@
package co.steamcloud.game;
public class Config {
public static String url = "https://admin.shhuanmeng.com/";//接口域名
public static String url = "https://api.onelight.vip/";//接口域名
public static String BsUrl = "https://os.zhijierongxing.com/";//游戏域名
public static String channel_id = "d612a79436ef9ceeee4d6847d854b2e1";

View File

@ -46,6 +46,7 @@ public class MainActivity extends FlutterActivity {
public void onCreate(@Nullable Bundle savedInstanceState, @Nullable PersistableBundle persistentState) {
super.onCreate(savedInstanceState, persistentState);
EventBus.getDefault().register(this);
WhaleCloud.getInstance().isShowLog(true);
}
@ -100,6 +101,7 @@ public class MainActivity extends FlutterActivity {
Config.userToken = call.argument("userToken");
Config.Channel = call.argument("Channel");
Config.Version = call.argument("Version");
Config.url = call.argument("Url");
initSdk(Config.BsUrl, Config.client_sid, gameToken, Config.sn);
Log.d(TAG, "onMethodCall: initData");

View File

@ -2880,7 +2880,6 @@ public class PlayGameActivity extends Activity {
}
});
}
}
@ -2904,7 +2903,7 @@ public class PlayGameActivity extends Activity {
@Override
public void onGameStop() {
//游戏结束
Log.i(TAG, "onGameStop: ");
Log.i(TAG, "onGameStop: 游戏结束");
if (ActivityCollector.activities != null && ActivityCollector.activities.size() > 0) {
ActivityCollector.removeActivity(PlayGameActivity.this);
}
@ -2931,7 +2930,6 @@ public class PlayGameActivity extends Activity {
TagMap.put("tag", "exitGame");
EventBus.getDefault().post(TagMap, EventBusParams.MAIN);
finish();
}
@ -3138,6 +3136,7 @@ public class PlayGameActivity extends Activity {
public void closeGame() {
Log.d(TAG, "closeGame: ");
ActivityCollector.removeActivity(this);
// netHander.stopSession(Config.gamePara.sc_id);
// Config.is_SolidHandle = String.valueOf(isHandelEnter());

View File

@ -2,6 +2,6 @@
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:radius="6dp" />
<solid android:color="#F0F0F0" />
<stroke android:width="1dp" android:color="#80898989"/>
</shape>

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#FF202530" />
<corners android:radius="14dp" />
</shape>

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#FF074CE7" />
<corners android:radius="6dp" />
</shape>

View File

@ -4,7 +4,7 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="320dp"
android:layout_height="188dp"
android:background="@mipmap/bg_base_dialog"
android:background="@drawable/shap_exit_game"
android:orientation="vertical">
@ -14,7 +14,7 @@
android:layout_height="wrap_content"
android:layout_marginTop="14dp"
android:gravity="center"
android:textColor="#000000"
android:textColor="@color/white"
android:textSize="20sp"
android:textStyle="bold"
app:layout_constraintLeft_toLeftOf="parent"
@ -27,9 +27,9 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="40dp"
android:layout_marginTop="30dp"
android:gravity="center"
android:textColor="#000000"
android:textColor="@color/white"
android:textSize="16sp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
@ -42,7 +42,7 @@
android:layout_width="120dp"
android:layout_height="40dp"
android:layout_gravity="center"
android:layout_marginTop="20dp"
android:layout_marginTop="30dp"
android:layout_marginBottom="20dp"
android:layout_weight="1"
android:background="@drawable/bg_base_dialog1"
@ -61,10 +61,10 @@
android:layout_width="120dp"
android:layout_height="40dp"
android:layout_gravity="center"
android:layout_marginTop="20dp"
android:layout_marginTop="30dp"
android:layout_marginBottom="20dp"
android:layout_weight="1"
android:background="@mipmap/btn_di"
android:background="@drawable/shap_exit_game_cancel"
android:gravity="center"
android:text="取消"
android:textColor="#FFFFFF"
@ -80,6 +80,7 @@
android:layout_height="40dp"
android:layout_marginTop="5dp"
android:layout_marginEnd="5dp"
android:visibility="gone"
android:padding="10dp"
android:src="@mipmap/btn_cuohao3"
app:layout_constraintRight_toRightOf="parent"

Binary file not shown.

Before

Width:  |  Height:  |  Size: 544 B

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 442 B

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 721 B

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 33 KiB

View File

@ -249,6 +249,7 @@ class HomeModel {
Future<void> exitPlayGame(gameId) async {
RequestCenter.instance.request(NetworkConfig.exitPlayGame, {
"gameId": gameId,
"playGameDetails": "playGameDetails",
}, (BaseEntity dataEntity) {
// ReconnectBean reconnectBean = ReconnectBean.fromJson(dataEntity.data);

View File

@ -46,6 +46,7 @@ class _HomePageState extends State<HomePage> with TickerProviderStateMixin {
late BuildContext lineUpContext;
late ReconnectBean reconnectBean;
bool isLineUp = false;
DateTime? _lastPressTime;
@ -116,6 +117,7 @@ class _HomePageState extends State<HomePage> with TickerProviderStateMixin {
"signKey": NetworkConfig.signKey,
"Channel": NetworkConfig.Channel,
"Version": NetworkConfig.Version,
"Url": NetworkConfig.ServerDomain_Online,
};
///token
@ -125,6 +127,7 @@ class _HomePageState extends State<HomePage> with TickerProviderStateMixin {
///
case "playGame":
isLineUp = false;
EasyLoading.dismiss();
Map<String, dynamic> gameMap = {
"gameId": event['gameId'],
@ -136,7 +139,7 @@ class _HomePageState extends State<HomePage> with TickerProviderStateMixin {
///
case "gameError":
EasyLoading.showToast("网络异常,请稍后再试");
EasyLoading.showToast("${event['data']}");
_viewModel.cancelQueue(event['gameId']);
break;
@ -145,31 +148,24 @@ class _HomePageState extends State<HomePage> with TickerProviderStateMixin {
EasyLoading.dismiss();
QueueBean queueBean = event['data'];
String gameId = event['gameId'];
// FunctionUtil.bottomNoSheetDialog(
// context,
// LineUpDialog(
// lineUpDialogKey,
// num: queueBean.queue_pos!,
// onTap: () {
// _viewModel.cancelQueue(gameId);
// // lineUpDialogKey.currentState?.setNum(3);
// },
// ));
showDialog(
context: context,
barrierDismissible: false,
builder: (BuildContext context) {
lineUpContext = context;
return LineUpDialog(
lineUpDialogKey,
num: queueBean.queue_pos!,
onTap: () {
_timer.cancel();
_viewModel.cancelQueue(gameId);
},
);
});
if (!isLineUp) {
showDialog(
context: context,
barrierDismissible: false,
builder: (BuildContext context) {
lineUpContext = context;
return LineUpDialog(
lineUpDialogKey,
num: queueBean.queue_pos!,
onTap: () {
_timer.cancel();
_viewModel.cancelQueue(gameId);
},
);
});
isLineUp = true;
}
//
_timer = Timer.periodic(const Duration(milliseconds: 5000), (as) {
@ -181,17 +177,19 @@ class _HomePageState extends State<HomePage> with TickerProviderStateMixin {
///
case "playGameQueue":
QueueBean queueBean = event['data'];
lineUpDialogKey.currentState?.setNum(queueBean.queue_pos);
break;
///
case "cancelQueue":
isLineUp = false;
lineUpDialogKey.currentState?.setNum(0);
_timer.cancel();
break;
///
case "gameQueueSuccess":
print("gameQueueSuccess");
Navigator.pop(lineUpContext);
_timer.cancel();
_viewModel.playGame(NetworkConfig.gameId);