I'm new to Android and upgrading, and you have one problem.
I want my words to allow the use of the "ServerCommunication" (singelton) class, where all the Retrofit magic is executed, and it will have public methods in which REST calls are made.
I want to use this instance of "ServerCommunication" in my actions to call the Rest service, but it is. Application logic must be executed in action. Thus, some Login actions call the Login (POJORequest) method in "ServerCommunication", where a real REST call is made through the Retrofit infrastructure, and the POJOResponse is returned. Thus, Activity does not care about REST communications, while ServerCommunication does not care about what logic should be applied to the REST service response since then.
With update 2, I donβt understand how I can block activity to wait for a response from the modification and how it can be returned. Well, I might think that I can use some callback methods in activity so that these methods can be called from ServerCommunication in OnPostExecute () to apply some logic based on the data from the response. I just think this should be a simpler approach.
Well, to clarify this whole mess above, imagine a simple case: you have data in your main action, you pass this data to your communication class, where the REST call is made and the answer is received. This answer must be checked to continue. And you want this validation to be performed in the main activity, and NOT in the communication class.
What is an Android template with Retrofit2?
Thank you in advance
android rest retrofit retrofit2
Tony
source share