Skip to content

Commit

Permalink
NTV-483 :Migrate ProjectStatsEnvelope.java to kotlin and deprecate Au…
Browse files Browse the repository at this point in the history
…toparcel (#1622)

* Migrate GCM.java to kotlin and deprecate Autoparcel

* refactor Builder in push activity

* Migrate ProjectStatsEnvelope.java to kotlin and deprecate Autoparcel

* add test cases

* Fix ktlint

* update the testing coverage

* update the testing coverage

Co-authored-by: Isabel Martin <arkariang@gmail.com>
  • Loading branch information
hadia and Arkariang committed May 4, 2022
1 parent d99859c commit 4b8ce8c
Show file tree
Hide file tree
Showing 11 changed files with 794 additions and 234 deletions.
Expand Up @@ -113,7 +113,7 @@ class DebugPushNotificationsView @JvmOverloads constructor(context: Context, att
.title("Check it out")
.alert("Christopher Wright backed SKULL GRAPHIC TEE.")
.build()
val activity = com.kickstarter.models.pushdata.Activity.Builder()
val activity = com.kickstarter.models.pushdata.Activity.builder()
.category(Activity.CATEGORY_BACKING)
.id(1)
.projectId(PROJECT_ID)
Expand All @@ -128,7 +128,7 @@ class DebugPushNotificationsView @JvmOverloads constructor(context: Context, att
.title("You're in good company")
.alert("Christopher Wright is following you on Kickstarter!")
.build()
val activity = com.kickstarter.models.pushdata.Activity.Builder()
val activity = com.kickstarter.models.pushdata.Activity.builder()
.category(Activity.CATEGORY_FOLLOW)
.id(2)
.userPhoto(USER_PHOTO)
Expand All @@ -154,7 +154,7 @@ class DebugPushNotificationsView @JvmOverloads constructor(context: Context, att
.title("Kickstarter")
.alert("SKULL GRAPHIC TEE has been canceled.")
.build()
val activity = com.kickstarter.models.pushdata.Activity.Builder()
val activity = com.kickstarter.models.pushdata.Activity.builder()
.category(Activity.CATEGORY_CANCELLATION)
.id(3)
.projectId(PROJECT_ID)
Expand All @@ -169,7 +169,7 @@ class DebugPushNotificationsView @JvmOverloads constructor(context: Context, att
.title("Kickstarter")
.alert("SKULL GRAPHIC TEE was not successfully funded.")
.build()
val activity = com.kickstarter.models.pushdata.Activity.Builder()
val activity = com.kickstarter.models.pushdata.Activity.builder()
.category(Activity.CATEGORY_FAILURE)
.id(4)
.projectId(PROJECT_ID)
Expand All @@ -184,7 +184,7 @@ class DebugPushNotificationsView @JvmOverloads constructor(context: Context, att
.title("Want to be the first backer?")
.alert("Taylor Moore just launched a project!")
.build()
val activity = com.kickstarter.models.pushdata.Activity.Builder()
val activity = com.kickstarter.models.pushdata.Activity.builder()
.category(Activity.CATEGORY_LAUNCH)
.id(5)
.projectId(PROJECT_ID)
Expand Down Expand Up @@ -231,7 +231,7 @@ class DebugPushNotificationsView @JvmOverloads constructor(context: Context, att
.title("News from Taylor Moore")
.alert("Update #1 posted by SKULL GRAPHIC TEE.")
.build()
val activity = com.kickstarter.models.pushdata.Activity.Builder()
val activity = com.kickstarter.models.pushdata.Activity.builder()
.category(Activity.CATEGORY_UPDATE)
.id(7)
.projectId(PROJECT_ID)
Expand All @@ -256,7 +256,7 @@ class DebugPushNotificationsView @JvmOverloads constructor(context: Context, att
.title("Time to celebrate!")
.alert("SKULL GRAPHIC TEE has been successfully funded.")
.build()
val activity = com.kickstarter.models.pushdata.Activity.Builder()
val activity = com.kickstarter.models.pushdata.Activity.builder()
.category(Activity.CATEGORY_SUCCESS)
.id(6)
.projectId(PROJECT_ID)
Expand Down

This file was deleted.

@@ -0,0 +1,16 @@
package com.kickstarter.mock.factories

import com.kickstarter.models.pushdata.GCM.Companion.builder
import com.kickstarter.services.apiresponses.PushNotificationEnvelope

object PushNotificationEnvelopeFactory {
fun envelope(): PushNotificationEnvelope {
val gcm = builder()
.alert("You've received a new push notification")
.title("Hello")
.build()
return PushNotificationEnvelope.builder()
.gcm(gcm)
.build()
}
}
7 changes: 7 additions & 0 deletions app/src/main/java/com/kickstarter/models/pushdata/Activity.kt
Expand Up @@ -74,4 +74,11 @@ class Activity private constructor(
}
return equals
}

companion object {
@JvmStatic
fun builder(): Builder {
return Builder()
}
}
}
27 changes: 0 additions & 27 deletions app/src/main/java/com/kickstarter/models/pushdata/GCM.java

This file was deleted.

48 changes: 48 additions & 0 deletions app/src/main/java/com/kickstarter/models/pushdata/GCM.kt
@@ -0,0 +1,48 @@
package com.kickstarter.models.pushdata

import android.os.Parcelable
import kotlinx.parcelize.Parcelize

@Parcelize
class GCM private constructor(
private val alert: String,
private val title: String
) : Parcelable {
fun alert() = this.alert
fun title() = this.title

@Parcelize
data class Builder(
private var alert: String = "",
private var title: String = ""
) : Parcelable {
fun alert(alert: String) = apply { this.alert = alert }
fun title(title: String) = apply { this.title = title }

fun build() = GCM(
alert = alert,
title = title
)
}

fun toBuilder() = Builder(
alert = alert,
title = title
)

override fun equals(other: Any?): Boolean {
var equals = super.equals(other)
if (other is GCM) {
equals = alert() == other.alert() &&
title() == other.title()
}
return equals
}

companion object {
@JvmStatic
fun builder(): Builder {
return Builder()
}
}
}

This file was deleted.

0 comments on commit 4b8ce8c

Please sign in to comment.