         (read-string (get-elmt activity ::time))
         (catch RuntimeException e "Time string is empty!"))]
     (when (number? date-key)
-      (swap! listing update-in [date-key] (fnil conj [])
-        [(get-elmt activity ::name) time-key])
+      (add-to-listing (get-elmt activity ::name) date-key time-key)
       (update-ui activity))))
 
 (defn date-picker [activity]

  (on-ui (config (find-view activity elmt) :text s)))

(defn update-ui [activity]
  (set-elmt-text activity ::name "")
  )

(defn add-event [activity]
  (let [

(declare date-picker)
(declare time-picker)

(defrecord Task [date name duration date-index])

(defn show-picker [activity picker picker-type]
  (. picker show (. activity getFragmentManager) picker-type))

(def listing (atom (sorted-map)))



(defn sorted-map-array-to-array-task [lst]
  (mapcat identity (map (fn [sorted-map-data]
                          (into [] (map-indexed (fn [i ele]  (apply ->Task (concat [(first sorted-map-data)] ele [i]))) (second sorted-map-data)))
                          ) lst)))


(defn make-date-adapter [activity]
  (adapters/ref-adapter
    (fn [_]
      [:linear-layout {:id-holder true
                       :orientation :vertical}
       [:text-view {:id ::date-tv}]
       [:text-view {:id ::event-tv}]
       ])
    (fn [_ view _ task]
      (let [date-view (find-view view ::date-tv)
            event-view (find-view view ::event-tv)]
        ;symptom of mutability
        (config date-view :visibility (if (= (:date-index task) 0) View/VISIBLE View/GONE))
        (config date-view :text (str (:date task)))

        (config event-view :text (str (:name task) " " (:duration task) " " (:date-index task) ))

        ))
    listing
    sorted-map-array-to-array-task))

(defn main-layout [activity]
  [:linear-layout {:orientation :vertical}
