Simple image search app using the Flickr Image Search API.
Features:
- Endless scrolling of search results
- 3 column grid view of images
- Auto search as you type
- RxJava - Used RxJava for easier concurrency and thread management.
Example:
- Searching: Ability to search as you type by debouncing keystrokes to avoid unnecessary requests
- Cancel existing network requests (both query and paging) when search query changes using
switchMap
operator. - Manage a bound thread pool of size 6 to fetch and decode images concurrently.
- OkHttp - Used for easier networking to fetch
json
andinput stream
forBitmap
s.
MVP with Repository to avoid logical code in Activity
and separate data related code. Loose coupling by making code dependent on interfaces rather than implementations eg: ImageCache
, ImagesDataSource
, ImageLoader
. Explicit dependency on Flickr is avoided and is accessed through contracts.
-
data
-ImagesDataSource
is a contract for a source that provides paged searching.FlickrImagesDataSource
is an implementation backed byFlickr API
. Also includes data classes for parsingjson
response. -
DepedencyInjector
- Utility class to manage dependencies throughout the app. Responsible for managing and providing dependencies when requested. Eg:DependencyInjector.provideHomePresenter
. -
Image Loading
-ImageLoader
andImageCache
are contracts for a system that loads images efficiently by reducing sample size, perform concurrent requests and caching.DefaultImageLoader
- Loader backed by Rx to handle multiple requests and decode images.MemoryImageCache
- Lru based memory cache to hold fewBitmap
s in memory.
-
SchedulerProvider
- Contract to provide various type ofSchedulers
for concurrency. Can be replaced during testing via DI. -
Home
- Home feature package that contains, presenter for communicating with data layer, adapter for rendering grid andHomeActivity
-
Test
- Presenter test for search term achieved by injectingMockImagesDataSource
and testing paging and searches.
ImageLoading
- While current implementation automatically usesImageViews
dimensions to downsize source image, there are other cases that could handled for better performance. Currently the load request is not cancelled when theImageView
is detached from window and relies onRecyclerView.Adapter.onViewRecycled
to cancel the request, this could be changed to useView.onAttachStateListener
to free one of the threads thereby improving load performance during scrolling. - Could use battle tested solutions likeGlide
orPicasso
.Paging
- By using PagedList and PageKeyedDataSource to simplify scroll listening, load more and concentrate on API implementationsDagger 2
- Use Dagger 2 instead of customDependencyInjector
to achieve compilation safety and scaling.State Restoration
- Currently only the search term is restored upon a config change, this could be changed to useViewModel
pattern to cache the image list as well to avoid additional network calls.Better Error handling
- When a paged list fails to load, possibly a retry button could be used to restart failed requests.Test
- Additional integration tests to avoid breakage due to 3rd parties.LocalDataSource
- Implement a local data source for provide search results stored on disk.