-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
15 changed files
with
169 additions
and
79 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,7 @@ org.gradle.parallel=true | |
makeevrserg.project.name=IRDBBackend | ||
makeevrserg.project.url=https://github.com/flipperdevices/IRDB-Backend | ||
makeevrserg.project.group=com.flipperdevices.ifrmvp.backend | ||
makeevrserg.project.version.string=0.5.1 | ||
makeevrserg.project.version.string=0.6.0 | ||
makeevrserg.project.description=Api for IfrSample | ||
makeevrserg.project.developers=makeevrserg|Makeev Roman|[email protected] | ||
# Java | ||
|
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
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,8 @@ | ||
import ru.astrainteractive.gradleplugin.property.extension.ModelPropertyValueExt.requireProjectInfo | ||
|
||
plugins { | ||
id("org.jetbrains.kotlin.jvm") | ||
} | ||
dependencies { | ||
testImplementation(kotlin("test")) | ||
} |
5 changes: 5 additions & 0 deletions
5
modules/resources/src/main/kotlin/com/flipperdevices/ifrmvp/resources/CoreR.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,5 @@ | ||
package com.flipperdevices.ifrmvp.resources | ||
|
||
object CoreR { | ||
val inputImage = ServerResource.Image("/images/input.png") | ||
} |
27 changes: 27 additions & 0 deletions
27
modules/resources/src/main/kotlin/com/flipperdevices/ifrmvp/resources/ServerResource.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,27 @@ | ||
package com.flipperdevices.ifrmvp.resources | ||
|
||
import java.io.InputStream | ||
import kotlin.io.encoding.Base64 | ||
import kotlin.io.encoding.ExperimentalEncodingApi | ||
|
||
sealed interface ServerResource { | ||
fun openStream(): InputStream | ||
|
||
class Image(val path: String) : ServerResource { | ||
override fun openStream(): InputStream { | ||
val resource = object {}.javaClass.getResource(path) | ||
return resource?.openStream() ?: error("Could not load file $path") | ||
} | ||
|
||
@OptIn(ExperimentalEncodingApi::class) | ||
fun toBase64(): String { | ||
return openStream().use { | ||
PNG_BASE64_HEADER + Base64.encode(it.readAllBytes()) | ||
} | ||
} | ||
|
||
companion object { | ||
private const val PNG_BASE64_HEADER = "data:image/png;base64," | ||
} | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions
10
modules/resources/src/test/kotlin/com/flipperdevices/ifrmvp/resources/ServerResourceTest.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,10 @@ | ||
package com.flipperdevices.ifrmvp.resources | ||
|
||
import kotlin.test.Test | ||
|
||
class ServerResourceTest { | ||
@Test | ||
fun testResource() { | ||
println(CoreR.inputImage.toBase64()) | ||
} | ||
} |
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