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 / 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)
@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 / 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;
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 / 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:
#
# Circle CI & gradle.properties live in harmony
#
# Android convention is to store your API keys in a local, non-versioned
# gradle.properties file. Circle CI doesn't allow users to upload pre-populated
# gradle.properties files to store this secret information, but instaed allows
# users to store such information as environment variables.
#
# This script creates a local gradle.properties file on current the Circle CI
# instance. It then reads environment variable TEST_API_KEY_ENV_VAR which a user
@luongvo
luongvo / cp-env-to-properties.sh
Created January 3, 2018 07:20 — forked from danielgomezrico/cp-env-to-properties.sh
Gradle / Bash - copy all env variables to app/gradle.properties (used to copy secret env vars from travis or circle CI to build android projects)
#!/usr/bin/env bash
#
# Copy env variables to app module gradle properties file
#
set +x // dont print the next lines on run script
printenv | tr ' ' '\n' > app/gradle.properties
set -x
@luongvo
luongvo / build.gradle
Created January 3, 2018 17:35
Aggregated Jacoco reports in a multi-project Gradle build
allprojects {
apply plugin: 'java'
apply plugin: 'jacoco'
repositories {
jcenter()
}
jacoco {
toolVersion = '0.7.1.201405082137'
@luongvo
luongvo / Readme.md
Created May 28, 2018 20:06 — forked from gabrielemariotti/Readme.md
A SimpleSectionedRecyclerViewAdapter: use this class to realize a simple sectioned `RecyclerView.Adapter`.

You can use this class to realize a simple sectioned RecyclerView.Adapter without changing your code.

The RecyclerView should use a LinearLayoutManager. You can use this code also with the TwoWayView with the ListLayoutManager (https://github.com/lucasr/twoway-view)

This is a porting of the class SimpleSectionedListAdapter provided by Google

Screen

Example:

@luongvo
luongvo / config.yml
Created September 10, 2018 17:39 — forked from bassaer/config.yml
CircleCI 2.0でAndroidライブラリの自動デプロイ ref: http://qiita.com/bassaer/items/6b9aedae4571d59f0fdf
version: 2
jobs:
build:
branches:
only:
- master
- develop
docker:
# specify the version you desire here
- image: circleci/android:api-26-alpha