All Projects → aNNiMON → Android Java 8 Stream Example

aNNiMON / Android Java 8 Stream Example

Demo app of using Java 8 features with Retrolambda and Lightweight-Stream-API

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Android Java 8 Stream Example

Circleci Demo Python Django
Example Django application running on CircleCI
Stars: ✭ 100 (-9.09%)
Mutual labels:  demo
Legacy Search
Demo project showing how to add elasticsearch to a legacy application.
Stars: ✭ 103 (-6.36%)
Mutual labels:  demo
Vaadin Microservices Demo
A microservices example developed with Spring Cloud and Vaadin
Stars: ✭ 108 (-1.82%)
Mutual labels:  demo
Joomla Demo Component
Home of a Demo Component for Joomla 3.x
Stars: ✭ 100 (-9.09%)
Mutual labels:  demo
Server Components Mdx Demo
React server components + MDX
Stars: ✭ 102 (-7.27%)
Mutual labels:  demo
Ios Lame Audio Transcoding
AVAudioRecorder
Stars: ✭ 105 (-4.55%)
Mutual labels:  demo
Nitro Demo
nuxt nitro preview
Stars: ✭ 100 (-9.09%)
Mutual labels:  demo
Flutter crop
Crop any widget/image in Android, iOS, Web and Desktop with fancy and customizable UI, in pure Dart code.
Stars: ✭ 107 (-2.73%)
Mutual labels:  demo
Framy Css
Very simple CSS Framework
Stars: ✭ 103 (-6.36%)
Mutual labels:  demo
Awesome Wechat Weapp
微信小程序开发资源汇总 💯
Stars: ✭ 36,769 (+33326.36%)
Mutual labels:  demo
D3 Audio Spectrum
Spectrum analysis demo using D3 and HTML5 audio
Stars: ✭ 101 (-8.18%)
Mutual labels:  demo
Efficientdet.pytorch
Implementation EfficientDet: Scalable and Efficient Object Detection in PyTorch
Stars: ✭ 1,383 (+1157.27%)
Mutual labels:  demo
Pingcrm
PingCRM on Rails - A Ruby on Rails demo application to illustrate how Inertia.js works
Stars: ✭ 106 (-3.64%)
Mutual labels:  demo
Gl Catmull Clark
A javascript implementation of the Catmull-Clark subdivision surface algorithm
Stars: ✭ 100 (-9.09%)
Mutual labels:  demo
Vue Meizi
vue最新实战项目,vue2 + vuex + webpack + es6 干货多多,新手福利
Stars: ✭ 1,476 (+1241.82%)
Mutual labels:  demo
Rnprojectplayground
🍨React Native 相关,涉及 MobX、MST使用,原生简易导航模块、列表组件封装,一些动画尝试,以及 HOC 应用。
Stars: ✭ 100 (-9.09%)
Mutual labels:  demo
Relay Northwind App
A complex React, Relay, GraphQL demo app. Online demo:
Stars: ✭ 104 (-5.45%)
Mutual labels:  demo
Wechatappdemo
微信小程序demo,微信小程序开发教程,小程序快速入门,新版SDK DEMO请查看
Stars: ✭ 110 (+0%)
Mutual labels:  demo
Demos
DragonBones Demos (Art assets only)
Stars: ✭ 109 (-0.91%)
Mutual labels:  demo
Reactriot2017 Dotamania
🌐 Web scraping made easy with the visual 🗺 mind map editor to JSON
Stars: ✭ 107 (-2.73%)
Mutual labels:  demo

Android Java 8 Stream API Example

Demo app of using Java 8 features with Retrolambda and Lightweight-Stream-API.

Features:

  • () -> lambda expression

    findViewById(R.id.go).setOnClickListener(v -> {
       final int index = mActionSpinner.getSelectedItemPosition();
       if (index != Spinner.INVALID_POSITION) {
           action(actions[index]);
       }
    });
    
  • Method::references

    int cmp = Objects.compare(word, other.word, String::compareToIgnoreCase);
    
  • Stream.API()

    return Stream.of(lines)
         .map(str -> str.split("\t"))
         .filter(arr -> arr.length == 2)
         .map(arr -> new Word(arr[0], arr[1]))
         .collect(Collectors.toList());
    
  • switch for "string"

    switch (action) {
        case "filter 1":
            // Filter one word
            stream = stream.filter(p -> p.getWord().split(" ").length == 1);
            break;
        case "filter 2+":
            // Filter two and more words
            stream = stream.filter(p -> p.getWord().split(" ").length >= 2);
            break;
        // ...
    }
    
  • try(with-resources) {}

    final List<String> lines = new ArrayList<>();
    try (final InputStream is = context.getAssets().open("words.txt");
         final InputStreamReader isr = new InputStreamReader(is, "UTF-8");
         final BufferedReader reader = new BufferedReader(isr)) {
        String line;
        while ( (line = reader.readLine()) != null ) {
            lines.add(line);
        }
    }
    
  • Objects (from Java 7)

    @Override
    public boolean equals(Object o) {
        // ...
        final Word other = (Word) o;
        return Objects.equals(translate, other.translate) &&
               Objects.equals(word, other.word);
    }
    
    @Override
    public int hashCode() {
        return Objects.hash(word, translate);
    }
    
  • try { Exceptional } catch (functional try/catch)

    return Exceptional.of(() -> {
        final InputStream is = context.getAssets().open("words.txt");
        // ... operations which throws Exception ...
        return lines;
    }).ifException(e -> Log.e("Java 8 Example", "Utils.readWords", e))
      .getOrElse(new ArrayList<>());
    

Links

Demo app: Java8StreamExample.apk

Blog (Russian): Java 8 в Android со Stream API и лямбдами

Retrolambda: https://github.com/orfjackal/retrolambda

Lightweight-Stream-API: https://github.com/aNNiMON/Lightweight-Stream-API

Screenshots

screen_1 screen_2

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].