From bf0c38302498d93083fc243a6334c20e28f31ccc Mon Sep 17 00:00:00 2001 From: Charles Lombardo Date: Sat, 11 Mar 2023 00:37:36 -0500 Subject: [PATCH] android: Convert GameIconRequestHandler to Kotlin --- .../utils/GameIconRequestHandler.java | 29 ------------------- .../yuzu_emu/utils/GameIconRequestHandler.kt | 22 ++++++++++++++ 2 files changed, 22 insertions(+), 29 deletions(-) delete mode 100644 src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/GameIconRequestHandler.java create mode 100644 src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/GameIconRequestHandler.kt diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/GameIconRequestHandler.java b/src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/GameIconRequestHandler.java deleted file mode 100644 index fd43575de..000000000 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/GameIconRequestHandler.java +++ /dev/null @@ -1,29 +0,0 @@ -package org.yuzu.yuzu_emu.utils; - -import android.graphics.Bitmap; -import android.graphics.BitmapFactory; - -import com.squareup.picasso.Picasso; -import com.squareup.picasso.Request; -import com.squareup.picasso.RequestHandler; - -import org.yuzu.yuzu_emu.NativeLibrary; - -import java.nio.IntBuffer; - -public class GameIconRequestHandler extends RequestHandler { - @Override - public boolean canHandleRequest(Request data) { - return "content".equals(data.uri.getScheme()); - } - - @Override - public Result load(Request request, int networkPolicy) { - String gamePath = request.uri.toString(); - byte[] data = NativeLibrary.GetIcon(gamePath); - BitmapFactory.Options options = new BitmapFactory.Options(); - options.inMutable = true; - Bitmap bitmap = BitmapFactory.decodeByteArray(data, 0, data.length, options); - return new Result(bitmap, Picasso.LoadedFrom.DISK); - } -} diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/GameIconRequestHandler.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/GameIconRequestHandler.kt new file mode 100644 index 000000000..f5a535327 --- /dev/null +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/GameIconRequestHandler.kt @@ -0,0 +1,22 @@ +package org.yuzu.yuzu_emu.utils + +import android.graphics.BitmapFactory +import com.squareup.picasso.Picasso +import com.squareup.picasso.Request +import com.squareup.picasso.RequestHandler +import org.yuzu.yuzu_emu.NativeLibrary + +class GameIconRequestHandler : RequestHandler() { + override fun canHandleRequest(data: Request): Boolean { + return "content" == data.uri.scheme + } + + override fun load(request: Request, networkPolicy: Int): Result { + val gamePath = request.uri.toString() + val data = NativeLibrary.GetIcon(gamePath) + val options = BitmapFactory.Options() + options.inMutable = true + val bitmap = BitmapFactory.decodeByteArray(data, 0, data.size, options) + return Result(bitmap, Picasso.LoadedFrom.DISK) + } +}