Skip to content

Commit

Permalink
Update function documentations of the BindingManager and BindingInitP…
Browse files Browse the repository at this point in the history
…rovider
  • Loading branch information
skydoves committed Feb 19, 2021
1 parent 62c5fd8 commit e55515e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,17 @@ import android.net.Uri
import android.util.Log

/**
* A binding initialization provider for binding Bindable properties when an application is started.
* @author skydoves (Jaewoong Eum)
*
* A binding initialization provider for binding `@Bindable` properties when an application is started.
* This initialization provider will be registered on the application as a content provider.
*/
class BindingInitProvider : ContentProvider() {

override fun onCreate(): Boolean {
val fieldSize = BindingManager.bind(BR::class)
if (fieldSize <= 1) {
Log.i(TAG, "BindingManager initialization successful, but empty bindable fields.")
if (fieldSize <= MIN_FIELD_SIZE) {
Log.i(TAG, "BindingManager initialization successful, but empty `@Bindable` fields.")
} else {
Log.i(TAG, "BindingManager initialization successful.")
}
Expand All @@ -45,5 +48,6 @@ class BindingInitProvider : ContentProvider() {

companion object {
private const val TAG = "BindingInitProvider"
private const val MIN_FIELD_SIZE = 1
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ object BindingManager {
* for finding the proper binding ID of properties.
*
* @param bindingClass The `BR` class that generated by the DataBinding processor.
* @return The size of the stored fields.
* @throws IllegalArgumentException If we bind non `BR` class into the manager.
*/
fun bind(bindingClass: KClass<*>): Int {
Expand All @@ -71,6 +72,7 @@ object BindingManager {
* Disassembles and stores declared binding fields in the `BR` class.
*
* @param bindingClass The `BR` class that generated by the DataBinding processor.
* @return The size of the stored fields.
*/
private fun storeDeclaredBindingFieldsIntoMap(bindingClass: KClass<*>): Int {
for (field in bindingClass.java.declaredFields) {
Expand Down

0 comments on commit e55515e

Please sign in to comment.