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

Add the Publication's positionList #91

Merged
merged 13 commits into from
Mar 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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