Skip to content

Instantly share code, notes, and snippets.

View alorma's full-sized avatar
🤡

Bernat Borrás Paronella alorma

🤡
View GitHub Profile
@alorma
alorma / BaseContract.java
Created February 13, 2014 22:49
Android interface to implement Data model contracts
package com.alorma.changetheworld.bbdd;
import android.provider.BaseColumns;
/**
* Created by Bernat on 11/02/14.
*/
public interface Contract extends BaseColumns{
String create();
String alter(int oldVersion, int newVersion);
@alorma
alorma / BaseCursorHelper.java
Created February 13, 2014 22:52
Android class that improves work with Cursor.
package com.alorma.changetheworld.bbdd;
import android.content.ContentValues;
import android.database.Cursor;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
@alorma
alorma / card_rounded_bg.xml
Created March 14, 2014 12:47
Card Ui and fade animation
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" android:enterFadeDuration="@android:integer/config_shortAnimTime" android:exitFadeDuration="@android:integer/config_shortAnimTime">
<item android:drawable="@drawable/card_rounded_bg_selected" android:state_selected="true" />
<item android:drawable="@drawable/card_rounded_bg_selected" android:state_pressed="true" />
<item android:drawable="@drawable/card_rounded_bg_normal" />
</selector>
@alorma
alorma / MainActivity.java
Created June 4, 2014 14:25
Fast version checker 2
package com.alorma.universidad;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
public class MainActivity extends Activity implements VersionChecker.VersionCheckerListener {
@Override
package app.picaboo.android.security;
import android.content.Context;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import java.util.UUID;
/**
* Created by Bernat on 07/06/2014.
@alorma
alorma / AccountCredentialsHelper.java
Created June 7, 2014 18:38
Account credential helper that add account on Android AccountManager
package app.picaboo.android.security;
import android.accounts.Account;
import android.accounts.AccountManager;
import android.content.Context;
import java.util.UUID;
import app.picaboo.android.BuildConfig;
private boolean checkMinVersion(String currentVersion) {
int[] currentVersionInts = convertToIntArray(currentVersion);
int[] minVersionInts = convertToIntArray(minimunVersion);
if ((currentVersionInts != null && currentVersionInts.length == 3) &&
(minVersionInts != null && minVersionInts.length == 3)) {
int majorC = currentVersionInts[0];
int minorC = currentVersionInts[1];
int patchC = currentVersionInts[2];
int majorM = minVersionInts[0];
@alorma
alorma / DirectionalScrollListener.java
Created June 21, 2014 13:24
Easy class that shows floating view in right bottom corner of ABsListView
package android.widget;
import android.os.CountDownTimer;
import android.view.View;
/**
* Created by a557114 on 20/06/2014.
*/
public class DirectionalScrollListener implements AbsListView.OnScrollListener {
@alorma
alorma / TabTitle.java
Created July 17, 2014 18:31
Tab title textview
package android.widget;
import android.content.Context;
import android.content.res.ColorStateList;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.RectF;
import android.text.Html;
@alorma
alorma / RoundNearest5.java
Created July 22, 2014 11:32
Round any number to their nearest 5 step.
protected int roundUp(int n) {
return (n + 4) / 5 * 5;
}