Created
May 13, 2020 14:37
-
-
Save kelmer44/a57ce318dc0dd377f5c685069f9580d2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private val executor: ExecutorService = Executors.newSingleThreadExecutor() | |
private val handler: Handler = Handler(Looper.getMainLooper()) | |
interface Callback { | |
fun onFinished(photoListPage: PhotoListPage) | |
} | |
private val adapter = PhotoAdapter() | |
override fun search(term: String, page: Int, callback: Callback) { | |
executor.submit { | |
val apiResponse = flickrService.search(apiKey, term, PERPAGE, page) | |
callback.onFinished(PhotoListPage(term, page, apiResponse.photos.photo.map(adapter::convert), page < apiResponse.photos.pages)) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment