Skip to content
This repository has been archived by the owner on Jul 29, 2022. It is now read-only.

Commit

Permalink
Merge pull request #91 from readium/feature/position-list
Browse files Browse the repository at this point in the history
Add the Publication's positionList
  • Loading branch information
mickael-menu authored Mar 20, 2020
2 parents 7db2455 + 76e3c65 commit 100914d
Show file tree
Hide file tree
Showing 14 changed files with 1,094 additions and 289 deletions.
5 changes: 5 additions & 0 deletions r2-shared/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,12 @@ dependencies {
implementation 'nl.komponents.kovenant:kovenant-functional:3.3.0'
implementation 'joda-time:joda-time:2.9.9'

testImplementation "androidx.test:core-ktx:1.2.0"
testImplementation "androidx.test.ext:junit-ktx:1.1.1"
testImplementation "junit:junit:4.12"
testImplementation "net.sf.kxml:kxml2:2.3.0"
testImplementation "org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version"
testImplementation "org.robolectric:robolectric:4.3.1"
testImplementation 'junit:junit:4.12'
testImplementation 'org.assertj:assertj-core:3.14.0'
testImplementation 'org.mockito:mockito-core:2.19.0'
Expand Down
14 changes: 14 additions & 0 deletions r2-shared/src/main/java/org/readium/r2/shared/Deprecated.kt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,20 @@ import org.readium.r2.shared.publication.encryption.Encryption
import org.readium.r2.shared.publication.presentation.Presentation
import java.net.URL

@Deprecated("Moved to another package", ReplaceWith("org.readium.r2.shared.publication.Locator"))
typealias Locator = org.readium.r2.shared.publication.Locator

@Deprecated("Renamed into [Locator.Locations]", ReplaceWith("Locator.Locations", "org.readium.r2.shared.publication.Locator"))
typealias Locations = org.readium.r2.shared.publication.Locator.Locations

@Deprecated("Renamed into [Locator.Text]", ReplaceWith("Locator.Text", "org.readium.r2.shared.publication.Locator"))
typealias LocatorText = org.readium.r2.shared.publication.Locator.Text

@Deprecated("Moved to another package", ReplaceWith("Locator.Text", "org.readium.r2.shared.publication.html.DomRange"))
typealias DomRange = org.readium.r2.shared.publication.html.DomRange

@Deprecated("Renamed into [DomRange.Point]", ReplaceWith("DomRange.Point", "org.readium.r2.shared.publication.html.DomRange"))
typealias Range = org.readium.r2.shared.publication.html.DomRange.Point

@Deprecated("Refactored into [LocalizedString]", ReplaceWith("org.readium.r2.shared.publication.LocalizedString"))
typealias MultilanguageString = org.readium.r2.shared.publication.LocalizedString
Expand Down
285 changes: 0 additions & 285 deletions r2-shared/src/main/java/org/readium/r2/shared/Locator.kt

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ internal fun JSONObject.putIfNotEmpty(name: String, collection: Collection<*>) {
*/
fun JSONObject.optPositiveInt(name: String, fallback: Int = -1, remove: Boolean = false): Int? {
val int = optInt(name, fallback)
val value = if (int > 0) int else null
val value = if (int >= 0) int else null
if (remove) {
this.remove(name)
}
Expand All @@ -122,7 +122,7 @@ fun JSONObject.optPositiveInt(name: String, fallback: Int = -1, remove: Boolean
*/
fun JSONObject.optPositiveDouble(name: String, fallback: Double = -1.0, remove: Boolean = false): Double? {
val double = optDouble(name, fallback)
val value = if (double > 0) double else null
val value = if (double >= 0) double else null
if (remove) {
this.remove(name)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,3 +153,10 @@ data class Link(
get() = rels.toList()

}

/**
* Returns the first [Link] with the given [href], or [null] if not found.
*/
fun List<Link>.indexOfFirstWithHref(href: String): Int? =
indexOfFirst { it.href == href }
.takeUnless { it == -1 }
Loading

0 comments on commit 100914d

Please sign in to comment.