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
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/clojure/neko/_utils.clj
Original file line number Diff line number Diff line change
Expand Up @@ -128,3 +128,12 @@
(.getName m)))
(.getDeclaredMethods c))))
methods)))

(defn closest-android-ancestor
[^Class c]
(loop [c c]
(when c
(if-let [cand-name
(re-find #"^class (android\..*)" (str c))]
(Class/forName (second cand-name))
(recur (.getSuperclass c))))))
4 changes: 2 additions & 2 deletions src/clojure/neko/ui/traits.clj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
[neko.listeners.text-view :as text-view-listeners]
[neko.listeners.adapter-view :as adapter-view]
neko.listeners.search-view
[neko.-utils :refer [memoized int-id]])
[neko.-utils :refer [memoized int-id closest-android-ancestor]])
(:import [android.widget LinearLayout$LayoutParams ListView TextView SearchView
ImageView RelativeLayout RelativeLayout$LayoutParams AdapterView
AbsListView$LayoutParams FrameLayout$LayoutParams Gallery$LayoutParams]
Expand Down Expand Up @@ -367,7 +367,7 @@ next-level elements."
use the container type to choose the correct LayoutParams instance."
{:applies? (constantly true)}
[wdg _ __]
(let [kw (kw/keyword-by-classname (type wdg))
(let [kw (kw/keyword-by-classname (closest-android-ancestor (class wdg)))
container-type (-> (kw/get-keyword-mapping) kw :container-type)]
{:options-fn #(assoc % :container-type (or container-type kw))}))

Expand Down