-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Noto image & animation sizes are now part of emoji details, which all…
…ows to size the emoji container before downloading the image or animation
- Loading branch information
1 parent
ab439bb
commit b0469b3
Showing
22 changed files
with
874 additions
and
212 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,45 @@ | ||
import okhttp3.OkHttpClient | ||
import okhttp3.Request | ||
import java.io.File | ||
import java.util.concurrent.ExecutorService | ||
import java.util.concurrent.Executors | ||
import java.util.concurrent.TimeUnit | ||
|
||
|
||
private fun ExecutorService.download(client: OkHttpClient, url: String, file: File) { | ||
if (file.exists()) return | ||
|
||
submit { | ||
val request = Request.Builder() | ||
.url(url) | ||
.get() | ||
.build() | ||
file.outputStream().use { output -> | ||
client.newCall(request).execute().use { response -> | ||
if (!response.isSuccessful) error(response) | ||
response.body!!.byteStream().use { input -> | ||
input.copyTo(output) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
internal fun downloadNotoFiles(forms: List<AnnotatedForm>, cacheDir: File) { | ||
|
||
val httpClient = OkHttpClient() | ||
val exec = Executors.newFixedThreadPool(16) | ||
|
||
forms.forEach { form -> | ||
val code = form.mainForm.entry.code.joinToString("_") { it.toString(radix = 16) } | ||
if (form.hasNotoImage) { | ||
exec.download(httpClient, "https://fonts.gstatic.com/s/e/notoemoji/latest/$code/emoji.svg", cacheDir.resolve("$code.svg")) | ||
} | ||
if (form.hasNotoAnimation) { | ||
exec.download(httpClient, "https://fonts.gstatic.com/s/e/notoemoji/latest/$code/lottie.json", cacheDir.resolve("$code.json")) | ||
} | ||
} | ||
|
||
exec.shutdown() | ||
exec.awaitTermination(Long.MAX_VALUE, TimeUnit.SECONDS) | ||
} |
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
File renamed without changes.
File renamed without changes.
Oops, something went wrong.