Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
ProgArkProject
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Sixten Müller
ProgArkProject
Merge requests
!27
added choose number of rounds round
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
added choose number of rounds round
choose-num-rounds
into
main
Overview
0
Commits
1
Pipelines
0
Changes
21
Merged
Marcus Christopher Wildish
requested to merge
choose-num-rounds
into
main
1 year ago
Overview
0
Commits
1
Pipelines
0
Changes
21
Expand
0
0
Merge request reports
Compare
main
main (base)
and
latest version
latest version
13e26091
1 commit,
1 year ago
21 files
+
252
−
38
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
21
Search (e.g. *.vue) (Ctrl+P)
android/src/com/wordbattle/game/AndroidInterfaceClass.java
+
28
−
1
Options
@@ -39,12 +39,13 @@ public class AndroidInterfaceClass implements FirebaseInterface {
}
@Override
public
void
createNewLobby
(
String
hostNickname
,
String
pin
)
{
public
void
createNewLobby
(
String
hostNickname
,
String
pin
,
String
numRounds
)
{
DatabaseReference
lobbyRef
=
database
.
getReference
(
"lobbies"
).
child
(
pin
);
Map
<
String
,
Object
>
lobbyData
=
new
HashMap
<>();
lobbyData
.
put
(
"gameStarted"
,
false
);
lobbyData
.
put
(
"hostNickname"
,
hostNickname
);
lobbyData
.
put
(
"pin"
,
pin
);
lobbyData
.
put
(
"NumberOfRounds"
,
numRounds
);
// Create a map to store players' scores and finished status
Map
<
String
,
Object
>
players
=
new
HashMap
<>();
@@ -231,6 +232,32 @@ public class AndroidInterfaceClass implements FirebaseInterface {
});
}
public
void
fetchNumRounds
(
String
lobbyPin
,
numRoundFetchCallback
callback
){
DatabaseReference
roundRef
=
FirebaseDatabase
.
getInstance
().
getReference
(
"lobbies"
)
.
child
(
lobbyPin
).
child
(
"NumberOfRounds"
);
roundRef
.
addListenerForSingleValueEvent
(
new
ValueEventListener
()
{
@Override
public
void
onDataChange
(
DataSnapshot
dataSnapshot
)
{
String
numRound
=
dataSnapshot
.
getValue
(
String
.
class
);
if
(
numRound
!=
null
)
{
callback
.
onNumRoundFetched
(
numRound
);
}
else
{
// Handle case where "rounds" node does not exist or is null
callback
.
onNumRoundFetched
(
numRound
);
// Assuming 0 as the default round number
}
}
@Override
public
void
onCancelled
(
@NonNull
DatabaseError
databaseError
)
{
callback
.
onError
(
databaseError
.
getMessage
());
}
});
}
@Override
public
void
fetchPlayers
(
String
pin
,
PlayerListUpdateCallback
callback
)
{
Loading