Skip to content

Commit

Permalink
Making the page setting on a PlaidItem mandatory
Browse files Browse the repository at this point in the history
  • Loading branch information
florina-muntenescu committed Jul 11, 2019
1 parent 80ddd6e commit aea0969
Show file tree
Hide file tree
Showing 15 changed files with 20 additions and 7 deletions.
2 changes: 2 additions & 0 deletions app/src/test/java/io/plaidapp/TestData.kt
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ val player = User(
val shot = Shot(
id = 1L,
title = "Foo Nick",
page = 0,
description = "",
images = Images(),
user = player
Expand All @@ -86,6 +87,7 @@ val storyLinks = StoryLinks(
val story = Story(
id = storyId,
title = "Plaid 2.0 was released",
page = 0,
createdAt = createdDate,
userId = userId,
links = storyLinks
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/io/plaidapp/core/data/PlaidItem.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ abstract class PlaidItem(
@Transient open val id: Long,
@Transient open val title: String,
@Transient open var url: String? = null,
@Transient open val page: Int = 0
@Transient open val page: Int
) {
var dataSource: String? = null
var weight: Float = 0F // used for sorting
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ fun getDefaultUrl(id: Long) = "https://www.designernews.co/click/stories/$id"
data class Story(
@SerializedName("id") override val id: Long,
@SerializedName("title") override val title: String,
@SerializedName("page") override val page: Int = 0,
@SerializedName("page") override val page: Int,
@SerializedName("url")
override var url: String? = getDefaultUrl(id),
@SerializedName("comment") val comment: String? = null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import java.util.Date

fun getDefaultStoryUrl(id: Long) = "https://www.designernews.co/click/stories/$id"

fun StoryResponse.toStory(page: Int = 0) = Story(
fun StoryResponse.toStory(page: Int) = Story(
id = id,
title = title,
page = page,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import java.util.Date
data class Shot(
@SerializedName("id") override val id: Long,
@SerializedName("title") override val title: String,
@SerializedName("page") override val page: Int = 0,
@SerializedName("page") override val page: Int,
@SerializedName("description") val description: String,
@SerializedName("images") val images: Images,
@SerializedName("views_count") val viewsCount: Int = 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ object DribbbleSearchConverter : Converter<ResponseBody, List<Shot>> {
id = id,
htmlUrl = htmlUrl,
title = title,
page = 0,
description = description,
images = Images(normal = imgUrl),
animated = animated,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ class Post(
val redirectUrl: String,
val commentsCount: Int,
val votesCount: Int
) : PlaidItem(id, title, url)
) : PlaidItem(id, title, url, 0)
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,13 @@ class StoryResponseTest {
)

// When converting it to a story
val story = storyResponse.toStory()
val story = storyResponse.toStory(0)

// The story has the expected data
val expectedStory = Story(
id = 987,
title = "My Plaid story",
page = 0,
comment = "This is amazing",
commentHtml = "www.plaid.com",
commentCount = 0,
Expand Down
3 changes: 3 additions & 0 deletions core/src/test/java/io/plaidapp/core/dribbble/data/TestData.kt
Original file line number Diff line number Diff line change
Expand Up @@ -37,20 +37,23 @@ val shots = listOf(
Shot(
id = 1L,
title = "Foo",
page = 0,
description = "",
images = Images(),
user = player
),
Shot(
id = 2L,
title = "Bar",
page = 0,
description = "",
images = Images(),
user = player
),
Shot(
id = 3L,
title = "Baz",
page = 0,
description = "",
images = Images(),
user = player
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class ShotWeigherTest {
private val shot0 = Shot(
likesCount = 0,
id = 1L,
page = 0,
title = "Foo",
description = "",
images = Images(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class GetStoryUseCase @Inject constructor(private val storiesRepository: Stories
operator fun invoke(id: Long): Result<Story> {
val result = storiesRepository.getStory(id)
return if (result is Result.Success) {
Result.Success(result.data.toStory())
Result.Success(result.data.toStory(0))
} else {
Result.Error(IllegalStateException("Story $id not cached"))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class GetStoryUseCaseTest {
Story(
id = storyId,
title = "Plaid 2.0 was released",
page = 0,
createdAt = createdDate,
userId = storyLinks.user,
links = storyLinks
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ class StoryViewModelTest {
private val testStory = Story(
id = storyId,
title = "Plaid 2.0 was released",
page = 0,
createdAt = createdDate,
userId = userId,
links = storyLinks
Expand Down
1 change: 1 addition & 0 deletions dribbble/src/test/java/io/plaidapp/dribbble/TestData.kt
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ val player = User(
val testShot = Shot(
id = 1L,
title = "Foo",
page = 0,
description = "Shot Description",
images = Images(hidpi = "hidpi"),
user = player,
Expand Down
2 changes: 2 additions & 0 deletions search/src/test/java/io/plaidapp/search/TestData.kt
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ val player2 = User(
val testShot1 = Shot(
id = 1L,
title = "Foo Nick",
page = 0,
description = "",
images = Images(),
user = player1
Expand All @@ -49,6 +50,7 @@ val testShot1 = Shot(
val testShot2 = Shot(
id = 199L,
title = "Foo Flo",
page = 0,
description = "",
images = Images(),
user = player2
Expand Down

0 comments on commit aea0969

Please sign in to comment.