Skip to content

Commit

Permalink
Replace View.BaseSavedState with android.support.v4.view.AbsSavedState
Browse files Browse the repository at this point in the history
  • Loading branch information
VladimirWrites committed Apr 5, 2018
1 parent 409d30b commit 02ac83b
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 23 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
@@ -1,5 +1,10 @@
Change Log
==========
Version 1.4.4 *(2018-04-05)*
----------------------------

* Replace `View.BaseSavedState` with `android.support.v4.view.AbsSavedState` in `BaseCurveProgressView`

Version 1.4.3 *(2018-04-04)*
----------------------------

Expand Down
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -40,7 +40,7 @@ Add to your module's build.gradle:
and to your app build.gradle:

dependencies {
compile 'com.github.vlad1m1r990:Lemniscate:1.4.3'
implementation 'com.github.vlad1m1r990:Lemniscate:1.4.4'
}

Usage
Expand Down
4 changes: 2 additions & 2 deletions lemniscate/build.gradle
Expand Up @@ -13,8 +13,8 @@ android {
defaultConfig {
minSdkVersion 14
targetSdkVersion 27
versionCode 143
versionName "1.4.3"
versionCode 144
versionName "1.4.4"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
Expand Down
Expand Up @@ -22,6 +22,7 @@ import android.graphics.Canvas
import android.graphics.Path
import android.os.Parcel
import android.os.Parcelable
import android.support.v4.view.AbsSavedState
import android.util.AttributeSet
import android.view.View
import android.view.animation.LinearInterpolator
Expand Down Expand Up @@ -201,8 +202,7 @@ abstract class BaseCurveProgressView : View, IBaseCurveView {
}

public override fun onSaveInstanceState(): Parcelable {
val superState = super.onSaveInstanceState()
val ss = BaseCurveSavedState(superState)
val ss = BaseCurveSavedState(super.onSaveInstanceState())
ss.curveSettings = this.presenter.curveSettings
ss.animationSettings = this.presenter.animationSettings
return ss
Expand All @@ -211,28 +211,32 @@ abstract class BaseCurveProgressView : View, IBaseCurveView {
public override fun onRestoreInstanceState(state: Parcelable) {
if (state is BaseCurveSavedState) {
super.onRestoreInstanceState(state.superState)
this.presenter.curveSettings = state.curveSettings
this.presenter.animationSettings = state.animationSettings
state.curveSettings?.let {
this.presenter.curveSettings = it
}
state.animationSettings?.let {
this.presenter.animationSettings = it
}
} else {
super.onRestoreInstanceState(state)
}
}

protected open class BaseCurveSavedState : View.BaseSavedState {
internal lateinit var curveSettings: CurveSettings
internal lateinit var animationSettings: AnimationSettings
protected open class BaseCurveSavedState : AbsSavedState {
internal var curveSettings: CurveSettings? = null
internal var animationSettings: AnimationSettings? = null

constructor(superState: Parcelable) : super(superState)

constructor(state: Parcel) : super(state) {
constructor(state: Parcel) : super(state, BaseCurveSavedState::class.java.classLoader) {
this.curveSettings = state.readParcelable(CurveSettings::class.java.classLoader)
this.animationSettings = state.readParcelable(AnimationSettings::class.java.classLoader)
}

override fun writeToParcel(out: Parcel, flags: Int) {
super.writeToParcel(out, flags)
out.writeParcelable(this.curveSettings, flags)
out.writeParcelable(this.animationSettings, flags)
out.writeParcelable(curveSettings, flags)
out.writeParcelable(animationSettings, flags)
}

companion object {
Expand Down
Expand Up @@ -96,16 +96,18 @@ abstract class BaseRouletteProgressView : BaseCurveProgressView {

override fun onRestoreInstanceState(state: Parcelable) {
if (state is RouletteCurveSavedState) {
super.onRestoreInstanceState(state.superState)
this.rouletteCurveSettings = state.rouletteCurveSettings
super.onRestoreInstanceState(state.superState!!)
state.rouletteCurveSettings?.let {
this.rouletteCurveSettings = it
}
} else {
super.onRestoreInstanceState(state)
}
}

protected open class RouletteCurveSavedState : BaseCurveSavedState {

internal lateinit var rouletteCurveSettings: RouletteCurveSettings
internal var rouletteCurveSettings: RouletteCurveSettings? = null

constructor(superState: Parcelable) : super(superState)

Expand All @@ -115,7 +117,7 @@ abstract class BaseRouletteProgressView : BaseCurveProgressView {

override fun writeToParcel(out: Parcel, flags: Int) {
super.writeToParcel(out, flags)
out.writeParcelable(this.rouletteCurveSettings, flags)
out.writeParcelable(rouletteCurveSettings, flags)
}

companion object {
Expand Down
@@ -1,9 +1,7 @@
package com.vlad1m1r.lemniscate.base.settings

import android.graphics.Paint
import android.os.Parcel
import com.google.common.truth.Truth.assertThat
import com.nhaarman.mockito_kotlin.mock
import com.vlad1m1r.lemniscate.base.models.LineLength
import org.junit.Before
import org.junit.Test
Expand All @@ -13,8 +11,6 @@ import org.robolectric.RobolectricTestRunner
@RunWith(RobolectricTestRunner::class)
class CurveSettingsParcelableTest {

private val paint = mock<Paint>()

private lateinit var curveSettings: CurveSettings

@Before
Expand Down
4 changes: 2 additions & 2 deletions sample/build.gradle
Expand Up @@ -10,8 +10,8 @@ android {
applicationId "com.vlad1m1r.lemniscate.sample"
minSdkVersion 14
targetSdkVersion 27
versionCode 122
versionName "1.2.2"
versionCode 123
versionName "1.2.3"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
Expand Down

0 comments on commit 02ac83b

Please sign in to comment.