Skip to content

Instantly share code, notes, and snippets.

View patrick-elmquist's full-sized avatar

Patrick Elmquist patrick-elmquist

View GitHub Profile
@patrick-elmquist
patrick-elmquist / avd_loading_bar.xml
Created October 2, 2017 13:37 — forked from nickbutcher/avd_loading_bar.xml
A prototype of a loading indicator utilizing repeated gradients. See https://twitter.com/crafty/status/914830571196571648
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2017 Google Inc.
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 distributed under the License
@patrick-elmquist
patrick-elmquist / ring_buffer.sql
Created September 22, 2017 14:48 — forked from elyezer/ring_buffer.sql
How to create a ring buffer table in SQLite
-- Example table
CREATE TABLE ring_buffer (id INTEGER PRIMARY KEY AUTOINCREMENT, data TEXT);
-- Number 10 on where statement defines the ring buffer's size
CREATE TRIGGER delete_tail AFTER INSERT ON ring_buffer
BEGIN
DELETE FROM ring_buffer WHERE id%10=NEW.id%10 AND id!=NEW.id;
END;
@patrick-elmquist
patrick-elmquist / example.xml
Last active July 26, 2017 18:14
Enter animation demo: Using GridRecyclerView
<com.patrickiv.demo.enteranimationdemo.recyclerview.GridRecyclerView
android:id="@+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layoutAnimation="@anim/grid_layout_animation_from_bottom"
/>
@patrick-elmquist
patrick-elmquist / example.java
Last active August 3, 2018 07:14
Enter animation demo: Apply GridLayoutAnimation
int resId = R.anim.grid_layout_animation_from_bottom;
LayoutAnimationController animation = AnimationUtils.loadLayoutAnimation(ctx, resId);
recyclerview.setLayoutAnimation(animation);
@patrick-elmquist
patrick-elmquist / stacktrace.txt
Last active July 26, 2017 18:07
Enter animation demo: GridLayoutAnimation vs RecyclerView stacktrace
com.patrickiv.demo.enteranimationdemo E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.patrickiv.demo.enteranimationdemo, PID: 19510
java.lang.ClassCastException: android.view.animation.LayoutAnimationController$AnimationParameters cannot be cast to android.view.animation.GridLayoutAnimationController$AnimationParameters
at android.view.animation.GridLayoutAnimationController.getDelayForView(GridLayoutAnimationController.java:299)
at android.view.animation.LayoutAnimationController.getAnimationForView(LayoutAnimationController.java:323)
at android.view.ViewGroup.bindLayoutAnimation(ViewGroup.java:4584)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3453)
at android.view.View.draw(View.java:17240)
at android.support.v7.widget.RecyclerView.draw(RecyclerView.java:3985)
...
@patrick-elmquist
patrick-elmquist / GridRecyclerView.java
Last active September 8, 2020 08:04
Enter animation demo: GridRecyclerView implementation
/**
* RecyclerView with support for grid animations.
*
* Based on:
* https://gist.github.com/Musenkishi/8df1ab549857756098ba
* Credit to Freddie (Musenkishi) Lust-Hed
*
* ...which in turn is based on the GridView implementation of attachLayoutParameters(...):
* https://android.googlesource.com/platform/frameworks/base/+/master/core/java/android/widget/GridView.java
*
@patrick-elmquist
patrick-elmquist / item_animation_from_bottom.xml
Last active July 26, 2017 18:06
Enter animation demo: Slide form bottom item animation
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="@integer/anim_duration_long">
<translate
android:interpolator="@android:anim/accelerate_decelerate_interpolator"
android:fromYDelta="50%p"
android:toYDelta="0"
/>
@patrick-elmquist
patrick-elmquist / grid_layout_animation_from_bottom.xml
Last active July 26, 2017 18:06
Enter Animation demo: Slide bottom GridLayoutAnimation example
<?xml version="1.0" encoding="utf-8"?>
<gridLayoutAnimation
xmlns:android="http://schemas.android.com/apk/res/android"
android:animation="@anim/item_animation_from_bottom"
android:animationOrder="normal"
android:columnDelay="15%"
android:rowDelay="15%"
android:direction="top_to_bottom|left_to_right"
/>
@patrick-elmquist
patrick-elmquist / item_animation_from_bottom.xml
Last active August 14, 2021 09:37
Enter animation demo: Slide from bottom demo
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="@integer/anim_duration_long">
<translate
android:interpolator="@android:anim/accelerate_decelerate_interpolator"
android:fromYDelta="50%p"
android:toYDelta="0"
/>
@patrick-elmquist
patrick-elmquist / item_animation_from_right.xml
Last active June 23, 2018 05:06
Enter animation demo: Slide from the right demo
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="@integer/anim_duration_long">
<translate
android:interpolator="@android:anim/decelerate_interpolator"
android:fromXDelta="100%p"
android:toXDelta="0"
/>