Last active
April 18, 2016 08:07
-
-
Save up1/4c3e0b0ff918cc4e51d65879ff82afd8 to your computer and use it in GitHub Desktop.
Demo :: Java8 in android with jack compiler
This file contains hidden or 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
| android { | |
| compileSdkVersion 'android-N' | |
| buildToolsVersion "24.0.0-rc3" | |
| defaultConfig { | |
| applicationId "up1.demoandroidn" | |
| minSdkVersion 24 | |
| targetSdkVersion 24 | |
| versionCode 1 | |
| versionName "1.0" | |
| jackOptions{ | |
| enabled true | |
| } | |
| } | |
| compileOptions { | |
| targetCompatibility 1.8 | |
| sourceCompatibility 1.8 | |
| } | |
| } |
This file contains hidden or 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 { | |
| @Override | |
| protected void onCreate(Bundle savedInstanceState) { | |
| super.onCreate(savedInstanceState); | |
| setContentView(R.layout.activity_main); | |
| Button clickMeButton = (Button) findViewById(R.id.clickMeButton); | |
| clickMeButton.setOnClickListener(view -> { | |
| makeText(MainActivity.this, "Hello", Toast.LENGTH_LONG).show(); | |
| } | |
| ); | |
| } | |
| } |
This file contains hidden or 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 interface Money { | |
| void setMoney(BigDecimal money); | |
| BigDecimal getMoney(); | |
| String getCurentcy(); | |
| default String getFormattedMoney() { | |
| return String.format(Locale.getDefault(), | |
| "Money is %.3f %s", getMoney().floatValue(), getCurentcy()); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment