Skip to content

Instantly share code, notes, and snippets.

@defHLT
Created December 21, 2014 01:06
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 defHLT/bbfe12377f70f1f79601 to your computer and use it in GitHub Desktop.
Save defHLT/bbfe12377f70f1f79601 to your computer and use it in GitHub Desktop.
(ns com.mlatu.clojure.test.main
(:use [neko.activity :only [defactivity set-content-view! *a]]
[neko.threading :only [on-ui]]
[neko.notify]
[neko.resource]))
(fire (*a) :notification
(notification :icon (get-resource (*a) :drawable :ic-launcher)
:ticker-text "You've got mail"
:content-title "One new message"
:content-text "FROM: foo@bar.com"
:action [:activity "com.mlatu.clojure.test.ACTION"]))
(cancel (*a) :notification)
(defn make-button [i]
[:button {:text (str "This is a button " i)
:tag (str i)
:on-click (fn [view] (show-toast view))}])
(defn unroll [s]
(vec (flatten s)))
(defn show-toast [view]
(toast (str (System/currentTimeMillis) "---" (.getTag view))
:long))
(defactivity com.mlatu.clojure.test.MainActivity
:key :main
:on-create
(fn [this bundle]
(on-ui
(set-content-view! (*a)
(make-ui
(let [layout [:linear-layout {:orientation :vertical}
[:text-view {:text "A text view"} ]]
buttons (for [i (range 5)]
(make-button i))]
(concat layout buttons)))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment