Fix occurrence of multiple headers in game list + Make TinyXML2 Static

This commit mainly fixes multiple headers in the game list, which was caused by using the wrong variable for the recursive function. In addition, it makes TinyXML2 statically linked to libskyline which makes it the lone shared objects present in APKs.
This commit is contained in:
◱ PixelyIon 2020-03-30 00:37:11 +05:30 committed by ◱ PixelyIon
parent 72272fa4c2
commit 820bbaede5
2 changed files with 27 additions and 25 deletions

View File

@ -3,9 +3,11 @@ project(Skyline LANGUAGES CXX ASM VERSION 0.3)
set(BUILD_TESTS OFF) set(BUILD_TESTS OFF)
set(BUILD_TESTING OFF) set(BUILD_TESTING OFF)
set(BUILD_SHARED_LIBS OFF) set(BUILD_SHARED_LIBS OFF CACHE BOOL "Build Shared Libraries" FORCE)
set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED TRUE) set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
set(source_DIR ${CMAKE_SOURCE_DIR}/src/main/cpp) set(source_DIR ${CMAKE_SOURCE_DIR}/src/main/cpp)
set(CMAKE_CXX_FLAGS_RELEASE "-Ofast -flto=full -Wno-unused-command-line-argument") set(CMAKE_CXX_FLAGS_RELEASE "-Ofast -flto=full -Wno-unused-command-line-argument")
if (uppercase_CMAKE_BUILD_TYPE STREQUAL "RELEASE") if (uppercase_CMAKE_BUILD_TYPE STREQUAL "RELEASE")

View File

@ -38,32 +38,32 @@ class MainActivity : AppCompatActivity(), View.OnClickListener {
Snackbar.make(findViewById(android.R.id.content), text, Snackbar.LENGTH_SHORT).show() Snackbar.make(findViewById(android.R.id.content), text, Snackbar.LENGTH_SHORT).show()
} }
private fun findFile(ext: String, loader: BaseLoader, directory: DocumentFile, entries: Int = 0): Int { private fun findFile(ext: String, loader: BaseLoader, directory: DocumentFile, found: Boolean = false): Boolean {
var entryCount = entries var foundCurrent = found
directory.listFiles() directory.listFiles()
.forEach { file -> .forEach { file ->
if (file.isDirectory) { if (file.isDirectory) {
entryCount = findFile(ext, loader, file, entries) foundCurrent = findFile(ext, loader, file, foundCurrent)
} else { } else {
if (ext.equals(file.name?.substringAfterLast("."), ignoreCase = true)) { if (ext.equals(file.name?.substringAfterLast("."), ignoreCase = true)) {
val document = RandomAccessDocument(this, file) val document = RandomAccessDocument(this, file)
if (loader.verifyFile(document)) { if (loader.verifyFile(document)) {
val entry = loader.getTitleEntry(document, file.uri) val entry = loader.getTitleEntry(document, file.uri)
val header = (entryCount == 0)
runOnUiThread { runOnUiThread {
if (header) if (!foundCurrent) {
adapter.addHeader(getString(R.string.nro)) adapter.addHeader(getString(R.string.nro))
foundCurrent = true
}
adapter.addItem(GameItem(entry)) adapter.addItem(GameItem(entry))
} }
entryCount++
} }
document.close() document.close()
} }
} }
} }
return entryCount return foundCurrent
} }
private fun refreshFiles(tryLoad: Boolean) { private fun refreshFiles(tryLoad: Boolean) {
@ -80,9 +80,9 @@ class MainActivity : AppCompatActivity(), View.OnClickListener {
runOnUiThread { snackbar.show() } runOnUiThread { snackbar.show() }
try { try {
runOnUiThread { adapter.clear() } runOnUiThread { adapter.clear() }
val entries = findFile("nro", NroLoader(this), DocumentFile.fromTreeUri(this, Uri.parse(sharedPreferences.getString("search_location", "")))!!) val foundNros = findFile("nro", NroLoader(this), DocumentFile.fromTreeUri(this, Uri.parse(sharedPreferences.getString("search_location", "")))!!)
runOnUiThread { runOnUiThread {
if (entries == 0) if (!foundNros)
adapter.addHeader(getString(R.string.no_rom)) adapter.addHeader(getString(R.string.no_rom))
try { try {
adapter.save(File("${applicationInfo.dataDir}/roms.bin")) adapter.save(File("${applicationInfo.dataDir}/roms.bin"))