1 |
|
package com.dreamcatcher.bicycle.core; |
2 |
|
|
3 |
|
import android.os.Bundle; |
4 |
|
import android.os.Handler; |
5 |
|
import android.os.Message; |
6 |
|
|
7 |
|
import com.dreamcatcher.bicycle.BicycleApp; |
8 |
|
import com.dreamcatcher.bicycle.interfaces.IAdService; |
9 |
|
import com.dreamcatcher.bicycle.util.Constants; |
10 |
|
import com.uucun.adsdk.UUAppConnect; |
11 |
|
import com.uucun.adsdk.UpdatePointListener; |
12 |
|
|
|
|
| 54,5% |
Uncovered Elements: 15 (33) |
Complexity: 9 |
Complexity Density: 0,35 |
|
13 |
|
public class AdService implements IAdService, UpdatePointListener { |
14 |
|
private BicycleApp mApp = BicycleApp.getInstance(); |
15 |
|
private Handler mHandler = null; |
16 |
|
private final static int GET_POINTS_SUCCESS = 0; |
17 |
|
private final static int GET_POINTS_FAILED = 1; |
18 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
19 |
1
|
public AdService(){... |
20 |
1
|
mHandler = new Handler(){ |
|
|
| 50% |
Uncovered Elements: 6 (12) |
Complexity: 3 |
Complexity Density: 0,25 |
|
21 |
1
|
@Override... |
22 |
|
public void handleMessage(Message msg) { |
23 |
1
|
switch (msg.what) { |
24 |
1
|
case GET_POINTS_SUCCESS: |
25 |
1
|
String currencyName = msg.getData().getString(Constants.ParcelableTag.CURRENCY_NAME); |
26 |
1
|
int totalPoint = msg.getData().getInt(Constants.ParcelableTag.TOTAL_POINT); |
27 |
|
|
28 |
1
|
BicycleService.getInstance().getAdEventListener().onPointsUpdated(currencyName, totalPoint); |
29 |
1
|
break; |
30 |
0
|
case GET_POINTS_FAILED: |
31 |
0
|
String error = msg.getData().getString(Constants.ParcelableTag.CURRENCY_NAME); |
32 |
0
|
BicycleService.getInstance().getAdEventListener().onPointsUpdateFailed(error); |
33 |
0
|
break; |
34 |
0
|
default: |
35 |
0
|
break; |
36 |
|
} |
37 |
|
} |
38 |
|
}; |
39 |
|
} |
40 |
|
|
41 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
42 |
1
|
@Override... |
43 |
|
public void getPoints() { |
44 |
1
|
UUAppConnect.getInstance(mApp).getPoints(this); |
45 |
|
} |
46 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
47 |
0
|
@Override... |
48 |
|
public void spendPoints(int point) { |
49 |
0
|
UUAppConnect.getInstance(mApp).spendPoints(point, this); |
50 |
|
} |
51 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
52 |
0
|
@Override... |
53 |
|
public void awardPoint(int point) { |
54 |
|
} |
55 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 1 |
Complexity Density: 0,2 |
|
56 |
0
|
@Override... |
57 |
|
public void onError(String error) { |
58 |
0
|
Message msg = Message.obtain(); |
59 |
0
|
Bundle data = new Bundle(); |
60 |
0
|
data.putString(Constants.ParcelableTag.GET_POINT_ERROR_MSG, error); |
61 |
0
|
msg.setData(data); |
62 |
0
|
mHandler.sendMessage(msg); |
63 |
|
} |
64 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0,17 |
|
65 |
1
|
@Override... |
66 |
|
public void onSuccess(String currencyName, int totalPoint) { |
67 |
1
|
Message msg = Message.obtain(); |
68 |
1
|
Bundle data = new Bundle(); |
69 |
1
|
data.putString(Constants.ParcelableTag.CURRENCY_NAME, currencyName); |
70 |
1
|
data.putInt(Constants.ParcelableTag.TOTAL_POINT, totalPoint); |
71 |
1
|
msg.setData(data); |
72 |
1
|
mHandler.sendMessage(msg); |
73 |
|
} |
74 |
|
} |