Skip to content

对Retrofit的简单封装:设置缓存、公共参数、添加headers、自定义响应体和统一的callback;

Notifications You must be signed in to change notification settings

Aleaves/RetrofitUtils

 
 

Repository files navigation

RetrofitUtils

请求:

     RetrofitUtils.getInstance(this)
                    .create(ApiService.class)
                    .addPara(2, 20)
                    .enqueue(new BaseCallback<BaseModel<TestModel>>() {

                        @Override
                        protected void onAfter() {
                            dismissProgress();
                        }

                        @Override
                        protected void onSuccess(BaseModel<TestModel> response) {

                            tvResult.setText("status:" + response.isStatus() + "\n" + response.getData().get(0).getDescription());
                        }

                        @Override
                        protected void onNoData(String msg) {
                            showToast(msg);
                        }

                        @Override
                        protected void onFail(String msg) {
                            showToast(msg);
                        }
                    });

About

对Retrofit的简单封装:设置缓存、公共参数、添加headers、自定义响应体和统一的callback;

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 100.0%