This file contains hidden or 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 EnumExtensions | |
{ | |
public static string Description(this Enum e) | |
{ | |
var type = e.GetType(); | |
var name = Enum.GetName(type, e); | |
var memberInfo = type.GetTypeInfo() | |
.DeclaredMembers | |
.Where(p => p.Name == name) |
This file contains hidden or 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; | |
using System.Net.Http; | |
using System.Net.Http.Headers; | |
using System.Threading; | |
using System.Threading.Tasks; | |
namespace MyNamespace | |
{ | |
public class LoggingHttpClientHandler : HttpClientHandler | |
{ |
This file contains hidden or 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
var response = await GetAsync (requestUri, token); | |
var responseType = response.Content?.Headers?.ContentType?.MediaType; | |
this.Debug (String.Format ("Response {0} ({1}) -> {2}", (int)response.StatusCode, response.StatusCode.ToString (), responseType)); | |
var responseText = await response.Content.ReadAsStringAsync (); |
This file contains hidden or 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
private int GetNavBarHeight() | |
{ | |
int resourceId = Resources.GetIdentifier("navigation_bar_height", "dimen", "android"); | |
if (resourceId > 0) | |
{ | |
return Resources.GetDimensionPixelSize(resourceId); | |
} | |
return 0; | |
} |
This file contains hidden or 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
<key>ITSAppUsesNonExemptEncryption</key><false/> |
This file contains hidden or 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://forums.xamarin.com/discussion/comment/180081/#Comment_180081 | |
// Platform project | |
{ | |
var type = item.GetType(); | |
var prop = type.GetProperty(picker.DisplayMember); | |
picker.Items.Add(prop.GetValue(item).ToString()); | |
} | |
// PCL | |
{ |
This file contains hidden or 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; | |
using System.Threading.Tasks; | |
namespace MyApp | |
{ | |
// Borrowed from @rid00z (http://www.michaelridland.com) | |
public static class AsyncMixin | |
{ | |
public static void RunForget(this Task t) | |
{ |
This file contains hidden or 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
// from https://forums.xamarin.com/discussion/comment/154636/#Comment_154636 | |
public static Task<T> BeginInvokeOnMainThreadAsync<T>(Func<T> a) | |
{ | |
var tcs = new TaskCompletionSource<T>(); | |
Device.BeginInvokeOnMainThread(() => | |
{ | |
try | |
{ | |
var result = a(); | |
tcs.SetResult(result); |
This file contains hidden or 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 void Shake (this View view, int shakes = 4, Action completion = null) | |
{ | |
Task.Run (() => { | |
Device.BeginInvokeOnMainThread (async () => { | |
uint duration = 50; | |
await view.TranslateTo (5.0, 0, duration, Easing.Linear); | |
for (var shake = 1; shake < shakes - 1; shake++) { | |
await view.TranslateTo (-10.0, 0, duration, Easing.Linear); | |
await view.TranslateTo (10.0, 0, duration, Easing.Linear); | |
} |
This file contains hidden or 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 void Wobble (this View view, int wobbles = 4, Action completion = null) | |
{ | |
Task.Run (() => { | |
Device.BeginInvokeOnMainThread (async () => { | |
uint duration = 50; | |
var count = 4; | |
await view.RelRotateTo (5.0, duration, Easing.Linear); | |
for (var shake = 1; shake < count - 1; shake++) { |