@@ -16,8 +16,8 @@ import android.widget.RelativeLayout
16
16
import com.cogitator.foldingit.animation.AnimationEndListener
17
17
import com.cogitator.foldingit.animation.FoldAnimation
18
18
import com.cogitator.foldingit.animation.HeightAnimation
19
+ import com.cogitator.foldingit.views.FoldingKitView
19
20
import com.freeankit.foldingit.R
20
- import com.freeankit.foldingit.views.FoldingKitView
21
21
import java.util.*
22
22
23
23
/* *
@@ -40,9 +40,9 @@ open class FoldingKit : RelativeLayout {
40
40
private val DEF_CAMERA_HEIGHT = 30
41
41
42
42
// current settings
43
- private var mAnimationDuration = DEF_ANIMATION_DURATION
44
- private var mBackSideColor = DEF_BACK_SIDE_COLOR
45
- private var mAdditionalFlipsCount = DEF_ADDITIONAL_FLIPS
43
+ public var animationDuration = DEF_ANIMATION_DURATION
44
+ public var backSideColor = DEF_BACK_SIDE_COLOR
45
+ public var additionalFlipsCount = DEF_ADDITIONAL_FLIPS
46
46
private var mCameraHeight = DEF_CAMERA_HEIGHT
47
47
48
48
constructor (context: Context , attrs: AttributeSet ) : super (context, attrs) {
@@ -70,9 +70,9 @@ open class FoldingKit : RelativeLayout {
70
70
* @param additionalFlipsCount count of additional flips (after first one), set 0 for auto
71
71
*/
72
72
fun initialize (animationDuration : Int , backSideColor : Int , additionalFlipsCount : Int ) {
73
- this .mAnimationDuration = animationDuration
74
- this .mBackSideColor = backSideColor
75
- this .mAdditionalFlipsCount = additionalFlipsCount
73
+ this .animationDuration = animationDuration
74
+ this .backSideColor = backSideColor
75
+ this .additionalFlipsCount = additionalFlipsCount
76
76
}
77
77
78
78
/* *
@@ -83,9 +83,9 @@ open class FoldingKit : RelativeLayout {
83
83
* @param additionalFlipsCount count of additional flips (after first one), set 0 for auto
84
84
*/
85
85
fun initialize (cameraHeight : Int , animationDuration : Int , backSideColor : Int , additionalFlipsCount : Int ) {
86
- this .mAnimationDuration = animationDuration
87
- this .mBackSideColor = backSideColor
88
- this .mAdditionalFlipsCount = additionalFlipsCount
86
+ this .animationDuration = animationDuration
87
+ this .backSideColor = backSideColor
88
+ this .additionalFlipsCount = additionalFlipsCount
89
89
this .mCameraHeight = cameraHeight
90
90
}
91
91
@@ -119,12 +119,12 @@ open class FoldingKit : RelativeLayout {
119
119
val foldingLayout = createAndPrepareFoldingContainer()
120
120
this .addView(foldingLayout)
121
121
// calculate heights of animation parts
122
- val heights = calculateHeightsForAnimationParts(titleView.height, contentView.height, mAdditionalFlipsCount )
122
+ val heights = calculateHeightsForAnimationParts(titleView.height, contentView.height, additionalFlipsCount )
123
123
// create list with animation parts for animation
124
124
val foldingCellElements = prepareViewsForAnimation(heights, bitmapFromTitleView, bitmapFromContentView)
125
125
// start unfold animation with end listener
126
126
val childCount = foldingCellElements.size
127
- val part90degreeAnimationDuration = mAnimationDuration / (childCount * 2 )
127
+ val part90degreeAnimationDuration = animationDuration / (childCount * 2 )
128
128
startUnfoldAnimation(foldingCellElements, foldingLayout, part90degreeAnimationDuration, object : AnimationEndListener () {
129
129
override fun onAnimationEnd (animation : Animation ? ) {
130
130
contentView.visibility = View .VISIBLE
@@ -175,11 +175,11 @@ open class FoldingKit : RelativeLayout {
175
175
this .addView(foldingLayout)
176
176
177
177
// calculate heights of animation parts
178
- val heights = calculateHeightsForAnimationParts(titleView.height, contentView.height, mAdditionalFlipsCount )
178
+ val heights = calculateHeightsForAnimationParts(titleView.height, contentView.height, additionalFlipsCount )
179
179
// create list with animation parts for animation
180
180
val foldingCellElements = prepareViewsForAnimation(heights, bitmapFromTitleView, bitmapFromContentView)
181
181
val childCount = foldingCellElements.size
182
- val part90degreeAnimationDuration = mAnimationDuration / (childCount * 2 )
182
+ val part90degreeAnimationDuration = animationDuration / (childCount * 2 )
183
183
// start fold animation with end listener
184
184
startFoldAnimation(foldingCellElements, foldingLayout, part90degreeAnimationDuration, object : AnimationEndListener () {
185
185
override fun onAnimationEnd (animation : Animation ? ) {
@@ -298,7 +298,7 @@ open class FoldingKit : RelativeLayout {
298
298
*/
299
299
private fun createBackSideView (height : Int ): ImageView {
300
300
val imageView = ImageView (context)
301
- imageView.setBackgroundColor(mBackSideColor )
301
+ imageView.setBackgroundColor(backSideColor )
302
302
imageView.layoutParams = RelativeLayout .LayoutParams (ViewGroup .LayoutParams .MATCH_PARENT , height)
303
303
return imageView
304
304
}
@@ -508,9 +508,9 @@ open class FoldingKit : RelativeLayout {
508
508
private fun initializeFromAttributes (context : Context , attrs : AttributeSet ) {
509
509
val array = context.theme.obtainStyledAttributes(attrs, R .styleable.FoldingKit , 0 , 0 )
510
510
try {
511
- this .mAnimationDuration = array.getInt(R .styleable.FoldingKit_animationDuration , DEF_ANIMATION_DURATION )
512
- this .mBackSideColor = array.getColor(R .styleable.FoldingKit_backSideColor , DEF_BACK_SIDE_COLOR )
513
- this .mAdditionalFlipsCount = array.getInt(R .styleable.FoldingKit_additionalFlipsCount , DEF_ADDITIONAL_FLIPS )
511
+ this .animationDuration = array.getInt(R .styleable.FoldingKit_animationDuration , DEF_ANIMATION_DURATION )
512
+ this .backSideColor = array.getColor(R .styleable.FoldingKit_backSideColor , DEF_BACK_SIDE_COLOR )
513
+ this .additionalFlipsCount = array.getInt(R .styleable.FoldingKit_additionalFlipsCount , DEF_ADDITIONAL_FLIPS )
514
514
this .mCameraHeight = array.getInt(R .styleable.FoldingKit_cameraHeight , DEF_CAMERA_HEIGHT )
515
515
} finally {
516
516
array.recycle()
0 commit comments