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 / 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
/*
* 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 / 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'