3

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();
}
Alvin
  • 416
  • 1
  • 8
  • 18
  • 1
    retrofit makes request on separate thread why are you using a thread for retrofit request – Pramod Yadav Feb 24 '15 at 05:14
  • @PramodYadav my ui is lagging.. i did not have this issue with async task.. thats why i tried running on a seperate thread... – Alvin Feb 24 '15 at 05:27
  • then you are executing retrofit wrong way – Pramod Yadav Feb 24 '15 at 05:29
  • @PramodYadav i tried it without thread.. same result.. and i checked the code.. i dont know what i am doing wrong.. could u help me?? the code is above – Alvin Feb 24 '15 at 06:07

0 Answers0