Skip to content
This repository was archived by the owner on Nov 21, 2019. It is now read-only.

Commit 184d717

Browse files
committed
Some improvements:
- Bump the Android gradle plugin version to 3.2.0-beta1 - Add License header for examples for MotionLayout - Remove unused variables or Views in layouts - Use val instead of var where appropriate in Kotlin
1 parent 7bcb94d commit 184d717

File tree

114 files changed

+1619
-206
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

114 files changed

+1619
-206
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ buildscript {
2323
jcenter()
2424
}
2525
dependencies {
26-
classpath 'com.android.tools.build:gradle:3.2.0-alpha17'
26+
classpath 'com.android.tools.build:gradle:3.2.0-beta01'
2727
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
2828

2929
// NOTE: Do not place your application dependencies here; they belong

motionlayout/build.gradle

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
/*
2+
* Copyright (C) 2018 The Android Open Source Project
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
117
apply plugin: 'com.android.application'
218

319
apply plugin: 'kotlin-android'

motionlayout/src/androidTest/java/com/google/androidstudio/motionlayoutexample/ExampleInstrumentedTest.kt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
/*
2+
* Copyright (C) 2018 The Android Open Source Project
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
117
package com.google.androidstudio.motionlayoutexample
218

319
import android.support.test.InstrumentationRegistry

motionlayout/src/main/AndroidManifest.xml

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,18 @@
11
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
Copyright (C) 2018 The Android Open Source Project
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
-->
216
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
317
package="com.google.androidstudio.motionlayoutexample">
418

@@ -19,8 +33,8 @@
1933
<activity android:name=".DemoActivity"/>
2034
<activity android:name=".viewpagerdemo.ViewPagerActivity"/>
2135
<activity android:name=".viewpagerdemo.ViewPagerActivity2"/>
22-
<activity android:name=".FragmentExampleActivity"/>
23-
<activity android:name=".FragmentExample2Activity"/>
36+
<activity android:name=".fragmentsdemo.FragmentExampleActivity"/>
37+
<activity android:name=".fragmentsdemo.FragmentExample2Activity"/>
2438
</application>
2539

2640
</manifest>

motionlayout/src/main/java/com/google/androidstudio/motionlayoutexample/DemoActivity.kt

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
/*
2+
* Copyright (C) 2018 The Android Open Source Project
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
117
package com.google.androidstudio.motionlayoutexample
218

319
import android.os.Bundle
@@ -16,23 +32,20 @@ class DemoActivity : AppCompatActivity() {
1632
motionLayout = findViewById<View>(R.id.motionLayout)
1733

1834
if (layout == R.layout.motion_11_coordinatorlayout) {
19-
var icon = findViewById<ImageView>(R.id.icon)
35+
val icon = findViewById<ImageView>(R.id.icon)
2036
icon?.clipToOutline = true
2137
}
2238

23-
var doShowPaths = intent.getBooleanExtra("showPaths", false)
39+
val doShowPaths = intent.getBooleanExtra("showPaths", false)
2440
(motionLayout as? MotionLayout)?.setShowPaths(doShowPaths)
2541
}
2642

2743
fun changeState(v: View?) {
2844
if (motionLayout == null || motionLayout !is MotionLayout) {
2945
return
3046
}
31-
var ml = motionLayout as? MotionLayout
32-
if (ml == null) {
33-
return
34-
}
35-
if (ml.getProgress() > 0.5f) {
47+
val ml = motionLayout as? MotionLayout ?: return
48+
if (ml.progress > 0.5f) {
3649
ml.transitionToStart()
3750
} else {
3851
ml.transitionToEnd()

motionlayout/src/main/java/com/google/androidstudio/motionlayoutexample/DemosAdapter.kt

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,22 @@
1+
/*
2+
* Copyright (C) 2018 The Android Open Source Project
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
117
package com.google.androidstudio.motionlayoutexample
218

3-
import android.content.Intent
419
import android.support.constraint.ConstraintLayout
5-
import android.support.v4.content.ContextCompat.startActivity
6-
import android.support.v7.app.AppCompatActivity
720
import android.support.v7.widget.RecyclerView
821
import android.view.LayoutInflater
922
import android.view.ViewGroup
@@ -24,7 +37,7 @@ class DemosAdapter(private val myDataset: Array<DemosAdapter.Demo>) :
2437

2538
init {
2639
layout.setOnClickListener {
27-
var context = it?.context as MainActivity
40+
val context = it?.context as MainActivity
2841
if (activity != null) {
2942
context.start(activity!!, layoutFileId)
3043
}

motionlayout/src/main/java/com/google/androidstudio/motionlayoutexample/MainActivity.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import android.os.Bundle
66
import android.support.v7.widget.LinearLayoutManager
77
import android.support.v7.widget.RecyclerView
88
import android.widget.CompoundButton
9+
import com.google.androidstudio.motionlayoutexample.fragmentsdemo.FragmentExample2Activity
10+
import com.google.androidstudio.motionlayoutexample.fragmentsdemo.FragmentExampleActivity
911
import com.google.androidstudio.motionlayoutexample.viewpagerdemo.ViewPagerActivity
1012
import com.google.androidstudio.motionlayoutexample.viewpagerdemo.ViewPagerActivity2
1113
import kotlinx.android.synthetic.main.activity_main.*

motionlayout/src/main/java/com/google/androidstudio/motionlayoutexample/fragmentsdemo/CustomAdapter.kt

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
/*
2+
* Copyright (C) 2018 The Android Open Source Project
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
117
package com.google.androidstudio.motionlayoutexample.fragmentsdemo
218

319
import android.graphics.Rect
@@ -9,9 +25,7 @@ import android.view.View
925
import android.view.ViewGroup
1026
import android.widget.FrameLayout
1127
import android.widget.TextView
12-
import com.google.androidstudio.motionlayoutexample.ItemFragment
1328
import com.google.androidstudio.motionlayoutexample.R
14-
import com.google.androidstudio.motionlayoutexample.User
1529

1630
class CustomAdapter(val userList: ArrayList<User>): RecyclerView.Adapter<CustomAdapter.ViewHolder>() {
1731

motionlayout/src/main/java/com/google/androidstudio/motionlayoutexample/fragmentsdemo/FragmentExample2Activity.kt

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,27 @@
1-
package com.google.androidstudio.motionlayoutexample
1+
/*
2+
* Copyright (C) 2018 The Android Open Source Project
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.google.androidstudio.motionlayoutexample.fragmentsdemo
218

319
import android.support.v7.app.AppCompatActivity
420
import android.os.Bundle
521
import android.support.constraint.motion.MotionLayout
622
import android.support.v4.app.Fragment
7-
import android.view.MotionEvent
823
import android.view.View
9-
import android.widget.Button
10-
import com.example.nicolasroard.transitionsexample.ui.main.ListFragment
11-
import com.example.nicolasroard.transitionsexample.ui.main.MainFragment
12-
import com.example.nicolasroard.transitionsexample.ui.main.SecondFragment
24+
import com.google.androidstudio.motionlayoutexample.R
1325
import kotlinx.android.synthetic.main.main_activity.*
1426

1527
class FragmentExample2Activity : AppCompatActivity(), View.OnClickListener, MotionLayout.TransitionListener {

motionlayout/src/main/java/com/google/androidstudio/motionlayoutexample/fragmentsdemo/FragmentExampleActivity.kt

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,27 @@
1-
package com.google.androidstudio.motionlayoutexample
1+
/*
2+
* Copyright (C) 2018 The Android Open Source Project
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.google.androidstudio.motionlayoutexample.fragmentsdemo
218

319
import android.support.v7.app.AppCompatActivity
420
import android.os.Bundle
521
import android.support.constraint.motion.MotionLayout
622
import android.support.v4.app.Fragment
7-
import android.view.MotionEvent
823
import android.view.View
9-
import android.widget.Button
10-
import com.example.nicolasroard.transitionsexample.ui.main.ListFragment
11-
import com.example.nicolasroard.transitionsexample.ui.main.MainFragment
12-
import com.example.nicolasroard.transitionsexample.ui.main.SecondFragment
24+
import com.google.androidstudio.motionlayoutexample.R
1325
import kotlinx.android.synthetic.main.main_activity.*
1426

1527
class FragmentExampleActivity : AppCompatActivity(), View.OnClickListener, MotionLayout.TransitionListener {

0 commit comments

Comments
 (0)