Skip to content

Instantly share code, notes, and snippets.

View devunwired's full-sized avatar

Dave Smith devunwired

View GitHub Profile
@devunwired
devunwired / FlickerActivity.java
Created December 22, 2016 22:27
Quick Android Things demo using ObjectAnimator to animate the brightness of a PWM output. This example uses a BounceInterpolator to create a flickering effect on an LED (like a candle).
/*
* Copyright 2016 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
Process: AndroidTool [48235]
Path: /Applications/AndroidTool.app/Contents/MacOS/AndroidTool
Identifier: com.mortenjust.AndroidTool
Version: 1.1 (3)
Code Type: X86-64 (Native)
Parent Process: ??? [1]
Responsible: AndroidTool [48235]
User ID: 501
Date/Time: 2015-04-29 10:58:40.001 -0600
Process: AndroidTool [46967]
Path: /Applications/AndroidTool.app/Contents/MacOS/AndroidTool
Identifier: com.mortenjust.AndroidTool
Version: 1.1 (3)
Code Type: X86-64 (Native)
Parent Process: ??? [1]
Responsible: AndroidTool [46967]
User ID: 501
Date/Time: 2015-04-29 10:53:03.224 -0600
@devunwired
devunwired / ExampleFragment.java
Created May 15, 2014 17:03
Method for animating Android fragment positions during a add/replace/remove transition using custom properties. This method does not require subclassing target views with additional setter methods, but instead requires subclassing the fragment...something you are likely already doing.
/**
* An example of adding these transitions to a Fragment. This simple
* version just applies opposite transitions to any Fragment whether it is
* entering or exiting view. You can also inspect the transit mode parameter
* (i.e. TRANSIT_FRAGMENT_OPEN, TRANSIT_FRAGMENT_CLOSE) in combination to do
* different animations for, say, adding a fragment versus popping the back stack.
*
* Transactions without an explicit transit mode set, in this example, will not
* animate. Allowing the initial fragment add, for example, to simply appear.
*/
@devunwired
devunwired / CustomRowView.java
Created January 30, 2014 07:15
Custom View Example for drawing raw text and images
public class CustomRowView extends View {
private CharSequence mText;
private Layout mTextLayout;
private TextPaint mTextPaint;
private Drawable mImageDrawable;
public CustomRowView(Context context) {
this(context, null);
@devunwired
devunwired / GifDecoder.java
Last active January 26, 2024 21:14
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:
@devunwired
devunwired / background_dialog.xml
Created November 14, 2012 20:09
XML Shape Drawable for Dialog Backgrounds. Applies a fixed outer margin to keep background from fully stretching to screen edge, and allows for additional internal padding to apply to the dialog content.
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Apply the margin value on the "item" element -->
<!-- This example creates a 15dp visible margin around the dialog -->
<item
android:top="15dp"
android:bottom="15dp"
android:left="15dp"
android:right="15dp">
<shape