删除部分冗余代码

删除部分冗余代码
This commit is contained in:
Little Mango
2018-07-03 18:31:39 +08:00
parent eb414b449a
commit ef078821a2
4 changed files with 12 additions and 18 deletions

3
.gitignore vendored
View File

@@ -53,3 +53,6 @@ google-services.json
freeline.py freeline.py
freeline/ freeline/
freeline_project_description.json freeline_project_description.json
.idea/vcs.xml
.idea/caches/build_file_checksums.ser
*.ser

Binary file not shown.

View File

@@ -64,20 +64,20 @@ class DefaultAnimation(scrollOrientation: ScrollOrientation, visibleCount: Int)
return mOutRotation return mOutRotation
} }
override fun doAnimation(movePercent: Float, itemView: View, position: Int) { override fun doAnimation(firstMovePercent: Float, itemView: View, position: Int) {
val scale: Float val scale: Float
var alpha = 1.0f var alpha = 1.0f
val rotation: Float val rotation: Float
if (position == 0) { if (position == 0) {
scale = 1 - ((1 - mOutScale) * movePercent) scale = 1 - ((1 - mOutScale) * firstMovePercent)
rotation = mOutRotation * movePercent rotation = mOutRotation * firstMovePercent
} else { } else {
val minScale = (Math.pow(mScale.toDouble(), position.toDouble())).toFloat() val minScale = (Math.pow(mScale.toDouble(), position.toDouble())).toFloat()
val maxScale = (Math.pow(mScale.toDouble(), (position - 1).toDouble())).toFloat() val maxScale = (Math.pow(mScale.toDouble(), (position - 1).toDouble())).toFloat()
scale = minScale + (maxScale - minScale) * movePercent scale = minScale + (maxScale - minScale) * firstMovePercent
//只对最后一个 item 做透明度变化 //只对最后一个 item 做透明度变化
if (position == mVisibleCount) { if (position == mVisibleCount) {
alpha = movePercent alpha = firstMovePercent
} }
rotation = 0f rotation = 0f
} }

View File

@@ -35,7 +35,7 @@ class StackLayoutManager(scrollOrientation: ScrollOrientation,
//触发翻页效果的最低 Fling速度 //触发翻页效果的最低 Fling速度
private var mPagerFlingVelocity = 0 private var mPagerFlingVelocity = 0
//标志当前滚动是否是调用{@link #scrollToCenter(Int, RecyclerView, Boolean)}之后触发的滚动 //标志当前滚动是否是调用scrollToCenter之后触发的滚动
private var mFixScrolling = false private var mFixScrolling = false
//fling的方向用来判断是前翻还是后翻 //fling的方向用来判断是前翻还是后翻
@@ -68,7 +68,7 @@ class StackLayoutManager(scrollOrientation: ScrollOrientation,
/** /**
* 设置是否为ViewPager 式翻页模式. * 设置是否为ViewPager 式翻页模式.
* <p> * <p>
* 当设置为 true 的时候,可以配合{@link #setPagerFlingVelocity(Int)} 设置触发翻页的最小速度. * 当设置为 true 的时候,可以配合[StackLayoutManager.setPagerFlingVelocity]设置触发翻页的最小速度.
* @param isPagerMode 这个值默认是 false当设置为 true 的时候,会有 viewPager 翻页效果. * @param isPagerMode 这个值默认是 false当设置为 true 的时候,会有 viewPager 翻页效果.
*/ */
fun setPagerMode(isPagerMode: Boolean) { fun setPagerMode(isPagerMode: Boolean) {
@@ -85,7 +85,7 @@ class StackLayoutManager(scrollOrientation: ScrollOrientation,
/** /**
* 设置触发ViewPager翻页效果的最小速度. * 设置触发ViewPager翻页效果的最小速度.
* <p> * <p>
* 该值仅在 {@link #getPagerMode() == true}的时候有效. * 该值仅在 [StackLayoutManager.getPagerMode] == true的时候有效.
* @param velocity 默认值是2000. * @param velocity 默认值是2000.
*/ */
fun setPagerFlingVelocity(@IntRange(from = 0, to = Int.MAX_VALUE.toLong()) velocity: Int) { fun setPagerFlingVelocity(@IntRange(from = 0, to = Int.MAX_VALUE.toLong()) velocity: Int) {
@@ -403,17 +403,8 @@ class StackLayoutManager(scrollOrientation: ScrollOrientation,
private fun getFirstVisibleItemMovePercent(): Float { private fun getFirstVisibleItemMovePercent(): Float {
return when (mScrollOrientation) { return when (mScrollOrientation) {
ScrollOrientation.RIGHT_TO_LEFT -> { ScrollOrientation.RIGHT_TO_LEFT -> (mScrollOffset % width) * 1.0f / width
return if (width == 0) {
0f
} else {
(mScrollOffset % width) * 1.0f / width
}
}
ScrollOrientation.LEFT_TO_RIGHT -> { ScrollOrientation.LEFT_TO_RIGHT -> {
if (width == 0) {
return 0f
}
val targetPercent = 1 - (mScrollOffset % width) * 1.0f / width val targetPercent = 1 - (mScrollOffset % width) * 1.0f / width
return if (targetPercent == 1f) { return if (targetPercent == 1f) {
0f 0f