Skip to content

Instantly share code, notes, and snippets.

View felipeslongo's full-sized avatar
🌴
Having Fun With Threads

Felipe de Souza Longo felipeslongo

🌴
Having Fun With Threads
View GitHub Profile
@felipeslongo
felipeslongo / PositionAwareImePadding.kt
Created May 14, 2024 19:36
Modifier.positionAwareImePadding
package com.felipeslongo
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.consumeWindowInsets
import androidx.compose.foundation.layout.imePadding
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableIntStateOf
import androidx.compose.runtime.remember
@felipeslongo
felipeslongo / ExpandableTextViewDelegate.kt
Created December 16, 2022 13:49
ExpandableTextViewDelegate
package myapp
import android.text.Layout
import android.util.Log
import android.widget.TextView
import myapp.ExpandableTextViewDelegate.State.*
import kotlin.properties.Delegates
private const val TAG = "ExpandableTextViewDel"
@felipeslongo
felipeslongo / Camera1Activity.kt
Last active June 9, 2022 16:54
Android Barcode Scanner with Camera1 + MLKit
package com.felipeslongo.mlbarcodescanner
import android.graphics.ImageFormat
import android.hardware.Camera
import android.os.Bundle
import android.util.Log
import android.view.SurfaceHolder
import android.view.SurfaceView
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
@felipeslongo
felipeslongo / AutoCompleteTextView_MostrarSugestoes.cs
Last active April 29, 2019 21:41
AppAutoCompleteTextView customizado pra um comportamento especifico.
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 April 25, 2019 18:01
Garante que o table header view vai ser redimensionado corretamente para encapsular a view atribuida
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 April 25, 2019 18:14
Adiciona barra de busca em qualquer versão do IOS
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
{
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 April 23, 2019 16:22
Setup a clear icon that when clicked executes que action provided
using System;
using Android.Text;
using Android.Views;
using Android.Widget;
using App.Droid.Utils;
namespace App.Droid.Extensions
{
/// <summary>
///
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;
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);