Skip to content

Instantly share code, notes, and snippets.

@benzap
Created July 25, 2014 13:05
Show Gist options
  • Save benzap/8cf4526f413339624c92 to your computer and use it in GitHub Desktop.
Save benzap/8cf4526f413339624c92 to your computer and use it in GitHub Desktop.
problem with Unbound Var
[:text-view {:id ::text-current-id
:text (str "Device Id: " @(delay (state/get-device-id)))
:text-size [30 :dp]
:layout-width :fill}]
[:text-view {:id ::text-current-id
:text (str "Version: " @(delay (state/get-current-version)))
:text-size [30 :dp]
:layout-width :fill}]
(defn get-device-id []
(let [sp (data/get-shared-preferences "main" :private)]
(.getInt sp "device-id" -1)))
(defn get-current-version[]
(let [sp (data/get-shared-preferences "main" :private)]
(.getString sp "version" "SNAPSHOT")))
@benzap
Copy link
Author

benzap commented Jul 25, 2014

FIXED

The compile-time representation was expecting a context, which isn't provided outside the activity. I ended up writing functions to update my textviews on the start of the fragment, like the code listed below. This seemed to solve my issue.

(defactivity fooActivity
  :def a
  :on-create
  (fn [this bundle]
    (on-ui
     (setup-action-bar
      a {:navigation-mode :tabs
         :tabs [
                [:tab {:text "Status"
                       :tab-listener 
                       (proxy [Fragment] []
                         (onCreateView [inflater container bundle]
                           (make-ui layout-fragment-status))
                         (onStart []
                           (proxy-super onStart)
                           (change-text-current-server! (state/get-current-server))
                           (change-text-device-id! (state/get-device-id))
                           (change-text-version! (state/get-current-version))))}]
                [:tab {:text "Settings"
                       :tab-listener (simple-fragment
                                      layout-fragment-settings)}]]}))
    (startup/start-service)))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment