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
public class GcmBroadcastReceiver extends WakefulBroadcastReceiver { | |
@Override | |
public void onReceive(Context context, Intent intent) { | |
ComponentName comp = new ComponentName(context.getPackageName(), GcmIntentService.class.getName()); | |
startWakefulService(context, (intent.setComponent(comp))); | |
setResultCode(Activity.RESULT_OK); | |
} | |
} |
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
public class GcmIntentService extends IntentService { | |
@Override | |
protected void onHandleIntent(Intent intent) { | |
Bundle extras = intent.getExtras(); | |
GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this); | |
String messageType = gcm.getMessageType(intent); | |
if (!extras.isEmpty() && GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType)) { | |
sendNotification(extras.getString("descricao"), extras.getString("endereco")); | |
} |
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
(def second (fn [list] (nth list 1) )) |
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
(def square (fn [n] (n * n))) | |
(def sum (fn [list] (apply + list))) | |
(def add-square (fn [list] (sum (map square list)) )) |
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
(def fac (fn [n] (apply * (range 1 (+ n 1) )))) |
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
(def fatorialT | |
(fn [n acc] | |
(if (= n 0) | |
acc | |
(fatorialT (dec n) (* acc n))))) | |
(prn (fatorialT 5 1)) |
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
(def rec | |
(fn [n acc] | |
(if (empty? n) | |
acc | |
(recur (rest n) (+ acc (first n)))))) | |
(prn (rec [4 3 2 1] 0)) |
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
(def rec | |
(fn [f numbers acc] | |
(if (empty? numbers) | |
acc | |
(recur f (rest numbers) (f acc (first numbers)))))) | |
(prn (rec * [4 2 3] 1 )) |
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 x [map key] | |
(conj map {key (count map)})) | |
(defn rec [f numbers acc] | |
(if (empty? numbers) | |
acc | |
(recur f (rest numbers) (f acc (first numbers))))) | |
(prn (rec x [:a :b :c] {} )) |
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
(+ (* (+ 1 2) 3) 4) | |
(-> (+ 1 2) (* 3) (+ 4)) |