Skip to content

Commit

Permalink
[n.threading] Finish cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-yakushev committed Jun 11, 2015
1 parent 2710fe5 commit 850a7f6
Showing 1 changed file with 3 additions and 45 deletions.
48 changes: 3 additions & 45 deletions src/clojure/neko/threading.clj
@@ -1,22 +1,7 @@
; Copyright © 2011 Sattvik Software & Technology Resources, Ltd. Co.
; All rights reserved.
;
; This program and the accompanying materials are made available under the
; terms of the Eclipse Public License v1.0 which accompanies this distribution,
; and is available at <http://www.eclipse.org/legal/epl-v10.html>.
;
; By using this software in any fashion, you are agreeing to be bound by the
; terms of this license. You must not remove this notice, or any other, from
; this software.

(ns neko.threading
"Utilities used to manage multiple threads on Android."
{:author "Daniel Solano Gómez"}
(:use [neko.debug :only [safe-for-ui]])
(:import android.app.Activity
android.view.View
clojure.lang.IFn
java.util.concurrent.TimeUnit
(:import android.view.View
android.os.Looper
android.os.Handler))

Expand All @@ -41,41 +26,14 @@
[f]
(on-ui (f)))

(defn ^{:deprecated "3.1.0"} post*
"Causes the function to be added to the message queue. The function will
execute on the UI thread. Returns true if successfully placed in the message
queue."
[^View view, f]
(.post view f))

(defmacro post
"Causes the macro body to be added to the message queue. It will execute on
the UI thread. Returns true if successfully placed in the message queue."
[view & body]
`(post* ~view (fn [] ~@body)))

(defn ^{:deprecated "3.1.0"} post-delayed*
"Causes the function to be added to the message queue, to be run after the
specified amount of time elapses. The function will execute on the UI
thread. Returns true if successfully placed in the message
queue."
[^View view, millis f]
(.postDelayed view f millis))
`(.post ^View ~view (fn [] ~@body)))

(defmacro post-delayed
"Causes the macro body to be added to the message queue. It will execute on
the UI thread. Returns true if successfully placed in the message queue."
[view millis & body]
`(post-delayed* ~view ~millis (fn [] ~@body)))

(def ^{:doc "A map of unit keywords to TimeUnit instances."
:private true}
unit-map
{; days/hours/minutes added in API level 9
;:days TimeUnit/DAYS
;:hours TimeUnit/HOURS
;:minutes TimeUnit/MINUTES
:seconds TimeUnit/SECONDS
:millis TimeUnit/MILLISECONDS
:micros TimeUnit/MICROSECONDS
:nanos TimeUnit/NANOSECONDS})
`(.postDelayed ^View ~view ~millis (fn [] ~@body)))

0 comments on commit 850a7f6

Please sign in to comment.