Skip to content

Commit

Permalink
added doc for pinRecompose function
Browse files Browse the repository at this point in the history
  • Loading branch information
neophron88 committed Jul 21, 2024
1 parent 2bd5c7d commit 9378fab
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
6 changes: 5 additions & 1 deletion pinview/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,8 @@ publishing {
}
}
}
}
repositories {
maven { url = uri("https://jitpack.io") }
}
}

13 changes: 10 additions & 3 deletions pinview/src/main/java/com/pulchukur/pinview/PinView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,14 @@ class PinView @JvmOverloads constructor(
handleInputSourceTextChange(pinsInputSource.text)
}
}

/**
*
* This method should be called when [pinItemLayout], [pinCount], [pinDecorationLayout] or [pinDecorationPositions] changed.
*
* Also when added new visual behavior by calling [pinAddVisualBehaviorProducer] function. Otherwise the changes will not be applied.
*
* Note, keep calling this function to a minimum, as it will reinflate pinview items if there are any changes.
*/
fun pinRecompose() {
if (
changeInfo.isPinItemLayoutChanged
Expand Down Expand Up @@ -258,8 +265,8 @@ class PinView @JvmOverloads constructor(
private fun MutableList<VisualBehaviorProducer>.produceBehaviors(viewId: Int): List<EachItemTargetBehaviors> {
return map { producer ->
_pinItems.mapIndexed { position, itemRoot ->
val targetView = itemRoot.findViewById<View>(viewId)
?: error("View with such id not found")
val targetView: View? = itemRoot.findViewById(viewId)
targetView ?: error("View with such id not found")
producer.createVisualBehavior(position, targetView)
}
}
Expand Down
2 changes: 1 addition & 1 deletion sample/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ dependencies {
implementation("androidx.core:core-ktx:1.13.1")
implementation("androidx.appcompat:appcompat:1.7.0")
implementation("com.google.android.material:material:1.12.0")
implementation("com.github.neophron88:PinView:1.4.2")
implementation("com.github.neophron88:PinView:1.0")
testImplementation("junit:junit:4.13.2")
androidTestImplementation("androidx.test.ext:junit:1.1.5")
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")
Expand Down

0 comments on commit 9378fab

Please sign in to comment.