Skip to content

Instantly share code, notes, and snippets.

@bgorkowy
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

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

View NavigationDrawerLayout.java
public class NavigationDrawerLayout extends ScrimInsetsLinearLayout {
private int drawerMaxWidth = -1;
public NavigationDrawerLayout(Context context) {
super(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="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>
View ion_JSON.java
@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
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.
View CustomTypefaceStyleSpan.java
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 Aug 29, 2015
.gitignore AS
View .gitgnore
# built application files
*.apk
*.ap_
# files for the dex VM
*.dex
# Java class files
*.class
View ion-ImageView.java
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 Apr 8, 2014
Shared Preference util class starting body, using Android Annotations
View PrefsUtil.java
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 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 'com.package.example.app'
// If you're using Android NBS flavors you should use the following line instead of hard-coded packageName