Skip to content

Commit

Permalink
Fix crash with caching
Browse files Browse the repository at this point in the history
  • Loading branch information
imallan committed Jul 29, 2016
1 parent 5bd9a31 commit 4dbcef5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class MainActivity : AppCompatActivity() {

constructor(view: View) {
mView = view
Toothpick.bind(this, view)
Toothpick.bind(this@MyView, view)
}

@OnClick(R.id.button_press_me_2)
Expand Down
6 changes: 3 additions & 3 deletions toothpick/src/main/kotlin/com/imallan/toothpick/Toothpick.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ object Toothpick {
fun bind(activity: Activity) {
val injectorName = "${activity.javaClass.canonicalName}\$\$ViewInjector"
var bindMethod = mMethodMap[injectorName]
if (mMethodMap[injectorName] == null) {
if (bindMethod == null) {
val clazz = Class.forName(injectorName)
bindMethod = clazz.getDeclaredMethod("bindActivity", Any::class.java, Activity::class.java)
mMethodMap.put(injectorName, bindMethod)
Expand All @@ -27,8 +27,8 @@ object Toothpick {

fun bind(obj: Any, view: View) {
val injectorName = "${obj.javaClass.name}\$\$ViewInjector"
var bindMethod = mMethodMap[injectorName]
if (mMethodMapForView[injectorName] == null) {
var bindMethod = mMethodMapForView[injectorName]
if (bindMethod == null) {
val clazz = Class.forName(injectorName)
bindMethod = clazz.getDeclaredMethod("bindView", Any::class.java, View::class.java)
mMethodMapForView.put(injectorName, bindMethod)
Expand Down

0 comments on commit 4dbcef5

Please sign in to comment.