Skip to content

Instantly share code, notes, and snippets.

@rsicarelli
rsicarelli / CpfEditText
Last active December 19, 2015 04:59
Component extends a EditText to create a mask for CPF (similar to Social Security Number in USA) in Android. Any comments please send me a private message. If you don't understand the comments in code (translating in some tradutor), let me know. Componente estendendo um EditText para uma máscara de CPF no Android. Alguma observação por favor me …
/*
* Componente para um EditText personalizado com uma máscara. Qualquer comentário ou lógica diferente
* por favor e-mail me rodrigo.sicarelli@gmail.com
*
* @author sicachester
*/
package br.com.sicachester.components;
import android.content.Context;
import android.support.test.runner.AndroidJUnit4;
import android.test.suitebuilder.annotation.LargeTest;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import static android.support.test.espresso.Espresso.onView;
import static android.support.test.espresso.Espresso.pressBack;
import static android.support.test.espresso.action.ViewActions.click;
private void writeToFile(final String data) {
new AsyncTask<Void, Void, Void>() {
@Override
protected Void doInBackground(Void... params) {
try {
Context context = Application.getApplication().getBaseContext();
File path = context.getExternalFilesDir(null);
File file = new File(path, "my_json.json");
FileOutputStream stream = new FileOutputStream(file);
@rsicarelli
rsicarelli / Triangle.java
Last active December 29, 2021 18:26
An programmatically example on how to create a Triangle view in Android.
public class Triangle extends View {
private Path path;
private Paint shapePaint;
private int fillColor;
private int type;
public Triangle(Context context, AttributeSet attrs) {
super(context, attrs);
init(context, attrs);
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="#000000"
android:pathData="M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59
// Gradle Plugin 2.0+
android {
defaultConfig {
vectorDrawables.useSupportLibrary = true
}
}
// Gradle Plugin 1.5
android {
defaultConfig {
<ImageView
android:layout_width=”wrap_content”
android:layout_height=”wrap_content”
app:srcCompat=“@drawable/ic_close” />
toolbar.setNavigationIcon(R.drawable.ic_close);
<selector xmlns:android=”http://schemas.android.com/apk/res/android">
<item android:drawable=”@drawable/ic_g_translate” />
</selector>