Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
吳展維
final
Commits
b1881e24
Commit
b1881e24
authored
2 years ago
by
吳展維
Browse files
Options
Download
Email Patches
Plain Diff
multifocus
parent
095ce2f6
master
main
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
app/src/main/java/com/example/jetsnack/model/FocusRoom.kt
+9
-0
app/src/main/java/com/example/jetsnack/model/FocusRoom.kt
app/src/main/java/com/example/jetsnack/ui/home/多人模式.kt
+54
-0
app/src/main/java/com/example/jetsnack/ui/home/多人模式.kt
with
63 additions
and
0 deletions
+63
-0
app/src/main/java/com/example/jetsnack/model/FocusRoom.kt
0 → 100644
View file @
b1881e24
package
com.example.jetsnack.model
import
android.os.Parcelable
import
kotlinx.android.parcel.Parcelize
@Parcelize
class
FocusRoom
(
val
id1
:
String
,
val
id2
:
String
,
val
id3
:
String
,
val
id4
:
String
,
val
roomId
:
String
,
val
start
:
Boolean
)
:
Parcelable
{
constructor
()
:
this
(
""
,
""
,
""
,
""
,
""
,
false
)
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
app/src/main/java/com/example/jetsnack/ui/home/多人模式.kt
View file @
b1881e24
...
...
@@ -17,6 +17,7 @@
package
com.example.jetsnack.ui.home
import
android.content.res.Configuration
import
android.net.Uri
import
androidx.compose.foundation.*
import
androidx.compose.foundation.layout.*
import
androidx.compose.foundation.shape.CircleShape
...
...
@@ -44,8 +45,16 @@ import androidx.navigation.NavHostController
import
com.example.jetsnack.R
import
com.example.jetsnack.database.Dogs
import
com.example.jetsnack.database.Select_index
import
com.example.jetsnack.model.FocusRoom
import
com.example.jetsnack.models.User
import
com.example.jetsnack.ui.components.JetsnackDivider
import
com.example.jetsnack.ui.theme.*
import
com.google.firebase.auth.FirebaseAuth
import
com.google.firebase.database.DataSnapshot
import
com.google.firebase.database.DatabaseError
import
com.google.firebase.database.FirebaseDatabase
import
com.google.firebase.database.ValueEventListener
import
kotlinx.android.synthetic.main.activity_main.*
import
java.time.format.TextStyle
@OptIn
(
ExperimentalComposeUiApi
::
class
)
...
...
@@ -494,7 +503,52 @@ fun MulModeHost(modifier: Modifier = Modifier, navController: NavHostController)
)
}
}
var
Isfull
=
false
fun
multiFocusBuild
(
roomId
:
String
,
id1
:
String
){
val
uid
=
FirebaseAuth
.
getInstance
().
uid
?:
""
val
ref
=
FirebaseDatabase
.
getInstance
().
getReference
(
"/focusRooms/$uid"
)
val
focusRoom
=
FocusRoom
(
id1
,
""
,
""
,
""
,
roomId
,
false
)
ref
.
setValue
(
focusRoom
)
}
fun
enterFocusRoom
(
invitedId
:
String
,
RoomId
:
String
){
val
ref
=
FirebaseDatabase
.
getInstance
().
getReference
(
"/focusRooms"
)
ref
.
addListenerForSingleValueEvent
(
object
:
ValueEventListener
{
override
fun
onDataChange
(
p0
:
DataSnapshot
)
{
// Get Post object and use the values to update the UI
p0
.
children
.
forEach
{
val
room
=
it
.
getValue
(
FocusRoom
::
class
.
java
)
if
(
room
!=
null
)
{
if
(
room
.
id2
!=
""
){
val
ref2
=
FirebaseDatabase
.
getInstance
().
getReference
(
"/focusRooms/$RoomId/id2"
)
ref2
.
setValue
(
invitedId
)
}
else
if
(
room
.
id2
!=
""
){
val
ref2
=
FirebaseDatabase
.
getInstance
().
getReference
(
"/focusRooms/$RoomId/id2"
)
ref2
.
setValue
(
invitedId
)
}
else
if
(
room
.
id3
!=
""
){
val
ref2
=
FirebaseDatabase
.
getInstance
().
getReference
(
"/focusRooms/$RoomId/id3"
)
ref2
.
setValue
(
invitedId
)
}
else
if
(
room
.
id4
!=
""
){
val
ref2
=
FirebaseDatabase
.
getInstance
().
getReference
(
"/focusRooms/$RoomId/id4"
)
ref2
.
setValue
(
invitedId
)
}
else
{
Isfull
=
true
}
}
}
}
override
fun
onCancelled
(
error
:
DatabaseError
)
{
}
})
}
fun
multiFocusStart
(
RoomId
:
String
){
val
ref
=
FirebaseDatabase
.
getInstance
().
getReference
(
"/focusRooms/$RoomId/start"
)
ref
.
setValue
(
true
)
}
@Preview
(
"defa"
,
showBackground
=
true
)
@Composable
fun
MulModeHostPreview
()
{
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help