Skip to content

Instantly share code, notes, and snippets.

@dannycabrera
dannycabrera / AwaitAlertAsync.cs
Last active Jun 14, 2018
Xamarin.Android await AlertDialog.Builder
View AwaitAlertAsync.cs
await AlertAsync(this, "My Title", "My Message", "Yes", "No");
public Task<bool> AlertAsync(Context context, string title, string message, string positiveButton, string negativeButton)
{
var tcs = new TaskCompletionSource<bool>();
using (var db = new AlertDialog.Builder(context))
{
db.SetTitle(title);
db.SetMessage(message);
@dannycabrera
dannycabrera / AwaitAlertAsync.cs
Created Jun 14, 2018
Xamarin.Android await AlertDialog.Builder
View AwaitAlertAsync.cs
public Task<bool> AlertAsync(Context context, string title, string message, string positiveButton, string negativeButton)
{
var tcs = new TaskCompletionSource<bool>();
using (var db = new AlertDialog.Builder(context))
{
db.SetTitle(title);
db.SetMessage(message);
db.SetPositiveButton(positiveButton, (sender, args) => { tcs.TrySetResult(true); });
db.SetNegativeButton(negativeButton, (sender, args) => { tcs.TrySetResult(false); });
@dannycabrera
dannycabrera / WriteWavHeader.cs
Last active Jun 1, 2018
Xamarin.Android Wave Header Method
View WriteWavHeader.cs
using System;
using System.IO;
public void WriteWavHeader(string filePath, int sampleRate, short bitsPerSample, short channels)
{
using (var fs = File.Open(filePath, FileMode.Open, FileAccess.ReadWrite))
{
using (BinaryWriter writer = new BinaryWriter(fs, System.Text.Encoding.UTF8))
{
writer.Seek(0, SeekOrigin.Begin);
@dannycabrera
dannycabrera / QuickZip.cs
Created May 21, 2018
QuickZip using .NET Framework System.IO.Compression assembly
View QuickZip.cs
using System.IO.Compression;
public bool QuickZip(string[] filesToZip, string destinationZipFullPath)
{
try
{
// Delete existing zip file if exists
if (File.Exists(destinationZipFullPath))
File.Delete(destinationZipFullPath);
@dannycabrera
dannycabrera / DismissAlertDialogOnDialogClickEventArgs.cs
Last active Apr 19, 2018
Xamarin.Android Dismiss SetSingleChoiceItems on DialogClickEventArgs handler
View DismissAlertDialogOnDialogClickEventArgs.cs
var dialogBuilder = new Android.App.AlertDialog.Builder(Context);
dialgBuilder.SetTitle("My Title");
string[] items = new string[] { "Item 1", "Item 2", "Item 3", "Item 4" };
dialogBuilder.SetSingleChoiceItems(items, 0, new EventHandler<DialogClickEventArgs>(delegate (object sender, DialogClickEventArgs e) {
// Get reference to AlertDialog
var d = (sender as Android.App.AlertDialog);
// Do something with selected index
Toast.MakeText(Context, $"SelectedItemIndex: {e.Which}", ToastLength.Short).Show();
View FontsAvailableOniOS.txt
AcademyEngravedLetPlain
AmericanTypewriter-CondensedLight
AmericanTypewriter-Light
AmericanTypewriter
AmericanTypewriter-Condensed
AmericanTypewriter-Bold
AmericanTypewriter-CondensedBold
AppleColorEmoji
AppleSDGothicNeo-Medium
AppleSDGothicNeo-Bold
@dannycabrera
dannycabrera / GetDroidModel_Changes_3-30-2018.csv
Created Mar 30, 2018
GetDroidModel device changes 3-30-2018
View GetDroidModel_Changes_3-30-2018.csv
Retail Branding Marketing Name Device Model
AVH San Luis S.A. ActionKids3.0 ActionKids3_0 ActionKids3.0
AVH San Luis S.A. Vortech3.0 Vortech3_0 Vortech3.0
Advan digital G3 ADVAN_G3 6001
Advan digital i5D ADVAN_i5D i5D
AllView AX502 AX502 AX502
AllView X4 Soul Infinity SV X4_Soul_Infinity_SV X4_Soul_Infinity_S
AllView X4 Soul Infinity Z X4_Soul_Infinity_ZV X4_Soul_Infinity_Z
Altice ALTICE S60 S60 S60
Altice ALTICE S70 S70 S70
@dannycabrera
dannycabrera / MoveToTop.cs
Created Mar 26, 2018
MoveToTop Extension
View MoveToTop.cs
// Create our model
class Model {
public int Id {get;set;}
public string Name {get;set;}
}
// Create handy extension (from: https://stackoverflow.com/a/2576736/461998)
static void MoveToTop<T>(this List<T> list, int index)
{
T item = list[index];
View ImageGetPropertyItem.cs
Image image = Image.FromFile(@"C:\ArthroscopyImages\1.jpg");
var userComment = Encoding.UTF8.GetString(image.GetPropertyItem(0x9286).Value);
View keybase.md

Keybase proof

I hereby claim:

  • I am dannycabrera on github.
  • I am dannyc (https://keybase.io/dannyc) on keybase.
  • I have a public key ASAQdo3ygYwQ9-kyIy9iP8hX1969zoXtQFb4vorZMYtX5go

To claim this, I am signing this object: