ground-android icon indicating copy to clipboard operation
ground-android copied to clipboard

[Code health] Handle visibility of custom views from within VM

Open shobhitagarwal1612 opened this issue 4 years ago • 1 comments

Visibility of FeatureRepositionView and PolygonDrawingView could be handled in a better manner.

Current:

User action --> Set state to "completed" (CustomViewModel) --> Subscribe to state change in "MapContainerFragment" --> Set mode to DEFAULT, MOVE_POINT, DRAW_POLYGON (in MapContainerViewModel) --> Subscribe to mode in "HomeFragment" and update visibility of custom view.

Proposed:

User action --> Add LiveData for visibility (in CustomViewModel) --> Update visibility of custom view either using data binding or in CustomView.

Pros:

  • Removes extra enum class "Mode"
  • Prevents storing internal state of views in external classes

shobhitagarwal1612 avatar Dec 04 '21 10:12 shobhitagarwal1612

@hemanp tried view bindings here, as did I, and for some reason couldn't get them to work. More work is needed here.

gino-m avatar Dec 07 '21 21:12 gino-m

@shobhitagarwal1612 Could you PTAL? Please assign back if you won't have cycles for this in Mar/Apr.

gino-m avatar Feb 27 '23 17:02 gino-m

This is irrelevant as all tasks are moved to a separate fragment.

shobhitagarwal1612 avatar Feb 27 '23 18:02 shobhitagarwal1612