This library includes a custom widget that makes it simpler to present models with a large number of fields with minimum effort. It uses the names and values of each field in your model to build a presentation layout with just a few lines of code.
On your project level build.gradle:
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
Then on your module level gradle file:
dependencies {
implementation 'com.github.nightcrawler-:android-model-to-view:<version>'
}
Initialize the ModelToView
object by passing a RecyclerView
to the constructor. This RecyclerView
will host the name-value pairs extracted from your model.
Call modelToView.setModel(<your model>)
to extract and display contents.
- You can pass a custom adapter and layout manager for a more fine grained presentaton.
- The library has a number of annotations for your fields to control the extraction of the name-value pairs.
@Capitalize - Return the titles/field names in all uppercase
@IgnoreExtraction - Skip the field
@Extracted name - Use a different name for the extracted title (different from the field name)
@MeasurementUnit - Append a measurement unit at the end of the extracted value
@Ordered - Since the order of the fields is not guaranteed (at least on JVM +1.6, they might be returned in the declared order). This annotation on the class, in conjunctio with @Index on the field, returns the fields in a pre-determined order.