Welcome back everyone! I thought about starting a tutorial series on Android development here on Steemit. So let's get right to it!
Yes, Android now supports some Java 8 features like lambdas. You know, the setOnClickListener(v -> doSomething())
stuff. Very neat. So you will say to yourself: great, let's use the other great Java8 feature: the streaming API. But nope! Not supported! :/
But as (almost) always, there's some awesome devs out there who come to help :D So let me introduce: Lightweight-Stream-API.
It is a backport of the Java8 stream API with the help of Java7 iterators.
Include in your project
dependencies {
compile 'com.annimon:stream:1.1.9'
}
Usage
Streams
Stream.of(/* array | list | set | map | anything based on Iterator/Iterable interface */)
.filter(..)
.map(..)
...
.sorted()
.forEach(..);
Stream.of(value1, value2, value3)...
IntStream.range(0, 10)...
Just be careful to import the proper classes: instead of importing java.util.stream.Stream
you have to import com.annimon.stream.Stream
!!!
Functional Interfaces
As an addition, the library also provides you all of the nice classes that help you implement functional programming in Java7 (like Function
, BiFunction
, etc...).
Also watch out for the correct class imports here!
PS: Sorry for the missing code highlighting. Unfortunately Steemit doesn't support code highlighting as of now. But as soon as they add this feature, it should automatically be enabled here :D
PPS: This is a test to see if this post performs any different in the #programming category then in the #androiddev category
PPPS: Trying out the utopian.io website
Posted on Utopian.io - Rewarding Open Source Contributors
Your contribution cannot be approved because it is not as informative as other contributions. See the Utopian Rules. Contributions need to be informative and descriptive in order to help readers and developers understand them.
Also, your repository doesnt have a license file and the readme file is empty.
You can contact us on Discord.
[utopian-moderator]