Skip to content

Instantly share code, notes, and snippets.

@kelmer44
Created May 13, 2020 14:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kelmer44/a57ce318dc0dd377f5c685069f9580d2 to your computer and use it in GitHub Desktop.
Save kelmer44/a57ce318dc0dd377f5c685069f9580d2 to your computer and use it in GitHub Desktop.
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