Closed ghost closed 9 years ago
Looks good, but I wonder if you could use optional access-fn
that can be passed to ref-adapter. Say:
(ref-adapter (fn [] [:text-view {}]) ; It is better now to just return UI-tree than to call make-ui explicitly
(fn [pos view parent [date events]] ..... )
listing
seq ; Here seq will be called on the value of an atom before setting the data
)
seq throws Exceptions for me. I think it's a Nullpointer one in InterchangeableListAdapter::getCount, but vec works like a charm.
This is a little weird, because clojure.lang.PersistentTreeMap$Seq
conforms to java.util.List
interface. But well, whatever works. Do you still think there is a necessity of extending InterchangeableListAdapter?
I'm happy with using vec as the fourth argument to ref-adapter. That pretty much made the changes to InterchangeableListAdapter obsolete (for me). The only reason to keeping the changes might be that some one doesn't use the ref-adapter and wants to use the InterchangeableListAdapter out of Java and not Clojure, but that's highly unlikely I guess. At this point the extensions are more of a convenience than a necessity.
There might be performance reasons behind modifying the class (as opposed to using access-fn). I will put off this PR for now, until I compare if there is any performance boost from this approach. Thank you for contributing!
YW. One thing to the NullpointerException: (seq (sorted-map)) == nil So if you've got an empty map, calling seq on it and passing it into Java classes might not be too healthy for your application.
Gotcha. vec
is more appropriate then.
After all I decided to keep this. Wouldn't hurt I guess. Merged as 49f6731b0e53b0d920f13e74e290f868cbfe7faf.
I was going through this tutorial and thought it would be neat to be able to feed the (def listing (atom (sorted-map))) directly to a list-view. This of course crashed my application until I modified the adapter itself. Now you can do this: