Skip to content

Instantly share code, notes, and snippets.

View StanKocken's full-sized avatar

Stan Kocken StanKocken

View GitHub Profile
@StanKocken
StanKocken / ListenerKeeper.java
Created April 24, 2015 08:47
ListenerKeeper
package com.preplay.android.util;
import android.content.Context;
import android.support.v4.app.Fragment;
import android.view.View;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
@StanKocken
StanKocken / MyManager.java
Last active November 7, 2015 11:14
A singleton pattern, to make the Mock of it easily
public class MyManager {
private MyManager() {}
public static MyManager getInstance() {

return Singleton.getInstance(MyManager.class);

}
public void myMethod() {
}
}
@StanKocken
StanKocken / LogP.java
Created June 15, 2013 13:49
An evolution of the basic "Log" of Android. This one will show the log, whatever the level, only if you are in debug. If your log is too long (like an answer of a webservice) it will be split in different log.
/*
* Copyright (C) 2013 Stan Kocken (http://www.stankocken.com)
*
* 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
@StanKocken
StanKocken / Chronometer.java
Last active December 18, 2015 13:09
A tool to measure time. Start (or restart) your Chronometer with "start()" and get time with "getElapsedTime()" "getMeanTime()" allow you to obtain the mean time of each elapsed time. This value can be reset with "resetMeanTime()"
/*
* Copyright (C) 2013 Stan Kocken (http://www.stankocken.com)
*
* 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
@StanKocken
StanKocken / GridLayoutUniform.java
Created August 6, 2013 09:14
A gridlayout override to have the same width for all cells (expect for the first one because in my case it's an header)
/*
* Copyright (C) 2013 Stan Kocken (http://www.stankocken.com)
*
* 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