-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAddonReceiver.java
More file actions
53 lines (43 loc) · 1.3 KB
/
AddonReceiver.java
File metadata and controls
53 lines (43 loc) · 1.3 KB
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
/**
* Copyright (C) 2020, ControlThings Oy Ab
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* @license Apache-2.0
*/
package addon;
import android.os.Bundle;
import android.os.Handler;
import android.os.ResultReceiver;
/**
* Created by jeppe on 10/25/17.
*/
public class AddonReceiver extends ResultReceiver {
private Receiver mReceiver;
public AddonReceiver(Receiver receiver) {
super(new Handler());
mReceiver = receiver;
//super();
}
public interface Receiver {
/* Callback function invoked when connection to Wish Core is established */
public void onConnected();
/* Callback function invoked when connection to Wish Core is lost */
public void onDisconnected();
}
@Override
protected void onReceiveResult(int resultCode, Bundle resultData) {
if (mReceiver != null) {
if (resultCode == AddonService.BRIDGE_CONNECTED) {
mReceiver.onConnected();
}
else if (resultCode == AddonService.BRIDGE_DISCONNECTED) {
mReceiver.onDisconnected();
}
}
}
}