Skip to content

Commit

Permalink
Fixes #10 Added equals method to ViewParam
Browse files Browse the repository at this point in the history
  • Loading branch information
AdamKobus committed Feb 7, 2022
1 parent 41043f5 commit 4ca8471
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 6 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@

### Changes

# 1.0.1

### Fixes

- [#10](https://github.com/AdamKobus/lifecycle-aware-viewmodel/issues/10) ViewParam now has equals method

# 1.0.0

### Changes
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ repositories {
dependencies {
// LifecycleObserverKtx
implementation "com.adamkobus:lifecycle-observer-ktx:1.0.0"
implementation "com.adamkobus:lifecycle-observer-ktx:1.0.1"
// LifecycleObserverKtx + LifecycleAwareViewModel + ViewParam
implementation "com.adamkobus:lifecycle-observer-viewmodel-ktx:1.0.0"
implementation "com.adamkobus:lifecycle-observer-viewmodel-ktx:1.0.1"
}
```

Expand All @@ -39,10 +39,10 @@ repositories {
dependencies {
// LifecycleObserverKtx
implementation "com.adamkobus:lifecycle-observer-ktx:1.0.0-SNAPSHOT"
implementation "com.adamkobus:lifecycle-observer-ktx:1.0.1-SNAPSHOT"
// LifecycleObserverKtx + LifecycleAwareViewModel + ViewParam
implementation "com.adamkobus:lifecycle-observer-viewmodel-ktx:1.0.0-SNAPSHOT"
implementation "com.adamkobus:lifecycle-observer-viewmodel-ktx:1.0.1-SNAPSHOT"
}
```

Expand Down
2 changes: 1 addition & 1 deletion gradle/publishing-root.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ rootProject.ext["adamkobusSonatypeStagingProfileId"] = ""

rootProject.ext["snapshot"] = System.getenv().getOrDefault("MAVEN_SNAPSHOT", "true")

def VERSION_BASE = "1.0.0"
def VERSION_BASE = "1.0.1"
def VERSION_SUFFIX = ""
if (rootProject.ext["snapshot"] == "true") {
VERSION_SUFFIX = "-SNAPSHOT"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,13 @@ class ViewParam<T> {
sealed class ViewParamState<T>(val getValue: () -> T) {
class Missing<T> : ViewParamState<T>({ throw IllegalStateException("Tried to access the value when it's missing") })

class Present<T>(val value: T) : ViewParamState<T>({ value })
class Present<T>(val value: T) : ViewParamState<T>({ value }) {
override fun equals(other: Any?): Boolean {
return other is Present<*> && other.value == value
}

override fun hashCode(): Int {
return value?.hashCode() ?: 0
}
}
}

0 comments on commit 4ca8471

Please sign in to comment.