Skip to content

Instantly share code, notes, and snippets.

Created February 23, 2011 03:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/839973 to your computer and use it in GitHub Desktop.
Save anonymous/839973 to your computer and use it in GitHub Desktop.
(gen-class :extends android.view.SurfaceView
:implements [android.view.SurfaceHolder$Callback]
:name org.stine.program.MainSurface
:init init
:constructors {[android.content.Context] [android.content.Context]}
:exposes-methods {setMeasuredDimension superSetMeasuredDimension}
:prefix mainsurf-)
(defn mainsurf-init [context]
[[context]])
(defn mainsurf-onDraw [this ^android.graphics.Canvas canvas]
(doto canvas
(.drawRGB 100 10 0)))
(defn mainsurf-onMeasure [this
^android.view.View$MeasureSpec width
^android.view.View$MeasureSpec height]
(let [processSpec (fn [spec]
(let [mode (View$MeasureSpec/getMode spec)
size (View$MeasureSpec/getSize spec)]
(condp = mode
View$MeasureSpec/EXACTLY size
View$MeasureSpec/AT_MOST size
View$MeasureSpec/UNSPECIFIED size
100)))]
(.superSetMeasuredDimension this
(int (processSpec width))
(int (processSpec height)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment