Manipulating View Components
One of the key pillars of the Vapor Android framework is that it gives you a fluent interface for working with Android Views, allowing you to create chains of method calls at will - just like you would in jQuery.
Related Type Hierarchies
Achieving fluency in a strongly typed language such as Java requires use of generic parameters so that we don't lose type information when using inherited methods. We use related type hierarchies in order to hides these generics, and keep the Vapor Android framework easy to use.
Vapor___<T extends ___,?> Types
Types in this hierarchy, starting from
VaporView<? extends View,?>, are the equivalent fluent Vapor companions to Android types.
VaporTextView is the Vapor companion for the Android
Indeed this simple naming convention is employed across all companion types in the framework, making it easy to work out the correct Vapor type to use for any given Android View type.
These types provide the fluent View methods that you will use in your Vapor code to interact with Android View components. You probably won't need to use this family of types directly however, as often the alias
described below are sufficient and easier to use.
V___<T extends ___> Types
VaporView type has a direct alias
On the whole,
V types only have one generic parameter, the Android type that it encapsulates. This is allowed to be any type derived from the companion Android
type. For example,
VaporTextView<T extends TextView> can accept any
T that extends the Android
This design was intentional as it allows you to use the Vapor View classes in conjunction with your own custom derived Android View types seamlessly.
VaporViews have a companion
VaporX type that allows for multiple
VaporView instances to be controlled and manipulated at once, similar to jQuery selectors. This is discussed in detail in the VaporX section which is highly recommended reading.
VaporX framework keeps your Android app code compact, and even allows you to
apply custom code on the members of the underlying group (described below).
VaporViewcomponents of the same class, you must use the Vapor companion for the most specific Android class that they all have in common. For example
VaporXTextViewwould be used to group
Button's together, as
VaporTextViewis the most specific class they have in common.
Any combination of the following types can be used to instantiate a
VaporViewinstance that can be safely treated as an instance of the type being instantiated
T- Any instance that can be safely treated as an instance of
int/Integer- An id that can be safely loaded from the content view as an instance of
VaporX___<T extends ___,?> Types
VaporX framework every
VaporView type has a companion
VaporXView type that provides a superset of the API, adding new methods that are applicable to managing related components simultaneously.
Read the VaporX section to see how
VaporXView behaviour differs from that of a singular
VX___<T extends ___> Types
VaporXView type has a companion
VX type. The
VX is purely an alias type that takes care of filling in some of the ugly generic class parameters required for a fluent architecture.
are therefore much easier to work with!