clojure-android / neko

The Clojure/Android Toolkit
Other
297 stars 36 forks source link

Make :container trait handle proxies of android.* classses #68

Closed satchit8 closed 7 years ago

satchit8 commented 7 years ago

Currently, :custom-constructor doesn't appear to work for proxied container widgets:

{:custom-constructor
 (fn [ctxt]
   (proxy [LinearLayout] [ctxt]))

leads to an error at runtime.

The deftrait for :container has:

(let [kw (kw/keyword-by-classname (type wdg))

So IIUC, if wdg is a proxy, kw becomes nil.

As a work-around, I added a function 'closest-android-ancestor' which tries to determine the 'closest' android.* ancestor (actually, the starting class is also considered). Replacing the aforementioned line with:

(let [kw (kw/keyword-by-classname (closest-android-ancestor (class wdg)))

yields better results here.

Likely there's a better way :)

coveralls commented 7 years ago

Coverage Status

Changes Unknown when pulling d6574cd4d6c15479988c140394bc6deb18f6916d on satchit8:custom-constructor-with-proxy-of-container into \ on clojure-android:master**.

alexander-yakushev commented 7 years ago

The workaround seems good enough for me. Also, tests have passed after I merged the other PR (which bumps lein-droid version). Thanks!