Skip to content

Instantly share code, notes, and snippets.

View Adam--'s full-sized avatar

Adam Anderson Adam--

View GitHub Profile
@Adam--
Adam-- / InterceptingViewPager.cs
Last active August 29, 2015 14:15
Xamarin Android ViewPager (Android.Support.V4.View) that allows for swiping between fragments even when a touch event lands initially on a child control.
using System;
using Android.Content;
using Android.Support.V4.View;
using Android.Util;
using Android.Views;
namespace InterceptingViewPagerExample.Droid
{
class InterceptingViewPager : ViewPager
{
@Adam--
Adam-- / AttributeBinding.cs
Last active August 29, 2015 14:28
MvvmCross binding examples
/// <summary>
/// Show the view model.
/// </summary>
[MvxCommand("ShowCommand")]
public void Show()
{
this.ShowViewModel<MainViewModel>();
}
@Adam--
Adam-- / PropertyNameSupport.cs
Last active September 25, 2015 13:09
Extracts a property name string from an Expression.
using System;
using System.Globalization;
using System.Linq.Expressions;
using System.Reflection;
public static class PropertyNameSupport
{
private const string ExceptionMessageFormat = "Property expression {0}. Ensure calling with () => Property.";
private const string ParameterName = "propertyExpression";
@Adam--
Adam-- / OverrideFormattedStringExtension.cs
Created February 19, 2016 15:27 — forked from alexlau811/OverrideFormattedStringExtension.cs
Override default FormattedString behaviour to allow custom font to be used in Label of Xamarin.Forms.Android
public static class OverrideFormattedStringExtension
{
//
// Static Methods
//
public static SpannableString ToAttributed(this FormattedString formattedString, Font defaultFont, Color defaultForegroundColor, TextView view)
{
if (formattedString == null)
{
return null;
@Adam--
Adam-- / back key.bat
Created April 8, 2016 14:08
Windows batch files for useful Android ADB commands. Replace [device] with your device as listed from "adb devices" or remove the -s [device] entirely.
adb -s [device] shell input keyevent 4
@Adam--
Adam-- / GifImageView.cs
Last active June 8, 2018 14:53
Android GifImageView custom renderer for Xamarin Forms
namespace LakeShore.Sources.Core.Instrument
{
using Xamarin.Forms;
public class GifImageView : View
{
public static readonly BindableProperty SourceProperty = BindableProperty.Create(
propertyName: nameof(Source),
returnType: typeof(string),
declaringType: typeof(GifImageView),
@Adam--
Adam-- / PCLStorageCopyExtension.cs
Created September 15, 2016 13:08
Copy a file to a folder using PCLStorage
namespace com.github.gist.adam--
{
using System.Threading;
using PCLStorage;
using FileAccess = PCLStorage.FileAccess;
public static class PCLStorageExtensions
{
public static async void CopyFileTo(this IFile file, IFolder destinationFolder, CancellationToken cancellationToken = default(CancellationToken))
{
@Adam--
Adam-- / adb_screenshot.bat
Last active May 31, 2024 07:15
Take an Android screenshot using ADB on Windows
adb devices
adb shell screencap -p /sdcard/screen.png
adb pull -p -a /sdcard/screen.png
adb shell rm /sdcard/screen.png
For /f "tokens=2-4 delims=/ " %%a in ('date /t') do (set mydate=%%c-%%a-%%b)
For /f "tokens=1-3 delims=/:" %%a in ("%TIME%") do (set mytime=%%a-%%b-%%c)
set mytime=%mytime: =%
@Adam--
Adam-- / app.config
Created April 26, 2017 11:56
Newtonsoft.Json binding redirect
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-9.0.0.0" newVersion="9.0.0.0" />
</dependentAssembly>
</assemblyBinding>
@Adam--
Adam-- / TestingCloudTableWithAzureStorageEmulator.cs
Last active February 14, 2021 13:58
Testing CloudTable dependent code using the Azure Storage Emulator and NUnit
public class TestingCloudTableWithAzureStorageEmulator
{
private CloudTableClient developmentCloudTableClient;
private CloudTable emulatedCloudTable;
[OneTimeSetUp]
public void OneTimeSetUp()
{
var azureStorageEmulatorProcess = Process.Start("C:\\Program Files (x86)\\Microsoft SDKs\\Azure\\Storage Emulator\\AzureStorageEmulator.exe", "start");
azureStorageEmulatorProcess?.WaitForExit(2000);