This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class ScaleToFitWidthHeightTransform implements com.squareup.picasso.Transformation { | |
private int mSize; // This has to be the maxHeight of the ImageView | |
private boolean isHeightScale; | |
public ScaleToFitWidthHeightTransform(int size, boolean isHeightScale){ | |
mSize =size; | |
this.isHeightScale = isHeightScale; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
yourview.getViewTreeObserver() | |
.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { | |
// Wait until layout to call Picasso | |
@Override | |
public void onGlobalLayout() { | |
// Ensure we call this only once | |
yourview.getViewTreeObserver() | |
.removeOnGlobalLayoutListener(this); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
com.squareup.picasso.Transformation transformation = new com.squareup.picasso.Transformation() { | |
@Override | |
public Bitmap transform(Bitmap source) { | |
int targetWidth = yourview.getWidth(); | |
double aspectRatio = (double) source.getHeight() / (double) source.getWidth(); | |
int targetHeight = (int) (targetWidth * aspectRatio); | |
Bitmap result = Bitmap.createScaledBitmap(source, targetWidth, targetHeight, false); | |
if (result != source) { | |
// Same bitmap is returned if sizes are the same |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/**** | |
*** use this class NonSwipeableViewPager instead of the standard ViewPager | |
****/ | |
package com.groupshoppy.helpers; | |
import android.content.Context; | |
import android.support.v4.view.ViewPager; | |
import android.util.AttributeSet; | |
import android.view.MotionEvent; |
NewerOlder