                       %
                       [:date :weight :bf :water :muscle]))
       (write-logfile activity (listing->csv @listing))
-      (update-ui activity))))
+      (update-ui activity date-key))))
 
 (defn date-picker [activity]
   (proxy [DialogFragment DatePickerDialog$OnDateSetListener] []

              [neko.resource :as res]
              [neko.find-view :refer [find-view]]
              [neko.threading :refer [on-ui]]
              [neko.ui :refer [config]]
              [neko.ui.mapping :refer [defelement]]
              [clojure.string :refer [join split-lines split]]
              [clojure.java.io :as io]
              [my.stuff.fitlogger.sebas :as seb])
    (:import (android.widget EditText TextView)
             (java.util Calendar)
             (java.io File)
             (android.app Activity)


(defn csv->listing [entries]
  (reduce (fn [l e] (csv-list->entry l (split e #",")))
          (sorted-map-by >)
          entries))

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

(defn index-of-key [key map]
  (count (take-while #(not= key %) (keys map))))

(defn update-table [activity key m]
  (let [idx (index-of-key key m)
        row (format-measurements (m key))]
    (on-ui (.addView (find-view activity :table) (make-ui (*a) row) idx))
    row))

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


(def logfile "log5.csv")

(defn write-logfile [activity t]
  (let [file (File. (.getFilesDir activity) logfile)]
