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 2a90e75d82..0000000000 --- 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 0000000000..2a1994db43 --- /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 + ) + } +}