This repository was archived by the owner on Aug 2, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Hero image transition #196
Open
andhie
wants to merge
13
commits into
android:main
Choose a base branch
from
andhie:transition
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
2ec9df2
Hero image transition
andhie 908a443
Remove dupe copyright header
andhie 2680ee1
Merge remote-tracking branch 'upstream/master' into transition
andhie 15da10b
Merge branch 'master' into transition
andhie f926cc8
Remove custom clicklistener
andhie 069b3c4
spotlessApply
andhie 0c7b02c
Tweak transition anim
andhie 69a748b
Tweak transition anim
andhie 33c75c2
Merge branch 'transition' of https://github.com/andhie/android-sunflo…
andhie 56a1e38
Merge branch 'master' into transition
andhie 0eb2ae8
spotlessApply
andhie 8d2e117
Merge branch 'master' into transition
andhie 71a47bf
Merge branch 'master' into transition
andhie File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
app/src/main/java/com/google/samples/apps/sunflower/utilities/AnimUtils.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/* | ||
* Copyright 2018 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.google.samples.apps.sunflower.utilities | ||
|
||
import android.view.animation.Interpolator | ||
import androidx.interpolator.view.animation.FastOutLinearInInterpolator | ||
import androidx.interpolator.view.animation.FastOutSlowInInterpolator | ||
import androidx.interpolator.view.animation.LinearOutSlowInInterpolator | ||
|
||
object AnimUtils { | ||
|
||
private val fastOutSlowIn by lazy { FastOutSlowInInterpolator() } | ||
private val fastOutLinearIn by lazy { FastOutLinearInInterpolator() } | ||
private val linearOutSlowIn by lazy { LinearOutSlowInInterpolator() } | ||
|
||
/** | ||
* Elements that begin and end at rest use standard easing. They speed up quickly | ||
* and slow down gradually, in order to emphasize the end of the transition. | ||
* | ||
* Suitable timing for animating visible Views moving around on screen. | ||
* | ||
* See <a href="https://material.io/design/motion/speed.html#easing"> | ||
* https://material.io/design/motion/speed.html#easing</a> | ||
*/ | ||
fun getFastOutSlowInInterpolator(): Interpolator? { | ||
return fastOutSlowIn | ||
} | ||
|
||
/** | ||
* Incoming elements are animated using deceleration easing, which starts a transition | ||
* at peak velocity (the fastest point of an element’s movement) and ends at rest. | ||
* | ||
* Suitable timing for animating Views entering a screen | ||
* | ||
* See <a href="https://material.io/design/motion/speed.html#easing"> | ||
* https://material.io/design/motion/speed.html#easing</a> | ||
*/ | ||
fun getFastOutLinearInInterpolator(): Interpolator? { | ||
return fastOutLinearIn | ||
} | ||
|
||
/** | ||
* Elements exiting a screen use acceleration easing, where they start at rest | ||
* and end at peak velocity. | ||
* | ||
* Suitable timing for animating Views exiting a screen | ||
* | ||
* See <a href="https://material.io/design/motion/speed.html#easing"> | ||
* https://material.io/design/motion/speed.html#easing</a> | ||
*/ | ||
fun getLinearOutSlowInInterpolator(): Interpolator? { | ||
return linearOutSlowIn | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
app/src/main/java/com/google/samples/apps/sunflower/utilities/MoveViews.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
* Copyright 2018 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.google.samples.apps.sunflower.utilities | ||
|
||
import android.content.Context | ||
import android.util.AttributeSet | ||
import androidx.transition.ChangeBounds | ||
import androidx.transition.ChangeImageTransform | ||
import androidx.transition.ChangeTransform | ||
import androidx.transition.TransitionSet | ||
|
||
class MoveViews : TransitionSet { | ||
|
||
constructor() { | ||
init() | ||
} | ||
|
||
constructor(context: Context, attrs: AttributeSet) : super(context, attrs) { | ||
init() | ||
} | ||
|
||
private fun init() { | ||
addTransition(ChangeBounds()) | ||
.addTransition(ChangeTransform()) | ||
.addTransition(ChangeImageTransform()) | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
|
||
<!-- Animation durations https://material.io/design/motion/speed.html#duration --> | ||
|
||
<!-- Duration suitable for icons and selection controls. --> | ||
<integer name="config_duration_area_small">100</integer> | ||
|
||
<!-- Expanding duration suitable for bottom sheets and expanding chips --> | ||
<integer name="config_duration_area_medium_expand">250</integer> | ||
|
||
<!-- Collapsing duration suitable for bottom sheets and expanding chips --> | ||
<integer name="config_duration_area_medium_collapse">200</integer> | ||
|
||
<!-- Expanding duration suitable for cards and persistent sheet --> | ||
<integer name="config_duration_area_large_expand">300</integer> | ||
|
||
<!-- Expanding duration suitable for cards and persistent sheet --> | ||
<integer name="config_duration_area_large_collapse">250</integer> | ||
|
||
</resources> |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.