Skip to content

Instantly share code, notes, and snippets.

View luongvo's full-sized avatar
🚀
flying in the sky

Luong Vo (Lucas) luongvo

🚀
flying in the sky
View GitHub Profile
@luongvo
luongvo / circle.yml
Created January 3, 2018 06:22 — forked from mugifly/circle.yml
Faster test & Build of Android Studio Project (Gradle Project) on Circle-CI.
machine:
java:
version: oraclejdk8
environment:
# Java options
JAVA_OPTS: "-Xms512m -Xmx2048m"
# ADB options
ADB_INSTALL_TIMEOUT: 5000
dependencies:
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Outline;
import android.graphics.Paint;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffXfermode;
import android.graphics.RectF;
import android.util.AttributeSet;
@luongvo
luongvo / RoundedImageView.java
Created December 20, 2017 18:08 — forked from dzeikei/RoundedImageView.java
Android Rounded ImageView without modifying the original bitmap. Best used with ScaleType.CENTER_CROP or ScaleType.FIT_XY
package com.snepo.common.widgets;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.Path.Direction;
import android.graphics.Path.FillType;
import android.graphics.PorterDuff.Mode;
import android.graphics.PorterDuffXfermode;
@luongvo
luongvo / MainActivity.java
Created December 20, 2017 18:05 — forked from gabrielemariotti/MainActivity.java
How to obtain a CardView (support library) with a Image and rounded corners for API<21
ImageView imageView = (ImageView) findViewById(R.id.card_thumbnail_image);
Bitmap mBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.rose);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP){
//Default
imageView.setBackgroundResource(R.drawable.rose);
} else {
//RoundCorners
RoundCornersDrawable round = new RoundCornersDrawable(mBitmap,
getResources().getDimension(R.dimen.cardview_default_radius), 0); //or your custom radius
@luongvo
luongvo / WrapContentHeightViewPager.java
Created November 27, 2017 07:34 — forked from egslava/WrapContentHeightViewPager.java
Wrap content height ViewPager (Android)
package org.cnii.layoutloader.ui;
import android.content.Context;
import android.support.v4.view.ViewPager;
import android.util.AttributeSet;
import android.view.View;
/**
* Special thanks to Daniel López Lacalle for his response
* (http://stackoverflow.com/questions/8394681/android-i-am-unable-to-have-viewpager-wrap-content/20784791#20784791)
/*
* Copyright 2014 Chris Banes
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@luongvo
luongvo / AndroidManifest.xml
Created June 13, 2017 04:50 — forked from cdsap/AndroidManifest.xml
Example ManifestPlaceHolder
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.myapplication" >
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
@luongvo
luongvo / FontAwareTabLayout.java
Created June 12, 2017 21:01 — forked from LuigiPapino/FontAwareTabLayout.java
Android - Calligraphy and TabLayout
/**
* Simple helper class which extends a TabLayout to allow us to customize the font of the tab.
* https://gist.github.com/tmtrademarked/09926077a406959be15fc8a824a52751
* https://github.com/chrisjenx/Calligraphy/issues/180
*/
public final class FontAwareTabLayout extends TabLayout {
private String fontPath;
public FontAwareTabLayout(Context context, AttributeSet attrs) {
@luongvo
luongvo / HideSoftkeyboardOnTap
Created May 21, 2017 18:26 — forked from elqsar/HideSoftkeyboardOnTap
Hide softkeyboard in android application if user tap outside EditText control
protected void setupParent(View view) {
//Set up touch listener for non-text box views to hide keyboard.
if(!(view instanceof EditText)) {
view.setOnTouchListener(new View.OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
hideSoftKeyboard();
return false;
}
});
}
@luongvo
luongvo / build.gradle
Created April 27, 2017 02:23 — forked from alexsinger/build.gradle
Separate Crashlytics reporting for debug and release buildTypes using a Gradle build
// The following code allows an app to report Crashlytics crashes separately
// for release and debug buildTypes when using Gradle. This code should be inserted
// into the specified locations within your build.gradle (Module:app) file
// The buildTypes { } block should be inserted inside the android { } block
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
ext.crashlyticsApiSecret = "release api secret"