Skip to content

Instantly share code, notes, and snippets.

Dorian Cussen doridori

Block or report user

Report or block doridori

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@doridori
doridori / ViewTreeObserver_Ex.java
Last active Aug 29, 2015
Grabbing content view dimensions via ViewTreeObserver - all Display methods have no guarantee if they will include system and status bars in height
View ViewTreeObserver_Ex.java
//inside a fragment. If in an Activity you could use findViewById(Window.ID_ANDROID_CONTENT);
getView().getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener()
{
@Override
public void onGlobalLayout()
{
//do something like measure a view etc
View content = getWindow().findViewById(Window.ID_ANDROID_CONTENT);
Log.d("DISPLAY", content.getWidth() + " x " + content.getHeight());
@doridori
doridori / MyWebView.java
Last active Aug 29, 2015
make WebViews computeHorizontalScrollRange() method public
View MyWebView.java
public class MyWebView extends WebView
{
public MyWebView(Context context)
{
super(context);
}
public MyWebView(Context context, AttributeSet attrs)
{
super(context, attrs);
@doridori
doridori / GsonObjectPersister.java
Created Jun 16, 2014
Standalone Gson Persister for RoboSpice
View GsonObjectPersister.java
public final class GsonObjectPersister<T> extends InFileObjectPersister<T>
{
// ============================================================================================
// FIELDS
// ============================================================================================
private final Gson gson;
// ============================================================================================
// CONSTRUCTOR
@doridori
doridori / ex1.java
Last active Aug 29, 2015
Java: Bitshifting Bytes post code samples
View ex1.java
byte aByte = -112; //0b1001_0000
byte bByte = (byte) (aByte >> 4); //would expect 0b1111_1001 (-7)
System.out.println(bByte); //-7
byte cByte = (byte) (aByte >>> 4); //would expect 0b0000_1001 (9)
System.out.println(cByte); //-7
View gist:93364ee7d6c823bde4fe
### Keybase proof
I hereby claim:
* I am doridori on github.
* I am dori (https://keybase.io/dori) on keybase.
* I have a public key whose fingerprint is CC45 C7F9 5462 AD1D 729C CA47 83C4 30D2 BC60 9EB5
To claim this, I am signing this object:
@doridori
doridori / gist:c3ec473f5e54969f46c0
Created Jun 13, 2014
robospice dropped result log
View gist:c3ec473f5e54969f46c0
D/dalvikvm﹕ Late-enabling CheckJNI
E/jdwp﹕ Failed sending reply to debugger: Broken pipe
D/dalvikvm﹕ Debugger has detached; object registry had 1 entries
D//SpiceManager.java:212﹕ 16:20:13.876 main SpiceManager started.
V//SpiceManager.java:1183﹕ 16:20:13.877 SpiceManagerThread 0 Binding to service.
D//SpiceManager.java:483﹕ 16:20:13.881 main adding request to request queue
V//SpiceManager.java:1189﹕ 16:20:13.881 SpiceManagerThread 0 Binding to service succeeded.
D//SpiceManager.java:1236﹕ 16:20:13.887 SpiceManagerThread 0 Waiting for service to be bound.
D/dalvikvm﹕ GC_CONCURRENT freed 182K, 3% free 9243K/9460K, paused 2ms+2ms, total 22ms
D//SpiceService.java:127﹕ 16:20:13.924 main SpiceService instance created.
@doridori
doridori / convertLocalizable.rb
Last active Dec 13, 2015 — forked from florianmski/convertLocalizable.rb
sub non alpha chars out - this could be done much better with regex
View convertLocalizable.rb
#!/usr/bin/ruby
# based on https://github.com/tmurakam/cashflow/blob/0a01ac9e0350dfb04979986444244f8daf4cb5a8/android/convertStrings.rb
# support comments and Converter such as "%@", "%d", "%0.1f"...
# in your directory : ./main.rb Localizable.strings
file = File.open("strings.xml", "w");
file.puts "<?xml version=\"1.0\" encoding=\"utf-8\"?>"
file.puts "<resources>"
@doridori
doridori / DaggerPilotStack.java
Created Mar 31, 2017
Example of a Dagger wrapped pilot stack for Activity/Stack scoped DI.
View DaggerPilotStack.java
/**
* A PilotStack that also holds a ref to a Dagger Component. This is useful for easy Activity-Scoped DI as the PilotStack has to already live
* on past the host-Activities config-change events by some mechanism (project dependent).
*
* @param <D> A Dagger Component to supply all deps for this stacks frames.
*/
//todo unused - here for dagger activity scope refactor (See trello)
public class DaggerPilotStack<D> extends PilotStack
{
D scopedDaggerComponent;
@doridori
doridori / build.gradle
Last active Apr 21, 2017
Incrementing android VersionCode via gradle
View build.gradle
//in your root build.gradle
//--------- Version Increment ----------//
//can call this like `./gradlew incrementVersionCode build`
task incrementVersionCode {
description = "Increments the version code in the version.properties file"
doLast {
File versionPropsFile = file('version.properties')
@doridori
doridori / DaggerHelper.java
Last active Aug 15, 2017
Testing with Dagger, Retrofit & MockWebServer gists
View DaggerHelper.java
/**
* Allows easy swapping of production and test modules to satisfy Dagger dependencies
*/
public class DaggerHelper
{
//DAGGER
private static ObjectGraph sObjectGraph;
private static final List<Object> productionModules;
You can’t perform that action at this time.