Skip to content

Instantly share code, notes, and snippets.

bgorkowy / multi-flavour-lib-module-howto.gradle
Created Jul 29, 2015
multi-flavour gradle library module
View multi-flavour-lib-module-howto.gradle
// Main app module
compile project(path: ':library', configuration: 'flavour1Release')
// 'library' module
android {
compileSdkVersion 22
buildToolsVersion "23.0.0 rc3"
defaultPublishConfig "flavour1Release"
publishNonDefault true
View gist:904de42d62a000b3aaf2


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

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

Let's get started.

public class NavigationDrawerLayout extends ScrimInsetsLinearLayout {
private int drawerMaxWidth = -1;
public NavigationDrawerLayout(Context context) {
public NavigationDrawerLayout(Context context, AttributeSet attrs) {
super(context, attrs);
View progress_drawable.xml
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="">
<item android:id="@android:id/background"
android:drawable="@drawable/progress_bar_bg" />
<item android:id="@android:id/progress">
<scale android:scaleWidth="100%"
android:drawable="@drawable/progress_bar_progress" />
public void onCompleted(Exception e, JsonObject result) {
try {
if (e != null) {
throw e;
} else {
// zapis do bazy
// (new onSomeDataDownloadedEvent())
} catch (Exception ex) {
bgorkowy /
Created May 21, 2014
CustomSpan, with the ability to set style from resource file and custom typeface. applyCustomTypeface() method taken from, TextApperanceSpan from android source code.
import android.content.Context;
import android.text.TextPaint;
* Created by bgorkowy on 2014-05-21.
public class CustomTypefaceStyleSpan extends TextAppearanceSpan {
bgorkowy / .gitgnore
Last active Aug 29, 2015
.gitignore AS
View .gitgnore
# built application files
# files for the dex VM
# Java class files
bgorkowy /
Created Apr 8, 2014
Shared Preference util class starting body, using Android Annotations
import org.androidannotations.annotations.sharedpreferences.DefaultInt;
import org.androidannotations.annotations.sharedpreferences.DefaultString;
import org.androidannotations.annotations.sharedpreferences.SharedPref;
@SharedPref(value = SharedPref.Scope.APPLICATION_DEFAULT)
public interface PrefsUtil {
* Example int preference, with default value 0
bgorkowy / app_build.gradle
Created Apr 8, 2014
Gradle Setup for use with Android Annotations.
View app_build.gradle
apply plugin: 'android'
apply plugin: 'android-apt'
def AAVersion = 'X.X.X'
apt {
arguments {
androidManifestFile variant.processResources.manifestFile
resourcePackageName ''
// If you're using Android NBS flavors you should use the following line instead of hard-coded packageName