0
I would like to know or understand how to put a loading on the screen. My app consults on a webservice, and sometimes depending on the connection it takes to bring the information. And the app turns all white. To the end user it seems that stuck. So I would like to put a loading screen.
HTTP request code
private static final String BASE_URL = "https://LINK DO MEU Json";
private static Retrofit mRetrofit;
private static ApiNOMEDOPROJETORequestInterceptor mInterceptor;
private static Gson mGson;
private static OkHttpClient mClient;
public static Retrofit getInstance() {
if (mRetrofit == null) {
//create Gson
mGson = new GsonBuilder()
.setDateFormat("yyyy-MM-dd HH:mm:ss")
.create();
//create interceptor
mInterceptor = new ApiNOMEDOPROJETORequestInterceptor();
//create httpClient with interceptor
mClient = new OkHttpClient.Builder().addInterceptor(mInterceptor).build();
//create retrofit
mRetrofit = new Retrofit.Builder()
.baseUrl(BASE_URL)
.addConverterFactory(GsonConverterFactory.create(mGson))
.client(mClient)
.build();
}
return mRetrofit;
}
}
Edit the question and enter the code that queries the webservice.
– ramaral
From what I understand, this whole white that the application gets during the procedure is because there is not really information on the screen. Right? If that is not the case, but because the screen is stuck, the solution starts by placing the request to the web service in a separate thread. On the subject of your loading screen, particularly, I would not create a screen for this, but use a Progressbar, displaying when the request starts and hiding when it is finished. Please show us your code as @ramaral requested so we can show you an example.
– Tássio Auad
@Youngerauad think what I need is this. I will edit my question and put the request code.
– Artur Mafezzoli Júnior
You have to capture the data of the webservice in the background, otherwise the screen is stuck waiting to finish the request.
– Mr_Anderson