How jbvincey/instantappsample works
Project Type and Purpose
• This is an Android Instant App sample demonstrating how to take a regular Android application and turn it into an Instant App with one or more feature modules.
• It uses the Model-View-Presenter (MVP) pattern, and is organized into multiple Gradle modules:
– A base feature module (formerly “app”)
– An installed APK wrapper module
– An Instant App wrapper module
– Two feature modules (Trip List and Trip Details)
High-Level Module Analysis
At the top level you have:
• instanttripapk (the “installed” application wrapper)
• instanttripinstantapp (the Instant App wrapper)
• instanttripbase (the base feature module containing common code and configuration)
• instanttriplist (feature module for the list of trips)
• instanttripdetails (feature module for trip details)
Relationships:
• instanttripapk and instanttripinstantapp both depend on instanttripbase (and, in the multi-feature setup, also on instanttriplist and instanttripdetails).
• instanttripbase declares its feature modules using Gradle “feature project(…)” directives.
• The two feature modules each contain their own Activities, layouts, and use API-level code from instanttripbase (models, repositories, helpers, presenters).
Core Components and Layers
Within the base feature module (instanttripbase):
• Application class: InstantAppSampleApplication
• Dependency injection setup: DependencyManager, RepositoryModule
• Data layer: TripRepository (reads trips.json from assets)
• Domain models: Trip, Coordinates
• Helpers and constants: IntentHelper, ResourceHelper, Constants
In each feature module (instanttriplist, instanttripdetails):
• UI: MainActivity or DetailsActivity, layouts (activity_main.xml, item_trip.xml, activity_detail.xml)
• Presenter: MainPresenter, DetailPresenter
• Adapter (list only): TripAdapter
• Feature-specific R resources
Interaction and Data Flow
• Activity ←→ Presenter: View calls Presenter to load data or handle user events; Presenter pushes data back to View.
• Presenter → Repository: Presenter requests data (e.g., list of trips or single trip) from TripRepository.
• Repository → Assets: Repository loads JSON from assets/trips/trips.json.
• Activity navigates to Detail feature by firing an Intent with a URL (IntentHelper).
Architectural Patterns and Principles
• Modular Feature-Based Architecture for Instant Apps: separate modules for each addressable feature
• Single base feature for shared code and resources
• Wrapper Application modules (installed vs. instant) that simply depend on features
• MVP pattern: clear separation between View (Activity), Presenter, and Model/Repository
• Explicit Intent-based navigation, using App Links (URL mapping) for instant modules