Skip to content
This repository has been archived by the owner on Sep 25, 2021. It is now read-only.

Clover UI infrastrucure

Floens edited this page Apr 12, 2016 · 1 revision

Clover UI infrastructure

You won't find any fragments in Clover v2, and there is only one Activity (the StartActivity)

This decision was made for the need for a more dynamic view system. Fragments have been troublesome and there is a move in the Android community for another way. Multiple activities are even more troublesome because the way the state restoring works, you can't give arbitrary objects to activities, everything must be done through Bundles. Animations are hard between activities. Lollipop introduced shared view animations between activities but my experience with them is that they're very buggy.
On top of this was a period after the launch of material design where Google did not release any compatibility views for older devices that made implementing it a pain. There was a huge inconsistency (well, there still is) between apps as they updated to md. The situation has since been improved, but that's long after the start of the redesign of Clover.

This is why Clover implements its own controller system inspired by iOS, and has its own material design views like the toolbar. The base of the system is here with most of the implemented controllers here. The toolbar stuff is here. I plan on decoupling this from the Clover code into a more separate package or even a library.

The controllers are containers around a base view, that have four lifecycle callbacks, onCreate, onShow, onHide and onDestroy. Controllers are embeddable in other controllers. For example the NavigationController is a controller with a toolbar that manages a stack of child controllers. The SplitNavigationController manages two controllers splitted by a divider and new controllers can be shown floating on top of the screen.

The system has been proven to work, adding an animation to the toolbar on controller transitions was easy, all controllers can be made swipeable, and they're easy to reuse.