-
Don't blindly accept that Google's approach to Android development is always the right way. Judge for yourself what the right approach is (often times it is Google's approach) based on your requirements and solution.
-
Be comfortable with examining the Android source code. It's not magic, there's always an answer. Helps you solve problems that would otherwise show up on Stackoverflow.
-
Be multi-discipline. Android can be your focus, but develop for other platforms and use other languages.
-
Master the tools. Make it work for you.
-
Be resourceful. Know when and why a library is the right choice over writing your own solution.
This file contains 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
Observable.just("Hello, world!") | |
.subscribe(new Action1<String>() { | |
@Override | |
public void call(String s) { | |
System.out.println(s); | |
} | |
}); | |
Observable.just("Hello, world!") | |
.subscribe(s -> System.out.println(s)); |
This file contains 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
// no DI | |
public class Refrigerator { | |
private PowerSource powerSource; | |
public Refrigerator() { | |
powerSource = new AcPowerSource(); | |
} | |
} | |
// with DI (manual) |
This file contains 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 MainActivity extends AppCompatActivity { | |
private Fragment savedFragment; | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_main); | |
if (savedInstanceState != null) { | |
savedFragment = getSupportFragmentManager().getFragment(savedInstanceState, "content"); |
This file contains 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
Enum<E extends Enum<E>> { ... } | |
<T extends Object & Comparable<? super T>> T Collections.max(Collection<? extends T>) { ... } | |
public <V extends Wrapper<? extends Comparable<T>>> | |
Comparator<V> comparator() { ... } | |
error: equalTo(Box<capture of ?>) in Box<capture of ?> cannot be applied to (Box<capture of ?>) | |
equal = unknownBox.equalTo(unknownBox) |
This file contains 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
for (int i = 0, remaining = 5; i < colorBucket.size() && remaining > 0; i++, remaining--) { | |
... | |
} |
This file contains 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
private <T> int picker(List<T> src, List<T> dst, int limit) { | |
Iterator<T> iterator = src.iterator(); | |
while (iterator.hasNext() && limit > 0) { | |
dst.add(iterator.next()); | |
limit--; | |
} | |
return limit; | |
} |
This file contains 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
List<Item> allBucket = ... | |
List<Item> genderBucket = ... | |
List<Item> sizeBucket = ... | |
List<Item> colorBucket = ... | |
List<Item> recommendations = new ArrayList<>(); | |
picker(recommendations, limit, colorBucket, sizeBucket, genderBucket, allBucket); | |
private <T> int picker(List<T> src, List<T> dst, int limit) { | |
Iterator<T> iterator = src.iterator(); |
This file contains 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
BehaviorSubject<Integer> timerSubject = BehaviorSubject.create(1); | |
timerSubject | |
.switchMap(interval -> Observable.timer(interval, TimeUnit.SECONDS, Schedulers.newThread())) | |
.flatMap(i -> Observable.just(randomInt())) | |
.doOnNext(timerSubject::onNext) | |
.subscribe(System.out::println); |
This file contains 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
Observable.just(1, 2, 3, 4, 5) | |
.groupBy(i -> i % 2 == 0 ? "even" : "odd") | |
.subscribe(obs -> { | |
if (obs.getKey().equals("even")) { | |
obs.subscribe(i -> System.out.println("even: " + i)); | |
} else { | |
obs.subscribe(i -> System.out.println("odd: " + i)); | |
} | |
}); |
OlderNewer