Home > Mobile >  Network layer request appear problem, and confirm the data of the Log
Network layer request appear problem, and confirm the data of the Log

Time:12-14

Presenter
Public class OnSalePagePresenter implements IOnSalePagePresenter {
Private int mCurrentPage=1;
Private IOnSalePageCallback onSalePageCallback=null;
Public Api Api;

Public OnSalePagePresenter () {
/* *
If it's a * side returns the retrofit singleton
*/
Retrofit Retrofit=RetrofitManager. GetInstance (). GetRetrofit ();
API=retrofit. The create (API) class);
/* *
* the log also play not to come out here
*/
The d (" OnSalePagePresenter ", "OnSalePagePresenter is created");
}
@ Override
Public void getContent () {
//get preferential content:
If (onSalePageCallback!=null) {
OnSalePageCallback. onl oading ();
}
/* *
The main problem is this why don't go in my code, inside the log would play not to come out,
*/
String onsalePageUrl=UrlUtils. GetOnsalePageUrl (mCurrentPage);
Call Task=API. GetOnSalePageContent (onsalePageUrl);
Task. The enqueue (new Callback () {
@ Override
Public void onResponse (Call Call, Response The response) {
Int code=response. Code ();
The d (" OnSalePagePresenter ", "getContent - & gt;" + code);
If (code==HttpURLConnection. HTTP_OK) {
OnSaleContent body.=the response body ();
OnSuccess (body);
The d (" OnSalePagePresenter ", "OnSaleContent - & gt;" + body);
} else {
If (onSalePageCallback!=null) {
OnSalePageCallback. OnNetworkError ();
}
}
}
@ Override
Public void onFailure (Call Call, Throwable t) {
If (onSalePageCallback!=null) {
OnSalePageCallback. OnNetworkError ();
}

}
});
}
Private void onSuccess (OnSaleContent body) {
If (onSalePageCallback!=null) {
Try {
Int size=body. GetData (). GetTbk_dg_optimus_material_response () getResult_list () getMap_data (). The size ();
If (size==0) {
OnEmppty ();
} else {
OnSalePageCallback. OnContentLoadSuccess (body);
}
} the catch (Exception e) {
e.printStackTrace();
OnEmppty ();
}
}
}
Private void onEmppty () {
If (onSalePageCallback!=null) {
OnSalePageCallback. OnEmpty ();
}
}

@ Override
Public void reLoad () {
Enclosing getContent ();

}

@ Override
Public void LoadMore () {
MCurrentPage++;
The String url=UrlUtils. GetOnsalePageUrl (mCurrentPage);
Call Task=API. GetOnSalePageContent (url);

Task. The enqueue (new Callback () {
@ Override
Public void onResponse (Call Call, Response The response) {
Int code=response. Code ();
If (code==HttpURLConnection. HTTP_OK) {
OnSaleContent body.=the response body ();
OnMoreLoaded (body);
} else {
OnLoadMoreError ();

}
}
@ Override
Public void onFailure (Call Call, Throwable t) {
OnLoadMoreError ();
}
});
}


Private void onl oadMoreError () {
MCurrentPage -;
OnSalePageCallback. OnMoreLoadError ();

}

Private void onMoreLoaded (OnSaleContent body) {

If (onSalePageCallback!=null) {
Try {
Int size=body. GetData (). GetTbk_dg_optimus_material_response () getResult_list () getMap_data (). The size ();
If (size==0) {
OnEmppty ();
} else {
//onSalePageCallback onContentLoadSuccess (body);
}
} the catch (Exception e) {
e.printStackTrace();
OnEmppty ();
}
}
}

@ Override
Public void registerViewCallback (IOnSalePageCallback callback) {
Enclosing onSalePageCallback=callback;

}

@ Override
Public void unregisterViewCallback (IOnSalePageCallback callback) {
Enclosing onSalePageCallback=null;
}
}
Fragments of the UI layer

Public class OnSaleFragment extends BaseFragment implements IOnSalePageCallback {
@ BindView (R.i d.o n_sale_list)
Public RecyclerView onSaleList;
Public OnSalePageAdapter OnSalePageAdapter;
Public OnSalePagePresenter OnSalePagePresenter;
@ Override
Protected void initPresenter () {
Super. InitPresenter ();
/* *
Here is a PresenterManager class return presenter in the various fragments singleton
*/
OnSalePagePresenter=PresenterManager. GetInstance (). GetOnSalePagePresenter ();
OnSalePagePresenter. RegisterViewCallback (this);
OnSalePagePresenter. GetContent ();
}

@ Override
Protected int getRootVireResId () {
/* *

*/
The d (" OnSaleFragment ", "fragment_red_packet is created");
Return R.l ayout. Fragment_red_packet;

}

@ Override
Protected void initView (View rootView) {
SetUpState (State. SUCCESS);
OnSalePageAdapter=new onSalePageAdapter ();
GridLayoutManager GridLayoutManager=new GridLayoutManager (getContext (), 2);
OnSaleList. SetLayoutManager (gridLayoutManager);
OnSaleList. SetAdapter (onSalePageAdapter);
}

@ Override
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related