-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add djvu translation assets and logic to link it
- Loading branch information
1 parent
bb6cdba
commit 4f1abd2
Showing
5 changed files
with
56 additions
and
3 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
29 changes: 29 additions & 0 deletions
29
orion-viewer/src/main/java/universe/constellation/orion/viewer/prefs/AssetsUtil.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,29 @@ | ||
package universe.constellation.orion.viewer.prefs | ||
|
||
import android.content.res.AssetManager | ||
import java.io.File | ||
|
||
fun copyResIfNotExists(assets: AssetManager, path: String, targetRoot: File) { | ||
val res = assets.list(path) | ||
res?.forEach { | ||
val relPath = "$path/$it" | ||
if (it.endsWith(".xml")) { | ||
val newFile = File(targetRoot, relPath) | ||
try { | ||
if (newFile.exists()) return | ||
newFile.parentFile?.mkdirs() | ||
assets.open(relPath).use { input -> | ||
newFile.outputStream().use { output -> | ||
println("Copy " + newFile.absolutePath) | ||
input.copyTo(output) | ||
} | ||
} | ||
} catch (e: Throwable) { | ||
e.printStackTrace() | ||
newFile.delete() | ||
} | ||
} else { | ||
copyResIfNotExists(assets, relPath, targetRoot) | ||
} | ||
} | ||
} |
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