Last active
September 30, 2015 12:05
-
-
Save MWhyte/3e9544e541d7d03a8438 to your computer and use it in GitHub Desktop.
Using lambda's with android. With help from gradle-retrolambda
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
buildscript { | |
repositories { | |
jcenter() | |
mavenCentral() | |
} | |
dependencies { | |
classpath 'com.android.tools.build:gradle:1.1.1' | |
classpath 'me.tatarka:gradle-retrolambda:3.2.3' | |
} | |
} | |
apply plugin: 'com.android.application' | |
apply plugin: 'me.tatarka.retrolambda' | |
repositories { | |
jcenter() | |
mavenCentral() | |
} | |
android { | |
compileSdkVersion 23 | |
buildToolsVersion "23.0.0" | |
defaultConfig { | |
applicationId "com.newboston.app" | |
minSdkVersion 11 | |
targetSdkVersion 23 | |
versionCode 1 | |
versionName "1.0" | |
} | |
compileOptions { | |
sourceCompatibility JavaVersion.VERSION_1_8 | |
targetCompatibility JavaVersion.VERSION_1_8 | |
} | |
buildTypes { | |
release { | |
minifyEnabled false | |
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' | |
} | |
} | |
} | |
dependencies { | |
compile fileTree(dir: 'libs', include: ['*.jar']) | |
compile 'com.android.support:appcompat-v7:23.0.1' | |
} |
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
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_main); | |
loginBtn = (Button) findViewById(R.id.login_btn); | |
loginBtn.setOnClickListener((View) -> login()); | |
Log.i(TAG, "onCreate finished"); | |
} | |
private void login() { | |
Context context = getApplicationContext(); | |
CharSequence text = "Hello toast!"; | |
int duration = Toast.LENGTH_SHORT; | |
Toast toast = Toast.makeText(context, text, duration); | |
toast.show(); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment