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 / 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;
@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 / 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 / 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 / gist:6cfe74c30c6dcbf47299
Created December 8, 2014 00:10
SquareImageView
public class SquareImageView extends ImageView
{
public SquareImageView(Context context)
{
super(context);
}
public SquareImageView(Context context, AttributeSet attrs)
{
super(context, attrs);
@gouravd
gouravd / gist:82dfe5a7634912094b41
Last active August 29, 2015 14:10
LongerRectangleImageView
public class SquareImageView extends ImageView
{
public SquareImageView(Context context)
{
super(context);
}
public SquareImageView(Context context, AttributeSet attrs)
{
super(context, attrs);
@gouravd
gouravd / RetrofitReadResponseBody
Created March 4, 2015 18:49
Retrofit read Response Body
package com.groupshoppy.helpers;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import retrofit.client.Response;
import retrofit.mime.MimeUtil;
import retrofit.mime.TypedByteArray;
import retrofit.mime.TypedInput;

Google's authentication-less on-the-fly image resizing service

I found it while poking around the Google+ HTML. Jotting down some notes felt like a good idea, so here goes. If you know more about this API, let me know, please!

(Word of warning: I spent ~30 minutes on both my experimentation and this here write-up, so it might not be the most thought-provoking, brilliant thing you read today.)

@gouravd
gouravd / ICloud.java
Last active August 29, 2015 14:19 — forked from funseiki/ICloud.java
// Uses retrofit to generate an implementation
public interface ICloud {
static String serviceProviderHeader = "X-Auth-Service-Provider";
static String credentialsAuthorizationHeader = "X-Verify-Credentials-Authorization";
@GET("/verify_credentials?provider=digits")
void verifyCredentials(
@Header(serviceProviderHeader) String serviceProvider,
@Header(credentialsAuthorizationHeader) String authorization,
@Query("id") long id,
@gouravd
gouravd / rvHideToobar
Created April 19, 2015 20:11
recyclerview hide toolbar
popularFeed.setOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
View toolbarholder = (getActivity().findViewById(R.id.hometoolbarholder));
View toolbar = (getActivity().findViewById(R.id.toolbar));
float y = recyclerView.getY();
super.onScrolled(recyclerView, dx, dy);
if (y < dy) {
toolbarholder.animate()
.translationY(-toolbar.getBottom())