Skip to content

Instantly share code, notes, and snippets.

View BrunoVT1992's full-sized avatar

Bruno Van Thournout BrunoVT1992

View GitHub Profile
@BrunoVT1992
BrunoVT1992 / Distance.cs
Last active April 26, 2016 07:40
Calculate the spline fling distance for Xamarin Android
using System;
using Android.App;
using Android.Hardware;
using Android.Views;
namespace Droid
{
public static class Distance
{
public static double CalculateSplineFlingDistance(float velocity)
@BrunoVT1992
BrunoVT1992 / Command.cs
Last active April 26, 2016 07:40
Mvvm ICommand implementation
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;
namespace Mvvm
{
public class Command : ICommand
@BrunoVT1992
BrunoVT1992 / NotifyPropertyChanged.cs
Last active April 26, 2016 07:40
Mvvm INotifyPropertyChanged implementation
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
namespace Mvvm
{
@BrunoVT1992
BrunoVT1992 / BaseRepository
Last active January 5, 2018 13:01
SQLite.NET async BaseRepository
using System;
using System.Threading.Tasks;
using System.Collections.Generic;
using SQLite;
using System.Linq.Expressions;
using System.Linq;
namespace SQLite
{
public interface IBaseRepository<TEntity, TPrimaryKey>
@BrunoVT1992
BrunoVT1992 / DpiToPixelConverter.cs
Last active April 26, 2016 07:39
Dpi to pixel converter for Xamarin Android
using Android.Content;
namespace Droid
{
public static class DpiToPixelConverter
{
public static int Convert(int dpi)
{
float scale = Application.Context.Resources.DisplayMetrics.Density;
return (int)(dpi * scale + 0.5f);
@BrunoVT1992
BrunoVT1992 / BitmapExtensions.cs
Last active April 26, 2016 07:39
Bitmap blur util for Xamarin Android
using Android.App;
using Android.Support.V8.Renderscript;
namespace Droid
{
public static class BitmapUtil
{
public static Bitmap Blur(Bitmap originalBitmap)
{
// Create the Renderscript instance that will do the work.
@BrunoVT1992
BrunoVT1992 / AsyncLock.cs
Last active May 13, 2016 13:28
This class makes a lock statement async so you can use await operators inside the lock statement
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
namespace CSharp
{
// http://blogs.msdn.com/b/pfxteam/archive/2012/02/12/10266988.aspx
public class AsyncLock
{
@BrunoVT1992
BrunoVT1992 / RotatedTextView.cs
Last active April 26, 2016 07:38
Rotated textview for Xamarin Android
using Android.Content;
using Android.Widget;
using Android.Util;
using Android.Graphics;
namespace Droid
{
public class RotatedTextView : TextView
{
public RotatedTextView(Context ctx, IAttributeSet attr)
@BrunoVT1992
BrunoVT1992 / CurrentActivityUtil.cs
Last active July 11, 2018 17:08
Function for getting the current activity in Xamarin Android
using System.Collections.Generic;
using System.Linq;
using Android.Runtime;
using Android.Util;
using Java.Lang;
using Java.Util;
namespace Droid
{
public static class CurrentActivityUtil
@BrunoVT1992
BrunoVT1992 / RoundedCornersFrameLayout.cs
Created May 13, 2016 13:03
Rounded corners for a framelayout in Xamarin Android
using Android.Content;
using Android.Graphics;
using Android.Util;
using Android.Widget;
namespace Droid
{
public class RoundedCornersFrameLayout : FrameLayout
{
private const float CornerRadius = 5.0f;