2020-04-19 23:04:05 +02:00
|
|
|
/*
|
|
|
|
* SPDX-License-Identifier: MPL-2.0
|
|
|
|
* Copyright © 2020 Skyline Team and Contributors (https://github.com/skyline-emu/)
|
|
|
|
*/
|
2020-03-27 20:36:02 +01:00
|
|
|
|
2019-12-02 14:39:08 +01:00
|
|
|
package emu.skyline
|
|
|
|
|
|
|
|
import android.content.Intent
|
|
|
|
import android.content.SharedPreferences
|
2020-04-24 13:39:13 +02:00
|
|
|
import android.content.pm.ActivityInfo
|
2019-12-02 14:39:08 +01:00
|
|
|
import android.net.Uri
|
|
|
|
import android.os.Bundle
|
|
|
|
import android.util.Log
|
|
|
|
import android.view.Menu
|
|
|
|
import android.view.MenuItem
|
|
|
|
import android.view.View
|
|
|
|
import androidx.appcompat.app.AppCompatActivity
|
2019-12-10 21:51:02 +01:00
|
|
|
import androidx.appcompat.app.AppCompatDelegate
|
2019-12-02 14:39:08 +01:00
|
|
|
import androidx.appcompat.widget.SearchView
|
|
|
|
import androidx.documentfile.provider.DocumentFile
|
|
|
|
import androidx.preference.PreferenceManager
|
2020-04-12 18:13:29 +02:00
|
|
|
import androidx.recyclerview.widget.DividerItemDecoration
|
2020-04-12 17:17:51 +02:00
|
|
|
import androidx.recyclerview.widget.GridLayoutManager
|
2020-04-12 18:13:29 +02:00
|
|
|
import androidx.recyclerview.widget.LinearLayoutManager
|
|
|
|
import androidx.recyclerview.widget.RecyclerView
|
2019-12-02 14:39:08 +01:00
|
|
|
import com.google.android.material.snackbar.Snackbar
|
2020-04-03 13:47:32 +02:00
|
|
|
import emu.skyline.adapter.AppAdapter
|
|
|
|
import emu.skyline.adapter.AppItem
|
2020-04-12 17:17:51 +02:00
|
|
|
import emu.skyline.adapter.GridLayoutSpan
|
|
|
|
import emu.skyline.adapter.LayoutType
|
2020-06-19 22:18:33 +02:00
|
|
|
import emu.skyline.loader.RomFile
|
|
|
|
import emu.skyline.loader.RomFormat
|
2019-12-10 11:13:19 +01:00
|
|
|
import kotlinx.android.synthetic.main.main_activity.*
|
2020-04-12 22:29:19 +02:00
|
|
|
import kotlinx.android.synthetic.main.titlebar.*
|
2019-12-02 14:39:08 +01:00
|
|
|
import java.io.File
|
|
|
|
import java.io.IOException
|
2020-01-09 02:37:54 +01:00
|
|
|
import kotlin.concurrent.thread
|
2020-04-12 17:17:51 +02:00
|
|
|
import kotlin.math.ceil
|
2019-12-02 14:39:08 +01:00
|
|
|
|
2020-04-12 22:29:19 +02:00
|
|
|
class MainActivity : AppCompatActivity(), View.OnClickListener, View.OnLongClickListener {
|
|
|
|
/**
|
|
|
|
* This is used to get/set shared preferences
|
|
|
|
*/
|
2020-04-24 13:39:13 +02:00
|
|
|
private lateinit var sharedPreferences : SharedPreferences
|
2020-01-09 02:37:54 +01:00
|
|
|
|
2020-04-12 22:29:19 +02:00
|
|
|
/**
|
|
|
|
* The adapter used for adding elements to [app_list]
|
|
|
|
*/
|
2020-04-24 13:39:13 +02:00
|
|
|
private lateinit var adapter : AppAdapter
|
2019-12-02 14:39:08 +01:00
|
|
|
|
2020-04-12 22:29:19 +02:00
|
|
|
/**
|
|
|
|
* This adds all files in [directory] with [extension] as an entry in [adapter] using [loader] to load metadata
|
|
|
|
*/
|
2020-06-19 22:18:33 +02:00
|
|
|
private fun addEntries(extension : String, romFormat : RomFormat, directory : DocumentFile, found : Boolean = false) : Boolean {
|
2020-03-29 21:07:11 +02:00
|
|
|
var foundCurrent = found
|
2020-03-08 13:28:18 +01:00
|
|
|
|
2020-04-12 22:29:19 +02:00
|
|
|
directory.listFiles().forEach { file ->
|
|
|
|
if (file.isDirectory) {
|
2020-06-19 22:18:33 +02:00
|
|
|
foundCurrent = addEntries(extension, romFormat, file, foundCurrent)
|
2020-04-12 22:29:19 +02:00
|
|
|
} else {
|
|
|
|
if (extension.equals(file.name?.substringAfterLast("."), ignoreCase = true)) {
|
2020-06-19 22:18:33 +02:00
|
|
|
val romFd = contentResolver.openFileDescriptor(file.uri, "r")!!
|
|
|
|
val romFile = RomFile(this, romFormat, romFd)
|
2020-04-12 22:29:19 +02:00
|
|
|
|
2020-06-19 22:18:33 +02:00
|
|
|
if (romFile.valid()) {
|
|
|
|
romFile.use {
|
|
|
|
val entry = romFile.getAppEntry(file.uri)
|
2020-04-12 22:29:19 +02:00
|
|
|
|
2020-06-19 22:18:33 +02:00
|
|
|
runOnUiThread {
|
|
|
|
if (!foundCurrent) {
|
|
|
|
adapter.addHeader(romFormat.name)
|
|
|
|
}
|
|
|
|
|
|
|
|
adapter.addItem(AppItem(entry))
|
2020-01-09 02:37:54 +01:00
|
|
|
}
|
2020-04-12 22:29:19 +02:00
|
|
|
|
2020-06-19 22:18:33 +02:00
|
|
|
foundCurrent = true
|
2019-12-02 14:39:08 +01:00
|
|
|
}
|
|
|
|
}
|
2020-04-12 22:29:19 +02:00
|
|
|
|
2020-06-25 17:51:05 +02:00
|
|
|
romFd.close()
|
2019-12-02 14:39:08 +01:00
|
|
|
}
|
2020-04-12 22:29:19 +02:00
|
|
|
}
|
|
|
|
}
|
2020-03-08 13:28:18 +01:00
|
|
|
|
2020-03-29 21:07:11 +02:00
|
|
|
return foundCurrent
|
2019-12-02 14:39:08 +01:00
|
|
|
}
|
|
|
|
|
2020-04-12 22:29:19 +02:00
|
|
|
/**
|
|
|
|
* This refreshes the contents of the adapter by either trying to load cached adapter data or searches for them to recreate a list
|
|
|
|
*
|
|
|
|
* @param tryLoad If this is false then trying to load cached adapter data is skipped entirely
|
|
|
|
*/
|
2020-04-24 13:39:13 +02:00
|
|
|
private fun refreshAdapter(tryLoad : Boolean) {
|
2019-12-02 14:39:08 +01:00
|
|
|
if (tryLoad) {
|
|
|
|
try {
|
2020-03-08 13:28:18 +01:00
|
|
|
adapter.load(File("${applicationInfo.dataDir}/roms.bin"))
|
2019-12-02 14:39:08 +01:00
|
|
|
return
|
2020-04-24 13:39:13 +02:00
|
|
|
} catch (e : Exception) {
|
2020-03-08 13:28:18 +01:00
|
|
|
Log.w("refreshFiles", "Ran into exception while loading: ${e.message}")
|
2019-12-02 14:39:08 +01:00
|
|
|
}
|
|
|
|
}
|
2020-04-03 13:47:32 +02:00
|
|
|
|
2020-01-09 02:37:54 +01:00
|
|
|
thread(start = true) {
|
2020-07-11 23:29:05 +02:00
|
|
|
val snackbar = Snackbar.make(coordinatorLayout, getString(R.string.searching_roms), Snackbar.LENGTH_INDEFINITE)
|
2020-04-24 13:39:13 +02:00
|
|
|
runOnUiThread {
|
|
|
|
snackbar.show()
|
|
|
|
requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_LOCKED
|
|
|
|
}
|
2020-04-03 13:47:32 +02:00
|
|
|
|
2019-12-10 21:51:02 +01:00
|
|
|
try {
|
2020-03-29 21:07:11 +02:00
|
|
|
runOnUiThread { adapter.clear() }
|
2020-04-12 22:29:19 +02:00
|
|
|
|
2020-06-25 17:51:05 +02:00
|
|
|
var foundRoms = addEntries("nro", RomFormat.NRO, DocumentFile.fromTreeUri(this, Uri.parse(sharedPreferences.getString("search_location", "")))!!)
|
|
|
|
foundRoms = foundRoms or addEntries("nso", RomFormat.NSO, DocumentFile.fromTreeUri(this, Uri.parse(sharedPreferences.getString("search_location", "")))!!)
|
2020-06-29 20:23:33 +02:00
|
|
|
foundRoms = foundRoms or addEntries("nca", RomFormat.NCA, DocumentFile.fromTreeUri(this, Uri.parse(sharedPreferences.getString("search_location", "")))!!)
|
2020-06-29 22:19:32 +02:00
|
|
|
foundRoms = foundRoms or addEntries("nsp", RomFormat.NSP, DocumentFile.fromTreeUri(this, Uri.parse(sharedPreferences.getString("search_location", "")))!!)
|
2020-04-03 13:47:32 +02:00
|
|
|
|
2020-01-09 02:37:54 +01:00
|
|
|
runOnUiThread {
|
2020-06-25 17:51:05 +02:00
|
|
|
if (!foundRoms)
|
2020-01-09 02:37:54 +01:00
|
|
|
adapter.addHeader(getString(R.string.no_rom))
|
2020-04-03 13:47:32 +02:00
|
|
|
|
2020-01-09 02:37:54 +01:00
|
|
|
try {
|
2020-03-08 13:28:18 +01:00
|
|
|
adapter.save(File("${applicationInfo.dataDir}/roms.bin"))
|
2020-04-24 13:39:13 +02:00
|
|
|
} catch (e : IOException) {
|
2020-03-08 13:28:18 +01:00
|
|
|
Log.w("refreshFiles", "Ran into exception while saving: ${e.message}")
|
2020-01-09 02:37:54 +01:00
|
|
|
}
|
|
|
|
}
|
2020-04-03 13:47:32 +02:00
|
|
|
|
2020-01-09 02:37:54 +01:00
|
|
|
sharedPreferences.edit().putBoolean("refresh_required", false).apply()
|
2020-04-24 13:39:13 +02:00
|
|
|
} catch (e : IllegalArgumentException) {
|
2020-01-09 02:37:54 +01:00
|
|
|
runOnUiThread {
|
|
|
|
sharedPreferences.edit().remove("search_location").apply()
|
2020-04-03 13:47:32 +02:00
|
|
|
|
2020-01-09 02:37:54 +01:00
|
|
|
val intent = intent
|
|
|
|
finish()
|
|
|
|
startActivity(intent)
|
|
|
|
}
|
2020-04-24 13:39:13 +02:00
|
|
|
} catch (e : Exception) {
|
2020-01-09 02:37:54 +01:00
|
|
|
runOnUiThread {
|
2020-04-12 22:29:19 +02:00
|
|
|
Snackbar.make(findViewById(android.R.id.content), getString(R.string.error) + ": ${e.localizedMessage}", Snackbar.LENGTH_SHORT).show()
|
2020-01-09 02:37:54 +01:00
|
|
|
}
|
2019-12-10 21:51:02 +01:00
|
|
|
}
|
2020-04-03 13:47:32 +02:00
|
|
|
|
2020-04-24 13:39:13 +02:00
|
|
|
runOnUiThread {
|
|
|
|
snackbar.dismiss()
|
|
|
|
requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED
|
|
|
|
}
|
2019-12-02 14:39:08 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-12 22:29:19 +02:00
|
|
|
/**
|
|
|
|
* This initializes [toolbar], [open_fab], [log_fab] and [app_list]
|
|
|
|
*/
|
2020-04-24 13:39:13 +02:00
|
|
|
override fun onCreate(savedInstanceState : Bundle?) {
|
2019-12-02 14:39:08 +01:00
|
|
|
super.onCreate(savedInstanceState)
|
2020-04-12 22:29:19 +02:00
|
|
|
|
2019-12-02 14:39:08 +01:00
|
|
|
setContentView(R.layout.main_activity)
|
2020-04-12 22:29:19 +02:00
|
|
|
|
|
|
|
setSupportActionBar(toolbar)
|
|
|
|
|
2019-12-02 14:39:08 +01:00
|
|
|
PreferenceManager.setDefaultValues(this, R.xml.preferences, false)
|
|
|
|
sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this)
|
2020-04-12 22:29:19 +02:00
|
|
|
|
2019-12-10 21:51:02 +01:00
|
|
|
AppCompatDelegate.setDefaultNightMode(when ((sharedPreferences.getString("app_theme", "2")?.toInt())) {
|
|
|
|
0 -> AppCompatDelegate.MODE_NIGHT_NO
|
|
|
|
1 -> AppCompatDelegate.MODE_NIGHT_YES
|
|
|
|
2 -> AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM
|
|
|
|
else -> AppCompatDelegate.MODE_NIGHT_UNSPECIFIED
|
|
|
|
})
|
2020-04-12 22:29:19 +02:00
|
|
|
|
2019-12-10 11:13:19 +01:00
|
|
|
open_fab.setOnClickListener(this)
|
|
|
|
log_fab.setOnClickListener(this)
|
2020-04-12 18:13:29 +02:00
|
|
|
|
2020-04-12 17:17:51 +02:00
|
|
|
val layoutType = LayoutType.values()[sharedPreferences.getString("layout_type", "1")!!.toInt()]
|
|
|
|
|
|
|
|
adapter = AppAdapter(this, layoutType)
|
|
|
|
app_list.adapter = adapter
|
2020-04-12 18:13:29 +02:00
|
|
|
|
2020-04-12 17:17:51 +02:00
|
|
|
when (layoutType) {
|
|
|
|
LayoutType.List -> {
|
|
|
|
app_list.layoutManager = LinearLayoutManager(this)
|
|
|
|
app_list.addItemDecoration(DividerItemDecoration(this, RecyclerView.VERTICAL))
|
2019-12-02 14:39:08 +01:00
|
|
|
}
|
2020-04-12 17:17:51 +02:00
|
|
|
|
|
|
|
LayoutType.Grid -> {
|
|
|
|
val itemWidth = 225
|
|
|
|
val metrics = resources.displayMetrics
|
|
|
|
val span = ceil((metrics.widthPixels / metrics.density) / itemWidth).toInt()
|
|
|
|
|
|
|
|
val layoutManager = GridLayoutManager(this, span)
|
|
|
|
layoutManager.spanSizeLookup = GridLayoutSpan(adapter, span)
|
|
|
|
|
|
|
|
app_list.layoutManager = layoutManager
|
2019-12-11 15:16:35 +01:00
|
|
|
}
|
|
|
|
}
|
2020-04-12 17:17:51 +02:00
|
|
|
|
2020-04-24 13:39:13 +02:00
|
|
|
app_list.addOnScrollListener(object : RecyclerView.OnScrollListener() {
|
|
|
|
var y : Int = 0
|
|
|
|
|
|
|
|
override fun onScrolled(recyclerView : RecyclerView, dx : Int, dy : Int) {
|
|
|
|
y += dy
|
|
|
|
|
|
|
|
if (!app_list.isInTouchMode) {
|
|
|
|
if (y == 0)
|
|
|
|
toolbar_layout.setExpanded(true)
|
|
|
|
else
|
|
|
|
toolbar_layout.setExpanded(false)
|
|
|
|
}
|
|
|
|
|
|
|
|
super.onScrolled(recyclerView, dx, dy)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2019-12-02 14:39:08 +01:00
|
|
|
if (sharedPreferences.getString("search_location", "") == "") {
|
|
|
|
val intent = Intent(Intent.ACTION_OPEN_DOCUMENT_TREE)
|
2019-12-10 11:13:19 +01:00
|
|
|
intent.flags = Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION or Intent.FLAG_GRANT_PREFIX_URI_PERMISSION or Intent.FLAG_GRANT_READ_URI_PERMISSION
|
2020-04-12 22:29:19 +02:00
|
|
|
|
2019-12-10 11:13:19 +01:00
|
|
|
startActivityForResult(intent, 1)
|
2019-12-02 14:39:08 +01:00
|
|
|
} else
|
2020-04-12 22:29:19 +02:00
|
|
|
refreshAdapter(!sharedPreferences.getBoolean("refresh_required", false))
|
2019-12-02 14:39:08 +01:00
|
|
|
}
|
|
|
|
|
2020-04-12 22:29:19 +02:00
|
|
|
/**
|
|
|
|
* This inflates the layout for the menu [R.menu.toolbar_main] and sets up searching the logs
|
|
|
|
*/
|
2020-04-24 13:39:13 +02:00
|
|
|
override fun onCreateOptionsMenu(menu : Menu) : Boolean {
|
2019-12-02 14:39:08 +01:00
|
|
|
menuInflater.inflate(R.menu.toolbar_main, menu)
|
2020-04-12 22:29:19 +02:00
|
|
|
|
|
|
|
val searchView = menu.findItem(R.id.action_search_main).actionView as SearchView
|
|
|
|
|
2019-12-02 14:39:08 +01:00
|
|
|
searchView.setOnQueryTextListener(object : SearchView.OnQueryTextListener {
|
2020-04-24 13:39:13 +02:00
|
|
|
override fun onQueryTextSubmit(query : String) : Boolean {
|
2019-12-02 14:39:08 +01:00
|
|
|
searchView.clearFocus()
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2020-04-24 13:39:13 +02:00
|
|
|
override fun onQueryTextChange(newText : String) : Boolean {
|
2019-12-02 14:39:08 +01:00
|
|
|
adapter.filter.filter(newText)
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
})
|
2020-04-12 22:29:19 +02:00
|
|
|
|
2019-12-02 14:39:08 +01:00
|
|
|
return super.onCreateOptionsMenu(menu)
|
|
|
|
}
|
|
|
|
|
2020-04-12 22:29:19 +02:00
|
|
|
/**
|
|
|
|
* This handles on-click interaction with [R.id.log_fab], [R.id.open_fab], [R.id.app_item_linear] and [R.id.app_item_grid]
|
|
|
|
*/
|
2020-04-24 13:39:13 +02:00
|
|
|
override fun onClick(view : View) {
|
2019-12-10 11:13:19 +01:00
|
|
|
when (view.id) {
|
|
|
|
R.id.log_fab -> startActivity(Intent(this, LogActivity::class.java))
|
2020-04-12 22:29:19 +02:00
|
|
|
|
2019-12-10 11:13:19 +01:00
|
|
|
R.id.open_fab -> {
|
|
|
|
val intent = Intent(Intent.ACTION_OPEN_DOCUMENT)
|
|
|
|
intent.addCategory(Intent.CATEGORY_OPENABLE)
|
|
|
|
intent.type = "*/*"
|
2020-04-12 22:29:19 +02:00
|
|
|
|
2019-12-10 11:13:19 +01:00
|
|
|
startActivityForResult(intent, 2)
|
|
|
|
}
|
2020-04-12 22:29:19 +02:00
|
|
|
|
|
|
|
R.id.app_item_linear, R.id.app_item_grid -> {
|
2020-04-12 18:13:29 +02:00
|
|
|
val tag = view.tag
|
|
|
|
if (tag is AppItem) {
|
2020-04-17 22:32:17 +02:00
|
|
|
if (sharedPreferences.getBoolean("select_action", false)) {
|
|
|
|
val dialog = AppDialog(tag)
|
|
|
|
dialog.show(supportFragmentManager, "game")
|
|
|
|
} else {
|
|
|
|
val intent = Intent(this, EmulationActivity::class.java)
|
|
|
|
intent.data = tag.uri
|
|
|
|
startActivity(intent)
|
|
|
|
}
|
2020-04-12 18:13:29 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-12 22:29:19 +02:00
|
|
|
/**
|
|
|
|
* This handles long-click interaction with [R.id.app_item_linear] and [R.id.app_item_grid]
|
|
|
|
*/
|
2020-04-24 13:39:13 +02:00
|
|
|
override fun onLongClick(view : View?) : Boolean {
|
2020-04-12 18:13:29 +02:00
|
|
|
when (view?.id) {
|
2020-04-12 22:29:19 +02:00
|
|
|
R.id.app_item_linear, R.id.app_item_grid -> {
|
2020-04-12 18:13:29 +02:00
|
|
|
val tag = view.tag
|
|
|
|
if (tag is AppItem) {
|
|
|
|
val dialog = AppDialog(tag)
|
|
|
|
dialog.show(supportFragmentManager, "game")
|
2020-04-17 22:32:17 +02:00
|
|
|
|
2020-04-12 18:13:29 +02:00
|
|
|
return true
|
|
|
|
}
|
|
|
|
}
|
2019-12-10 11:13:19 +01:00
|
|
|
}
|
2020-04-12 18:13:29 +02:00
|
|
|
|
|
|
|
return false
|
2019-12-02 14:39:08 +01:00
|
|
|
}
|
|
|
|
|
2020-04-12 22:29:19 +02:00
|
|
|
/**
|
|
|
|
* This handles menu interaction for [R.id.action_settings] and [R.id.action_refresh]
|
|
|
|
*/
|
2020-04-24 13:39:13 +02:00
|
|
|
override fun onOptionsItemSelected(item : MenuItem) : Boolean {
|
2019-12-02 14:39:08 +01:00
|
|
|
return when (item.itemId) {
|
|
|
|
R.id.action_settings -> {
|
2020-02-15 10:38:17 +01:00
|
|
|
startActivityForResult(Intent(this, SettingsActivity::class.java), 3)
|
2019-12-02 14:39:08 +01:00
|
|
|
true
|
|
|
|
}
|
2020-04-12 22:29:19 +02:00
|
|
|
|
2019-12-02 14:39:08 +01:00
|
|
|
R.id.action_refresh -> {
|
2020-04-12 22:29:19 +02:00
|
|
|
refreshAdapter(false)
|
2019-12-02 14:39:08 +01:00
|
|
|
true
|
|
|
|
}
|
2020-04-12 22:29:19 +02:00
|
|
|
|
2019-12-02 14:39:08 +01:00
|
|
|
else -> super.onOptionsItemSelected(item)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-12 22:29:19 +02:00
|
|
|
/**
|
|
|
|
* This handles receiving activity result from [Intent.ACTION_OPEN_DOCUMENT_TREE], [Intent.ACTION_OPEN_DOCUMENT] and [SettingsActivity]
|
|
|
|
*/
|
2020-04-24 13:39:13 +02:00
|
|
|
override fun onActivityResult(requestCode : Int, resultCode : Int, intent : Intent?) {
|
2020-02-15 10:38:17 +01:00
|
|
|
super.onActivityResult(requestCode, resultCode, intent)
|
2020-04-12 22:29:19 +02:00
|
|
|
|
2019-12-02 14:39:08 +01:00
|
|
|
if (resultCode == RESULT_OK) {
|
2019-12-10 11:13:19 +01:00
|
|
|
when (requestCode) {
|
|
|
|
1 -> {
|
2020-02-15 10:38:17 +01:00
|
|
|
val uri = intent!!.data!!
|
2019-12-10 11:13:19 +01:00
|
|
|
contentResolver.takePersistableUriPermission(uri, Intent.FLAG_GRANT_READ_URI_PERMISSION)
|
|
|
|
sharedPreferences.edit().putString("search_location", uri.toString()).apply()
|
2020-04-12 22:29:19 +02:00
|
|
|
|
|
|
|
refreshAdapter(!sharedPreferences.getBoolean("refresh_required", false))
|
2019-12-10 11:13:19 +01:00
|
|
|
}
|
2020-04-12 22:29:19 +02:00
|
|
|
|
2019-12-10 11:13:19 +01:00
|
|
|
2 -> {
|
|
|
|
try {
|
2020-04-03 13:47:32 +02:00
|
|
|
val intentGame = Intent(this, EmulationActivity::class.java)
|
2020-04-12 22:29:19 +02:00
|
|
|
intentGame.data = intent!!.data!!
|
|
|
|
|
2019-12-11 01:14:16 +01:00
|
|
|
if (resultCode != 0)
|
2020-02-15 10:38:17 +01:00
|
|
|
startActivityForResult(intentGame, resultCode)
|
2019-12-11 01:14:16 +01:00
|
|
|
else
|
2020-02-15 10:38:17 +01:00
|
|
|
startActivity(intentGame)
|
2020-04-24 13:39:13 +02:00
|
|
|
} catch (e : Exception) {
|
2020-04-12 22:29:19 +02:00
|
|
|
Snackbar.make(findViewById(android.R.id.content), getString(R.string.error) + ": ${e.localizedMessage}", Snackbar.LENGTH_SHORT).show()
|
2019-12-10 11:13:19 +01:00
|
|
|
}
|
|
|
|
}
|
2020-04-12 22:29:19 +02:00
|
|
|
|
2020-02-15 10:38:17 +01:00
|
|
|
3 -> {
|
|
|
|
if (sharedPreferences.getBoolean("refresh_required", false))
|
2020-04-12 22:29:19 +02:00
|
|
|
refreshAdapter(false)
|
2020-02-15 10:38:17 +01:00
|
|
|
}
|
2019-12-02 14:39:08 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|