Skip to content

Commit 8e32bba

Browse files
committed
Minor code reformat
1 parent f6a205e commit 8e32bba

File tree

5 files changed

+27
-26
lines changed

5 files changed

+27
-26
lines changed

app/src/main/java/net/ciphen/polyhoot/Polyhoot.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ package net.ciphen.polyhoot
1919
import com.google.android.material.color.DynamicColors
2020
import com.google.firebase.FirebaseApp
2121

22-
class Polyhoot: android.app.Application() {
22+
class Polyhoot : android.app.Application() {
2323
override fun onCreate() {
2424
super.onCreate()
2525
FirebaseApp.initializeApp(this)

app/src/main/java/net/ciphen/polyhoot/activity/GameActivity.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import net.ciphen.polyhoot.databinding.GameActivityBinding
2727
import net.ciphen.polyhoot.fragments.JoinGameFragment
2828
import net.ciphen.polyhoot.game.WebSocketSession
2929

30-
class GameActivity: AppCompatActivity() {
30+
class GameActivity : AppCompatActivity() {
3131
private lateinit var binding: GameActivityBinding
3232
private lateinit var webSocketSession: WebSocketSession
3333

app/src/main/java/net/ciphen/polyhoot/fragments/GameFragment.kt

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,7 @@ import android.view.ViewGroup
2424
import android.view.WindowManager
2525
import androidx.fragment.app.Fragment
2626
import com.google.android.material.card.MaterialCardView
27-
import kotlinx.serialization.json.int
28-
import kotlinx.serialization.json.Json
29-
import kotlinx.serialization.json.jsonObject
30-
import kotlinx.serialization.json.JsonObject
31-
import kotlinx.serialization.json.jsonPrimitive
32-
import kotlinx.serialization.json.JsonPrimitive
27+
import kotlinx.serialization.json.*
3328
import net.ciphen.polyhoot.R
3429
import net.ciphen.polyhoot.databinding.FragmentGameBinding
3530
import net.ciphen.polyhoot.game.WebSocketSession

app/src/main/java/net/ciphen/polyhoot/fragments/JoinGameFragment.kt

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,14 @@ class JoinGameFragment : Fragment(), Observer {
9494
args = pair.second as String
9595
}
9696
when (event) {
97-
GameEventType.CONNECTED -> binding.statusText.text = getString(R.string.status, "CONNECTED")
98-
GameEventType.CONNECTING -> binding.statusText.text = getString(R.string.status, "CONNECTING...")
99-
GameEventType.DEBUG_MESSAGE -> binding.statusText.text = getString(R.string.status, args)
100-
GameEventType.FAIL -> binding.statusText.text = getString(R.string.status,"FAIL! $args")
97+
GameEventType.CONNECTED -> binding.statusText.text =
98+
getString(R.string.status, "CONNECTED")
99+
GameEventType.CONNECTING -> binding.statusText.text =
100+
getString(R.string.status, "CONNECTING...")
101+
GameEventType.DEBUG_MESSAGE -> binding.statusText.text =
102+
getString(R.string.status, args)
103+
GameEventType.FAIL -> binding.statusText.text =
104+
getString(R.string.status, "FAIL! $args")
101105
GameEventType.STATUS -> {
102106
requireActivity().supportFragmentManager.commit {
103107
setReorderingAllowed(true)
@@ -119,7 +123,8 @@ class JoinGameFragment : Fragment(), Observer {
119123
Snackbar.make(
120124
binding.root,
121125
"Game with ID $gameId doesn't exist!",
122-
NO_SUCH_GAME_SNACKBAR_DURATION)
126+
NO_SUCH_GAME_SNACKBAR_DURATION
127+
)
123128
.show()
124129
}
125130
GameEventType.NAME_TAKEN -> {

app/src/main/java/net/ciphen/polyhoot/game/WebSocketSession.kt

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,7 @@ import kotlinx.serialization.json.jsonPrimitive
2323
import net.ciphen.polyhoot.game.event.GameEventType
2424
import net.ciphen.polyhoot.patterns.observer.Observable
2525
import net.ciphen.polyhoot.patterns.observer.Observer
26-
import okhttp3.OkHttpClient
27-
import okhttp3.Request
28-
import okhttp3.Response
29-
import okhttp3.WebSocket
30-
import okhttp3.WebSocketListener
26+
import okhttp3.*
3127

3228
private const val WEBSOCKET_CLOSE_CODE = 1000
3329

@@ -67,14 +63,19 @@ class WebSocketSession : Observable, WebSocketListener() {
6763
val json = Json.parseToJsonElement(text)
6864
Log.i("WebSocketSession", text)
6965
when (json.jsonObject["event"]!!.jsonPrimitive.content) {
70-
"CONNECT" -> notifyObservers(Pair(GameEventType.STATUS, json.jsonObject["status"].toString()))
71-
"NAME_TAKEN" -> { notifyObservers(Pair(GameEventType.NAME_TAKEN, null)) }
72-
"START_GAME" -> { notifyObservers(Pair(GameEventType.START_GAME, null))}
73-
"QUESTION" -> { notifyObservers(Pair(GameEventType.QUESTION, text))}
74-
"FORCE_STOP" -> { notifyObservers(Pair(GameEventType.FORCE_STOP, null)) }
75-
"GET_READY" -> { notifyObservers(Pair(GameEventType.GET_READY, null))}
76-
"END" -> { notifyObservers(Pair(GameEventType.END, null)) }
77-
"TIME_UP" -> { notifyObservers(Pair(GameEventType.TIME_UP, text))}
66+
"CONNECT" -> notifyObservers(
67+
Pair(
68+
GameEventType.STATUS,
69+
json.jsonObject["status"].toString()
70+
)
71+
)
72+
"NAME_TAKEN" -> notifyObservers(Pair(GameEventType.NAME_TAKEN, null))
73+
"START_GAME" -> notifyObservers(Pair(GameEventType.START_GAME, null))
74+
"QUESTION" -> notifyObservers(Pair(GameEventType.QUESTION, text))
75+
"FORCE_STOP" -> notifyObservers(Pair(GameEventType.FORCE_STOP, null))
76+
"GET_READY" -> notifyObservers(Pair(GameEventType.GET_READY, null))
77+
"END" -> notifyObservers(Pair(GameEventType.END, null))
78+
"TIME_UP" -> notifyObservers(Pair(GameEventType.TIME_UP, text))
7879
"NO_SUCH_GAME" -> notifyObservers(Pair(GameEventType.NO_SUCH_GAME, null))
7980
else -> notifyObservers(Pair(GameEventType.DEBUG_MESSAGE, text))
8081
}

0 commit comments

Comments
 (0)