snackbar
This commit is contained in:
parent
8387482e45
commit
7500de9e73
@ -10,7 +10,7 @@
|
|||||||
android:supportsRtl="true"
|
android:supportsRtl="true"
|
||||||
android:theme="@style/Theme.AppCompat">
|
android:theme="@style/Theme.AppCompat">
|
||||||
<activity android:name=".MainActivity"
|
<activity android:name=".MainActivity"
|
||||||
android:screenOrientation="landscape">
|
android:screenOrientation="sensorLandscape">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN"/>
|
<action android:name="android.intent.action.MAIN"/>
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package adrienmalin.pingpoints
|
package adrienmalin.pingpoints
|
||||||
|
|
||||||
|
import android.content.pm.ActivityInfo
|
||||||
import android.support.v7.app.AppCompatActivity
|
import android.support.v7.app.AppCompatActivity
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.text.Html
|
import android.text.Html
|
||||||
@ -9,6 +10,7 @@ import android.os.Build
|
|||||||
import android.text.Spanned
|
import android.text.Spanned
|
||||||
import android.text.TextUtils.join
|
import android.text.TextUtils.join
|
||||||
import kotlin.math.abs
|
import kotlin.math.abs
|
||||||
|
import android.support.design.widget.Snackbar
|
||||||
|
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
@ -42,6 +44,10 @@ class MainActivity : AppCompatActivity() {
|
|||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
setContentView(R.layout.activity_main)
|
setContentView(R.layout.activity_main)
|
||||||
|
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) {
|
||||||
|
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE);
|
||||||
|
}
|
||||||
|
|
||||||
val names: Array<String> = resources.getStringArray(R.array.players_names)
|
val names: Array<String> = resources.getStringArray(R.array.players_names)
|
||||||
for ((player, name) in players.zip(names)) {
|
for ((player, name) in players.zip(names)) {
|
||||||
player.name = name
|
player.name = name
|
||||||
@ -55,6 +61,9 @@ class MainActivity : AppCompatActivity() {
|
|||||||
)
|
)
|
||||||
|
|
||||||
update_ui()
|
update_ui()
|
||||||
|
|
||||||
|
Snackbar.make(findViewById(R.layout.activity_main), R.string.info, Snackbar.LENGTH_LONG)
|
||||||
|
.show()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun update_ui() {
|
fun update_ui() {
|
||||||
@ -87,16 +96,15 @@ class MainActivity : AppCompatActivity() {
|
|||||||
fun updateScore(scoringPlayerId: Int) {
|
fun updateScore(scoringPlayerId: Int) {
|
||||||
players[scoringPlayerId].score++
|
players[scoringPlayerId].score++
|
||||||
|
|
||||||
|
if (
|
||||||
|
(players.map { it -> it.score } .max() ?: 0 < 11) or
|
||||||
|
(abs(players[0].score - players[1].score) < 2)
|
||||||
|
) {
|
||||||
if (players.sumBy { it.score } % 2 == 0) {
|
if (players.sumBy { it.score } % 2 == 0) {
|
||||||
server = notServer.also { notServer = server }
|
server = notServer.also { notServer = server }
|
||||||
}
|
}
|
||||||
|
|
||||||
update_ui()
|
update_ui()
|
||||||
|
} else {
|
||||||
if (
|
|
||||||
(players.map { it -> it.score } .max() ?: 0 >= 11) and
|
|
||||||
(abs(players[0].score - players[1].score) >= 2)
|
|
||||||
) {
|
|
||||||
endOfMatch()
|
endOfMatch()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -83,7 +83,6 @@
|
|||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:bufferType="spannable"
|
android:bufferType="spannable"
|
||||||
android:onClick="onClickPlayer1"
|
android:onClick="onClickPlayer1"
|
||||||
android:text="Button"
|
|
||||||
android:textAllCaps="false"
|
android:textAllCaps="false"
|
||||||
android:textAppearance="@style/TextAppearance.AppCompat.Button"
|
android:textAppearance="@style/TextAppearance.AppCompat.Button"
|
||||||
android:textSize="24sp"
|
android:textSize="24sp"
|
||||||
@ -108,7 +107,6 @@
|
|||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:bufferType="spannable"
|
android:bufferType="spannable"
|
||||||
android:onClick="onClickPlayer2"
|
android:onClick="onClickPlayer2"
|
||||||
android:text="Button"
|
|
||||||
android:textAllCaps="false"
|
android:textAllCaps="false"
|
||||||
android:textAppearance="@style/TextAppearance.AppCompat.Button"
|
android:textAppearance="@style/TextAppearance.AppCompat.Button"
|
||||||
android:textSize="24sp"
|
android:textSize="24sp"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user