 ;; 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]

          events)
   (join "                        ")))

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

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

(defn update-ui [activity]
  (set-elmt activity ::listing (format-listing @listing))
  (set-elmt activity ::location "")
  (set-elmt activity ::name ""))

(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 update-in [date-key] (fnil conj [])
             [(get-elmt activity ::location) (get-elmt activity ::name)])
      (update-ui activity))))

(defn date-picker [activity]


(defn main-layout [activity]
  [:linear-layout {:orientation :vertical}
   [:linear-layout {:orientation :horizontal}
    [:button {:text "Date",
              :id ::date,
              :on-click (fn [_] (show-picker activity
                                            (date-picker activity)))}]
    [:edit-text {:hint "Weight",
                 :id ::weight}]
    [:edit-text {:hint "BF%",
                 :id ::bf}]
    [:edit-text {:hint "H2O%",
                 :id ::water}]
    [:edit-text {:hint "M%",
                 :id ::muscle}]]
   [:button {:text "Add log",
             :on-click (fn [_]
                         (add-event activity))}]
   [:text-view {:text (format-listing @listing),
