This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class BindableObjectExtensions | |
{ | |
// chainable, with a string for property | |
// usage : new Button().WithBinding(Button.CommandProperty, "SomeCommand"), | |
public static T WithBinding<T>(this T obj, | |
BindableProperty bindableProperty, | |
string path, | |
BindingMode mode = BindingMode.Default, | |
IValueConverter converter = null, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class BundleExtensions | |
{ | |
const string SERIALIZED_KEY = "__JSONSERIALIZED__"; | |
static List<IMapItem> typesMapping; | |
//TODO: put in order of preference (cf string/charseq , serializable/parcelable, ...) because the for loop will stop at the first recognized type | |
static BundleExtensions() { | |
typesMapping = new List<IMapItem>{ | |
new TypeMap<IBinder> ((b, i, v) => b.PutBinder(i, v), (b, i) => b.GetBinder(i)), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using R = YOUR_ANDROID_PROJECT_HERE.Resource; | |
// so you can do R.String.Ok instead of Resource.String.Ok, so that it looks like native Android a bit more |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.app.Activity; | |
import android.app.Application; | |
import android.os.Bundle; | |
import android.util.Log; | |
import android.widget.Toast; | |
/** | |
* // Usage : | |
* // in your app's Application | |
* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.app.Activity; | |
import android.util.Log; | |
import com.google.inject.Inject; | |
import roboguice.activity.event.*; | |
import roboguice.context.event.*; | |
import roboguice.event.Observes; | |
import roboguice.inject.ContextSingleton; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// usage : in your Android Application OnCreate() : | |
// this.RegisterActivityLifecycleCallbacks(new TimeOutPassCodeActivityCallBacks("1234")); | |
class TimeOutPassCodeActivityCallBacks : Java.Lang.Object, Android.App.Application.IActivityLifecycleCallbacks | |
{ | |
DateTime? loggedInTime = null; | |
readonly string passcode; | |
readonly int timeoutInSeconds; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class ViewExtensions | |
{ | |
public static T FindViewHolderById<T> (this View @this, int resID) | |
where T : View | |
{ | |
return (@this.GetTag (resID) as T) ?? @this.SetTagAndReturnValue (resID, @this.FindViewById<T> (resID)) as T; | |
} | |
public static T SetTagAndReturnValue<T> (this T @this, int key, T view) | |
where T : View |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Diagnostics; | |
using System.Runtime.CompilerServices; | |
// ReSharper disable once CheckNamespace | |
// ReSharper disable once InconsistentNaming | |
public static class TODO | |
{ | |
#if DEBUG | |
// for mandatory TODOs, will break release compilation AND remind when debugging |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//https://dotnetfiddle.net/KXXMef | |
// shorter but less generic : | |
// https://dotnetfiddle.net/R3m1h2 | |
using System; | |
using System.Collections; | |
using System.Linq; | |
public class Program | |
{ |
OlderNewer