How to return value from onResponse() of Volley when its finished ?

262 views
Skip to first unread message

Uğur Can

unread,
Nov 9, 2017, 8:55:39 PM11/9/17
to Volley Users
Hello, Im trying to make basit football game bet app.

I have two different json API links. First one has event informations like:

- matchId
- matchDate
- homeTeamName
- awayTeamName
- matchTime ......

Second API Url has event odds like :

- matchId
- odd_1
- odd_x
- odd_2 ........ 

I need to collect them together in my object. In the first activity, Im having userGuess for the event result and all event information from first API url, then writing to database.

In the second activity Im fetching these guesses and event informations from database to an object. My aim is to show all games and their own guessed odds which was guessed by him. So, creating ArrayList which has objects like this:

- matchId
- matchDate
- homeTeamName
- awayTeamName
- matchTime
- guessForEventResult
- guessOdd

At the last, Im trying to have guessOdd with giving the "matchId" and guessForEventResult to the second API url. I can fetch all guessOdds from second API Url. But they are not at the right sort.
I can not collect them with right sort. I mean, for example, user guessed for first event as odd_1, and second event as odd_2, but Im fetching these guesses in wrong sort. If I can get these matchId-guessOdd  key-values out of onResponse method of Volley, I can make it out. But Volley working as asynctask. I can never know when the Volley's onChange method is finished. And can not return gameOdds from i because its void method. So how can I solve this ?

How to return value from Volley onResponse ?
How to know when Volley data fetching is finished ?

Thanks for help.

Reply all
Reply to author
Forward
0 new messages