Skip to content

Instantly share code, notes, and snippets.

@danielesegato
danielesegato / TestFlowCollector.kt
Last active Jan 25, 2021
TestFlowCollector to test kotlin coroutines Flow
View TestFlowCollector.kt
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.Job
import kotlinx.coroutines.flow.*
import kotlinx.coroutines.launch
import kotlinx.coroutines.test.TestCoroutineScope
import org.junit.Assert.*
import kotlin.coroutines.coroutineContext
import kotlin.reflect.KClass
@danielesegato
danielesegato / CreditCardFormatTextWatcher.java
Last active Apr 8, 2021 — forked from liberorignanese/MarginSpan.java
Android TextInputLayout with credit card mask
View CreditCardFormatTextWatcher.java
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.text.Editable;
import android.text.Spannable;
import android.text.TextWatcher;
@danielesegato
danielesegato / Maven-Publish.Android-Library.md
Last active Nov 19, 2019
Android Library Publishing Maven Artifacts via gradle
View Maven-Publish.Android-Library.md

What is this

This gitst contains a script to push Android libraries as artifacts on a maven repository using the gradle build system.

It is somewhate a fork of Chris Banes gradle push script.

This was me while trying to understand how to setup maven publishing with gradle:

confused AF

Documentation is absent or very lacking and I found no script handling javadoc properly for Android.

@danielesegato
danielesegato / _Serverless-Bash-Autocomplete.md
Last active Jul 25, 2016 — forked from davidgf/serverless
Bash completion for Serverless
View _Serverless-Bash-Autocomplete.md

To enable serverless bash completion:

  • Install serverless: npm -g serverless
  • Append the servereless.bash code to the .bashrc or .bash_profile file in your home directory

This gitst is a fork of https://gist.github.com/davidgf/5bd76141aa70f9ed4d8f716851e68830. It avoid using find .to look for lambda functions: the command, if executed in the root directory or a big directory, can be really bad for performances. It also add subcommand handling for non-functions.

The script instead look for the serverless project file s-project.json starting from the current directory and looking up,

@danielesegato
danielesegato / RXJava-Wrap-CallbackAPI-README.md
Last active Feb 4, 2020
RxJava: Creating Observable from legacy asynchronous API using callbacks
View RXJava-Wrap-CallbackAPI-README.md

About the gist

EDIT: This has become soon obsolete when Observable.fromAsync() has been released in RxJava. An issue from JakeWarthon here: https://github.com/ReactiveX/RxJava/issues/4177 generated a pull request which is being implemented / discussed here: https://github.com/ReactiveX/RxJava/pull/4179 . See below on how to use it.

I'm learning RxJava. Many Rx-libraries out there are using Obvservable.create() with an inline OnSubscribe implementation to wrap legacy APIs, like this one for the Android GoogleMap API:

class MapFragmentMapReadyOnSubscribe implements Observable.OnSubscribe<GoogleMap> {
  final MapFragment fragment;
@danielesegato
danielesegato / SlowARTDebugActivity.java
Created Oct 23, 2014
TESTCASE: Debug very slow on ART for method Html.fromHtml() - android bug 77984
View SlowARTDebugActivity.java
package com.neosperience.projects.playgroundandroid;
import android.app.Activity;
import android.os.Bundle;
import android.text.Html;
import android.text.Spanned;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
@danielesegato
danielesegato / .gitignore
Last active May 5, 2017
Android development Git Ignores
View .gitignore
# Android
gen/
build/
local.properties
# Old Android
bin/
proguard/
# suggestion: also ignore libs/*.properties files for old eclipse project
# can't be added here because multiple libs/ directory can be around in different paths
@danielesegato
danielesegato / AndroidBug-OptionItems-Fragments-29472-workaround.md
Last active Mar 27, 2019
Android Option Menu + Fragments Workaround with ViewPager / ActionBar / Drawer, Menu Items not displaying
View AndroidBug-OptionItems-Fragments-29472-workaround.md

This gist is a workaround to this bug:

https://code.google.com/p/android/issues/detail?id=29472

No changes are needed to your current code but changing the extended fragment/activity class.

All you have to do is put this two classes in your code and make your activity extend MenuManagerActivity and your fragment MenuDelegatorFragment. If you are using Nested fragment you must make sure that all fragments containing nested Fragments with options menu also extend MenuDelegatorFragment (both if the parent fragment need an option menu both if it doesn't need it).

@danielesegato
danielesegato / assimp.android.make.verbose.log
Created Aug 9, 2013
This is the log of the make command when compiling from Android. Following this guide: http://jazzyjester.wordpress.com/2013/02/02/test With the modifications I describe in the comments of that guide to compile for android-9
View assimp.android.make.verbose.log
/usr/bin/cmake -H/home/mastro/ws/third-parties/assimp -B/home/mastro/ws/third-parties/assimp/buildandroid --check-build-system CMakeFiles/Makefile.cmake 0
/usr/bin/cmake -E cmake_progress_start /home/mastro/ws/third-parties/assimp/buildandroid/CMakeFiles /home/mastro/ws/third-parties/assimp/buildandroid/CMakeFiles/progress.marks
make -f CMakeFiles/Makefile2 all
make[1]: Entering directory `/home/mastro/ws/third-parties/assimp/buildandroid'
make -f code/CMakeFiles/assimp.dir/build.make code/CMakeFiles/assimp.dir/depend
make[2]: Entering directory `/home/mastro/ws/third-parties/assimp/buildandroid'
cd /home/mastro/ws/third-parties/assimp/buildandroid && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /home/mastro/ws/third-parties/assimp /home/mastro/ws/third-parties/assimp/code /home/mastro/ws/third-parties/assimp/buildandroid /home/mastro/ws/third-parties/assimp/buildandroid/code /home/mastro/ws/third-parties/assimp/buildandroid/code/CMakeFiles/assimp.dir/DependInfo.cmake --color=
make[2]: Leaving directory `