Skip to content

Instantly share code, notes, and snippets.

View gouravd's full-sized avatar

das_vicky gouravd

  • Cayfay
  • Hyderabad, India
View GitHub Profile
@gouravd
gouravd / gist:5c5a3b6deafcdf444349
Created December 8, 2014 00:08
PicassoScaleToFitHeightWidthTransform
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;
}
@gouravd
gouravd / PicassoTransformation2.4.0
Created December 7, 2014 13:57
FixedWidth VariableHeight Image resizing in Picasso 2.4.0
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);
@gouravd
gouravd / PicassoTransformation<2.4.0
Last active August 29, 2015 14:10
FixedWidth_VariableHeight_ImageResizing Transformation_Picasso
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
@gouravd
gouravd / NonSwipeableViewPager
Created December 5, 2014 08:47
Disable Swiping in ViewPager
/****
*** 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;