Skip to content

Instantly share code, notes, and snippets.

View akshaydashrath's full-sized avatar

Akshay Dashrath akshaydashrath

View GitHub Profile
@akshaydashrath
akshaydashrath / ViewVisibilityAnimator.java
Last active April 17, 2016 09:42
Collapse and expand a view on Android with a clean animation
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.Animation;
import android.view.animation.Transformation;
public class ViewVisibilityAnimator {
private static final String VISIBILITY = "VISIBILITY";
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2015 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
public class AccountAuthenticator extends AbstractAccountAuthenticator {
private final Context context;
@Inject @ClientId String clientId;
@Inject @ClientSecret String clientSecret;
@Inject ApiService apiService;
public AccountAuthenticator(Context context) {
super(context);
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.layoutfab);
//Outline
int size = getResources().getDimensionPixelSize(R.dimen.fab_size);
Outline outline = new Outline();
/*
* Copyright (C) 2014 Chris Banes
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@akshaydashrath
akshaydashrath / gist:10119943
Last active March 25, 2024 13:54
Signing HttpUrlConnection using OkHttpClient and Retrofit
@Override
public Response execute(Request request) throws IOException {
HttpsURLConnection connection = (HttpsURLConnection) super.openConnection(request);
try {
prepareRequest(connection, request);
} catch (Exception e) {
e.printStackTrace();
}
return readResponse(connection);
}
@akshaydashrath
akshaydashrath / ToggleImageButton
Created March 20, 2014 11:49
A ToggleImageButton for Android
import android.content.Context;
import android.content.res.TypedArray;
import android.os.Bundle;
import android.os.Parcelable;
import android.util.AttributeSet;
import android.view.View;
import android.widget.Checkable;
import android.widget.ImageButton;
public class ToggleImageButton extends ImageButton implements Checkable {
import android.media.MediaPlayer;
import android.media.MediaPlayer.OnCompletionListener;
import android.media.MediaPlayer.OnErrorListener;
import android.media.MediaPlayer.OnPreparedListener;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.webkit.WebChromeClient;
import android.widget.FrameLayout;
import android.widget.VideoView;
package com.psrivastava.deviceframegenerator.widget;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.TextView;
import android.widget.Toast;
@akshaydashrath
akshaydashrath / ActionBarDrawerToggleCompat
Created June 7, 2013 06:30
Support for ActionbarSherlock with the new DrawerLayout
import android.app.Activity;
import android.support.v4.app.ActionBarDrawerToggle;
import android.support.v4.view.GravityCompat;
import android.support.v4.widget.DrawerLayout;
import com.actionbarsherlock.view.MenuItem;
/**
* Created by akshay on 06/06/2013.
*/
public class ActionBarDrawerToggleCompat extends ActionBarDrawerToggle {