Skip to content

Commit 8740319

Browse files
committed
SensorConfig replaceWith
1 parent 7c4bcf1 commit 8740319

2 files changed

Lines changed: 54 additions & 42 deletions

File tree

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ This repository contains the the core classes to use while implementing an aware
1414
## Example usage
1515

1616
In your root `build.gradle` add the jitpack repository.
17+
1718
```gradle
1819
allprojects {
1920
repositories {
@@ -23,6 +24,7 @@ allprojects {
2324
}
2425
}
2526
```
27+
2628
In your app `build.gradle` add the dependency to the accelerometer.
2729

2830
```gradle
Lines changed: 52 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package com.awareframework.android.core.model
22

3-
import android.content.Context
43
import com.awareframework.android.core.db.Engine
54

65
/**
@@ -11,44 +10,55 @@ import com.awareframework.android.core.db.Engine
1110
*/
1211

1312
open class SensorConfig(
14-
/**
15-
* Sensor is enabled or not. (optional)
16-
*/
17-
var enabled: Boolean = false,
18-
19-
/**
20-
* Enables logging. (optional)
21-
*/
22-
var debug: Boolean = false,
23-
24-
/**
25-
* Label for the data. (optional)
26-
*/
27-
var label: String = "",
28-
29-
/**
30-
* User given deviceId. (optional)
31-
*/
32-
var deviceId: String = "",
33-
34-
/**
35-
* Encryption key for the database. (optional)
36-
*/
37-
var dbEncryptionKey: String? = null,
38-
39-
/**
40-
* Which database to use. (optional)
41-
* defaults to NONE, which doesn't preserve any data.
42-
*/
43-
var dbType: Engine.DatabaseType = Engine.DatabaseType.NONE,
44-
45-
/**
46-
* Database name/path. (optional)? TODO (sercant): discuss
47-
*/
48-
var dbPath: String = "aware",
49-
50-
/**
51-
* Database sync host. (optional)
52-
*/
53-
var dbHost: String? = null
54-
)
13+
/**
14+
* Sensor is enabled or not. (optional)
15+
*/
16+
var enabled: Boolean = false,
17+
18+
/**
19+
* Enables logging. (optional)
20+
*/
21+
var debug: Boolean = false,
22+
23+
/**
24+
* Label for the data. (optional)
25+
*/
26+
var label: String = "",
27+
28+
/**
29+
* User given deviceId. (optional)
30+
*/
31+
var deviceId: String = "",
32+
33+
/**
34+
* Encryption key for the database. (optional)
35+
*/
36+
var dbEncryptionKey: String? = null,
37+
38+
/**
39+
* Which database to use. (optional)
40+
* defaults to NONE, which doesn't preserve any data.
41+
*/
42+
var dbType: Engine.DatabaseType = Engine.DatabaseType.NONE,
43+
44+
/**
45+
* Database name/path. (optional)? TODO (sercant): discuss
46+
*/
47+
var dbPath: String = "aware",
48+
49+
/**
50+
* Database sync host. (optional)
51+
*/
52+
var dbHost: String? = null
53+
) {
54+
open fun <T : SensorConfig> replaceWith(config: T) {
55+
enabled = config.enabled
56+
debug = config.debug
57+
label = config.label
58+
deviceId = config.deviceId
59+
dbEncryptionKey = config.dbEncryptionKey
60+
dbType = config.dbType
61+
dbPath = config.dbPath
62+
dbHost = config.dbHost
63+
}
64+
}

0 commit comments

Comments
 (0)