Skip to content

Instantly share code, notes, and snippets.

View ryanamaral's full-sized avatar

Ryan Amaral ryanamaral

View GitHub Profile
@ryanamaral
ryanamaral / OkHttpProgressGlideModule.java
Created March 20, 2017 11:52 — forked from TWiStErRob/OkHttpProgressGlideModule.java
Full POC for showing progress of loading in Glide v3 via OkHttp v2
// TODO add <meta-data android:value="GlideModule" android:name="....OkHttpProgressGlideModule" />
// TODO add <meta-data android:value="GlideModule" tools:node="remove" android:name="com.bumptech.glide.integration.okhttp.OkHttpGlideModule" />
// or not use 'okhttp@aar' in Gradle depdendencies
public class OkHttpProgressGlideModule implements GlideModule {
@Override public void applyOptions(Context context, GlideBuilder builder) { }
@Override public void registerComponents(Context context, Glide glide) {
OkHttpClient client = new OkHttpClient();
client.networkInterceptors().add(createInterceptor(new DispatchingProgressListener()));
glide.register(GlideUrl.class, InputStream.class, new OkHttpUrlLoader.Factory(client));
}
@ryanamaral
ryanamaral / ArcTranslateAnimation.java
Created March 18, 2017 12:05 — forked from guohai/ArcTranslateAnimation.java
Curved Path Animation in Android
import android.graphics.PointF;
import android.view.animation.Animation;
import android.view.animation.Transformation;
// http://www.math.ubc.ca/~cass/gfx/bezier.html
public class ArcTranslateAnimation extends Animation {
private int mFromXType = ABSOLUTE;
private int mToXType = ABSOLUTE;
@ryanamaral
ryanamaral / IntroActivity.java
Created March 17, 2017 23:44 — forked from MizzleDK/IntroActivity.java
Android intro screen
public class IntroActivity extends ActionBarActivity {
private ViewPager mViewPager;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.intro_layout);
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;
import io.realm.Realm;
import io.realm.RealmObject;
/**
* RealmAutoIncrement.
*
@ryanamaral
ryanamaral / build.gradle
Created January 11, 2016 00:14 — forked from ph0b/build.gradle
sample build.gradle for generating split APKs per ABI
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig{
minSdkVersion 14
targetSdkVersion 21
versionCode 101
@ryanamaral
ryanamaral / 0_localcast.md
Created December 8, 2015 21:24 — forked from eyecatchup/0_localcast.md
How-To cast any mp4 file from Android to Chromecast.

Cast any (local & remote) mp4 file from Chrome for Android to Chromecast


> If you prefer a _magazine-style_ formatting to read [this gist](https://gist.github.com/eyecatchup/10706409), [click here](http://gist.io/10706409).
A few days ago (April 10th 2014) I was very surprised when I've read on Engadget.com the headline [*"Chrome beta for Android makes it easy to send web video to Chromecast"*](http://j.mp/1gzphu7).

The post attached to this headline refered to a blog post by the Chrome Release team, which was published the same day - April 10th 2014 - and announced the beta release of Chrome 35 for Android. And, indeed, as one of the new features the Chrome team listed

@ryanamaral
ryanamaral / EndlessListActivity.java
Created November 29, 2015 09:20 — forked from polbins/EndlessListActivity.java
Android Endless Scroll using RecyclerView
public class EndlessListActivity<D> extends Activity {
private EndlessRecyclerOnScrollListener mEndlessScrollListener;
private EndlessListAdapter mAdapter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
RecyclerView listView = (RecyclerView) findViewById(R.id.list);
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this);
@ryanamaral
ryanamaral / strip_play_services.gradle
Created September 29, 2015 16:34 — forked from dmarcato/strip_play_services.gradle
Gradle task to strip unused packages on Google Play Services library
def toCamelCase(String string) {
String result = ""
string.findAll("[^\\W]+") { String word ->
result += word.capitalize()
}
return result
}
afterEvaluate { project ->
Configuration runtimeConfiguration = project.configurations.getByName('compile')
@ryanamaral
ryanamaral / GifDecoder.java
Created September 29, 2015 01:57 — forked from devunwired/GifDecoder.java
An optimized implementation of GifDecoder for Android devices.
/**
* Copyright (c) 2013 Xcellent Creations, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
/*
* Copyright 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