Skip to content

Commit

Permalink
Merge pull request #2 from alexandregpereira/dev
Browse files Browse the repository at this point in the history
Spring animations and Jerry APIs
  • Loading branch information
alexandregpereira authored Oct 17, 2020
2 parents 5054294 + 79fe770 commit b48a29c
Show file tree
Hide file tree
Showing 64 changed files with 3,907 additions and 790 deletions.
20 changes: 20 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,37 @@
</intent-filter>
</activity>

<activity android:name=".animation.TextExpandableSpringAnimationActivity" />

<activity android:name=".animation.TextExpandableAnimationActivity" />

<activity android:name=".animation.FadeSpringAnimationActivity" />

<activity android:name=".animation.FadeAnimationActivity" />

<activity android:name=".animation.CollapseFadingSpringAnimationActivity" />

<activity android:name=".animation.CollapseFadingAnimationActivity" />

<activity android:name=".animation.ExpandFadingSpringAnimationActivity" />

<activity android:name=".animation.ExpandFadingAnimationActivity" />

<activity android:name=".animation.CollapseSpringAnimationActivity" />

<activity android:name=".animation.CollapseAnimationActivity" />

<activity android:name=".animation.ExpandSpringAnimationActivity" />

<activity android:name=".animation.ExpandAnimationActivity" />

<activity android:name=".recyclerview.RecyclerViewActivity" />

<activity android:name=".recyclerview.RecyclerViewSpringActivity" />

<activity android:name=".recyclerview.GridRecyclerViewActivity" />

<activity android:name=".recyclerview.GridRecyclerViewSpringActivity" />
</application>

</manifest>
76 changes: 70 additions & 6 deletions app/src/main/java/br/alexandregpereira/jerry/app/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,30 @@ import androidx.appcompat.app.AppCompatActivity
import androidx.core.content.ContextCompat
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import br.alexandregpereira.jerry.app.animation.*
import br.alexandregpereira.jerry.app.widgets.setMaterialShapeDrawable
import br.alexandregpereira.jerry.app.animation.CollapseAnimationActivity
import br.alexandregpereira.jerry.app.animation.CollapseFadingAnimationActivity
import br.alexandregpereira.jerry.app.animation.CollapseSpringAnimationActivity
import br.alexandregpereira.jerry.app.animation.CollapseFadingSpringAnimationActivity
import br.alexandregpereira.jerry.app.animation.ExpandAnimationActivity
import br.alexandregpereira.jerry.app.animation.ExpandFadingAnimationActivity
import br.alexandregpereira.jerry.app.animation.ExpandSpringAnimationActivity
import br.alexandregpereira.jerry.app.animation.ExpandFadingSpringAnimationActivity
import br.alexandregpereira.jerry.app.animation.FadeAnimationActivity
import br.alexandregpereira.jerry.app.animation.FadeSpringAnimationActivity
import br.alexandregpereira.jerry.app.animation.TextExpandableAnimationActivity
import br.alexandregpereira.jerry.app.animation.TextExpandableSpringAnimationActivity
import br.alexandregpereira.jerry.app.recyclerview.GridRecyclerViewActivity
import br.alexandregpereira.jerry.app.recyclerview.GridRecyclerViewSpringActivity
import br.alexandregpereira.jerry.app.recyclerview.RecyclerViewActivity
import br.alexandregpereira.jerry.app.recyclerview.RecyclerViewSpringActivity
import br.alexandregpereira.jerry.app.widgets.configMaterialShapeDrawable
import kotlinx.android.synthetic.main.activity_main.*

class MainActivity : AppCompatActivity() {
class MainActivity : AppCompatActivity(R.layout.activity_main) {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)

appBarLayout.isLiftOnScroll = true

componentsRecycler.apply {
layoutManager = LinearLayoutManager(this@MainActivity)
Expand All @@ -23,21 +39,54 @@ class MainActivity : AppCompatActivity() {
AnimationComponent.FADE.ordinal -> startActivity(
FadeAnimationActivity.getStartIntent(this@MainActivity)
)
AnimationComponent.FADE_SPRING.ordinal -> startActivity(
FadeSpringAnimationActivity.getStartIntent(this@MainActivity)
)
AnimationComponent.COLLAPSE_FADING.ordinal -> startActivity(
CollapseFadingAnimationActivity.getStartIntent(this@MainActivity)
)
AnimationComponent.COLLAPSE_FADING.ordinal -> startActivity(
CollapseFadingAnimationActivity.getStartIntent(this@MainActivity)
)
AnimationComponent.COLLAPSE_FADING_SPRING.ordinal -> startActivity(
CollapseFadingSpringAnimationActivity.getStartIntent(this@MainActivity)
)
AnimationComponent.EXPAND_FADING.ordinal -> startActivity(
ExpandFadingAnimationActivity.getStartIntent(this@MainActivity)
)
AnimationComponent.EXPAND_FADING_SPRING.ordinal -> startActivity(
ExpandFadingSpringAnimationActivity.getStartIntent(this@MainActivity)
)
AnimationComponent.COLLAPSE.ordinal -> startActivity(
CollapseAnimationActivity.getStartIntent(this@MainActivity)
)
AnimationComponent.COLLAPSE_SPRING.ordinal -> startActivity(
CollapseSpringAnimationActivity.getStartIntent(this@MainActivity)
)
AnimationComponent.EXPAND.ordinal -> startActivity(
ExpandAnimationActivity.getStartIntent(this@MainActivity)
)
AnimationComponent.EXPAND_SPRING.ordinal -> startActivity(
ExpandSpringAnimationActivity.getStartIntent(this@MainActivity)
)
AnimationComponent.TEXT_EXPANDABLE.ordinal -> startActivity(
TextExpandableAnimationActivity.getStartIntent(this@MainActivity)
)
AnimationComponent.TEXT_EXPANDABLE_SPRING.ordinal -> startActivity(
TextExpandableSpringAnimationActivity.getStartIntent(this@MainActivity)
)
AnimationComponent.RECYCLER.ordinal -> startActivity(
RecyclerViewActivity.getStartIntent(this@MainActivity)
)
AnimationComponent.RECYCLER_SPRING.ordinal -> startActivity(
RecyclerViewSpringActivity.getStartIntent(this@MainActivity)
)
AnimationComponent.GRID_RECYCLER.ordinal -> startActivity(
GridRecyclerViewActivity.getStartIntent(this@MainActivity)
)
AnimationComponent.GRID_RECYCLER_SPRING.ordinal -> startActivity(
GridRecyclerViewSpringActivity.getStartIntent(this@MainActivity)
)
}
}
}
Expand All @@ -49,7 +98,22 @@ fun getAnimationComponentsName(): List<String> {
}

enum class AnimationComponent {
COLLAPSE, COLLAPSE_FADING, EXPAND, EXPAND_FADING, FADE, TEXT_EXPANDABLE
COLLAPSE,
COLLAPSE_SPRING,
COLLAPSE_FADING,
COLLAPSE_FADING_SPRING,
EXPAND,
EXPAND_SPRING,
EXPAND_FADING,
EXPAND_FADING_SPRING,
FADE,
FADE_SPRING,
TEXT_EXPANDABLE,
TEXT_EXPANDABLE_SPRING,
RECYCLER,
RECYCLER_SPRING,
GRID_RECYCLER,
GRID_RECYCLER_SPRING
}

class MainAdapter(
Expand Down Expand Up @@ -78,7 +142,7 @@ class MainAdapter(
}

setTextColor(ContextCompat.getColor(context, R.color.textSecondaryColor))
setMaterialShapeDrawable()
configMaterialShapeDrawable()
})
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,21 @@ package br.alexandregpereira.jerry.app.animation
import android.content.Context
import android.content.Intent
import android.os.Bundle
import android.widget.SeekBar
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat
import br.alexandregpereira.jerry.expandable.animateWidthVisibility
import br.alexandregpereira.jerry.app.R
import br.alexandregpereira.jerry.collapseHeight
import br.alexandregpereira.jerry.collapseWidth
import br.alexandregpereira.jerry.expandHeight
import br.alexandregpereira.jerry.expandWidth
import br.alexandregpereira.jerry.expandable.collapseHeight
import br.alexandregpereira.jerry.expandable.collapseWidth
import br.alexandregpereira.jerry.expandable.expandHeight
import br.alexandregpereira.jerry.expandable.expandWidth
import kotlinx.android.synthetic.main.activity_collapse_animation.*
import kotlinx.android.synthetic.main.container_seek_bar.*
import kotlinx.android.synthetic.main.container_animation_info.view.*

class CollapseAnimationActivity : AppCompatActivity(R.layout.activity_collapse_animation) {

var collapseTextViewCount = 1
private var collapseTextViewCount = 1
private var collapseMatchWidthViewVisible = true

companion object {
fun getStartIntent(context: Context): Intent {
Expand All @@ -26,37 +28,29 @@ class CollapseAnimationActivity : AppCompatActivity(R.layout.activity_collapse_a
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

seekBar.setOnSeekBarChangeListener(object : SeekBar.OnSeekBarChangeListener {
override fun onProgressChanged(seekBar: SeekBar?, progress: Int, fromUser: Boolean) {
seekBarValue.text = progress.getSeekBarAnimationDuration().run {
"$this ms"
}
}

override fun onStartTrackingTouch(seekBar: SeekBar?) {}

override fun onStopTrackingTouch(seekBar: SeekBar?) {}
})
ViewCompat.setTranslationZ(
collapseAnimationInfo,
resources.getDimension(R.dimen.strong_elevation)
)

collapseTextView.expandHeight()
collapseTextButton.setOnClickListener {
collapseTextView.collapseHeight(
duration = seekBar.progress.getSeekBarAnimationDuration(),
onProgressChange = { interpolatedTime ->
collapsePercentageTextView.text = (interpolatedTime * 100).toInt().toString()
collapseAnimationInfo.percentageTextView.text = (interpolatedTime * 100).toInt().toString()
}
) {
collapseCountTextView.text = collapseTextViewCount++.toString()
collapseAnimationInfo.countTextView.text = collapseTextViewCount++.toString()
}
}

collapseExpandTextButton.setOnClickListener {
collapseTextView.expandHeight(
duration = seekBar.progress.getSeekBarAnimationDuration(),
onProgressChange = { interpolatedTime ->
collapsePercentageTextView.text = (interpolatedTime * 100).toInt().toString()
collapseAnimationInfo.percentageTextView.text = (interpolatedTime * 100).toInt().toString()
}
) {
collapseCountTextView.text = collapseTextViewCount++.toString()
collapseAnimationInfo.countTextView.text = collapseTextViewCount++.toString()
}
}

Expand All @@ -76,6 +70,14 @@ class CollapseAnimationActivity : AppCompatActivity(R.layout.activity_collapse_a
collapseWidthTextView.expandWidth()
}

collapseReverseMatchWidthButton.setOnClickListener {
collapseMatchWidthView.animateWidthVisibility(
visible = collapseMatchWidthViewVisible.not().also {
collapseMatchWidthViewVisible = it
}
)
}

collapseMatchWidthButton.setOnClickListener {
collapseMatchWidthView.collapseWidth()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import android.content.Intent
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import br.alexandregpereira.jerry.app.R
import br.alexandregpereira.jerry.collapseHeightFading
import br.alexandregpereira.jerry.collapseWidthFading
import br.alexandregpereira.jerry.expandHeightFading
import br.alexandregpereira.jerry.expandWidthFading
import br.alexandregpereira.jerry.expandable.collapseHeightFading
import br.alexandregpereira.jerry.expandable.collapseWidthFading
import br.alexandregpereira.jerry.expandable.expandHeightFading
import br.alexandregpereira.jerry.expandable.expandWidthFading
import kotlinx.android.synthetic.main.activity_collapse_fading_animation.*

class CollapseFadingAnimationActivity : AppCompatActivity() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
package br.alexandregpereira.jerry.app.animation

import android.content.Context
import android.content.Intent
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import br.alexandregpereira.jerry.app.R
import br.alexandregpereira.jerry.expandable.collapseHeightFadingSpring
import br.alexandregpereira.jerry.expandable.collapseWidthFadingSpring
import br.alexandregpereira.jerry.expandable.expandHeightFadingSpring
import br.alexandregpereira.jerry.expandable.expandWidthFadingSpring
import kotlinx.android.synthetic.main.activity_collapse_fading_animation.*

class CollapseFadingSpringAnimationActivity : AppCompatActivity() {

companion object {
fun getStartIntent(context: Context): Intent {
return Intent(context, CollapseFadingSpringAnimationActivity::class.java)
}
}

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_collapse_fading_animation)

collapseFadingLabel.setText(R.string.collapse_fading_spring)

collapseFadingTextButton.setOnClickListener {
collapseFadingTextView.collapseHeightFadingSpring()
}

collapseExpandFadingTextButton.setOnClickListener {
collapseFadingTextView.expandHeightFadingSpring()
}

collapseFixedFadingTextButton.setOnClickListener {
collapseFixedFadingTextView.collapseHeightFadingSpring()
}

collapseExpandFixedFadingTextButton.setOnClickListener {
collapseFixedFadingTextView.expandHeightFadingSpring()
}

collapseWidthFadingTextButton.setOnClickListener {
collapseWidthFadingTextView.collapseWidthFadingSpring()
}

collapseExpandWidthFadingTextButton.setOnClickListener {
collapseWidthFadingTextView.expandWidthFadingSpring()
}

collapseMatchWidthFadingButton.setOnClickListener {
collapseMatchWidthFadingView.collapseWidthFadingSpring()
}

collapseExpandMatchWidthFadingButton.setOnClickListener {
collapseMatchWidthFadingView.expandWidthFadingSpring()
}

collapseFixedWidthFadingButton.setOnClickListener {
collapseFixedWidthFadingView.collapseWidthFadingSpring()
}

collapseExpandFixedWidthFadingButton.setOnClickListener {
collapseFixedWidthFadingView.expandWidthFadingSpring()
}
}
}
Loading

0 comments on commit b48a29c

Please sign in to comment.