Skip to content

Instantly share code, notes, and snippets.

View amlcurran's full-sized avatar

Alex Curran amlcurran

View GitHub Profile
@amlcurran
amlcurran / MultiContentAdapter.java
Last active December 11, 2015 03:38
Simple Adapter which can handle multiple input cursors asynchronously (ideal for usage with CursorLoaders)
/* Copyright 2013 Alex Curran
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 is distributed on an "AS IS" BASIS,
@amlcurran
amlcurran / XmlFileParser.java
Created February 19, 2013 13:51
Helper class that can generate an List of a given class from a simple XML file.
/* Copyright 2013 Alex Curran
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 is distributed on an "AS IS" BASIS,
@amlcurran
amlcurran / ListItem.java
Last active December 13, 2015 22:39
XmlFileParser example project
package com.espian.formulae.data;
/**
* Created with IntelliJ IDEA.
* User: alexcurran
* Date: 18/02/2013
*/
public class ListItem {
public String label;
@amlcurran
amlcurran / PreferenceMenuItemHelper
Last active December 15, 2015 11:29
Helper class which can associate a checkable MenuItem with a boolean preference
/**
* Copyright 2013 Alex Curran
*
* 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
@amlcurran
amlcurran / ColorAnimator.java
Last active July 18, 2018 11:24
Class which allows animation between two colors. Compatible with NineOldAndroids or the standard Android Animator APIs.
/**
* Copyright 2013 Alex Curran
*
* 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
@amlcurran
amlcurran / LightboxActivity.java
Last active December 17, 2015 05:49
An Activity which produces a "Lightbox"-type UI, where the entire screen except an image is dimmed - putting the image front and centre for your users. Compatible with Chris Banes' PhotoView, or the standard ImageView widget.
/**
* Copyright 2013 Alex Curran
*
* 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
@amlcurran
amlcurran / LoadHideHelper.java
Last active December 19, 2015 20:09
Utility class which makes it easy to hide and show areas of the UI until the data they represent is loaded. Simply initialise with a Fragment or view(s), and call show() to show, and hide() to hide the UI. You can automatically add a ProgressBar* which will show and hide exactly when you need it to, and even supply your own custom animations by …
/*
* Copyright (c) 2013 Alex Curran
*
* 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
@amlcurran
amlcurran / DemoActivity.java
Created July 17, 2013 11:28
LoadHideHelperDemo
package com.example.demolhh;
import android.app.Activity;
import android.os.AsyncTask;
import android.os.Bundle;
public class MainActivity extends Activity {
private LoadHideHelper mHideHelper;
@amlcurran
amlcurran / gist:b5f69b0ebc410f1eca75
Created May 19, 2014 17:45
Linkify StrictMode violation stacktrace
05-19 18:42:40.856 11430-11430/com.amlcurran.messages D/StrictMode﹕ StrictMode policy violation; ~duration=144 ms: android.os.StrictMode$StrictModeDiskReadViolation: policy=2079 violation=2
at android.os.StrictMode$AndroidBlockGuardPolicy.onReadFromDisk(StrictMode.java:1135)
at libcore.io.BlockGuardOs.read(BlockGuardOs.java:148)
at libcore.io.IoBridge.read(IoBridge.java:425)
at java.io.RandomAccessFile.read(RandomAccessFile.java:287)
at java.util.zip.ZipFile$RAFStream.read(ZipFile.java:464)
at java.io.InputStream.read(InputStream.java:162)
at java.io.BufferedInputStream.fillbuf(BufferedInputStream.java:142)
at java.io.BufferedInputStream.read(BufferedInputStream.java:288)
at libcore.io.Streams.readFully(Streams.java:81)
@amlcurran
amlcurran / Example usage.java
Created May 21, 2014 15:33
Injection of listeners through Activty
@Override
public void onAttach(Activity activity) {
super.onAttach(activity);
messageLoader = new ProviderHelper<MessagesLoaderProvider>(MessagesLoaderProvider.class).get(activity).getMessagesLoader();
}