├── .gitignore
├── README.md
├── app
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── cn
│ │ └── feng
│ │ └── constraintlayoutsample
│ │ └── ExampleInstrumentedTest.kt
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── cn
│ │ │ └── feng
│ │ │ └── constraintlayoutsample
│ │ │ ├── activity
│ │ │ ├── CircularRevealHelperActivity.kt
│ │ │ ├── ComposeMultipleHelperActivity.kt
│ │ │ ├── FlyInHelperActivity.kt
│ │ │ ├── LayerActivity.kt
│ │ │ └── MainActivity.kt
│ │ │ ├── adapter
│ │ │ └── BaseRecyclerAdapter.java
│ │ │ ├── helps
│ │ │ ├── CircularRevealHelper.kt
│ │ │ ├── CircularRevealHelper2.kt
│ │ │ ├── ExampleFlyinBounceHelper.kt
│ │ │ ├── FlipRevealHelper.kt
│ │ │ ├── Flyin2Helper.kt
│ │ │ ├── FlyinHelper.kt
│ │ │ └── MetaballsDecorator.kt
│ │ │ └── utils
│ │ │ └── ViewExtensions.kt
│ └── res
│ │ ├── drawable-hdpi
│ │ ├── ic_accessibility_new.png
│ │ ├── ic_accessible.png
│ │ ├── ic_airline_seat_individual_suite.png
│ │ ├── ic_airline_seat_recline_normal.png
│ │ ├── ic_directions_bike.png
│ │ ├── ic_directions_car.png
│ │ ├── ic_directions_run.png
│ │ └── ic_directions_walk.png
│ │ ├── drawable-mdpi
│ │ ├── ic_accessibility_new.png
│ │ ├── ic_accessible.png
│ │ ├── ic_airline_seat_individual_suite.png
│ │ ├── ic_airline_seat_recline_normal.png
│ │ ├── ic_directions_bike.png
│ │ ├── ic_directions_car.png
│ │ ├── ic_directions_run.png
│ │ └── ic_directions_walk.png
│ │ ├── drawable-v24
│ │ └── ic_launcher_foreground.xml
│ │ ├── drawable-xhdpi
│ │ ├── ic_accessibility_new.png
│ │ ├── ic_accessible.png
│ │ ├── ic_airline_seat_individual_suite.png
│ │ ├── ic_airline_seat_recline_normal.png
│ │ ├── ic_directions_bike.png
│ │ ├── ic_directions_car.png
│ │ ├── ic_directions_run.png
│ │ └── ic_directions_walk.png
│ │ ├── drawable-xxhdpi
│ │ ├── ic_accessibility_new.png
│ │ ├── ic_accessible.png
│ │ ├── ic_airline_seat_individual_suite.png
│ │ ├── ic_airline_seat_recline_normal.png
│ │ ├── ic_directions_bike.png
│ │ ├── ic_directions_car.png
│ │ ├── ic_directions_run.png
│ │ └── ic_directions_walk.png
│ │ ├── drawable-xxxhdpi
│ │ ├── ic_accessibility_new.png
│ │ ├── ic_accessible.png
│ │ ├── ic_airline_seat_individual_suite.png
│ │ ├── ic_airline_seat_recline_normal.png
│ │ ├── ic_directions_bike.png
│ │ ├── ic_directions_car.png
│ │ ├── ic_directions_run.png
│ │ └── ic_directions_walk.png
│ │ ├── drawable
│ │ ├── background.jpeg
│ │ ├── batman.jpg
│ │ ├── daxiao.png
│ │ ├── frame.xml
│ │ ├── ic_launcher_background.xml
│ │ └── mario.jpg
│ │ ├── layout
│ │ ├── activity_main.xml
│ │ ├── activity_main1.xml
│ │ ├── activity_main2.xml
│ │ ├── activity_main3.xml
│ │ ├── activity_main4.xml
│ │ ├── activity_main5.xml
│ │ ├── activity_main6.xml
│ │ ├── layout_helper_circular_reveal.xml
│ │ ├── layout_helper_metables_decorator.xml
│ │ ├── layout_hepler_fly_in.xml
│ │ ├── layout_layer.xml
│ │ ├── layout_multiple_helper.xml
│ │ ├── motion_01_basic.xml
│ │ ├── motion_01_cl_end.xml
│ │ ├── motion_01_cl_start.xml
│ │ ├── motion_02.xml
│ │ ├── motion_04_imagefilter.xml
│ │ ├── motion_05_imagefilter.xml
│ │ ├── motion_06.xml
│ │ └── motion_07.xml
│ │ ├── mipmap-anydpi-v26
│ │ ├── ic_launcher.xml
│ │ └── ic_launcher_round.xml
│ │ ├── mipmap-hdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-mdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxxhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── values
│ │ ├── colors.xml
│ │ ├── strings.xml
│ │ └── styles.xml
│ │ └── xml
│ │ ├── scene_01.xml
│ │ ├── scene_02.xml
│ │ ├── scene_04.xml
│ │ ├── scene_05.xml
│ │ ├── scene_06.xml
│ │ └── scene_07.xml
│ └── test
│ └── java
│ └── cn
│ └── feng
│ └── constraintlayoutsample
│ └── ExampleUnitTest.kt
├── build.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/caches
5 | /.idea/libraries
6 | /.idea/modules.xml
7 | /.idea/workspace.xml
8 | /.idea/navEditor.xml
9 | /.idea/assetWizardSettings.xml
10 | .DS_Store
11 | /build
12 | /captures
13 | .externalNativeBuild
14 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | ConstraintLayout 2.0 新特性详解及实战
2 | https://juejin.im/post/5d0c46246fb9a07ec9561573
3 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | apply plugin: 'kotlin-android'
4 |
5 | apply plugin: 'kotlin-android-extensions'
6 |
7 | android {
8 | compileSdkVersion 28
9 | defaultConfig {
10 | applicationId "cn.feng.constraintlayoutsample"
11 | minSdkVersion 19
12 | targetSdkVersion 28
13 | versionCode 1
14 | versionName "1.0"
15 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
16 | }
17 | buildTypes {
18 | release {
19 | minifyEnabled false
20 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
21 | }
22 | }
23 | }
24 |
25 | dependencies {
26 | implementation fileTree(dir: 'libs', include: ['*.jar'])
27 | implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
28 | implementation 'com.android.support:appcompat-v7:28.0.0'
29 | implementation 'com.android.support.constraint:constraint-layout:1.1.3'
30 | testImplementation 'junit:junit:4.12'
31 | androidTestImplementation 'com.android.support.test:runner:1.0.2'
32 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
33 |
34 |
35 | implementation 'com.android.support.constraint:constraint-layout:2.0.0-beta1'
36 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
37 | implementation 'com.android.support:design:28.0.0'
38 | }
39 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/cn/feng/constraintlayoutsample/ExampleInstrumentedTest.kt:
--------------------------------------------------------------------------------
1 | package cn.feng.constraintlayoutsample
2 |
3 | import android.support.test.InstrumentationRegistry
4 | import android.support.test.runner.AndroidJUnit4
5 |
6 | import org.junit.Test
7 | import org.junit.runner.RunWith
8 |
9 | import org.junit.Assert.*
10 |
11 | /**
12 | * Instrumented test, which will execute on an Android device.
13 | *
14 | * See [testing documentation](http://d.android.com/tools/testing).
15 | */
16 | @RunWith(AndroidJUnit4::class)
17 | class ExampleInstrumentedTest {
18 | @Test
19 | fun useAppContext() {
20 | // Context of the app under test.
21 | val appContext = InstrumentationRegistry.getTargetContext()
22 | assertEquals("cn.feng.constraintlayoutsample", appContext.packageName)
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/feng/constraintlayoutsample/activity/CircularRevealHelperActivity.kt:
--------------------------------------------------------------------------------
1 | package cn.feng.constraintLayout2.activity
2 |
3 | import android.os.Bundle
4 | import android.support.v7.app.AppCompatActivity
5 | import cn.feng.constraintlayoutsample.R
6 |
7 | class CircularRevealHelperActivity : AppCompatActivity() {
8 |
9 | override fun onCreate(savedInstanceState: Bundle?) {
10 | super.onCreate(savedInstanceState)
11 | setContentView(R.layout.layout_helper_circular_reveal)
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/feng/constraintlayoutsample/activity/ComposeMultipleHelperActivity.kt:
--------------------------------------------------------------------------------
1 | package cn.feng.constraintLayout2.activity
2 |
3 | import android.os.Bundle
4 | import android.support.v7.app.AppCompatActivity
5 | import cn.feng.constraintlayoutsample.R
6 |
7 | class ComposeMultipleHelperActivity : AppCompatActivity() {
8 |
9 | override fun onCreate(savedInstanceState: Bundle?) {
10 | super.onCreate(savedInstanceState)
11 | setContentView(R.layout.layout_multiple_helper)
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/feng/constraintlayoutsample/activity/FlyInHelperActivity.kt:
--------------------------------------------------------------------------------
1 | package cn.feng.constraintLayout2.activity
2 |
3 | import android.os.Bundle
4 | import android.support.v7.app.AppCompatActivity
5 | import cn.feng.constraintlayoutsample.R
6 |
7 | class FlyInHelperActivity : AppCompatActivity() {
8 |
9 | override fun onCreate(savedInstanceState: Bundle?) {
10 | super.onCreate(savedInstanceState)
11 | setContentView(R.layout.layout_hepler_fly_in)
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/feng/constraintlayoutsample/activity/LayerActivity.kt:
--------------------------------------------------------------------------------
1 | package cn.feng.constraintLayout2.activity
2 |
3 | import android.animation.ValueAnimator
4 | import android.os.Bundle
5 | import android.support.v7.app.AppCompatActivity
6 | import cn.feng.constraintlayoutsample.R
7 | import kotlinx.android.synthetic.main.layout_layer.*
8 |
9 | class LayerActivity : AppCompatActivity() {
10 |
11 | override fun onCreate(savedInstanceState: Bundle?) {
12 | super.onCreate(savedInstanceState)
13 | setContentView(R.layout.layout_layer)
14 |
15 | button8.setOnClickListener {
16 |
17 | val anim = ValueAnimator.ofFloat(0f, 360f)
18 | anim.duration = 300
19 | anim.addUpdateListener { animation ->
20 | val angle = animation.animatedValue as Float
21 | layer.rotation = angle
22 | layer.scaleX = 1 + (180 - Math.abs(angle - 180)) / 20f
23 | layer.scaleY = 1 + (180 - Math.abs(angle - 180)) / 20f
24 |
25 |
26 | var shift_x = 500 * Math.sin(Math.toRadians((angle * 5).toDouble())).toFloat()
27 | var shift_y = 500 * Math.sin(Math.toRadians((angle * 7).toDouble())).toFloat()
28 | layer.translationX = shift_x
29 | layer.translationY = shift_y
30 | }
31 | anim.duration = 4000
32 | anim.start()
33 | }
34 |
35 |
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/feng/constraintlayoutsample/activity/MainActivity.kt:
--------------------------------------------------------------------------------
1 | package cn.feng.constraintLayout2.activity
2 |
3 | import android.content.Intent
4 | import android.os.Bundle
5 | import android.support.constraint.ConstraintProperties
6 | import android.support.constraint.ConstraintSet
7 | import android.support.v7.app.AppCompatActivity
8 | import android.support.v7.widget.DividerItemDecoration
9 | import cn.feng.constraintlayoutsample.R
10 | import cn.feng.constraintlayoutsample.adapter.BaseRecyclerAdapter
11 | import kotlinx.android.synthetic.main.activity_main.*
12 |
13 | class MainActivity : AppCompatActivity() {
14 | private val mData = arrayOf("LayerActivity", "CircularRevealHelper", "FlyInHelper", "ComposeMultipleHelper")
15 |
16 |
17 | override fun onCreate(savedInstanceState: Bundle?) {
18 | super.onCreate(savedInstanceState)
19 | setContentView(R.layout.activity_main)
20 |
21 |
22 | rv.addItemDecoration(DividerItemDecoration(this, DividerItemDecoration.VERTICAL))
23 | rv.adapter = object : BaseRecyclerAdapter(mData.toList()) {
24 | override fun getItemLayoutId(viewType: Int): Int {
25 | return android.R.layout.simple_list_item_1
26 | }
27 |
28 | override fun convert(viewHolder: BaseVH, viewType: Int, data: String, position: Int) {
29 | viewHolder.setText(android.R.id.text1, data)
30 | viewHolder.itemView.setOnClickListener {
31 | when (position) {
32 | 0 -> startActivity(Intent(this@MainActivity, LayerActivity::class.java))
33 | 1 -> startActivity(Intent(this@MainActivity, CircularRevealHelperActivity::class.java))
34 | 2 -> startActivity(Intent(this@MainActivity, FlyInHelperActivity::class.java))
35 | 3 -> startActivity(Intent(this@MainActivity, ComposeMultipleHelperActivity::class.java))
36 | }
37 | }
38 | }
39 |
40 | }
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/feng/constraintlayoutsample/adapter/BaseRecyclerAdapter.java:
--------------------------------------------------------------------------------
1 | package cn.feng.constraintlayoutsample.adapter;
2 |
3 | import android.support.annotation.DrawableRes;
4 | import android.support.annotation.IdRes;
5 | import android.support.annotation.LayoutRes;
6 | import android.support.annotation.NonNull;
7 | import android.support.annotation.StringRes;
8 | import android.support.v7.widget.RecyclerView;
9 | import android.util.SparseArray;
10 | import android.view.LayoutInflater;
11 | import android.view.View;
12 | import android.view.ViewGroup;
13 | import android.widget.ImageView;
14 | import android.widget.TextView;
15 |
16 | import java.util.List;
17 |
18 | public abstract class BaseRecyclerAdapter extends RecyclerView.Adapter {
19 | List mDataList;
20 |
21 | public BaseRecyclerAdapter(List dataList) {
22 | mDataList = dataList;
23 | }
24 |
25 | public BaseRecyclerAdapter() {
26 | }
27 |
28 | @NonNull
29 | @Override
30 | public BaseVH onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
31 | return BaseVH.get(parent, getItemLayoutId(viewType));
32 | }
33 |
34 | @Override
35 | public void onBindViewHolder(@NonNull BaseVH holder, int position) {
36 | convert(holder, getItemViewType(position), mDataList.get(position), position);
37 | }
38 |
39 |
40 | public abstract @LayoutRes
41 | int getItemLayoutId(int viewType);
42 |
43 | public abstract void convert(BaseVH viewHolder, int viewType, T data, int position);
44 |
45 | @Override
46 | public int getItemCount() {
47 | if (mDataList == null) {
48 | return 0;
49 | }
50 | return mDataList.size();
51 | }
52 |
53 |
54 | public void setData(List dataList) {
55 | mDataList = dataList;
56 | notifyDataSetChanged();
57 | }
58 |
59 |
60 | public static class BaseVH extends RecyclerView.ViewHolder {
61 | private final View mItemView;
62 | private SparseArray mViews;
63 |
64 | public BaseVH(View itemView) {
65 | super(itemView);
66 | mItemView = itemView;
67 | mViews = new SparseArray<>();
68 | }
69 |
70 | public static BaseVH get(ViewGroup parent, @LayoutRes int itemLayoutId) {
71 | return new BaseVH(LayoutInflater.from(parent.getContext()).inflate(itemLayoutId, parent, false));
72 | }
73 |
74 |
75 | public T getView(@IdRes int viewId) {
76 | View view = mViews.get(viewId);
77 | if (view == null) {
78 | view = mItemView.findViewById(viewId);
79 | mViews.put(viewId, view);
80 | }
81 | return (T) view;
82 | }
83 |
84 |
85 | public void setText(@IdRes int viewId, String text) {
86 | TextView view = getView(viewId);
87 | view.setText(text);
88 | }
89 |
90 | public void setText(@IdRes int viewId, @StringRes int textRes) {
91 | setText(viewId, itemView.getContext().getString(textRes));
92 | }
93 |
94 |
95 | public void setImage(@IdRes int viewId, @DrawableRes int imgRes){
96 | ImageView view = getView(viewId);
97 | view.setImageResource(imgRes);
98 | }
99 |
100 | public View getItemView() {
101 | return mItemView;
102 | }
103 |
104 | @Override
105 | public String toString() {
106 | return itemView.toString();
107 | }
108 | }
109 |
110 |
111 | public void remove(int position) {
112 | mDataList.remove(position);
113 | notifyItemRemoved(position);
114 | }
115 |
116 | public void add(T t, int position) {
117 | mDataList.add(position, t);
118 | notifyItemInserted(position);
119 | }
120 | }
121 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/feng/constraintlayoutsample/helps/CircularRevealHelper.kt:
--------------------------------------------------------------------------------
1 | package cn.feng.constraintLayout2.helps
2 |
3 | import android.content.Context
4 | import android.os.Build
5 | import android.support.constraint.ConstraintHelper
6 | import android.support.constraint.ConstraintLayout
7 | import android.util.AttributeSet
8 | import android.view.ViewAnimationUtils
9 |
10 | class CircularRevealHelper @JvmOverloads constructor(
11 | context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0
12 | ) : ConstraintHelper(context, attrs, defStyleAttr) {
13 |
14 | override fun updatePostLayout(container: ConstraintLayout) {
15 | super.updatePostLayout(container)
16 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
17 | val views = getViews(container)
18 | for (view in views) {
19 | val anim = ViewAnimationUtils.createCircularReveal(view, view.width / 2,
20 | view.height / 2, 0f,
21 | Math.hypot((view.height / 2).toDouble(), (view.width / 2).toDouble()).toFloat())
22 | anim.duration = 3000
23 | anim.start()
24 | }
25 | }
26 | }
27 | }
--------------------------------------------------------------------------------
/app/src/main/java/cn/feng/constraintlayoutsample/helps/CircularRevealHelper2.kt:
--------------------------------------------------------------------------------
1 | package cn.feng.constraintLayout2.helps
2 |
3 | import android.content.Context
4 | import android.os.Build
5 | import android.support.constraint.ConstraintLayout
6 | import android.support.constraint.helper.Layer
7 | import android.util.AttributeSet
8 | import android.view.ViewAnimationUtils
9 |
10 | class CircularRevealHelper2 @JvmOverloads constructor(
11 | context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0
12 | ) : Layer(context, attrs, defStyleAttr) {
13 |
14 | // override fun updatePostLayout(container: ConstraintLayout) {
15 | // super.updatePostLayout(container)
16 | // if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
17 | // var centerPoint = calculateCenterPoint(container)
18 | // val anim = ViewAnimationUtils.createCircularReveal(this, centerPoint.x.toInt(),
19 | // centerPoint.y.toInt(), 0f,
20 | // Math.hypot(centerPoint.x.toDouble(), centerPoint.y.toDouble()).toFloat())
21 | // anim.duration = 3000
22 | // anim.start()
23 | // }
24 | // }
25 |
26 |
27 | override fun updatePostLayout(container: ConstraintLayout) {
28 | super.updatePostLayout(container)
29 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
30 | val anim = ViewAnimationUtils.createCircularReveal(this, (left + right) / 2,
31 | (top + bottom) / 2, 0f,
32 | Math.hypot(((left + right) / 2 - left).toDouble(), ((top + bottom) / 2 - top).toDouble()).toFloat())
33 | anim.duration = 3000
34 | anim.start()
35 | }
36 | }
37 |
38 |
39 | // private fun calculateCenterPoint(container: ConstraintLayout?): PointF {
40 | // var leftMin: Float = Float.MAX_VALUE
41 | // var topMin = Float.MAX_VALUE
42 | // var rightMax = Float.MIN_VALUE
43 | // var bottomMax = Float.MIN_VALUE
44 | //
45 | //
46 | // val views = getViews(container)
47 | // for (view in views) {
48 | // leftMin = if (view.left < leftMin) view.left.toFloat() else leftMin
49 | // topMin = if (view.top < topMin) view.top.toFloat() else topMin
50 | // rightMax = if (view.right > rightMax) view.right.toFloat() else rightMax
51 | // bottomMax = if (view.bottom > bottomMax) view.bottom.toFloat() else bottomMax
52 | // }
53 | // Log.d("FlyinHelper2", "leftMin:$leftMin topMin:$topMin rightMax:$rightMax bottomMax:$bottomMax")
54 | //
55 | // return PointF((rightMax + leftMin) / 2, (bottomMax + topMin) / 2)
56 | // }
57 |
58 | }
--------------------------------------------------------------------------------
/app/src/main/java/cn/feng/constraintlayoutsample/helps/ExampleFlyinBounceHelper.kt:
--------------------------------------------------------------------------------
1 | package cn.feng.constraintLayout2.helps
2 |
3 | import android.animation.ObjectAnimator
4 | import android.content.Context
5 | import android.support.constraint.ConstraintHelper
6 | import android.support.constraint.ConstraintLayout
7 | import android.util.AttributeSet
8 |
9 | class ExampleFlyinBounceHelper @JvmOverloads constructor(
10 | context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0
11 | ) : ConstraintHelper(context, attrs, defStyleAttr) {
12 | private var mContainer: ConstraintLayout? = null
13 |
14 | override fun updatePreLayout(container: ConstraintLayout) {
15 | if (mContainer !== container) {
16 | val views = getViews(container)
17 | for (view in views) {
18 | val animator = ObjectAnimator.ofFloat(view, "translationX", -2000f, 0f).setDuration(1000)
19 | animator.start()
20 | }
21 | }
22 | mContainer = container
23 | }
24 |
25 | }
--------------------------------------------------------------------------------
/app/src/main/java/cn/feng/constraintlayoutsample/helps/FlipRevealHelper.kt:
--------------------------------------------------------------------------------
1 | package cn.feng.constraintLayout2.helps
2 |
3 | import android.animation.ObjectAnimator
4 | import android.content.Context
5 | import android.support.constraint.ConstraintHelper
6 | import android.support.constraint.ConstraintLayout
7 | import android.util.AttributeSet
8 |
9 |
10 | class FlipRevealHelper @JvmOverloads constructor(
11 | context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0
12 | ) : ConstraintHelper(context, attrs, defStyleAttr) {
13 |
14 |
15 | override fun updatePostLayout(container: ConstraintLayout?) {
16 | super.updatePostLayout(container)
17 | val views = getViews(container)
18 | for (view in views) {
19 | val animator = ObjectAnimator.ofFloat(view, "rotationY", 90f, 0f).setDuration(3000)
20 | animator.start()
21 | }
22 | }
23 | }
--------------------------------------------------------------------------------
/app/src/main/java/cn/feng/constraintlayoutsample/helps/Flyin2Helper.kt:
--------------------------------------------------------------------------------
1 | package cn.feng.constraintLayout2.helps
2 |
3 | import android.animation.ValueAnimator
4 | import android.content.Context
5 | import android.graphics.PointF
6 | import android.support.constraint.ConstraintLayout
7 | import android.support.constraint.helper.Layer
8 | import android.util.AttributeSet
9 | import android.util.Log
10 |
11 | class Flyin2Helper @JvmOverloads constructor(
12 | context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0
13 | ) : Layer(context, attrs, defStyleAttr) {
14 |
15 |
16 | override fun updatePostLayout(container: ConstraintLayout) {
17 | Log.d("FlyinHelper", "updatePostLayout")
18 | super.updatePostLayout(container)
19 | val centerPoint = PointF(((left + right) / 2).toFloat(), ((top + bottom) / 2).toFloat())
20 |
21 |
22 | val animator = ValueAnimator.ofFloat(0f, 1f).setDuration(1000)
23 | animator.addUpdateListener { animation ->
24 | val animatedFraction = animation.animatedFraction
25 | updateTranslation(centerPoint, animatedFraction, container)
26 | }
27 | animator.start()
28 | }
29 |
30 | private fun updateTranslation(centerPoint: PointF, animatedFraction: Float, container: ConstraintLayout) {
31 |
32 | val views = getViews(container)
33 | for (view in views) {
34 |
35 | val viewCenterX = (view.left + view.right) / 2
36 | val viewCenterY = (view.top + view.bottom) / 2
37 |
38 |
39 | val startTranslationX = if (viewCenterX < centerPoint.x) -2000f else 2000f
40 | val startTranslationY = if (viewCenterY < centerPoint.y) -2000f else 2000f
41 |
42 |
43 | view.translationX = (1 - animatedFraction) * startTranslationX
44 | view.translationY = (1 - animatedFraction) * startTranslationY
45 | }
46 | }
47 | }
--------------------------------------------------------------------------------
/app/src/main/java/cn/feng/constraintlayoutsample/helps/FlyinHelper.kt:
--------------------------------------------------------------------------------
1 | package cn.feng.constraintLayout2.helps
2 |
3 | import android.animation.ValueAnimator
4 | import android.content.Context
5 | import android.graphics.PointF
6 | import android.support.constraint.ConstraintHelper
7 | import android.support.constraint.ConstraintLayout
8 | import android.util.AttributeSet
9 | import android.util.Log
10 |
11 | class FlyinHelper @JvmOverloads constructor(
12 | context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0
13 | ) : ConstraintHelper(context, attrs, defStyleAttr) {
14 |
15 | override fun updatePreLayout(container: ConstraintLayout?) {
16 | super.updatePreLayout(container)
17 | Log.d("FlyinHelper", "updatePreLayout")
18 |
19 | }
20 |
21 | override fun updatePostLayout(container: ConstraintLayout) {
22 | Log.d("FlyinHelper", "updatePostLayout")
23 | super.updatePostLayout(container)
24 | val centerPoint = calculateCenterPoint(container)
25 | val animator = ValueAnimator.ofFloat(0f, 1f).setDuration(1000)
26 | animator.addUpdateListener { animation ->
27 | val animatedFraction = animation.animatedFraction
28 | updateTranslation(centerPoint, animatedFraction, container)
29 | }
30 | animator.start()
31 | }
32 |
33 | private fun updateTranslation(centerPoint: PointF, animatedFraction: Float, container: ConstraintLayout) {
34 |
35 | val views = getViews(container)
36 | for (view in views) {
37 |
38 | val viewCenterX = (view.left + view.right) / 2
39 | val viewCenterY = (view.top + view.bottom) / 2
40 |
41 |
42 | val startTranslationX = if (viewCenterX < centerPoint.x) -2000f else 2000f
43 | val startTranslationY = if (viewCenterY < centerPoint.y) -2000f else 2000f
44 |
45 |
46 | view.translationX = (1 - animatedFraction) * startTranslationX
47 | view.translationY = (1 - animatedFraction) * startTranslationY
48 | }
49 | }
50 |
51 | private fun calculateCenterPoint(container: ConstraintLayout?): PointF {
52 | var leftMin: Float = Float.MAX_VALUE
53 | var topMin = Float.MAX_VALUE
54 | var rightMax = Float.MIN_VALUE
55 | var bottomMax = Float.MIN_VALUE
56 |
57 |
58 | val views = getViews(container)
59 | for (view in views) {
60 | leftMin = if (view.left < leftMin) view.left.toFloat() else leftMin
61 | topMin = if (view.top < topMin) view.top.toFloat() else topMin
62 | rightMax = if (view.right > rightMax) view.right.toFloat() else rightMax
63 | bottomMax = if (view.bottom > bottomMax) view.bottom.toFloat() else bottomMax
64 | }
65 | Log.d("FlyinHelper", "leftMin:$leftMin topMin:$topMin rightMax:$rightMax bottomMax:$bottomMax")
66 |
67 | return PointF((rightMax + leftMin) / 2, (bottomMax + topMin) / 2)
68 | }
69 |
70 |
71 | }
--------------------------------------------------------------------------------
/app/src/main/java/cn/feng/constraintlayoutsample/helps/MetaballsDecorator.kt:
--------------------------------------------------------------------------------
1 | package cn.feng.constraintLayout2.helps
2 |
3 | import android.animation.ValueAnimator
4 | import android.content.Context
5 | import android.graphics.Canvas
6 | import android.graphics.Color
7 | import android.graphics.Paint
8 | import android.support.constraint.ConstraintHelper
9 | import android.support.constraint.ConstraintLayout
10 | import android.util.AttributeSet
11 | import android.view.View
12 | import cn.feng.constraintLayout2.utils.dp2Px
13 | import cn.feng.constraintlayoutsample.R
14 |
15 | class MetaballsDecorator @JvmOverloads constructor(
16 | context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0
17 | ) : ConstraintHelper(context, attrs, defStyleAttr) {
18 | private lateinit var mContainer: ConstraintLayout
19 | private var mPaint: Paint = Paint(Paint.ANTI_ALIAS_FLAG)
20 |
21 | private var mPaint2: Paint = Paint(Paint.ANTI_ALIAS_FLAG)
22 |
23 | init {
24 | mPaint.color = Color.RED
25 | mPaint.style = Paint.Style.FILL_AND_STROKE
26 |
27 |
28 | mPaint2.color = Color.BLUE
29 | mPaint2.style = Paint.Style.FILL_AND_STROKE
30 | mPaint2.strokeWidth = 10f
31 |
32 | }
33 |
34 |
35 | override fun updatePostLayout(container: ConstraintLayout) {
36 | mContainer = container
37 | }
38 |
39 |
40 | fun startAnim() {
41 | val animator = ValueAnimator.ofFloat(0f, 1f).setDuration(5000)
42 | animator.addUpdateListener { animation ->
43 | val animatedFraction = animation.animatedFraction
44 | update(animatedFraction)
45 | }
46 | animator.start()
47 | }
48 |
49 | private fun update(fraction: Float) {
50 | val views = getViews(mContainer)
51 | var centerView = mContainer.findViewById(R.id.img_directions_bike)
52 | for (referencedView in views) {
53 | if (referencedView.tag == "centerView") {
54 | continue
55 | }
56 | var translationXDistance = (centerView.left + centerView.width / 2) - (referencedView.left + referencedView.width / 2)
57 | var translationYDistance = (centerView.top + centerView.height / 2) - (referencedView.top + referencedView.height / 2)
58 |
59 | referencedView.translationX = translationXDistance * fraction
60 | referencedView.translationY = translationYDistance * fraction
61 |
62 | referencedView.scaleX = 1 - fraction
63 | referencedView.scaleY = 1 - fraction
64 |
65 | invalidate()
66 | }
67 | }
68 |
69 |
70 | override fun onDraw(canvas: Canvas) {
71 |
72 | super.onDraw(canvas)
73 | val views = getViews(mContainer)
74 | for (referencedView in views) {
75 | canvas.drawCircle(((referencedView.left + referencedView.right) / 2 + referencedView.translationX),
76 | ((referencedView.top + referencedView.bottom) / 2 + referencedView.translationY),
77 | Math.hypot((referencedView.width * referencedView.scaleX / 2).toDouble(), (referencedView.height * referencedView.scaleY / 2).toDouble()).toFloat()+dp2Px(10f),
78 | mPaint)
79 | }
80 | }
81 |
82 |
83 | }
--------------------------------------------------------------------------------
/app/src/main/java/cn/feng/constraintlayoutsample/utils/ViewExtensions.kt:
--------------------------------------------------------------------------------
1 | package cn.feng.constraintLayout2.utils
2 |
3 | import android.content.res.Resources
4 | import android.text.Spannable
5 | import android.text.Spanned.SPAN_INCLUSIVE_EXCLUSIVE
6 | import android.util.Log
7 | import android.util.TypedValue
8 | import android.view.View
9 |
10 |
11 | inline fun View.onLayoutChange(crossinline action: () -> Unit) {
12 | addOnLayoutChangeListener(object : View.OnLayoutChangeListener {
13 | override fun onLayoutChange(v: View?, left: Int, top: Int, right: Int, bottom: Int, oldLeft: Int, oldTop: Int, oldRight: Int, oldBottom: Int) {
14 | removeOnLayoutChangeListener(this)
15 | action()
16 | }
17 |
18 | })
19 | }
20 |
21 | inline fun T.logi(message: String) = Log.i(T::class.java.simpleName, message)
22 |
23 |
24 | inline operator fun Spannable.plusAssign(span: Any) =
25 | setSpan(span, 0, length, SPAN_INCLUSIVE_EXCLUSIVE)
26 |
27 |
28 | inline fun T.dp2Px(dp: Float): Float {
29 | return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, Resources.getSystem().displayMetrics)
30 |
31 | }
32 |
33 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_accessibility_new.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/feng0403/ConstraintLayoutSamples/1c7a972ed0a85a2e2cfc7825729af20c775b6bbe/app/src/main/res/drawable-hdpi/ic_accessibility_new.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_accessible.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/feng0403/ConstraintLayoutSamples/1c7a972ed0a85a2e2cfc7825729af20c775b6bbe/app/src/main/res/drawable-hdpi/ic_accessible.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_airline_seat_individual_suite.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/feng0403/ConstraintLayoutSamples/1c7a972ed0a85a2e2cfc7825729af20c775b6bbe/app/src/main/res/drawable-hdpi/ic_airline_seat_individual_suite.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_airline_seat_recline_normal.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/feng0403/ConstraintLayoutSamples/1c7a972ed0a85a2e2cfc7825729af20c775b6bbe/app/src/main/res/drawable-hdpi/ic_airline_seat_recline_normal.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_directions_bike.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/feng0403/ConstraintLayoutSamples/1c7a972ed0a85a2e2cfc7825729af20c775b6bbe/app/src/main/res/drawable-hdpi/ic_directions_bike.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_directions_car.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/feng0403/ConstraintLayoutSamples/1c7a972ed0a85a2e2cfc7825729af20c775b6bbe/app/src/main/res/drawable-hdpi/ic_directions_car.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_directions_run.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/feng0403/ConstraintLayoutSamples/1c7a972ed0a85a2e2cfc7825729af20c775b6bbe/app/src/main/res/drawable-hdpi/ic_directions_run.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_directions_walk.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/feng0403/ConstraintLayoutSamples/1c7a972ed0a85a2e2cfc7825729af20c775b6bbe/app/src/main/res/drawable-hdpi/ic_directions_walk.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-mdpi/ic_accessibility_new.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/feng0403/ConstraintLayoutSamples/1c7a972ed0a85a2e2cfc7825729af20c775b6bbe/app/src/main/res/drawable-mdpi/ic_accessibility_new.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-mdpi/ic_accessible.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/feng0403/ConstraintLayoutSamples/1c7a972ed0a85a2e2cfc7825729af20c775b6bbe/app/src/main/res/drawable-mdpi/ic_accessible.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-mdpi/ic_airline_seat_individual_suite.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/feng0403/ConstraintLayoutSamples/1c7a972ed0a85a2e2cfc7825729af20c775b6bbe/app/src/main/res/drawable-mdpi/ic_airline_seat_individual_suite.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-mdpi/ic_airline_seat_recline_normal.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/feng0403/ConstraintLayoutSamples/1c7a972ed0a85a2e2cfc7825729af20c775b6bbe/app/src/main/res/drawable-mdpi/ic_airline_seat_recline_normal.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-mdpi/ic_directions_bike.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/feng0403/ConstraintLayoutSamples/1c7a972ed0a85a2e2cfc7825729af20c775b6bbe/app/src/main/res/drawable-mdpi/ic_directions_bike.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-mdpi/ic_directions_car.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/feng0403/ConstraintLayoutSamples/1c7a972ed0a85a2e2cfc7825729af20c775b6bbe/app/src/main/res/drawable-mdpi/ic_directions_car.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-mdpi/ic_directions_run.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/feng0403/ConstraintLayoutSamples/1c7a972ed0a85a2e2cfc7825729af20c775b6bbe/app/src/main/res/drawable-mdpi/ic_directions_run.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-mdpi/ic_directions_walk.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/feng0403/ConstraintLayoutSamples/1c7a972ed0a85a2e2cfc7825729af20c775b6bbe/app/src/main/res/drawable-mdpi/ic_directions_walk.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v24/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
12 |
13 |
19 |
22 |
25 |
26 |
27 |
28 |
34 |
35 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_accessibility_new.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/feng0403/ConstraintLayoutSamples/1c7a972ed0a85a2e2cfc7825729af20c775b6bbe/app/src/main/res/drawable-xhdpi/ic_accessibility_new.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_accessible.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/feng0403/ConstraintLayoutSamples/1c7a972ed0a85a2e2cfc7825729af20c775b6bbe/app/src/main/res/drawable-xhdpi/ic_accessible.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_airline_seat_individual_suite.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/feng0403/ConstraintLayoutSamples/1c7a972ed0a85a2e2cfc7825729af20c775b6bbe/app/src/main/res/drawable-xhdpi/ic_airline_seat_individual_suite.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_airline_seat_recline_normal.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/feng0403/ConstraintLayoutSamples/1c7a972ed0a85a2e2cfc7825729af20c775b6bbe/app/src/main/res/drawable-xhdpi/ic_airline_seat_recline_normal.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_directions_bike.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/feng0403/ConstraintLayoutSamples/1c7a972ed0a85a2e2cfc7825729af20c775b6bbe/app/src/main/res/drawable-xhdpi/ic_directions_bike.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_directions_car.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/feng0403/ConstraintLayoutSamples/1c7a972ed0a85a2e2cfc7825729af20c775b6bbe/app/src/main/res/drawable-xhdpi/ic_directions_car.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_directions_run.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/feng0403/ConstraintLayoutSamples/1c7a972ed0a85a2e2cfc7825729af20c775b6bbe/app/src/main/res/drawable-xhdpi/ic_directions_run.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_directions_walk.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/feng0403/ConstraintLayoutSamples/1c7a972ed0a85a2e2cfc7825729af20c775b6bbe/app/src/main/res/drawable-xhdpi/ic_directions_walk.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/ic_accessibility_new.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/feng0403/ConstraintLayoutSamples/1c7a972ed0a85a2e2cfc7825729af20c775b6bbe/app/src/main/res/drawable-xxhdpi/ic_accessibility_new.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/ic_accessible.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/feng0403/ConstraintLayoutSamples/1c7a972ed0a85a2e2cfc7825729af20c775b6bbe/app/src/main/res/drawable-xxhdpi/ic_accessible.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/ic_airline_seat_individual_suite.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/feng0403/ConstraintLayoutSamples/1c7a972ed0a85a2e2cfc7825729af20c775b6bbe/app/src/main/res/drawable-xxhdpi/ic_airline_seat_individual_suite.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/ic_airline_seat_recline_normal.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/feng0403/ConstraintLayoutSamples/1c7a972ed0a85a2e2cfc7825729af20c775b6bbe/app/src/main/res/drawable-xxhdpi/ic_airline_seat_recline_normal.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/ic_directions_bike.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/feng0403/ConstraintLayoutSamples/1c7a972ed0a85a2e2cfc7825729af20c775b6bbe/app/src/main/res/drawable-xxhdpi/ic_directions_bike.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/ic_directions_car.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/feng0403/ConstraintLayoutSamples/1c7a972ed0a85a2e2cfc7825729af20c775b6bbe/app/src/main/res/drawable-xxhdpi/ic_directions_car.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/ic_directions_run.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/feng0403/ConstraintLayoutSamples/1c7a972ed0a85a2e2cfc7825729af20c775b6bbe/app/src/main/res/drawable-xxhdpi/ic_directions_run.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/ic_directions_walk.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/feng0403/ConstraintLayoutSamples/1c7a972ed0a85a2e2cfc7825729af20c775b6bbe/app/src/main/res/drawable-xxhdpi/ic_directions_walk.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxxhdpi/ic_accessibility_new.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/feng0403/ConstraintLayoutSamples/1c7a972ed0a85a2e2cfc7825729af20c775b6bbe/app/src/main/res/drawable-xxxhdpi/ic_accessibility_new.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxxhdpi/ic_accessible.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/feng0403/ConstraintLayoutSamples/1c7a972ed0a85a2e2cfc7825729af20c775b6bbe/app/src/main/res/drawable-xxxhdpi/ic_accessible.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxxhdpi/ic_airline_seat_individual_suite.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/feng0403/ConstraintLayoutSamples/1c7a972ed0a85a2e2cfc7825729af20c775b6bbe/app/src/main/res/drawable-xxxhdpi/ic_airline_seat_individual_suite.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxxhdpi/ic_airline_seat_recline_normal.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/feng0403/ConstraintLayoutSamples/1c7a972ed0a85a2e2cfc7825729af20c775b6bbe/app/src/main/res/drawable-xxxhdpi/ic_airline_seat_recline_normal.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxxhdpi/ic_directions_bike.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/feng0403/ConstraintLayoutSamples/1c7a972ed0a85a2e2cfc7825729af20c775b6bbe/app/src/main/res/drawable-xxxhdpi/ic_directions_bike.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxxhdpi/ic_directions_car.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/feng0403/ConstraintLayoutSamples/1c7a972ed0a85a2e2cfc7825729af20c775b6bbe/app/src/main/res/drawable-xxxhdpi/ic_directions_car.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxxhdpi/ic_directions_run.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/feng0403/ConstraintLayoutSamples/1c7a972ed0a85a2e2cfc7825729af20c775b6bbe/app/src/main/res/drawable-xxxhdpi/ic_directions_run.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxxhdpi/ic_directions_walk.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/feng0403/ConstraintLayoutSamples/1c7a972ed0a85a2e2cfc7825729af20c775b6bbe/app/src/main/res/drawable-xxxhdpi/ic_directions_walk.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/background.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/feng0403/ConstraintLayoutSamples/1c7a972ed0a85a2e2cfc7825729af20c775b6bbe/app/src/main/res/drawable/background.jpeg
--------------------------------------------------------------------------------
/app/src/main/res/drawable/batman.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/feng0403/ConstraintLayoutSamples/1c7a972ed0a85a2e2cfc7825729af20c775b6bbe/app/src/main/res/drawable/batman.jpg
--------------------------------------------------------------------------------
/app/src/main/res/drawable/daxiao.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/feng0403/ConstraintLayoutSamples/1c7a972ed0a85a2e2cfc7825729af20c775b6bbe/app/src/main/res/drawable/daxiao.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/frame.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_launcher_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
10 |
15 |
20 |
25 |
30 |
35 |
40 |
45 |
50 |
55 |
60 |
65 |
70 |
75 |
80 |
85 |
90 |
95 |
100 |
105 |
110 |
115 |
120 |
125 |
130 |
135 |
140 |
145 |
150 |
155 |
160 |
165 |
170 |
171 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/mario.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/feng0403/ConstraintLayoutSamples/1c7a972ed0a85a2e2cfc7825729af20c775b6bbe/app/src/main/res/drawable/mario.jpg
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
9 |
18 |
19 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main1.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
22 |
23 |
34 |
35 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main2.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
9 |
21 |
22 |
32 |
33 |
44 |
45 |
55 |
56 |
65 |
66 |
75 |
76 |
82 |
83 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main3.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
11 |
22 |
23 |
33 |
34 |
44 |
45 |
55 |
56 |
63 |
64 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main4.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
10 |
20 |
21 |
28 |
29 |
36 |
37 |
43 |
44 |
50 |
51 |
61 |
62 |
74 |
75 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main5.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
10 |
24 |
25 |
29 |
30 |
34 |
35 |
39 |
40 |
41 |
45 |
46 |
50 |
51 |
55 |
56 |
57 |
61 |
62 |
66 |
67 |
71 |
72 |
76 |
77 |
83 |
84 |
88 |
89 |
95 |
96 |
110 |
111 |
125 |
126 |
127 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main6.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
9 |
23 |
24 |
28 |
29 |
33 |
34 |
38 |
39 |
40 |
44 |
45 |
49 |
50 |
54 |
55 |
59 |
60 |
64 |
65 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/layout_helper_circular_reveal.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
9 |
18 |
19 |
25 |
26 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/layout_helper_metables_decorator.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 |
15 |
16 |
26 |
27 |
36 |
37 |
38 |
48 |
49 |
50 |
60 |
61 |
62 |
71 |
72 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/layout_hepler_fly_in.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
9 |
14 |
15 |
26 |
27 |
37 |
38 |
48 |
49 |
60 |
61 |
73 |
74 |
75 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/layout_layer.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
9 |
20 |
21 |
30 |
31 |
42 |
43 |
54 |
55 |
66 |
67 |
78 |
79 |
88 |
89 |
98 |
99 |
100 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/layout_multiple_helper.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
10 |
17 |
18 |
19 |
25 |
26 |
27 |
34 |
35 |
42 |
43 |
53 |
54 |
55 |
66 |
67 |
77 |
78 |
89 |
90 |
91 |
102 |
103 |
112 |
113 |
122 |
123 |
134 |
135 |
136 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/motion_01_basic.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
17 |
18 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/motion_01_cl_end.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
18 |
19 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/motion_01_cl_start.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
18 |
19 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/motion_02.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
16 |
17 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/motion_04_imagefilter.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
18 |
19 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/motion_05_imagefilter.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
15 |
16 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/motion_06.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
16 |
17 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/motion_07.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
15 |
16 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/feng0403/ConstraintLayoutSamples/1c7a972ed0a85a2e2cfc7825729af20c775b6bbe/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/feng0403/ConstraintLayoutSamples/1c7a972ed0a85a2e2cfc7825729af20c775b6bbe/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/feng0403/ConstraintLayoutSamples/1c7a972ed0a85a2e2cfc7825729af20c775b6bbe/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/feng0403/ConstraintLayoutSamples/1c7a972ed0a85a2e2cfc7825729af20c775b6bbe/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/feng0403/ConstraintLayoutSamples/1c7a972ed0a85a2e2cfc7825729af20c775b6bbe/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/feng0403/ConstraintLayoutSamples/1c7a972ed0a85a2e2cfc7825729af20c775b6bbe/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/feng0403/ConstraintLayoutSamples/1c7a972ed0a85a2e2cfc7825729af20c775b6bbe/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/feng0403/ConstraintLayoutSamples/1c7a972ed0a85a2e2cfc7825729af20c775b6bbe/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/feng0403/ConstraintLayoutSamples/1c7a972ed0a85a2e2cfc7825729af20c775b6bbe/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/feng0403/ConstraintLayoutSamples/1c7a972ed0a85a2e2cfc7825729af20c775b6bbe/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #008577
4 | #00574B
5 | #D81B60
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | ConstraintLayout2Demo
3 |
4 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/app/src/main/res/xml/scene_01.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
9 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/app/src/main/res/xml/scene_02.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
9 |
13 |
14 |
15 |
16 |
24 |
25 |
26 |
29 |
30 |
31 |
32 |
33 |
34 |
42 |
45 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/app/src/main/res/xml/scene_04.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
10 |
14 |
15 |
16 |
17 |
25 |
28 |
29 |
30 |
31 |
32 |
40 |
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/app/src/main/res/xml/scene_05.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
10 |
14 |
15 |
16 |
17 |
23 |
26 |
27 |
28 |
29 |
30 |
36 |
39 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/app/src/main/res/xml/scene_06.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
10 |
14 |
15 |
16 |
21 |
22 |
28 |
29 |
30 |
31 |
32 |
40 |
43 |
44 |
45 |
46 |
47 |
55 |
58 |
59 |
60 |
61 |
--------------------------------------------------------------------------------
/app/src/main/res/xml/scene_07.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
10 |
14 |
15 |
16 |
22 |
28 |
29 |
30 |
31 |
32 |
40 |
43 |
44 |
45 |
46 |
47 |
55 |
58 |
59 |
60 |
61 |
--------------------------------------------------------------------------------
/app/src/test/java/cn/feng/constraintlayoutsample/ExampleUnitTest.kt:
--------------------------------------------------------------------------------
1 | package cn.feng.constraintlayoutsample
2 |
3 | import org.junit.Test
4 |
5 | import org.junit.Assert.*
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * See [testing documentation](http://d.android.com/tools/testing).
11 | */
12 | class ExampleUnitTest {
13 | @Test
14 | fun addition_isCorrect() {
15 | assertEquals(4, 2 + 2)
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | ext.kotlin_version = '1.3.31'
5 | repositories {
6 | google()
7 | jcenter()
8 |
9 | }
10 | dependencies {
11 | classpath 'com.android.tools.build:gradle:3.4.1'
12 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
13 | // NOTE: Do not place your application dependencies here; they belong
14 | // in the individual module build.gradle files
15 | }
16 | }
17 |
18 | allprojects {
19 | repositories {
20 | google()
21 | jcenter()
22 |
23 | }
24 | }
25 |
26 | task clean(type: Delete) {
27 | delete rootProject.buildDir
28 | }
29 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 | # IDE (e.g. Android Studio) users:
3 | # Gradle settings configured through the IDE *will override*
4 | # any settings specified in this file.
5 | # For more details on how to configure your build environment visit
6 | # http://www.gradle.org/docs/current/userguide/build_environment.html
7 | # Specifies the JVM arguments used for the daemon process.
8 | # The setting is particularly useful for tweaking memory settings.
9 | org.gradle.jvmargs=-Xmx1536m
10 | # When configured, Gradle will run in incubating parallel mode.
11 | # This option should only be used with decoupled projects. More details, visit
12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
13 | # org.gradle.parallel=true
14 | # Kotlin code style for this project: "official" or "obsolete":
15 | kotlin.code.style=official
16 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/feng0403/ConstraintLayoutSamples/1c7a972ed0a85a2e2cfc7825729af20c775b6bbe/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Fri May 31 17:32:15 CST 2019
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Attempt to set APP_HOME
10 | # Resolve links: $0 may be a link
11 | PRG="$0"
12 | # Need this for relative symlinks.
13 | while [ -h "$PRG" ] ; do
14 | ls=`ls -ld "$PRG"`
15 | link=`expr "$ls" : '.*-> \(.*\)$'`
16 | if expr "$link" : '/.*' > /dev/null; then
17 | PRG="$link"
18 | else
19 | PRG=`dirname "$PRG"`"/$link"
20 | fi
21 | done
22 | SAVED="`pwd`"
23 | cd "`dirname \"$PRG\"`/" >/dev/null
24 | APP_HOME="`pwd -P`"
25 | cd "$SAVED" >/dev/null
26 |
27 | APP_NAME="Gradle"
28 | APP_BASE_NAME=`basename "$0"`
29 |
30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
31 | DEFAULT_JVM_OPTS=""
32 |
33 | # Use the maximum available, or set MAX_FD != -1 to use that value.
34 | MAX_FD="maximum"
35 |
36 | warn () {
37 | echo "$*"
38 | }
39 |
40 | die () {
41 | echo
42 | echo "$*"
43 | echo
44 | exit 1
45 | }
46 |
47 | # OS specific support (must be 'true' or 'false').
48 | cygwin=false
49 | msys=false
50 | darwin=false
51 | nonstop=false
52 | case "`uname`" in
53 | CYGWIN* )
54 | cygwin=true
55 | ;;
56 | Darwin* )
57 | darwin=true
58 | ;;
59 | MINGW* )
60 | msys=true
61 | ;;
62 | NONSTOP* )
63 | nonstop=true
64 | ;;
65 | esac
66 |
67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
68 |
69 | # Determine the Java command to use to start the JVM.
70 | if [ -n "$JAVA_HOME" ] ; then
71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
72 | # IBM's JDK on AIX uses strange locations for the executables
73 | JAVACMD="$JAVA_HOME/jre/sh/java"
74 | else
75 | JAVACMD="$JAVA_HOME/bin/java"
76 | fi
77 | if [ ! -x "$JAVACMD" ] ; then
78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
79 |
80 | Please set the JAVA_HOME variable in your environment to match the
81 | location of your Java installation."
82 | fi
83 | else
84 | JAVACMD="java"
85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
86 |
87 | Please set the JAVA_HOME variable in your environment to match the
88 | location of your Java installation."
89 | fi
90 |
91 | # Increase the maximum file descriptors if we can.
92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
93 | MAX_FD_LIMIT=`ulimit -H -n`
94 | if [ $? -eq 0 ] ; then
95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
96 | MAX_FD="$MAX_FD_LIMIT"
97 | fi
98 | ulimit -n $MAX_FD
99 | if [ $? -ne 0 ] ; then
100 | warn "Could not set maximum file descriptor limit: $MAX_FD"
101 | fi
102 | else
103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
104 | fi
105 | fi
106 |
107 | # For Darwin, add options to specify how the application appears in the dock
108 | if $darwin; then
109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
110 | fi
111 |
112 | # For Cygwin, switch paths to Windows format before running java
113 | if $cygwin ; then
114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
116 | JAVACMD=`cygpath --unix "$JAVACMD"`
117 |
118 | # We build the pattern for arguments to be converted via cygpath
119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 | SEP=""
121 | for dir in $ROOTDIRSRAW ; do
122 | ROOTDIRS="$ROOTDIRS$SEP$dir"
123 | SEP="|"
124 | done
125 | OURCYGPATTERN="(^($ROOTDIRS))"
126 | # Add a user-defined pattern to the cygpath arguments
127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 | fi
130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 | i=0
132 | for arg in "$@" ; do
133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135 |
136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 | else
139 | eval `echo args$i`="\"$arg\""
140 | fi
141 | i=$((i+1))
142 | done
143 | case $i in
144 | (0) set -- ;;
145 | (1) set -- "$args0" ;;
146 | (2) set -- "$args0" "$args1" ;;
147 | (3) set -- "$args0" "$args1" "$args2" ;;
148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 | esac
155 | fi
156 |
157 | # Escape application args
158 | save () {
159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
160 | echo " "
161 | }
162 | APP_ARGS=$(save "$@")
163 |
164 | # Collect all arguments for the java command, following the shell quoting and substitution rules
165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
166 |
167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
169 | cd "$(dirname "$0")"
170 | fi
171 |
172 | exec "$JAVACMD" "$@"
173 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | set DIRNAME=%~dp0
12 | if "%DIRNAME%" == "" set DIRNAME=.
13 | set APP_BASE_NAME=%~n0
14 | set APP_HOME=%DIRNAME%
15 |
16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
17 | set DEFAULT_JVM_OPTS=
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windows variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 |
53 | :win9xME_args
54 | @rem Slurp the command line arguments.
55 | set CMD_LINE_ARGS=
56 | set _SKIP=2
57 |
58 | :win9xME_args_slurp
59 | if "x%~1" == "x" goto execute
60 |
61 | set CMD_LINE_ARGS=%*
62 |
63 | :execute
64 | @rem Setup the command line
65 |
66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
67 |
68 | @rem Execute Gradle
69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
70 |
71 | :end
72 | @rem End local scope for the variables with windows NT shell
73 | if "%ERRORLEVEL%"=="0" goto mainEnd
74 |
75 | :fail
76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
77 | rem the _cmd.exe /c_ return code!
78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
79 | exit /b 1
80 |
81 | :mainEnd
82 | if "%OS%"=="Windows_NT" endlocal
83 |
84 | :omega
85 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------