package debug;

import com.orhanobut.logger.Logger;
import com.uas.module.common.base.BaseApplication;
import com.uas.module.common.http.DataType;
import com.uas.module.common.http.HttpClient;
import com.uas.module.common.http.OnResultListener;
import com.uas.module.news.Constants;
import com.uas.module.news.data.bean.StoryList;


public class NewsApplication extends BaseApplication {

    @Override
    public void onCreate() {
        super.onCreate();
        Logger.d("新闻组件初始...");
        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);
            }
        });
    }

}
