Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
PolycentricAndroid
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
VideoStreaming
PolycentricAndroid
Commits
b28f0ab1
Commit
b28f0ab1
authored
1 year ago
by
Koen
Browse files
Options
Downloads
Patches
Plain Diff
Fixed Glide image loading.
parent
700b764c
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
app/src/main/java/com/futo/polycentric/core/ApiMethods.kt
+4
-2
4 additions, 2 deletions
app/src/main/java/com/futo/polycentric/core/ApiMethods.kt
app/src/main/java/com/futo/polycentric/core/Utility.kt
+4
-3
4 additions, 3 deletions
app/src/main/java/com/futo/polycentric/core/Utility.kt
with
8 additions
and
5 deletions
app/src/main/java/com/futo/polycentric/core/ApiMethods.kt
+
4
−
2
View file @
b28f0ab1
...
...
@@ -16,6 +16,7 @@ import okhttp3.RequestBody.Companion.toRequestBody
import
okhttp3.Response
import
okio.IOException
import
userpackage.Protocol
import
java.nio.ByteBuffer
import
kotlin.coroutines.resume
import
kotlin.coroutines.resumeWithException
...
...
@@ -132,7 +133,7 @@ class ApiMethods {
}
}
suspend
fun
getDataFromServerAndReassemble
(
dataLink
:
Protocol
.
URLInfoDataLink
):
Byte
Array
=
withContext
(
Dispatchers
.
IO
)
{
suspend
fun
getDataFromServerAndReassemble
(
dataLink
:
Protocol
.
URLInfoDataLink
):
Byte
Buffer
=
withContext
(
Dispatchers
.
IO
)
{
val
server
=
dataLink
.
serversList
.
first
()
//TODO: Handle multiple servers better
val
blobProcessRangesToGet
=
Protocol
.
RangesForProcess
.
newBuilder
()
.
addAllRanges
(
dataLink
.
sectionsList
)
...
...
@@ -140,8 +141,9 @@ class ApiMethods {
.
build
()
val
blobEvents
=
getEvents
(
server
,
dataLink
.
system
,
Protocol
.
RangesForSystem
.
newBuilder
()
.
addRangesForProcesses
(
blobProcessRangesToGet
).
build
()).
eventsList
.
map
{
SignedEvent
.
fromProto
(
it
)
}
blobEvents
.
reassembleSections
(
dataLink
.
byteCount
.
toInt
(),
dataLink
.
sectionsList
)
val
reassembledData
=
blobEvents
.
reassembleSections
(
dataLink
.
byteCount
.
toInt
(),
dataLink
.
sectionsList
)
?:
throw
Exception
(
"Failed to reassemble sections due to missing data"
)
return
@withContext
reassembledData
}
suspend
fun
<
T
>
executeCall
(
call
:
Call
,
handler
:
(
Response
)
->
T
):
T
=
suspendCancellableCoroutine
{
continuation
->
...
...
This diff is collapsed.
Click to expand it.
app/src/main/java/com/futo/polycentric/core/Utility.kt
+
4
−
3
View file @
b28f0ab1
...
...
@@ -7,6 +7,7 @@ import kotlinx.serialization.Serializable
import
userpackage.Protocol
import
userpackage.Protocol.Claim
import
userpackage.Protocol.URLInfoSystemLink
import
java.nio.ByteBuffer
fun
ByteArray
.
toHexString
():
String
=
joinToString
(
separator
=
""
)
{
eachByte
->
"%02x"
.
format
(
eachByte
)
}
...
...
@@ -146,8 +147,8 @@ fun Protocol.ImageManifest.toURLInfoSystemLinkUrl(system: Protocol.PublicKey, pr
return
"polycentric://"
+
urlInfo
.
toByteArray
().
toBase64Url
()
}
fun
List
<
SignedEvent
>.
reassembleSections
(
totalSize
:
Int
,
sections
:
Iterable
<
Protocol
.
Range
>):
Byte
Array
?
{
val
totalArray
=
Byte
Array
(
totalSize
)
fun
List
<
SignedEvent
>.
reassembleSections
(
totalSize
:
Int
,
sections
:
Iterable
<
Protocol
.
Range
>):
Byte
Buffer
?
{
val
totalArray
=
Byte
Buffer
.
allocate
(
totalSize
)
var
offset
=
0
for
(
section
in
sections
)
{
...
...
@@ -160,7 +161,7 @@ fun List<SignedEvent>.reassembleSections(totalSize: Int, sections: Iterable<Prot
sectionEvents
.
forEach
{
val
blobSection
=
it
.
event
.
content
val
size
=
blobSection
.
size
blobSection
.
copyInto
(
totalArray
,
offset
)
blobSection
.
copyInto
(
totalArray
.
array
()
,
offset
)
offset
+=
size
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment