This repository has been archived by the owner on Jul 29, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from readium/develop
1.0.0
- Loading branch information
Showing
27 changed files
with
361 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package org.readium.r2.shared | ||
|
||
data class Collection(var name: String) { | ||
var sortAs: String? = null | ||
var identifier: String? = null | ||
var position: Double? = null | ||
var links:MutableList<Link> = mutableListOf() | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
r2-shared/src/main/java/org/readium/r2/shared/FuelPromiseExtension.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package org.readium.r2.shared | ||
|
||
import com.github.kittinunf.fuel.core.Request | ||
import com.github.kittinunf.fuel.core.Response | ||
import com.github.kittinunf.result.Result | ||
import nl.komponents.kovenant.Promise | ||
import nl.komponents.kovenant.deferred | ||
import nl.komponents.kovenant.task | ||
|
||
fun Request.promise(): Promise<Triple<Request, Response, ByteArray>, Exception> { | ||
val deferred = deferred<Triple<Request, Response, ByteArray>, Exception>() | ||
task { response() } success { | ||
val (request, response, result) = it | ||
when(result) { | ||
is Result.Success -> deferred.resolve(Triple(request, response, result.value)) | ||
is Result.Failure -> deferred.reject(result.error) | ||
} | ||
} fail { | ||
deferred.reject(it) | ||
} | ||
return deferred.promise | ||
} | ||
|
||
val Response.contentTypeEncoding: String | ||
get() = contentTypeEncoding() | ||
|
||
fun Response.contentTypeEncoding(default: String = "utf-8"): String { | ||
val contentType: String = httpResponseHeaders["Content-Type"]?.first() ?: return default | ||
return contentType.substringAfterLast("charset=", default).substringAfter(' ', default) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.