Skip to content

Instantly share code, notes, and snippets.

View aashreys's full-sized avatar
zooming...

Aashrey Sharma aashreys

zooming...
View GitHub Profile
@aashreys
aashreys / build.gradle
Created May 18, 2016 16:19
build.gradle script additions to allow uploading debug and release builds to different maven repos.
configurations {
debugArchives
releaseArchives
}
artifacts {
def path = "${project.rootDir}/library/build/outputs/aar/"
debugArchives file: file(path + "${project.getName()}-debug.aar")
releaseArchives file: file(path + "${project.getName()}-release.aar")
}
@aashreys
aashreys / ForegroundImageView.java
Created November 23, 2016 03:28
Modified ForegroundImageView from Jake Wharton's original code. Implemented #drawableHotspotChanged() to start ripple effect from a touch point.
package com.aashreys.walls.ui.utils;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.util.AttributeSet;
import android.widget.ImageView;
@aashreys
aashreys / QuickActionView.java
Last active July 3, 2017 07:00
A simple view for providing iOS's Assistive Touch capabilities to your application's screens.
import android.animation.Animator;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.content.Context;
import android.content.res.TypedArray;
import android.os.Build;
import android.support.annotation.ColorRes;
import android.support.annotation.DrawableRes;
@aashreys
aashreys / ChromeTabUtils.java
Last active November 20, 2019 06:00
Simple helper to check if Chrome Tabs is supported on a device and open urls.
public class ChromeTabUtils {
public static void openUrl(Context context, String url) {
if (isChromeTabSupported(context)) {
// Build intent to open Chrome Tab
CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder();
builder.setToolbarColor(getColor(context, R.color.toolbarBackground));
CustomTabsIntent customTabsIntent = builder.build();
customTabsIntent.launchUrl(context, Uri.parse(url));
} else {
@aashreys
aashreys / resources.xml
Created February 5, 2017 18:05
Unbounded ripples which gracefully fallback to the default selector in pre-lollipop devices.
<?xml version="1.0" encoding="utf-8"?>
<resources>
<attr name="selectableItemBackgroundBorderlessCompat" />
</resources>
@aashreys
aashreys / EndlessScrollAdapter.java
Last active February 9, 2017 13:23
A RecyclerView.Adapter extension which adds a callback to assist in the creation of endlessly scrollable lists i.e. lists which load more data as the user reaches the end.
public class EndlessScrollAdapter extends RecyclerView.Adapter<EndlessScrollAdapter.ImageViewHolder> {
private static final String TAG = EndlessScrollAdapter.class.getSimpleName();
private int loadingThreshold = 5; // Default value
private LoadMoreCallback loadMoreCallback;
public EndlessScrollAdapter() {}
@aashreys
aashreys / dimens.xml
Created March 13, 2017 12:20
Standard dimensions for Android
<resources>
<dimen name="spacing_xxs">2dp</dimen>
<dimen name="spacing_xs">4dp</dimen>
<dimen name="spacing_small">8dp</dimen>
<dimen name="spacing_medium">16dp</dimen>
<dimen name="spacing_large">24dp</dimen>
<dimen name="spacing_xl">32dp</dimen>
<dimen name="spacing_xxl">48dp</dimen>
<dimen name="spacing_xxxl">72dp</dimen>
@aashreys
aashreys / AspectRatioImageView.java
Created April 20, 2017 20:33
An ImageView which can be locked to an aspect ratio.
public class AspectRatioImageView extends ImageView {
private float widthToHeightRatio;
public AspectRatioImageView(Context context) {
super(context);
}
public AspectRatioImageView(Context context, AttributeSet attrs) {
super(context, attrs);
@aashreys
aashreys / Migrator.java
Last active April 24, 2017 04:01
A class for managing application migration across updates
/**
* A simple class for managing application migration across updates.
*
* Created by aashreys on 24/04/17.
*/
public class Migrator {
private static final String KEY_LAST_VERSION = "migrator_key_last_version";
@aashreys
aashreys / FlickrBaseEncoder.java
Created April 24, 2017 14:50
A class to encode number for use with Flickr's short url template.
/*
* Copyright {2017} {Aashrey Kamal Sharma}
*
* 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