Skip to content

Commit eac6e2e

Browse files
committed
Retrofit to do http requests get post ok
1 parent 27439f3 commit eac6e2e

9 files changed

Lines changed: 693 additions & 2 deletions

File tree

‎blereceiver/build.gradle‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,14 @@ dependencies {
5353
implementation fileTree(include: ['*.jar'], dir: 'libs')
5454
annotationProcessor deps.arouter_compiler
5555
implementation project(':lib_common')
56-
api 'com.marshalchen.ultimaterecyclerview:library:0.7.3'
5756
// Log Bluetooth LE events in nRF Logger
5857
implementation 'no.nordicsemi.android:log:2.1.1'
5958
// BLE library
60-
// implementation 'no.nordicsemi.android:ble:1.1.0'
59+
// implementation 'no.nordicsemi.android:ble:1.1.0'
6160
implementation project(':ble')
61+
implementation 'joda-time:joda-time:2.3'
62+
63+
testImplementation 'junit:junit:4.12'
64+
// androidTestImplementation 'com.android.support.test:runner:1.0.2'
65+
// androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
6266
}

‎blereceiver/src/main/java/com/demo/icarbox/blereceiver/BleReceiverActivity.java‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.demo.icarbox.blereceiver;
22

3+
import android.accounts.Account;
34
import android.bluetooth.BluetoothAdapter;
45
import android.bluetooth.BluetoothDevice;
56
import android.content.BroadcastReceiver;
@@ -99,6 +100,7 @@ protected void onResume() {
99100

100101
LocalBroadcastManager.getInstance(getApplicationContext())
101102
.registerReceiver(broadcastReceiver, intentFilter);
103+
102104
}
103105

104106
@Override
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package com.icarbonx.smartdevice.account;
2+
3+
/**
4+
* Base account to decide common proterties
5+
*/
6+
public class Account implements JsonInterface{
7+
8+
@Override
9+
public String toJson() {
10+
return "{}";
11+
}
12+
}
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
package com.icarbonx.smartdevice.account;
2+
3+
import com.google.gson.Gson;
4+
5+
import org.joda.time.DateTime;
6+
import org.joda.time.LocalDate;
7+
8+
/**
9+
* Base response class for user account controller
10+
* @author lavi
11+
*/
12+
public class BaseResp<T> implements JsonInterface{
13+
T data;
14+
15+
//error message
16+
String errMsg;
17+
//error code
18+
int errorCode;
19+
//current pasge index
20+
int pageIndex;
21+
//current page size
22+
int pageSize;
23+
//time stamp for the response
24+
long timestamp;
25+
//total number
26+
int totalNum;
27+
//total page count
28+
int totalPage;
29+
30+
public T getData() {
31+
return data;
32+
}
33+
34+
public BaseResp<T> setData(T data) {
35+
this.data = data;
36+
return this;
37+
}
38+
39+
public String getErrMsg() {
40+
return errMsg;
41+
}
42+
43+
public int getErrorCode() {
44+
return errorCode;
45+
}
46+
47+
public int getPageIndex() {
48+
return pageIndex;
49+
}
50+
51+
public int getPageSize() {
52+
return pageSize;
53+
}
54+
55+
public long getTimestamp() {
56+
return timestamp;
57+
}
58+
59+
public int getTotalNum() {
60+
return totalNum;
61+
}
62+
63+
public int getTotalPage() {
64+
return totalPage;
65+
}
66+
67+
@Override
68+
public String toString() {
69+
return toJson();
70+
}
71+
72+
@Override
73+
public String toJson() {
74+
return new Gson().toJson(this);
75+
}
76+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package com.icarbonx.smartdevice.account;
2+
3+
/**
4+
* Convert class to json string.
5+
*/
6+
public interface JsonInterface {
7+
String toJson();
8+
}

0 commit comments

Comments
 (0)