Skip to content

Commit

Permalink
fix mock hand service hands out original preset instances
Browse files Browse the repository at this point in the history
deep clone to avoid saving without saving
  • Loading branch information
georg-jung committed Jul 2, 2020
1 parent f76c738 commit e72684e
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import android.bluetooth.BluetoothDevice
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import com.gjung.haifa3d.model.HandAction
import com.gjung.haifa3d.model.decodeHandAction
import no.nordicsemi.android.ble.livedata.state.ConnectionState
import no.nordicsemi.android.ble.observer.ConnectionObserver
import java.util.*
Expand Down Expand Up @@ -83,7 +84,9 @@ class MockHandService : IHandService {
presets[presetNumber] = action
}

override suspend fun readPreset(presetNumber: Int): HandAction? = presets[presetNumber]
override suspend fun readPreset(presetNumber: Int): HandAction? =
// easy way to deep clone
presets[presetNumber]?.toBytes()?.toList()?.toUByteArray()?.decodeHandAction()
}

override val triggerService: ITriggerService =
Expand Down

0 comments on commit e72684e

Please sign in to comment.