Skip to content

Instantly share code, notes, and snippets.

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

#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.

public class NavigationDrawerLayout extends ScrimInsetsLinearLayout {
private int drawerMaxWidth = -1;
public NavigationDrawerLayout(Context context) {
super(context);
}
public NavigationDrawerLayout(Context context, AttributeSet attrs) {
super(context, attrs);
@bgorkowy
bgorkowy / progress_drawable.xml
Created July 18, 2014 09:01
Round Progress Bar
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/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" />
</item>
</layer-list>
@Override
public void onCompleted(Exception e, JsonObject result) {
try {
if (e != null) {
throw e;
} else {
// zapis do bazy
// EventBus.post (new onSomeDataDownloadedEvent())
}
} catch (Exception ex) {
@bgorkowy
bgorkowy / CustomTypefaceStyleSpan.java
Created May 21, 2014 14:35
CustomSpan, with the ability to set style from resource file and custom typeface. applyCustomTypeface() method taken from http://goo.gl/dtJulZ, TextApperanceSpan from android source code.
import android.content.Context;
import android.graphics.Paint;
import android.graphics.Typeface;
import android.text.TextPaint;
import android.text.style.TextAppearanceSpan;
/**
* Created by bgorkowy on 2014-05-21.
*/
public class CustomTypefaceStyleSpan extends TextAppearanceSpan {
@bgorkowy
bgorkowy / .gitgnore
Last active August 29, 2015 14:00
.gitignore AS
# built application files
*.apk
*.ap_
# files for the dex VM
*.dex
# Java class files
*.class
Ion.with(imageView)
.placeholder(R.drawable.placeholder_image)
.error(R.drawable.error_image)
.animateLoad(spinAnimation)
.animateIn(fadeInAnimation)
.load("http://example.com/image.png");
@bgorkowy
bgorkowy / PrefsUtil.java
Created April 8, 2014 22:44
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
bgorkowy / app_build.gradle
Created April 8, 2014 22:23
Gradle Setup for use with Android Annotations.
apply plugin: 'android'
apply plugin: 'android-apt'
def AAVersion = 'X.X.X'
apt {
arguments {
androidManifestFile variant.processResources.manifestFile
resourcePackageName 'com.package.example.app'
// If you're using Android NBS flavors you should use the following line instead of hard-coded packageName