diff options
author | Charles Lombardo <clombardo169@gmail.com> | 2023-03-11 06:35:31 +0100 |
---|---|---|
committer | bunnei <bunneidev@gmail.com> | 2023-06-03 09:05:40 +0200 |
commit | 8710c6e14c6b36de011b7725803749cce8ddc304 (patch) | |
tree | c32a24bccdd34ec9edd5faccfbc76dde368e4d3f /src | |
parent | android: Convert PlatformGamesView to Kotlin (diff) | |
download | yuzu-8710c6e14c6b36de011b7725803749cce8ddc304.tar yuzu-8710c6e14c6b36de011b7725803749cce8ddc304.tar.gz yuzu-8710c6e14c6b36de011b7725803749cce8ddc304.tar.bz2 yuzu-8710c6e14c6b36de011b7725803749cce8ddc304.tar.lz yuzu-8710c6e14c6b36de011b7725803749cce8ddc304.tar.xz yuzu-8710c6e14c6b36de011b7725803749cce8ddc304.tar.zst yuzu-8710c6e14c6b36de011b7725803749cce8ddc304.zip |
Diffstat (limited to 'src')
-rw-r--r-- | src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/AddDirectoryHelper.java | 38 | ||||
-rw-r--r-- | src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/AddDirectoryHelper.kt | 27 |
2 files changed, 27 insertions, 38 deletions
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/AddDirectoryHelper.java b/src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/AddDirectoryHelper.java deleted file mode 100644 index 2a90e75d8..000000000 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/AddDirectoryHelper.java +++ /dev/null @@ -1,38 +0,0 @@ -package org.yuzu.yuzu_emu.utils; - -import android.content.AsyncQueryHandler; -import android.content.ContentValues; -import android.content.Context; -import android.net.Uri; - -import org.yuzu.yuzu_emu.model.GameDatabase; -import org.yuzu.yuzu_emu.model.GameProvider; - -public class AddDirectoryHelper { - private Context mContext; - - public AddDirectoryHelper(Context context) { - this.mContext = context; - } - - public void addDirectory(String dir, AddDirectoryListener addDirectoryListener) { - AsyncQueryHandler handler = new AsyncQueryHandler(mContext.getContentResolver()) { - @Override - protected void onInsertComplete(int token, Object cookie, Uri uri) { - addDirectoryListener.onDirectoryAdded(); - } - }; - - ContentValues file = new ContentValues(); - file.put(GameDatabase.KEY_FOLDER_PATH, dir); - - handler.startInsert(0, // We don't need to identify this call to the handler - null, // We don't need to pass additional data to the handler - GameProvider.URI_FOLDER, // Tell the GameProvider we are adding a folder - file); - } - - public interface AddDirectoryListener { - void onDirectoryAdded(); - } -} diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/AddDirectoryHelper.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/AddDirectoryHelper.kt new file mode 100644 index 000000000..2a1994db4 --- /dev/null +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/AddDirectoryHelper.kt @@ -0,0 +1,27 @@ +package org.yuzu.yuzu_emu.utils + +import android.content.AsyncQueryHandler +import android.content.ContentValues +import android.content.Context +import android.net.Uri +import org.yuzu.yuzu_emu.model.GameDatabase +import org.yuzu.yuzu_emu.model.GameProvider + +class AddDirectoryHelper(private val context: Context) { + fun addDirectory(dir: String?, onAddUnit: () -> Unit) { + val handler: AsyncQueryHandler = object : AsyncQueryHandler(context.contentResolver) { + override fun onInsertComplete(token: Int, cookie: Any?, uri: Uri) { + onAddUnit.invoke() + } + } + + val file = ContentValues() + file.put(GameDatabase.KEY_FOLDER_PATH, dir) + handler.startInsert( + 0, // We don't need to identify this call to the handler + null, // We don't need to pass additional data to the handler + GameProvider.URI_FOLDER, // Tell the GameProvider we are adding a folder + file + ) + } +} |