Skip to content
Permalink
Browse files

Bring back game banner loading code deleted in 3f21975

  • Loading branch information
JosJuice committed Jun 16, 2019
1 parent 5ed0cf8 commit c2952c466f7945428d12e249a9675995de810537
@@ -69,7 +69,7 @@ public GameViewHolder onCreateViewHolder(ViewGroup parent, int viewType)
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());
@@ -49,7 +49,7 @@ public void onBindViewHolder(ViewHolder viewHolder, Object item)
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());
@@ -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);
}
}
@@ -2,6 +2,7 @@

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 @@
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 @@ else if ((cover = new File(gameFile.getCoverPath())).exists())
.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()

0 comments on commit c2952c4

Please sign in to comment.
You can’t perform that action at this time.