I have an array list of API
allSignsList = ArrayList()
allSignsList.add(AllSignsList( "Overview", "overview.aspx"))
allSignsList.add(AllSignsList( "Details", "details.aspx"))
allSignsList.add(AllSignsList( "Description", "description.aspx"))
allSignsList.add(AllSignsList( "profile", "profile.aspx"))
I am making the request using for loop in the allSignList array since the response format is same in all the API. But the main problem that I am facing is the result is not in sequential order. I want to wait for the request to complete before calling another API.
I am making network call this way:
try {
mApiServiceNetwork.getNetworkServiceForXml(getNewXmlBaseUrl())
.getXmlTest(path)
.subscribeOn(Schedulers.newThread())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(object : Subscriber<RSSFeedItems>() {
override fun onCompleted() {
//Do nothing for now
}
override fun onError(e: Throwable) {
Log.e(TAG, "onError " + Log.getStackTraceString(e))
apiResult.onAPIFail()
}
override fun onNext(rssFeed: RSSFeedItems) {
Log.e(TAG+" Weekly", (MainActivity.weeklyCount++).toString() + " Operation performed successfully")
apiResult.onModel(rssFeed)
}
})
} catch (e: Exception) {
Log.e(TAG, "Exception" + Log.getStackTraceString(e))
apiResult.onError(e)
}