diff options
| author | 2023-03-11 00:35:31 -0500 | |
|---|---|---|
| committer | 2023-06-03 00:05:40 -0700 | |
| commit | 8710c6e14c6b36de011b7725803749cce8ddc304 (patch) | |
| tree | c32a24bccdd34ec9edd5faccfbc76dde368e4d3f /src/android | |
| parent | android: Convert PlatformGamesView to Kotlin (diff) | |
| download | yuzu-8710c6e14c6b36de011b7725803749cce8ddc304.tar.gz yuzu-8710c6e14c6b36de011b7725803749cce8ddc304.tar.xz yuzu-8710c6e14c6b36de011b7725803749cce8ddc304.zip | |
android: Convert AddDirectoryHelper to Kotlin
Diffstat (limited to 'src/android')
| -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 @@ | |||
| 1 | package org.yuzu.yuzu_emu.utils; | ||
| 2 | |||
| 3 | import android.content.AsyncQueryHandler; | ||
| 4 | import android.content.ContentValues; | ||
| 5 | import android.content.Context; | ||
| 6 | import android.net.Uri; | ||
| 7 | |||
| 8 | import org.yuzu.yuzu_emu.model.GameDatabase; | ||
| 9 | import org.yuzu.yuzu_emu.model.GameProvider; | ||
| 10 | |||
| 11 | public class AddDirectoryHelper { | ||
| 12 | private Context mContext; | ||
| 13 | |||
| 14 | public AddDirectoryHelper(Context context) { | ||
| 15 | this.mContext = context; | ||
| 16 | } | ||
| 17 | |||
| 18 | public void addDirectory(String dir, AddDirectoryListener addDirectoryListener) { | ||
| 19 | AsyncQueryHandler handler = new AsyncQueryHandler(mContext.getContentResolver()) { | ||
| 20 | @Override | ||
| 21 | protected void onInsertComplete(int token, Object cookie, Uri uri) { | ||
| 22 | addDirectoryListener.onDirectoryAdded(); | ||
| 23 | } | ||
| 24 | }; | ||
| 25 | |||
| 26 | ContentValues file = new ContentValues(); | ||
| 27 | file.put(GameDatabase.KEY_FOLDER_PATH, dir); | ||
| 28 | |||
| 29 | handler.startInsert(0, // We don't need to identify this call to the handler | ||
| 30 | null, // We don't need to pass additional data to the handler | ||
| 31 | GameProvider.URI_FOLDER, // Tell the GameProvider we are adding a folder | ||
| 32 | file); | ||
| 33 | } | ||
| 34 | |||
| 35 | public interface AddDirectoryListener { | ||
| 36 | void onDirectoryAdded(); | ||
| 37 | } | ||
| 38 | } | ||
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 @@ | |||
| 1 | package org.yuzu.yuzu_emu.utils | ||
| 2 | |||
| 3 | import android.content.AsyncQueryHandler | ||
| 4 | import android.content.ContentValues | ||
| 5 | import android.content.Context | ||
| 6 | import android.net.Uri | ||
| 7 | import org.yuzu.yuzu_emu.model.GameDatabase | ||
| 8 | import org.yuzu.yuzu_emu.model.GameProvider | ||
| 9 | |||
| 10 | class AddDirectoryHelper(private val context: Context) { | ||
| 11 | fun addDirectory(dir: String?, onAddUnit: () -> Unit) { | ||
| 12 | val handler: AsyncQueryHandler = object : AsyncQueryHandler(context.contentResolver) { | ||
| 13 | override fun onInsertComplete(token: Int, cookie: Any?, uri: Uri) { | ||
| 14 | onAddUnit.invoke() | ||
| 15 | } | ||
| 16 | } | ||
| 17 | |||
| 18 | val file = ContentValues() | ||
| 19 | file.put(GameDatabase.KEY_FOLDER_PATH, dir) | ||
| 20 | handler.startInsert( | ||
| 21 | 0, // We don't need to identify this call to the handler | ||
| 22 | null, // We don't need to pass additional data to the handler | ||
| 23 | GameProvider.URI_FOLDER, // Tell the GameProvider we are adding a folder | ||
| 24 | file | ||
| 25 | ) | ||
| 26 | } | ||
| 27 | } | ||