Skip to content

Instantly share code, notes, and snippets.

Avatar
🌴
Having Fun With Threads

Felipe de Souza Longo felipeslongo

🌴
Having Fun With Threads
View GitHub Profile
@felipeslongo
felipeslongo / AutoCompleteTextView_MostrarSugestoes.cs
Last active Apr 29, 2019
AppAutoCompleteTextView customizado pra um comportamento especifico.
View AutoCompleteTextView_MostrarSugestoes.cs
using System;
using System.Linq;
using System.Threading.Tasks;
using Android.Widget;
namespace App.Droid.Extensions
{
public static class AutoCompleteTextView_MostrarSugestoes
{
public static void MostrarSugestoesAoInteragir(this AutoCompleteTextView @this)
@felipeslongo
felipeslongo / UITableView+AtribuirTableHeaderView.cs
Last active Apr 25, 2019
Garante que o table header view vai ser redimensionado corretamente para encapsular a view atribuida
View UITableView+AtribuirTableHeaderView.cs
using UIKit;
namespace App.iOS.Extensions
{
//https://stackoverflow.com/questions/5484493/changing-the-height-of-a-tableheaderview-hides-the-cells/5764819#5764819
public static class UITableViewAtribuirTableHeaderView
{
private static bool VersaoIosBugadaQueNaoAtualizaOTamanhoCorretamenteDoTableHeaderView =>
!UIDevice.CurrentDevice.CheckSystemVersion(9, 0);
@felipeslongo
felipeslongo / UIViewController+AdicionarBarraDeBusca.cs
Last active Apr 25, 2019
Adiciona barra de busca em qualquer versão do IOS
View UIViewController+AdicionarBarraDeBusca.cs
using System;
using App.iOS.Utils;
using UIKit;
namespace App.iOS.Extensions
{
//https://stackoverflow.com/questions/48007690/issue-with-uisearchcontroller-in-uitableview-on-ios-11
//https://stackoverflow.com/questions/28326269/uisearchbar-presented-by-uisearchcontroller-in-table-header-view-animates-too-fa?rq=1
public static class UIViewController_AdicionarBarraDeBusca
{
View TextViewDrawableTouchEventHandler.cs
using System;
using Android.Graphics.Drawables;
using Android.Views;
using Android.Widget;
namespace App.Droid.Utils
{
public static class TextViewDrawableTouchEventHandler
{
const int DrawableLeft = 0;
@felipeslongo
felipeslongo / EditText+SetupClearButtonWithAction.cs
Last active Apr 23, 2019
Setup a clear icon that when clicked executes que action provided
View EditText+SetupClearButtonWithAction.cs
using System;
using Android.Text;
using Android.Views;
using Android.Widget;
using App.Droid.Utils;
namespace App.Droid.Extensions
{
/// <summary>
///
View SelfCancellingAndRestartingTask.cs
Task pendingTask = null; // pending session
CancellationTokenSource cts = null; // CTS for pending session
// SpellcheckAsync is called by the client app on the UI thread
public async Task<bool> SpellcheckAsync(CancellationToken token)
{
// SpellcheckAsync can be re-entered
var previousCts = this.cts;
var newCts = CancellationTokenSource.CreateLinkedTokenSource(token);
this.cts = newCts;
View UIViewController+AddSearchController
using System;
using UIKit;
namespace App.iOS.Extensions
{
public static class UIViewController_AddSearchController
{
public static UISearchController AddSearchController(this UIViewController @this)
{
var searchController = new UISearchController(null as UIViewController);
@felipeslongo
felipeslongo / CancellationTokenSourceRenew
Last active Apr 24, 2019
Utility to renew a cancellation token correctly
View CancellationTokenSourceRenew
using System.Threading;
namespace Core.Extensions
{
public static class CancellationTokenSourceRenew
{
public static CancellationTokenSource Renew(this CancellationTokenSource @this)
{
Cancel(@this);
return new CancellationTokenSource();
@felipeslongo
felipeslongo / StringCaseInsensitiveUnaccented.cs
Created Apr 12, 2019
Encapsulates a string that is case insensitive and dont care about accents
View StringCaseInsensitiveUnaccented.cs
using Core.Extensions;
namespace Core.ValueTypes
{
public class StringCaseInsensitiveUnaccented
{
public static bool Compare(string a, string b)
=> a.RemoveDiacritics().ToUpper().Equals(b.RemoveDiacritics().ToUpper());
}
}
View String+RemoveDiacritics.cs
using System.Globalization;
using System.Linq;
using System.Text;
namespace Core.Extensions
{
public static class String_RemoveDiacritics
{
public static string RemoveDiacritics(this string @this)
=> string.Concat(