Skip to content

Instantly share code, notes, and snippets.

Avatar
🤡

Bernat Borrás Paronella alorma

🤡
View GitHub Profile
@alorma
alorma / BaseContract.java
Created Feb 13, 2014
Android interface to implement Data model contracts
View BaseContract.java
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 Feb 13, 2014
Android class that improves work with Cursor.
View BaseCursorHelper.java
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 Mar 14, 2014
Card Ui and fade animation
View card_rounded_bg.xml
<?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 Jun 4, 2014
Fast version checker 2
View MainActivity.java
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
View CredentialsHelper
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 Jun 7, 2014
Account credential helper that add account on Android AccountManager
View AccountCredentialsHelper.java
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;
View VersionResponse.java
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 Jun 21, 2014
Easy class that shows floating view in right bottom corner of ABsListView
View DirectionalScrollListener.java
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 Jul 17, 2014
Tab title textview
View TabTitle.java
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 Jul 22, 2014
Round any number to their nearest 5 step.
View RoundNearest5.java
protected int roundUp(int n) {
return (n + 4) / 5 * 5;
}