Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Stefan Zabka
Companion App Android
Commits
134c13c6
Commit
134c13c6
authored
Aug 22, 2019
by
Stefan Zabka
Browse files
bunch of random cleanup
parent
8e4c68ed
Pipeline
#2832
failed with stage
in 7 minutes and 29 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
app/src/main/java/de/ccc/events/badge/card10/hatchery/AppDetailFragment.kt
View file @
134c13c6
...
...
@@ -22,7 +22,6 @@
package
de.ccc.events.badge.card10.hatchery
import
android.net.Uri
import
android.os.AsyncTask
import
android.os.Bundle
import
android.util.Log
...
...
@@ -69,7 +68,7 @@ class AppDetailFragment : Fragment() {
val
ctx
=
activity
?:
throw
java
.
lang
.
IllegalStateException
()
val
loadingDialog
=
LoadingDialog
()
loadingDialog
.
show
(
fragmentManager
,
"loading"
)
loadingDialog
.
show
(
fragmentManager
!!
,
"loading"
)
val
errorDialog
=
AlertDialog
.
Builder
(
ctx
).
setMessage
(
R
.
string
.
hatchery_error_generic
)
...
...
app/src/main/java/de/ccc/events/badge/card10/mood/MoodFragment.kt
View file @
134c13c6
...
...
@@ -38,6 +38,7 @@ import de.ccc.events.badge.card10.ROCKETS_CHARACTERISTIC_UUID
import
kotlinx.android.synthetic.main.mood_fragment.*
import
java.util.concurrent.CountDownLatch
@ExperimentalUnsignedTypes
class
MoodFragment
:
Fragment
()
{
private
val
bluetoothAdapter
=
BluetoothAdapter
.
getDefaultAdapter
()
...
...
@@ -50,13 +51,13 @@ class MoodFragment : Fragment() {
val
callback
=
object
:
BluetoothGattCallback
()
{
override
fun
onConnectionStateChange
(
gatt
:
BluetoothGatt
,
status
:
Int
,
newState
:
Int
)
{
System
.
out
.
println
(
"===== onConnectionStateChange "
+
gatt
+
" / "
+
status
+
" / "
+
newState
)
println
(
"===== onConnectionStateChange "
+
gatt
+
" / "
+
status
+
" / "
+
newState
)
if
(
newState
==
BluetoothGatt
.
STATE_CONNECTED
)
gatt
.
discoverServices
()
}
override
fun
onServicesDiscovered
(
gatt
:
BluetoothGatt
,
status
:
Int
)
{
System
.
out
.
println
(
"===== onServicesDiscovered "
+
gatt
+
" / "
+
status
)
println
(
"===== onServicesDiscovered "
+
gatt
+
" / "
+
status
)
val
card10Service
=
gatt
.
getService
(
CARD10_SERVICE_UUID
)
rocketsCharacteristic
=
card10Service
.
getCharacteristic
(
ROCKETS_CHARACTERISTIC_UUID
)
}
...
...
@@ -66,8 +67,8 @@ class MoodFragment : Fragment() {
characteristic
:
BluetoothGattCharacteristic
,
status
:
Int
)
{
System
.
out
.
println
(
"===== onCharacteristicWrite "
+
characteristic
.
uuid
.
toString
()
+
" / "
+
characteristic
.
value
+
" / "
+
status
)
writeLatch
?.
countDown
()
;
println
(
"===== onCharacteristicWrite "
+
characteristic
.
uuid
.
toString
()
+
" / "
+
characteristic
.
value
+
" / "
+
status
)
writeLatch
?.
countDown
()
}
}
...
...
@@ -83,15 +84,15 @@ class MoodFragment : Fragment() {
}
override
fun
onViewCreated
(
view
:
View
,
savedInstanceState
:
Bundle
?)
{
mood_good
.
setOnClickListener
(
{
writeGatt
(
rocketsCharacteristic
!!
,
ubyteArrayOf
(
0xffu
,
0x00u
,
0x00u
).
toByteArray
())
}
)
mood_neutral
.
setOnClickListener
(
{
mood_good
.
setOnClickListener
{
writeGatt
(
rocketsCharacteristic
!!
,
ubyteArrayOf
(
0xffu
,
0x00u
,
0x00u
).
toByteArray
())
}
mood_neutral
.
setOnClickListener
{
writeGatt
(
rocketsCharacteristic
!!
,
ubyteArrayOf
(
0x00u
,
0xffu
,
0x00u
).
toByteArray
())
}
)
mood_bad
.
setOnClickListener
(
{
}
mood_bad
.
setOnClickListener
{
writeGatt
(
rocketsCharacteristic
!!
,
ubyteArrayOf
(
0x00u
,
0x00u
,
0xffu
).
toByteArray
())
}
)
}
}
fun
writeGatt
(
characteristic
:
BluetoothGattCharacteristic
,
values
:
ByteArray
)
{
...
...
@@ -100,11 +101,11 @@ class MoodFragment : Fragment() {
if
(!
init
)
System
.
out
.
println
(
"Failed to initiate writing GATT attribute"
)
writeLatch
=
CountDownLatch
(
1
)
writeLatch
!!
.
await
()
;
writeLatch
!!
.
await
()
}
override
fun
onDestroy
()
{
gatt
.
close
()
;
gatt
.
close
()
super
.
onDestroy
()
}
}
Write
Preview
Supports
Markdown
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