Correct random option
This commit is contained in:
@ -28,8 +28,6 @@ import androidx.compose.ui.tooling.preview.Preview
|
|||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import androidx.compose.ui.unit.sp
|
import androidx.compose.ui.unit.sp
|
||||||
import de.luh.hci.mi.vibrationpattern.ui.theme.VibrationPatternTheme
|
import de.luh.hci.mi.vibrationpattern.ui.theme.VibrationPatternTheme
|
||||||
import kotlin.random.Random
|
|
||||||
|
|
||||||
class MainActivity : ComponentActivity() {
|
class MainActivity : ComponentActivity() {
|
||||||
private lateinit var vibrator: Vibrator
|
private lateinit var vibrator: Vibrator
|
||||||
|
|
||||||
@ -90,14 +88,7 @@ class MainActivity : ComponentActivity() {
|
|||||||
|
|
||||||
Spacer(modifier = Modifier.height(20.dp))
|
Spacer(modifier = Modifier.height(20.dp))
|
||||||
Button(
|
Button(
|
||||||
onClick = {
|
onClick = { vibrator.vibrate(vibes.random()); isVibrating = true },
|
||||||
vibrator.vibrate(
|
|
||||||
VibrationEffect.createWaveform(
|
|
||||||
LongArray(Random.Default.nextInt(2,10)){
|
|
||||||
Random.Default.nextLong(100, 2000)},
|
|
||||||
1))
|
|
||||||
isVibrating = true
|
|
||||||
},
|
|
||||||
modifier = Modifier.fillMaxWidth()
|
modifier = Modifier.fillMaxWidth()
|
||||||
) {
|
) {
|
||||||
Text("Random")
|
Text("Random")
|
||||||
@ -164,9 +155,11 @@ class MainActivity : ComponentActivity() {
|
|||||||
private val CHILL = VibrationEffect.createWaveform(
|
private val CHILL = VibrationEffect.createWaveform(
|
||||||
longArrayOf(
|
longArrayOf(
|
||||||
0, 100, 50, 150, 1600
|
0, 100, 50, 150, 1600
|
||||||
|
), intArrayOf(
|
||||||
|
0, 50, 0, 150, 0
|
||||||
), 1
|
), 1
|
||||||
)
|
)
|
||||||
private val vibes = arrayOf(HEART, SOS, WALTZ)
|
private val vibes = arrayOf(HEART, SOS, WALTZ, ANGRY, CHILL)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user