 ;; This is how an Activity is defined. We create one and specify its onCreate
 ;; method. Inside we create a user interface that consists of an edit and a
 ;; button. We also give set callback to the button.
-(defactivity my.stuff.events.MainActivity
+(defactivity my.stuff.fitlogger.MainActivity
   :key :main
 
   (onCreate [this bundle]


(defn main-layout [activity]
  [:linear-layout {:orientation :vertical}
   [:edit-text {:hint "Event name",
                :id ::name}]
   [:edit-text {:hint "Event location",
                :id ::location}]
   [:linear-layout {:orientation :horizontal}
    [:text-view {:hint "Event date",
                 :id ::date}]
    [:button {:text "...",
              :on-click (fn [_] (show-picker activity
                                            (date-picker activity)))}]]
   [:button {:text "+ Event",
             :on-click (fn [_]
                         (add-event activity))}]
   [:text-view {:text (format-listing @listing),

          events)
   (join "                        ")))

;; (defn format-listing [lst]
;;   (->> (map (fn [[date events]]
;;             (format "%s - %s" date (format-events events)))
;;           lst)
;;      join))

(defn format-listing [lst] lst)

(def listing (atom {}))

(defn update-ui [activity]
  (set-elmt activity ::listing (format-listing @listing))
  (set-elmt activity ::weight "")
  (set-elmt activity ::bf "")
  (set-elmt activity ::water "")
  (set-elmt activity ::muscle ""))

(defn add-event [activity]
  (let [date-key (try
                   (read-string (get-elmt activity ::date))
                   (catch RuntimeException e "Date string is empty!"))]
    (when (number? date-key)
      (swap! listing
             #(reduce (fn [l k] (assoc-in l [date-key k] (get-elmt activity k)))
                      %
                      [::date ::weight ::bf ::water ::muscle]))
      (update-ui activity))))

(defn date-picker [activity]
