Android Retrofit 2.0:对HTTP调用无响应

时间:2018-09-25 09:10:51

标签: retrofit

我是一名Android开发人员,正在与Retrofit合作。第一天,我收到了答复,但是第二天没有收到答复,为什么我可以在卸载并安装应用程序后继续工作,然后才可以工作,为什么,如何解决,请帮助我...

private void HomeWorks() {
    HomeWorkApi homeWorkApi =
            MissReportServer.getClient().create(HomeWorkApi.class);
    Call<VrrittamResponse<ArrayList<HomeWork>>> call =
            homeWorkApi.getHomeWork(access_token);
    call.enqueue(new Callback<VrrittamResponse<ArrayList<HomeWork>>>() {
        @Override
        public void onResponse(Call<VrrittamResponse<ArrayList<HomeWork>>> call, Response<VrrittamResponse<ArrayList<HomeWork>>> response) {
            try {
                ArrayList<HomeWork> homeWork = response.body().getContent();

                if (homeWork != null && !homeWork.isEmpty()) {

                    recyclerView.setAdapter(new HomeWorkAdapter(homeWork,
                            R.layout.list_item_homework, getActivity()));
                }
                else {
                    ExceptionHandle.alertDialogNotShow(getActivity());
                }
            }

            catch (Exception ex){
                ExceptionHandle.alertDialogNotShow(getActivity());
            }

        }

        @Override
        public void onFailure(Call<VrrittamResponse<ArrayList<HomeWork>>> call, Throwable t) {
            Log.e("TAG",t.getMessage());
            ExceptionHandle.alertDialogShow(getActivity());
        }
    });
}

0 个答案:

没有答案