How unsplash/unsplash-photopicker-android works
Project type and purpose
• This is an Android multi-module project consisting of:
• A library module (photopicker) that implements an Unsplash photo picker UI component.
• An example application module (example) that demonstrates how to integrate and use the picker.
• Purpose: provide a reusable, drop-in Android component to search Unsplash, display a gallery, let users pick photos, and return the results to the host app.
File structure
• Top-level:
• settings.gradle: includes :photopicker and :example modules.
• Root build.gradle, Gradle wrapper, CI/GitHub config and license.
• photopicker module:
• src/main/java/com/unsplash/pickerandroid/photopicker subdivided into:
– data (network models & endpoints)
– domain (data sources, repository, network state)
– presentation (activities, view models, adapters, views)
• Injector.kt: central dependency provider.
• UnsplashPhotoPicker.kt: Kotlin object used to initialize the library with API keys.
• Resources: drawables, layouts, styles for the picker UI.
• example module:
• Standard Android app structure demonstrating how to call UnsplashPhotoPicker.init(...) and start UnsplashPickerActivity.
README for additional insights
• Confirms library init flow: init() → UnsplashPickerActivity → return UnsplashPhoto list.
• Highlights external dependency on Unsplash HTTP API (access key, secret key).
• Shows minimal integration code in the host app.
a. Main components to represent:
1. Host Application (the example or any consumer app)
2. UnsplashPhotoPicker Library Module
• Initialization object (UnsplashPhotoPicker)
• Presentation layer (UnsplashPickerActivity, PhotoShowActivity, adapters, custom views)
• Domain layer (ViewModels, State objects, Listener interfaces)
• Data layer (Repositories, DataSources, NetworkEndpoints, DTOs)
3. External Service: Unsplash REST API
4. Android framework (Activities, Intents, ViewModels, RecyclerView)
b. Relationships and interactions:
• Host App calls UnsplashPhotoPicker.init(app, key, secret) → config stored in Injector.
• Host App launches UnsplashPickerActivity via Intent.
• UnsplashPickerActivity uses UnsplashPickerViewModel (via factory) to coordinate:
– Calls Repository.searchPhotos(...) or loadMorePhotos()
– Repository delegates to SearchPhotoDataSource / LoadPhotoDataSource (domain)
– DataSource uses NetworkEndpoints to make HTTP requests to Unsplash API
– JSON → SearchResponse → list of UnsplashPhoto DTOs
– ViewModel exposes LiveData of paging data + network state → UI updates via adapter
• User selects photo(s). Activity returns result Intent containing ArrayList<UnsplashPhoto>.
• Host App receives result in onActivityResult.
c. Architectural patterns and design principles:
• MVVM: Activities + Adapters observe ViewModel state.
• Clean layering: Data → Domain → Presentation
• Dependency Injection via simple Injector object
• Repository & DataSource pattern for paging and API abstractions
d. Technologies, frameworks, libraries:
• Kotlin, AndroidX, ViewModel, LiveData/Observer
• RecyclerView, custom Views
• Retrofit/OKHttp (implied by NetworkEndpoints) or similar HTTP client
• Gradle multi-module build
Final advice
• Be detailed: breakdown each module’s subcomponents.
• Key flows: initialization, API request, UI rendering, selection result.
• Keep the external Unsplash API as its own node to show the network dependency.