Bring back game banner loading code deleted in 3f21975
This commit is contained in:
parent
5ed0cf8e0e
commit
c2952c466f
|
@ -69,7 +69,7 @@ public final class GameAdapter extends RecyclerView.Adapter<GameViewHolder> impl
|
||||||
public void onBindViewHolder(GameViewHolder holder, int position)
|
public void onBindViewHolder(GameViewHolder holder, int position)
|
||||||
{
|
{
|
||||||
GameFile gameFile = mGameFiles.get(position);
|
GameFile gameFile = mGameFiles.get(position);
|
||||||
PicassoUtils.loadGameBanner(holder.imageScreenshot, gameFile);
|
PicassoUtils.loadGameCover(holder.imageScreenshot, gameFile);
|
||||||
|
|
||||||
holder.textGameTitle.setText(gameFile.getTitle());
|
holder.textGameTitle.setText(gameFile.getTitle());
|
||||||
holder.textCompany.setText(gameFile.getCompany());
|
holder.textCompany.setText(gameFile.getCompany());
|
||||||
|
|
|
@ -49,7 +49,7 @@ public final class GameRowPresenter extends Presenter
|
||||||
GameFile gameFile = (GameFile) item;
|
GameFile gameFile = (GameFile) item;
|
||||||
|
|
||||||
holder.imageScreenshot.setImageDrawable(null);
|
holder.imageScreenshot.setImageDrawable(null);
|
||||||
PicassoUtils.loadGameBanner(holder.imageScreenshot, gameFile);
|
PicassoUtils.loadGameCover(holder.imageScreenshot, gameFile);
|
||||||
|
|
||||||
holder.cardParent.setTitleText(gameFile.getTitle());
|
holder.cardParent.setTitleText(gameFile.getTitle());
|
||||||
holder.cardParent.setContentText(gameFile.getCompany());
|
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 @@ package org.dolphinemu.dolphinemu.utils;
|
||||||
|
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
import android.graphics.drawable.BitmapDrawable;
|
import android.graphics.drawable.BitmapDrawable;
|
||||||
|
import android.net.Uri;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
|
|
||||||
import com.squareup.picasso.Callback;
|
import com.squareup.picasso.Callback;
|
||||||
|
@ -15,6 +16,22 @@ import java.io.File;
|
||||||
public class PicassoUtils
|
public class PicassoUtils
|
||||||
{
|
{
|
||||||
public static void loadGameBanner(ImageView imageView, GameFile gameFile)
|
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());
|
File cover = new File(gameFile.getCustomCoverPath());
|
||||||
if (cover.exists())
|
if (cover.exists())
|
||||||
|
@ -41,10 +58,8 @@ public class PicassoUtils
|
||||||
.error(R.drawable.no_banner)
|
.error(R.drawable.no_banner)
|
||||||
.into(imageView);
|
.into(imageView);
|
||||||
}
|
}
|
||||||
/**
|
// GameTDB has a pretty close to complete collection for US/EN covers. First pass at getting
|
||||||
* 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.
|
||||||
* the cover will be by the disk's region, second will be the US cover, and third EN.
|
|
||||||
*/
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Picasso.get()
|
Picasso.get()
|
||||||
|
|
Loading…
Reference in New Issue