android: Picasso: Use newer version and some minor cleanup.
This commit is contained in:
parent
14655ca14e
commit
9217c10db0
@ -117,7 +117,7 @@ dependencies {
|
||||
implementation 'de.hdodenhof:circleimageview:2.1.0'
|
||||
|
||||
// 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.
|
||||
implementation 'io.reactivex:rxandroid:1.2.1'
|
||||
|
@ -193,7 +193,7 @@ public final class EmulationActivity extends AppCompatActivity {
|
||||
// the animation until we say so.
|
||||
postponeEnterTransition();
|
||||
|
||||
Picasso.with(this)
|
||||
Picasso.get()
|
||||
.load(mScreenPath)
|
||||
.noFade()
|
||||
.noPlaceholder()
|
||||
@ -202,9 +202,8 @@ public final class EmulationActivity extends AppCompatActivity {
|
||||
public void onSuccess() {
|
||||
supportStartPostponedEnterTransition();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError() {
|
||||
public void onError(Exception ex) {
|
||||
// Still have to do this, or else the app will crash.
|
||||
supportStartPostponedEnterTransition();
|
||||
}
|
||||
@ -309,10 +308,10 @@ public final class EmulationActivity extends AppCompatActivity {
|
||||
public void exitWithAnimation() {
|
||||
runOnUiThread(() ->
|
||||
{
|
||||
Picasso.with(EmulationActivity.this)
|
||||
Picasso.get()
|
||||
.invalidate(mScreenPath);
|
||||
|
||||
Picasso.with(EmulationActivity.this)
|
||||
Picasso.get()
|
||||
.load(mScreenPath)
|
||||
.noFade()
|
||||
.noPlaceholder()
|
||||
@ -323,7 +322,7 @@ public final class EmulationActivity extends AppCompatActivity {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError() {
|
||||
public void onError(Exception ex) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
|
@ -70,8 +70,7 @@ public final class GameAdapter extends RecyclerView.Adapter<GameViewHolder> impl
|
||||
public void onBindViewHolder(GameViewHolder holder, int position) {
|
||||
if (mDatasetValid) {
|
||||
if (mCursor.moveToPosition(position)) {
|
||||
String screenPath = mCursor.getString(GameDatabase.GAME_COLUMN_SCREENSHOT_PATH);
|
||||
PicassoUtils.loadGameBanner(holder.imageScreenshot, screenPath,
|
||||
PicassoUtils.loadGameBanner(holder.imageScreenshot,
|
||||
mCursor.getString(GameDatabase.GAME_COLUMN_PATH));
|
||||
|
||||
holder.textGameTitle.setText(mCursor.getString(GameDatabase.GAME_COLUMN_TITLE));
|
||||
|
@ -39,10 +39,8 @@ public final class GameRowPresenter extends Presenter {
|
||||
TvGameViewHolder holder = (TvGameViewHolder) viewHolder;
|
||||
Game game = (Game) item;
|
||||
|
||||
String screenPath = game.getScreenshotPath();
|
||||
|
||||
holder.imageScreenshot.setImageDrawable(null);
|
||||
PicassoUtils.loadGameBanner(holder.imageScreenshot, screenPath, game.getPath());
|
||||
PicassoUtils.loadGameBanner(holder.imageScreenshot, game.getPath());
|
||||
|
||||
holder.cardParent.setTitleText(game.getTitle());
|
||||
holder.cardParent.setContentText(game.getCompany());
|
||||
|
@ -78,7 +78,7 @@ public final class GameDetailsDialog extends DialogFragment {
|
||||
});
|
||||
|
||||
// Fill in the view contents.
|
||||
Picasso.with(imageGameScreen.getContext())
|
||||
Picasso.get()
|
||||
.load(getArguments().getString(ARG_GAME_SCREENSHOT_PATH))
|
||||
.fit()
|
||||
.centerCrop()
|
||||
|
@ -8,38 +8,20 @@ import com.squareup.picasso.Picasso;
|
||||
|
||||
import org.citra.citra_android.R;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.URI;
|
||||
|
||||
public class PicassoUtils {
|
||||
public static void loadGameBanner(ImageView imageView, String screenshotPath, 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())
|
||||
.addRequestHandler(new GameBannerRequestHandler())
|
||||
.build();
|
||||
|
||||
picassoInstance
|
||||
.load(Uri.parse("iso:/" + gamePath))
|
||||
.fit()
|
||||
.noFade()
|
||||
.noPlaceholder()
|
||||
.config(Bitmap.Config.RGB_565)
|
||||
.error(R.drawable.no_banner)
|
||||
.into(imageView);
|
||||
}
|
||||
|
||||
public static void loadGameBanner(ImageView imageView, String gamePath) {
|
||||
Picasso picassoInstance = new Picasso.Builder(imageView.getContext())
|
||||
.addRequestHandler(new GameBannerRequestHandler())
|
||||
.build();
|
||||
|
||||
picassoInstance
|
||||
.load(Uri.parse("iso:/" + gamePath))
|
||||
.noFade()
|
||||
.noPlaceholder()
|
||||
.fit()
|
||||
.centerInside()
|
||||
.config(Bitmap.Config.RGB_565)
|
||||
.error(R.drawable.no_banner)
|
||||
.into(imageView);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user