diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/adapters/GameAdapter.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/adapters/GameAdapter.java index 82d97bee21..3f463b372a 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/adapters/GameAdapter.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/adapters/GameAdapter.java @@ -69,7 +69,7 @@ public final class GameAdapter extends RecyclerView.Adapter impl public void onBindViewHolder(GameViewHolder holder, int position) { GameFile gameFile = mGameFiles.get(position); - PicassoUtils.loadGameBanner(holder.imageScreenshot, gameFile); + PicassoUtils.loadGameCover(holder.imageScreenshot, gameFile); holder.textGameTitle.setText(gameFile.getTitle()); holder.textCompany.setText(gameFile.getCompany()); diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/adapters/GameRowPresenter.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/adapters/GameRowPresenter.java index 6fef4a941f..d2d720db53 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/adapters/GameRowPresenter.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/adapters/GameRowPresenter.java @@ -49,7 +49,7 @@ public final class GameRowPresenter extends Presenter GameFile gameFile = (GameFile) item; holder.imageScreenshot.setImageDrawable(null); - PicassoUtils.loadGameBanner(holder.imageScreenshot, gameFile); + PicassoUtils.loadGameCover(holder.imageScreenshot, gameFile); holder.cardParent.setTitleText(gameFile.getTitle()); holder.cardParent.setContentText(gameFile.getCompany()); diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/utils/GameBannerRequestHandler.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/utils/GameBannerRequestHandler.java new file mode 100644 index 0000000000..81362404d1 --- /dev/null +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/utils/GameBannerRequestHandler.java @@ -0,0 +1,36 @@ +package org.dolphinemu.dolphinemu.utils; + +import android.graphics.Bitmap; + +import com.squareup.picasso.Picasso; +import com.squareup.picasso.Request; +import com.squareup.picasso.RequestHandler; + +import org.dolphinemu.dolphinemu.model.GameFile; + +public class GameBannerRequestHandler extends RequestHandler +{ + private GameFile mGameFile; + + public GameBannerRequestHandler(GameFile gameFile) + { + mGameFile = gameFile; + } + + @Override + public boolean canHandleRequest(Request data) + { + return true; + } + + @Override + public Result load(Request request, int networkPolicy) + { + int[] vector = mGameFile.getBanner(); + int width = mGameFile.getBannerWidth(); + int height = mGameFile.getBannerHeight(); + Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); + bitmap.setPixels(vector, 0, width, 0, 0, width, height); + return new Result(bitmap, Picasso.LoadedFrom.DISK); + } +} diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/utils/PicassoUtils.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/utils/PicassoUtils.java index cc272e72f9..4dc0c200a6 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/utils/PicassoUtils.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/utils/PicassoUtils.java @@ -2,6 +2,7 @@ package org.dolphinemu.dolphinemu.utils; import android.graphics.Bitmap; import android.graphics.drawable.BitmapDrawable; +import android.net.Uri; import android.widget.ImageView; import com.squareup.picasso.Callback; @@ -15,6 +16,22 @@ import java.io.File; public class PicassoUtils { public static void loadGameBanner(ImageView imageView, GameFile gameFile) + { + Picasso picassoInstance = new Picasso.Builder(imageView.getContext()) + .addRequestHandler(new GameBannerRequestHandler(gameFile)) + .build(); + + picassoInstance + .load(Uri.parse("iso:/" + gameFile.getPath())) + .fit() + .noFade() + .noPlaceholder() + .config(Bitmap.Config.RGB_565) + .error(R.drawable.no_banner) + .into(imageView); + } + + public static void loadGameCover(ImageView imageView, GameFile gameFile) { File cover = new File(gameFile.getCustomCoverPath()); if (cover.exists()) @@ -41,10 +58,8 @@ public class PicassoUtils .error(R.drawable.no_banner) .into(imageView); } - /** - * GameTDB has a pretty close to complete collection for US/EN covers. First pass at getting - * the cover will be by the disk's region, second will be the US cover, and third EN. - */ + // GameTDB has a pretty close to complete collection for US/EN covers. First pass at getting + // the cover will be by the disk's region, second will be the US cover, and third EN. else { Picasso.get()