android: Picasso: Use newer version and some minor cleanup.

This commit is contained in:
bunnei 2019-08-24 13:08:52 -04:00
parent 14655ca14e
commit 9217c10db0
6 changed files with 22 additions and 44 deletions

View File

@ -117,7 +117,7 @@ dependencies {
implementation 'de.hdodenhof:circleimageview:2.1.0' implementation 'de.hdodenhof:circleimageview:2.1.0'
// For loading huge screenshots from the disk. // For loading huge screenshots from the disk.
implementation 'com.squareup.picasso:picasso:2.5.2' implementation 'com.squareup.picasso:picasso:2.71828'
// Allows FRP-style asynchronous operations in Android. // Allows FRP-style asynchronous operations in Android.
implementation 'io.reactivex:rxandroid:1.2.1' implementation 'io.reactivex:rxandroid:1.2.1'

View File

@ -193,7 +193,7 @@ public final class EmulationActivity extends AppCompatActivity {
// the animation until we say so. // the animation until we say so.
postponeEnterTransition(); postponeEnterTransition();
Picasso.with(this) Picasso.get()
.load(mScreenPath) .load(mScreenPath)
.noFade() .noFade()
.noPlaceholder() .noPlaceholder()
@ -202,9 +202,8 @@ public final class EmulationActivity extends AppCompatActivity {
public void onSuccess() { public void onSuccess() {
supportStartPostponedEnterTransition(); supportStartPostponedEnterTransition();
} }
@Override @Override
public void onError() { public void onError(Exception ex) {
// Still have to do this, or else the app will crash. // Still have to do this, or else the app will crash.
supportStartPostponedEnterTransition(); supportStartPostponedEnterTransition();
} }
@ -309,10 +308,10 @@ public final class EmulationActivity extends AppCompatActivity {
public void exitWithAnimation() { public void exitWithAnimation() {
runOnUiThread(() -> runOnUiThread(() ->
{ {
Picasso.with(EmulationActivity.this) Picasso.get()
.invalidate(mScreenPath); .invalidate(mScreenPath);
Picasso.with(EmulationActivity.this) Picasso.get()
.load(mScreenPath) .load(mScreenPath)
.noFade() .noFade()
.noPlaceholder() .noPlaceholder()
@ -323,7 +322,7 @@ public final class EmulationActivity extends AppCompatActivity {
} }
@Override @Override
public void onError() { public void onError(Exception ex) {
finish(); finish();
} }
}); });

View File

@ -70,8 +70,7 @@ public final class GameAdapter extends RecyclerView.Adapter<GameViewHolder> impl
public void onBindViewHolder(GameViewHolder holder, int position) { public void onBindViewHolder(GameViewHolder holder, int position) {
if (mDatasetValid) { if (mDatasetValid) {
if (mCursor.moveToPosition(position)) { if (mCursor.moveToPosition(position)) {
String screenPath = mCursor.getString(GameDatabase.GAME_COLUMN_SCREENSHOT_PATH); PicassoUtils.loadGameBanner(holder.imageScreenshot,
PicassoUtils.loadGameBanner(holder.imageScreenshot, screenPath,
mCursor.getString(GameDatabase.GAME_COLUMN_PATH)); mCursor.getString(GameDatabase.GAME_COLUMN_PATH));
holder.textGameTitle.setText(mCursor.getString(GameDatabase.GAME_COLUMN_TITLE)); holder.textGameTitle.setText(mCursor.getString(GameDatabase.GAME_COLUMN_TITLE));

View File

@ -39,10 +39,8 @@ public final class GameRowPresenter extends Presenter {
TvGameViewHolder holder = (TvGameViewHolder) viewHolder; TvGameViewHolder holder = (TvGameViewHolder) viewHolder;
Game game = (Game) item; Game game = (Game) item;
String screenPath = game.getScreenshotPath();
holder.imageScreenshot.setImageDrawable(null); holder.imageScreenshot.setImageDrawable(null);
PicassoUtils.loadGameBanner(holder.imageScreenshot, screenPath, game.getPath()); PicassoUtils.loadGameBanner(holder.imageScreenshot, game.getPath());
holder.cardParent.setTitleText(game.getTitle()); holder.cardParent.setTitleText(game.getTitle());
holder.cardParent.setContentText(game.getCompany()); holder.cardParent.setContentText(game.getCompany());

View File

@ -78,7 +78,7 @@ public final class GameDetailsDialog extends DialogFragment {
}); });
// Fill in the view contents. // Fill in the view contents.
Picasso.with(imageGameScreen.getContext()) Picasso.get()
.load(getArguments().getString(ARG_GAME_SCREENSHOT_PATH)) .load(getArguments().getString(ARG_GAME_SCREENSHOT_PATH))
.fit() .fit()
.centerCrop() .centerCrop()

View File

@ -8,38 +8,20 @@ import com.squareup.picasso.Picasso;
import org.citra.citra_android.R; import org.citra.citra_android.R;
import java.io.File;
import java.net.URI;
public class PicassoUtils { public class PicassoUtils {
public static void loadGameBanner(ImageView imageView, String screenshotPath, String gamePath) { public static void loadGameBanner(ImageView imageView, String gamePath) {
File file = new File(URI.create(screenshotPath.replaceAll(" ", "%20")));
if (file.exists()) {
// Fill in the view contents.
Picasso.with(imageView.getContext())
.load(screenshotPath)
.fit()
.centerCrop()
.noFade()
.noPlaceholder()
.config(Bitmap.Config.RGB_565)
.error(R.drawable.no_banner)
.into(imageView);
} else {
Picasso picassoInstance = new Picasso.Builder(imageView.getContext()) Picasso picassoInstance = new Picasso.Builder(imageView.getContext())
.addRequestHandler(new GameBannerRequestHandler()) .addRequestHandler(new GameBannerRequestHandler())
.build(); .build();
picassoInstance picassoInstance
.load(Uri.parse("iso:/" + gamePath)) .load(Uri.parse("iso:/" + gamePath))
.fit()
.noFade() .noFade()
.noPlaceholder() .noPlaceholder()
.fit()
.centerInside()
.config(Bitmap.Config.RGB_565) .config(Bitmap.Config.RGB_565)
.error(R.drawable.no_banner) .error(R.drawable.no_banner)
.into(imageView); .into(imageView);
} }
}
} }