Skip to content

Commit bc87168

Browse files
committed
add LambdaSample
1 parent edd2076 commit bc87168

File tree

17 files changed

+168
-0
lines changed

17 files changed

+168
-0
lines changed

LambdaSample/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

LambdaSample/build.gradle

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
apply plugin: 'com.android.application'
2+
apply plugin: 'me.tatarka.retrolambda'
3+
4+
android {
5+
compileSdkVersion rootProject.ext.compileSdkVersion
6+
buildToolsVersion rootProject.ext.buildToolsVersion
7+
defaultConfig {
8+
minSdkVersion rootProject.ext.minSdkVersion
9+
targetSdkVersion rootProject.ext.targetSdkVersion
10+
versionCode rootProject.ext.projectVersionCode
11+
versionName rootProject.ext.projectVersionName
12+
}
13+
compileOptions {
14+
sourceCompatibility JavaVersion.VERSION_1_8
15+
targetCompatibility JavaVersion.VERSION_1_8
16+
}
17+
}
18+
19+
dependencies {
20+
compile fileTree(dir: 'libs', include: ['*.jar'])
21+
compile "com.android.support:appcompat-v7:$supportLibraryVersion"
22+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="com.lambdasample">
4+
5+
<application
6+
android:allowBackup="true"
7+
android:icon="@mipmap/ic_launcher"
8+
android:label="@string/app_name"
9+
android:supportsRtl="true"
10+
android:theme="@style/AppTheme">
11+
<activity android:name=".MainActivity">
12+
<intent-filter>
13+
<action android:name="android.intent.action.MAIN" />
14+
15+
<category android:name="android.intent.category.LAUNCHER" />
16+
</intent-filter>
17+
</activity>
18+
</application>
19+
20+
</manifest>
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
package com.lambdasample;
2+
3+
import android.os.Bundle;
4+
import android.support.v7.app.AppCompatActivity;
5+
import android.util.Log;
6+
import android.view.View;
7+
import android.widget.Button;
8+
import android.widget.Toast;
9+
10+
import static com.lambdasample.R.id.btn_test;
11+
12+
public class MainActivity extends AppCompatActivity {
13+
14+
private Button buttonOnClick;
15+
private Button buttonOnLongClick;
16+
private Button buttonTest;
17+
18+
@Override
19+
protected void onCreate(Bundle savedInstanceState) {
20+
super.onCreate(savedInstanceState);
21+
setContentView(R.layout.activity_main);
22+
buttonOnClick = (Button) findViewById(R.id.btn_onClick);
23+
buttonOnLongClick = (Button) findViewById(R.id.btn_long);
24+
buttonTest = (Button) findViewById(btn_test);
25+
26+
27+
buttonOnClick.setOnClickListener(v -> Toast.makeText(v.getContext(), "onClick", Toast.LENGTH_SHORT).show());
28+
// buttonOnClick.setOnClickListener(onClickListener);
29+
30+
buttonOnLongClick.setOnLongClickListener(v -> {
31+
Toast.makeText(v.getContext(), "onLong", Toast.LENGTH_SHORT).show();
32+
return false;
33+
});
34+
// buttonOnLongClick.setOnLongClickListener(onLongClickListener);
35+
36+
37+
/**
38+
* 如果项目支持Lambda 这里会直接给出提示
39+
*/
40+
buttonTest.setOnClickListener(new View.OnClickListener() {
41+
@Override
42+
public void onClick(View v) {
43+
44+
}
45+
});
46+
buttonTest.setOnLongClickListener(new View.OnLongClickListener() {
47+
@Override
48+
public boolean onLongClick(View v) {
49+
return false;
50+
}
51+
});
52+
this.runOnUiThread(() -> Log.i(getClass().getSimpleName(), "runOnUiThread"));
53+
}
54+
55+
View.OnClickListener onClickListener = v -> Toast.makeText(v.getContext(), "onClick", Toast.LENGTH_SHORT).show();
56+
57+
View.OnLongClickListener onLongClickListener = v -> {
58+
Toast.makeText(v.getContext(), "onLong", Toast.LENGTH_SHORT).show();
59+
return false;
60+
};
61+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:tools="http://schemas.android.com/tools"
4+
android:id="@+id/activity_main"
5+
android:layout_width="match_parent"
6+
android:layout_height="match_parent"
7+
android:orientation="vertical"
8+
android:paddingBottom="@dimen/activity_vertical_margin"
9+
android:paddingLeft="@dimen/activity_horizontal_margin"
10+
android:paddingRight="@dimen/activity_horizontal_margin"
11+
android:paddingTop="@dimen/activity_vertical_margin"
12+
tools:context="com.lambdasample.MainActivity">
13+
14+
<Button
15+
android:id="@+id/btn_onClick"
16+
android:layout_width="wrap_content"
17+
android:layout_height="wrap_content"
18+
android:text="onClick" />
19+
20+
<Button
21+
android:id="@+id/btn_long"
22+
android:layout_width="wrap_content"
23+
android:layout_height="wrap_content"
24+
android:text="onLongClick" />
25+
26+
<Button
27+
android:id="@+id/btn_test"
28+
android:layout_width="wrap_content"
29+
android:layout_height="wrap_content"
30+
android:text="test" />
31+
</LinearLayout>
Loading
Loading
Loading
Loading
Loading
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<resources>
2+
<!-- Example customization of dimensions originally defined in res/values/dimens.xml
3+
(such as screen margins) for screens with more than 820dp of available width. This
4+
would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively). -->
5+
<dimen name="activity_horizontal_margin">64dp</dimen>
6+
</resources>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<resources>
3+
<color name="colorPrimary">#3F51B5</color>
4+
<color name="colorPrimaryDark">#303F9F</color>
5+
<color name="colorAccent">#FF4081</color>
6+
</resources>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<resources>
2+
<!-- Default screen margins, per the Android Design guidelines. -->
3+
<dimen name="activity_horizontal_margin">16dp</dimen>
4+
<dimen name="activity_vertical_margin">16dp</dimen>
5+
</resources>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<resources>
2+
<string name="app_name">LambdaSample</string>
3+
</resources>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<resources>
2+
3+
<!-- Base application theme. -->
4+
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
5+
<!-- Customize your theme here. -->
6+
<item name="colorPrimary">@color/colorPrimary</item>
7+
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
8+
<item name="colorAccent">@color/colorAccent</item>
9+
</style>
10+
11+
</resources>

build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ buildscript {
88
classpath 'com.android.tools.build:gradle:2.2.3'
99
classpath 'org.greenrobot:greendao-gradle-plugin:3.2.0' //greenDao3.0
1010
classpath 'com.tencent.tinker:tinker-patch-gradle-plugin:1.7.3' //tinker
11+
classpath 'me.tatarka:gradle-retrolambda:3.5.0' //Lambda
1112
// NOTE: Do not place your application dependencies here; they belong
1213
// in the individual module build.gradle files
1314
}

settings.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
//include ':app', ':Auxiliary', ':Banner', ':BiliRecommendUI', ':library', ':cameraSimple', ':codeKKSimple', ':ExpandableListSimple', ':Fiction', ':FingerDemo', ':FuckApp', ':greenDao', ':greendao_3.0', ':greenDaoExternal', ':JsoupSimple', ':LazyFragment', ':ReadList', ':RefreshLayout', ':SaveImage', ':SuperAdapter', ':TabFragment', ':TinkerDemo', ':ViewPagerFragment', ':wheelview', ':WheelViewSimple'
22
include ':app'
3+
include ':LambdaSample'
34
include ':Auxiliary'
45
include ':Banner'
56
include ':BiliRecommendUI'

0 commit comments

Comments
 (0)