Skip to content

Instantly share code, notes, and snippets.

View talenguyen's full-sized avatar
🎯
Focusing

Nguyen Truong Giang talenguyen

🎯
Focusing
View GitHub Profile
@talenguyen
talenguyen / CircleImageView.java
Created November 17, 2015 07:55
Custom SwipeRefresh
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.RadialGradient;
import android.graphics.Shader;
import android.graphics.drawable.ShapeDrawable;
import android.graphics.drawable.shapes.OvalShape;
import android.support.v4.view.ViewCompat;
@talenguyen
talenguyen / RxBus.java
Last active November 17, 2015 12:26
EventBus implementation use RxJava
import rx.Subscription;
import rx.functions.Action1;
import rx.subjects.PublishSubject;
import rx.subjects.SerializedSubject;
import rx.subjects.Subject;
public class RxBus {
private final Subject<Object, Object> bus = new SerializedSubject<Object, Object>(PublishSubject.create());
@talenguyen
talenguyen / howto.md
Created May 27, 2016 02:22 — forked from neworld/howto.md
How to make faster Android build without sacrificing new api lint check

Original solution sacrifices new api lint check.

Here my solution:

int minSdk = hasProperty('minSdk') ? minSdk.toInteger() : 16

apply plugin: 'com.android.application'

android {
 compileSdkVersion 23
import android.app.Dialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatDialogFragment;
import android.util.Log;
/**
@talenguyen
talenguyen / gist:73bd589c5bb6b4d67591ac537df32a09
Created August 22, 2016 23:04 — forked from dodyg/gist:5823184
Kotlin Programming Language Cheat Sheet Part 1

#Intro

Kotlin is a new programming language for the JVM. It produces Java bytecode, supports Android and generates JavaScript. The latest version of the language is Kotlin M5.3

Kotlin project website is at kotlin.jetbrains.org.

All the codes here can be copied and run on Kotlin online editor.

Let's get started.

#!/bin/bash
# Fix the CircleCI path
function install() {
TARGET="$1"
if [ ! -e $TARGET ]; then
echo y | android update sdk --no-ui --all --filter $2
else
echo "$TARGET has installed"
fi
@talenguyen
talenguyen / PlaygroundComponentSpec.java
Created May 12, 2017 02:48
Demo issue of RecyclerBinderUpdateCallback belong to fblitho (http://fblitho.com)
import android.graphics.Color;
import android.support.v7.util.DiffUtil;
import android.support.v7.widget.OrientationHelper;
import com.facebook.litho.Column;
import com.facebook.litho.ComponentContext;
import com.facebook.litho.ComponentInfo;
import com.facebook.litho.ComponentLayout;
import com.facebook.litho.annotations.LayoutSpec;
import com.facebook.litho.annotations.OnCreateLayout;
@talenguyen
talenguyen / Bundles.kt
Created July 7, 2017 07:11
Bundle binding inspired by KotterKnife
import android.app.Activity
import android.app.Fragment
import android.content.Context
import android.content.Intent
import android.os.Bundle
import android.os.Parcelable
import android.support.annotation.VisibleForTesting
import android.support.v4.app.FragmentActivity
import android.util.SparseArray
@talenguyen
talenguyen / Daggers.md
Created November 8, 2017 05:12
Daggers configuration

Daggers

Configuration

My minimal configuration would be.

AppComponent

@Singleton
@Component(modules = AppModule.class)
public interface AppComponent {
@talenguyen
talenguyen / PermissionRequest.java
Created January 6, 2018 02:36
Runtime permission Request
import android.app.Activity;
import android.content.pm.PackageManager;
import android.support.annotation.Nullable;
import android.support.v4.app.ActivityCompat;
import android.support.v7.app.AlertDialog;
public class PermissionRequest {
private static int RC = 1;
private final String permission;