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
if (BuildConfig.DEBUG) { | |
Timber.plant(new Timber.DebugTree()); | |
} else { | |
Timber.plant(new CrashReportingTree()); | |
} | |
.... | |
private static class CrashReportingTree extends Timber.Tree { | |
@Override protected void log(int priority, String tag, String message, Throwable t) { |
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
/** | |
* Created by ice on 5/3/15. | |
*/ | |
public class RetryWithDelay implements Func1<Observable<? extends Throwable>, Observable<?>> { | |
private final int maxRetries; | |
private final int retryDelayMillis; | |
private int retryCount; |
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
mySubscription = retrofitInterface.doSmth(param) | |
.subscribeOn(Schedulers.io()) | |
.observeOn(Schedulers.io()) | |
.retryWhen(new RetryWithDelay(4, 2000)) | |
.subscribe(....) | |
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
package com.mlatu.tv.ui; | |
import android.support.v7.widget.RecyclerView; | |
import android.view.LayoutInflater; | |
import android.view.View; | |
import android.view.ViewGroup; | |
import android.widget.ImageView; | |
import android.widget.TextView; | |
import com.mlatu.tv.R; |
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
/* | |
* Copyright (C) 2014 skyfish.jy@gmail.com | |
* | |
* Licensed under the Apache License, Version 2.0 (the "License"); | |
* you may not use this file except in compliance with the License. | |
* You may obtain a copy of the License at | |
* | |
* http://www.apache.org/licenses/LICENSE-2.0 | |
* | |
* Unless required by applicable law or agreed to in writing, software |
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
import java.util.Iterator; | |
class HelloWorldApp { | |
public static void main(String[] args) { | |
Iterable<Integer> fibo = new Iterable<Integer>() { | |
@Override | |
public Iterator<Integer> iterator() { | |
return new Iterator<Integer>() { | |
int a = 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
fib = Enumerator.new do |y| | |
a, b = 0, 1 | |
loop do | |
y.yield a | |
a, b = b, a + b | |
end | |
end | |
p fib.take 25 |
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
7 user=> (def get-prev-and-set (let [a (atom {})] (fn [x] (let [r (@a :a)] (swap! a assoc :a x) r)))) | |
6 #'user/get-prev-and-set | |
5 user=> (get-prev-and-set 1) | |
4 nil | |
3 user=> (get-prev-and-set 123) | |
2 1 | |
1 user=> (get-prev-and-set 42) | |
8 123 |
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
@Override | |
public void onAttach(final Activity activity) { | |
super.onAttach(activity); | |
mContextStream.onNext(activity); | |
} | |
// ...... | |
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
t.search(query) // Retrofit | |
.subscribeOn(Schedulers.io()) | |
.retry(3) | |
.observeOn(Schedulers.io()) | |
.subscribe(new Observer<List<SearchResult>>() { | |
@Override | |
public void onCompleted() { | |
} | |
@Override |