From 8710c6e14c6b36de011b7725803749cce8ddc304 Mon Sep 17 00:00:00 2001 From: Charles Lombardo Date: Sat, 11 Mar 2023 00:35:31 -0500 Subject: android: Convert AddDirectoryHelper to Kotlin --- .../yuzu/yuzu_emu/utils/AddDirectoryHelper.java | 38 ---------------------- .../org/yuzu/yuzu_emu/utils/AddDirectoryHelper.kt | 27 +++++++++++++++ 2 files changed, 27 insertions(+), 38 deletions(-) delete mode 100644 src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/AddDirectoryHelper.java create mode 100644 src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/AddDirectoryHelper.kt (limited to 'src') 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 + ) + } +} -- cgit v1.2.3