I recently started using retrofit libraries.. long story short, my UI is getting frozen, until all retrofit calls are completed..
point to be noted in the place of retrofit if you are using async task then the UI has no problem there is no freezing..
i tried calling the retrofit methods in do in background no change... also tried calling it in a thread.. no change..
between the ui contains a custom progress bar, which should be continuously running..
so how to remove the lag?? retrofit code
public static ApiClientInterface mainUrl() {
if (apiClientInterface == null) {
RestAdapter restAdapter = new RestAdapter.Builder().setEndpoint(
"http://projects.quinoid.com").build();
// common.php?&status=
apiClientInterface = restAdapter.create(ApiClientInterface.class);
}
public interface ApiClientInterface {
@GET("/LTFoods/json/common.php")
void getCategories(@Query("status") String status,
@Query("viewset") String viewset,
@Query("currentdate") String date,
Callback<CategoriesModel> callback);
}
this is the final code.. using threads ..
private void threads(String date, String login,
Context activityContext){
final String currentDate = date;
final String loginOne = login;
final Context activityContexT = activityContext;
new Thread(new Runnable() {
@Override
public void run() {
// TODO Auto-generated method stub
URL_Retrofit.Categories(currentDate, activityContexT, false);
}
}).start();
new Thread(new Runnable() {
@Override
public void run() {
// TODO Auto-generated method stub
URL_Retrofit.Directors(activityContexT, currentDate);
}
}).start();
new Thread(new Runnable() {
@Override
public void run() {
// TODO Auto-generated method stub
URL_Retrofit.CorporateAddress(activityContexT, currentDate);
}
}).start();
new Thread(new Runnable() {
@Override
public void run() {
// TODO Auto-generated method stub
URL_Retrofit.DistributorDetails(activityContexT, loginOne,
currentDate);
}
}).start();
}