Skip to content

Instantly share code, notes, and snippets.

@lenamuit
lenamuit / resource_annotations.java
Created April 2, 2015 16:11
Resource annotation for Android Studio
@AnimatorRes
@AnimRes
@AnyRes
@ArrayRes
@AttrRes
@BoolRes
@ColorRes
@DimenRes
@DrawableRes
@FractionRes
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
public abstract class EndlessRecyclerOnScrollListener extends RecyclerView.OnScrollListener {
public static String TAG = EndlessRecyclerOnScrollListener.class.getSimpleName();
private int previousTotal = 0; // The total number of items in the dataset after the last load
private boolean loading = true; // True if we are still waiting for the last set of data to load.
private int visibleThreshold = 5; // The minimum amount of items to have below your current scroll position before loading more.
int firstVisibleItem, visibleItemCount, totalItemCount;
@lenamuit
lenamuit / DrawerArrowDrawable.java
Created January 24, 2015 04:38
DrawerArrowDrawable with Android L style
import android.content.res.Resources;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.ColorFilter;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.PathMeasure;
import android.graphics.PixelFormat;
import android.graphics.Rect;
@lenamuit
lenamuit / buiild.gradle
Created January 23, 2015 03:29
[generatereleaseJavadoc] task config
android.libraryVariants.all { variant ->
task("generate${variant.name}Javadoc", type: Javadoc) {
title = "$name $version API"
description "Generates Javadoc for $variant.name."
source = variant.javaCompile.source
ext.androidJar =
"${android.sdkDirectory}/platforms/${android.compileSdkVersion}/android.jar"
classpath = files(variant.javaCompile.classpath.files) + files(ext.androidJar)
@lenamuit
lenamuit / strong-dependencies-build.gradle
Created January 21, 2015 08:27
Stronger dependencies is usually used in modern android project
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.2'
compile 'com.squareup.dagger:dagger:1.2.2'
compile 'com.squareup.dagger:dagger-compiler:1.2.2'
compile 'com.google.android.gms:play-services:6.1.71'
compile 'com.android.support:recyclerview-v7:21.0.2'
compile 'com.android.support:cardview-v7:21.0.2'
compile 'com.squareup.picasso:picasso:2.4.0'
compile 'com.squareup.okhttp:okhttp:2.1.0'
@lenamuit
lenamuit / top_scroll.java
Created January 17, 2015 09:25
Using ObservableRecycleView to handle top banner scrollable
@Override
public void onScrollChanged(int scrollY, boolean firstScroll, boolean dragging) {
int max = fxTopView.getHeight();
int delta = currentScrollY - scrollY;
mTopScrollY += delta;
Timber.e("mTopScrollY %d",mTopScrollY);
@lenamuit
lenamuit / DeviceUuidFactory.java
Created January 12, 2015 02:33
Generate UUID for Android
import android.content.Context;
import android.content.SharedPreferences;
import android.provider.Settings.Secure;
import android.telephony.TelephonyManager;
import java.io.UnsupportedEncodingException;
import java.util.UUID;
public class DeviceUuidFactory {
@lenamuit
lenamuit / createdb.sh
Created January 11, 2015 14:44
create db in mysql script
#!/bin/bash
#use: ./createdb testdb testuser secretpass
EXPECTED_ARGS=3
E_BADARGS=65
MYSQL=`which mysql`
Q1="CREATE DATABASE IF NOT EXISTS $1;"
Q2="GRANT ALL ON *.* TO '$2'@'localhost' IDENTIFIED BY '$3';"
@lenamuit
lenamuit / install-oracle-jdk
Created January 6, 2015 17:36
Install JDK on Ubuntu
You can completely remove the OpenJDK and fresh Install Oracle Java JDK by the following steps:
Remove OpenJDK completely by this command: sudo apt-get purge openjdk-\*
Download the Oracle Java JDK here.
Note: download appropriate file, for example if your system is x64 Ubuntu (i.e, Debian) the download file is named like this: jdk-8u20-linux-x64.tar.gz
Create a folder named java in /usr/local/by this command: sudo mkdir -p /usr/local/java
Copy the Downloaded file in the directory /usr/local/java. To do this, CD into directory where downloaded file is located and use this command for copying that file to /usr/local/java/:
@lenamuit
lenamuit / modern-android-api-client.md
Last active August 29, 2015 14:11
[Android] Modern, fast and security method to develop an Android client application

This is the sort example about new method to develop an Android Client Application Target: Build the RegisterActivity.

Webservice.java

public interface Webservice{
    @FormUrlEncoded
    @POST("/users.json")
    Observable<UserDto> register(@Field("email") String email,
                              @Field("nickname") String nickname,
                              @Field("password") String password,