-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathListenerService.java
66 lines (53 loc) · 2.07 KB
/
ListenerService.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package uma.hbs;
import android.util.Log;
import com.google.android.gms.wearable.MessageEvent;
import com.google.android.gms.wearable.WearableListenerService;
import java.util.List;
import uma.hbs.db.TableDataSource;
import uma.hbs.model.Action;
import uma.hbs.model.Activity;
import uma.hbs.model.HBSensor;
/**
* Created by Administrator on 17/02/2016.
*/
public class ListenerService extends WearableListenerService {
String nodeId;
TableDataSource dataSource;
@Override
public void onMessageReceived(MessageEvent messageEvent) {
nodeId = messageEvent.getSourceNodeId();
Log.d("REPLY", "nodeid: " + nodeId + " - message: " + messageEvent.getPath());
dataSource = new TableDataSource(getApplicationContext());
dataSource.open();
String[] separated = messageEvent.getPath().split("-");
int L1 = separated.length;
Long[] ids = new Long[L1];
for (int i = 0; i < L1; i++) {
ids[i] = Long.parseLong(separated[i]);
}
List<HBSensor> q = dataSource.findAllHBSSetBellowId(0l, ids[0]);
int sizeHBSGlobal = q.size();
if(sizeHBSGlobal != 0) {
for (HBSensor a : q) {
dataSource.updateHBS(a.getId());
Log.d("REPLY", "HBS UPDATED with id:" + a.getId());
}
}
List<Activity> q1 = dataSource.findAllActivitiesSetBellowId(0l, ids[1]);
int sizeActivityGlobal = q1.size();
if(sizeActivityGlobal != 0) {
for (Activity a2 : q1) {
dataSource.updateActtivity(a2.getId2(), 1l);
//Log.d("TESTE", "ACTIVITY UPDATED with id:" + a2.getId2());
}
}
List<Action> q2 = dataSource.findAllActionsSetBellowId(0l, ids[2]);
int sizeActionGlobal = q2.size();
if(sizeActionGlobal != 0) {
for (Action a : q2) {
dataSource.updateAction(a.getId());
Log.d("REPLY", "ACTION UPDATED with id:" + a.getId());
}
}
}
}