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

Commit d6574cd

Browse files
committed
Make :container trait handle proxies of android.* classses
1 parent b73ad97 commit d6574cd

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

src/clojure/neko/_utils.clj

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,3 +128,12 @@
128128
(.getName m)))
129129
(.getDeclaredMethods c))))
130130
methods)))
131+
132+
(defn closest-android-ancestor
133+
[^Class c]
134+
(loop [c c]
135+
(when c
136+
(if-let [cand-name
137+
(re-find #"^class (android\..*)" (str c))]
138+
(Class/forName (second cand-name))
139+
(recur (.getSuperclass c))))))

src/clojure/neko/ui/traits.clj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
[neko.listeners.text-view :as text-view-listeners]
77
[neko.listeners.adapter-view :as adapter-view]
88
neko.listeners.search-view
9-
[neko.-utils :refer [memoized int-id]])
9+
[neko.-utils :refer [memoized int-id closest-android-ancestor]])
1010
(:import [android.widget LinearLayout$LayoutParams ListView TextView SearchView
1111
ImageView RelativeLayout RelativeLayout$LayoutParams AdapterView
1212
AbsListView$LayoutParams FrameLayout$LayoutParams Gallery$LayoutParams]
@@ -367,7 +367,7 @@ next-level elements."
367367
use the container type to choose the correct LayoutParams instance."
368368
{:applies? (constantly true)}
369369
[wdg _ __]
370-
(let [kw (kw/keyword-by-classname (type wdg))
370+
(let [kw (kw/keyword-by-classname (closest-android-ancestor (class wdg)))
371371
container-type (-> (kw/get-keyword-mapping) kw :container-type)]
372372
{:options-fn #(assoc % :container-type (or container-type kw))}))
373373

0 commit comments

Comments
 (0)