forked from guiying712/AndroidModulePattern
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNewsApplication.java
More file actions
56 lines (47 loc) · 1.45 KB
/
NewsApplication.java
File metadata and controls
56 lines (47 loc) · 1.45 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
54
55
56
package debug;
import com.guiying.module.common.base.BaseApplication;
import com.guiying.module.common.http.DataType;
import com.guiying.module.common.http.HttpClient;
import com.guiying.module.common.http.OnResultListener;
import com.guiying.module.news.Constants;
import com.guiying.module.news.data.bean.StoryList;
import com.orhanobut.logger.Logger;
/**
* <p>类说明</p>
*
* @author 张华洋 2017/2/15 20:11
* @version V1.2.0
* @name NewsApplication
*/
public class NewsApplication extends BaseApplication {
@Override
public void onCreate() {
super.onCreate();
login();
}
/**
* 在这里模拟登陆,然后拿到sessionId或者Token
* 这样就能够在组件请求接口了
*/
private void login() {
HttpClient client = new HttpClient.Builder()
.baseUrl(Constants.ZHIHU_DAILY_BEFORE_MESSAGE)
.url("20170419")
.bodyType(DataType.JSON_OBJECT, StoryList.class)
.build();
client.get(new OnResultListener<StoryList>() {
@Override
public void onSuccess(StoryList result) {
Logger.e(result.toString());
}
@Override
public void onError(int code, String message) {
Logger.e(message);
}
@Override
public void onFailure(String message) {
Logger.e(message);
}
});
}
}