Skip to content
This repository was archived by the owner on Apr 25, 2024. It is now read-only.

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

Merged
merged 1 commit into from
Nov 14, 2016
Merged

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

merged 1 commit into from
Nov 14, 2016

Conversation

satchit8
Copy link

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
Copy link

Coverage Status

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

@alexander-yakushev
Copy link

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

@alexander-yakushev alexander-yakushev merged commit df40df5 into clojure-android:master Nov 14, 2016
@satchit8 satchit8 deleted the custom-constructor-with-proxy-of-container branch November 17, 2016 13:19
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants