Skip to content

Instantly share code, notes, and snippets.

View amlcurran's full-sized avatar

Alex Curran amlcurran

View GitHub Profile
@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();
}
@amlcurran
amlcurran / StrictMode violation with Intent.ACTION_CALL
Last active August 29, 2015 14:01
StrictMode violation with Intent.ACTION_CALL
05-24 17:44:17.270 1388-1388/com.amlcurran.messages D/StrictMode﹕ StrictMode policy violation; ~duration=233 ms: android.os.StrictMode$StrictModeDiskReadViolation: policy=2335 violation=2
at android.os.StrictMode$AndroidBlockGuardPolicy.onReadFromDisk(StrictMode.java:1135)
at libcore.io.BlockGuardOs.open(BlockGuardOs.java:106)
at libcore.io.IoBridge.open(IoBridge.java:393)
at java.io.FileOutputStream.<init>(FileOutputStream.java:88)
at java.io.FileOutputStream.<init>(FileOutputStream.java:73)
at com.android.server.pm.Settings.writePackageRestrictionsLPr(Settings.java:1062)
at com.android.server.pm.PackageManagerService.findPreferredActivity(PackageManagerService.java:3086)
at com.android.server.pm.PackageManagerService.chooseBestActivity(PackageManagerService.java:2945)
at com.android.server.pm.PackageManagerService.resolveIntent(PackageManagerService.java:2886)
<link rel="import" href="../core-icon-button/core-icon-button.html">
<link rel="import" href="../core-toolbar/core-toolbar.html">
<link rel="import" href="../core-header-panel/core-header-panel.html">
<polymer-element name="my-element">
<template>
<style>
:host {
position: absolute;
@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 / 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