Created
July 25, 2014 13:05
-
-
Save benzap/8cf4526f413339624c92 to your computer and use it in GitHub Desktop.
problem with Unbound Var
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[: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}] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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"))) |
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
Compiling com.ais.ifidsremoteclient.main
Exception in thread "main" java.lang.ClassCastException: clojure.lang.Var$Unbound cannot be cast to android.content.Context, compiling:(main.clj:52:24)
at clojure.lang.Compiler$InvokeExpr.eval(Compiler.java:3558)
at clojure.lang.Compiler$InvokeExpr.eval(Compiler.java:3552)
at clojure.lang.Compiler$MapExpr.eval(Compiler.java:2931)
at clojure.lang.Compiler$VectorExpr.eval(Compiler.java:3101)
at clojure.lang.Compiler$VectorExpr.eval(Compiler.java:3101)
at clojure.lang.Compiler$VectorExpr.eval(Compiler.java:3101)
at clojure.lang.Compiler$DefExpr.eval(Compiler.java:417)
at clojure.lang.Compiler.compile1(Compiler.java:7226)
at clojure.lang.Compiler.compile(Compiler.java:7292)
at clojure.lang.RT.compile(RT.java:423)
at clojure.lang.RT.load(RT.java:463)
at clojure.lang.RT.load(RT.java:436)
at clojure.core$load$fn__5066.invoke(core.clj:5641)
at clojure.core$load.doInvoke(core.clj:5640)
at clojure.lang.RestFn.invoke(RestFn.java:408)
at clojure.core$load_one.invoke(core.clj:5446)
at clojure.core$compile$fn__5071.invoke(core.clj:5652)
at clojure.core$compile.invoke(core.clj:5651)
at user$eval7.invoke(form-init5089163030663588903.clj:1)
at clojure.lang.Compiler.eval(Compiler.java:6703)
at clojure.lang.Compiler.eval(Compiler.java:6693)
at clojure.lang.Compiler.load(Compiler.java:7130)
at clojure.lang.Compiler.loadFile(Compiler.java:7086)
at clojure.main$load_script.invoke(main.clj:279)
at clojure.main$init_opt.invoke(main.clj:284)
at clojure.main$initialize.invoke(main.clj:312)
at clojure.main$null_opt.invoke(main.clj:347)
at clojure.main$main.doInvoke(main.clj:425)
at clojure.lang.RestFn.invoke(RestFn.java:421)
at clojure.lang.Var.invoke(Var.java:383)
at clojure.lang.AFn.applyToHelper(AFn.java:156)
at clojure.lang.Var.applyTo(Var.java:700)
at clojure.main.main(main.java:37)
Caused by: java.lang.ClassCastException: clojure.lang.Var$Unbound cannot be cast to android.content.Context
at neko.data$get_shared_preferences.invoke(data.clj:99)
at com.ais.ifidsremoteclient.state$get_device_id.invoke(state.clj:31)
at clojure.lang.Var.invoke(Var.java:375)
at com.ais.ifidsremoteclient.main$fn__26.invoke(main.clj:52)
at clojure.lang.Delay.deref(Delay.java:37)
at clojure.core$deref.invoke(core.clj:2200)
at clojure.lang.AFn.applyToHelper(AFn.java:154)
at clojure.lang.AFn.applyTo(AFn.java:144)
at clojure.lang.Compiler$InvokeExpr.eval(Compiler.java:3553)
... 32 more
Compilation failed.