android: Convert GameIconRequestHandler to Kotlin

This commit is contained in:
Charles Lombardo 2023-03-11 00:37:36 -05:00 committed by bunnei
parent 5d5233ec32
commit bf0c383024
2 changed files with 22 additions and 29 deletions

View File

@ -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);
}
}

View File

@ -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)
}
}