Skip to main content

Posts

Showing posts with the label RetroLambda

Let's start Lambda in Android

In Android programming, I think Java & J2EE programming are not that different, we developers put many boiler plate code particularly when we use anonymous instances. Example1. Simple example button1.setOnClickListener(new OnClickListener(){ @Override public void onClick(View view){ //Do something } }); In the above example, what we really need is inside of onClick() method. Other code is actually decorations and we don't want it. How about we can pass just onClick method body as a parameter of setOnClickListener method like below? button1.setOnClickListener(view->{ //Do something }); That's what we have exactly wanted. We can use the code style in Java 8. I think you already might know about Java 8 Lambda but there is no official support for Java 8 in Android 8. It would be awesome we can use it in Android and there is a way to be able to use Lambda in Android as well. You can refer my previous blog to setup RetroLambda in Andro...

How to setup RetroLambda, Roboletric and RxAndroid together in Android Studio

Testing environment Before you proceed the process, Java 1.8 should be installed first in your system. Here is my testing system: OS: MacOSX Yosemite(Version 10.10.3) Android Studio: Version 1.2 Java SDK: Version 1.8.0_45 Project structure /Project /app /src /main /java AndroidManifest.xml /testDebug /java build.gradle /build /gradle build.gradle Configuration /Project/build.gradle Add dependencies for retrolambda and robolectric plugins under dependencies block. buildscript { repositories { jcenter() } dependencies { classpath 'com.android.tools.build:gradle:1.2.2' classpath 'me.tatarka:gradle-retrolambda:3.1.0' classpath 'org.robolectric:robolectric-gradle-plugin:1.0.1' } } allprojects { repositories { jcenter() } } Configuration /Project/app/build.gradle apply plugin: 'co...