mapbox / mapbox/mapbox-navigation-android

Android Drop-In UI : Separate the lifecycle states for view and data streams

Open
#5,841 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

jira-sync-complete UI
Dominant language
Kotlin
Stars
651
Forks
321
PR merge metrics
No merged PRs in 30d

Description

Following discussion from https://github.com/mapbox/mapbox-navigation-android/pull/5818

## Description of issue

Right now `NavigationView` ties all view inflations and data resource streams to the [Lifecycle.State.CREATED](https://github.com/mapbox/mapbox-navigation-android/blob/09cd530425a2ec891e39f9d2fa0ff6a729cc1af9/libnavui-dropin/src/main/java/com/mapbox/navigation/dropin/NavigationView.kt#L108). This is appropriate for view inflations, but not always needed for data resources. For example, there is no need to update the current road label when the user cannot see the current road label.

Another issue here, is if you detach the NavigationView from the owning Activity/Fragment; the view needs to stop updating the view resources.

We also need to maintain support for being able to pull data resources streams while the app is in background. For this, the `MapboxNavigationApp` and `MapboxNavigationObserver` architecture can be used. For example, audio guidance is still useful while the app is in background.

## Proposal

Look to update the `UiCoordinator` `UiBinder` `UIComponent` architecture to separate the lifecycle states for view and data streams.

`UiBinder` is responsible for all of the `NavigationView` View inflations. The `UiCoordinator` has control of both the `bind` (view) and the `attach` (data). The `UICoordinator` can be a Lifecycle aware object that binds `UIBinder` when the lifecycle is created. And then it attaches the binder components to the `Lifecycle.State.STARTED` state.

This will not require changes to any of the underlying components, i'm thinking it can all be done by `UiCoordinator`

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with NavigationView.kt and trace how UiCoordinator, UiBinder, and UIComponent currently bind view inflations and data streams at CREATED. Then read the MapboxNavigationApp and MapboxNavigationObserver architecture for background data support. Done means view resources stop updating when detached or not visible while data streams, including audio guidance, remain available in the background.

Written by the indexing model from the issue text.

Assessment

Tech stack
kotlin
Domain
mobile
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.