Skip to content

Instantly share code, notes, and snippets.

View sergiandreplace's full-sized avatar
:shipit:
Fluuuttering

Sergi Martínez sergiandreplace

:shipit:
Fluuuttering
View GitHub Profile
@sergiandreplace
sergiandreplace / DespicableContentProvider.java
Created December 29, 2013 00:23
Despicable & Minion Content Provider for Android
package com.sergiandreplace.content;
import android.content.ContentProvider;
import android.content.ContentValues;
import android.content.Context;
import android.content.UriMatcher;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.net.Uri;
import android.util.SparseArray;
@sergiandreplace
sergiandreplace / HorizontalListView.java
Created January 22, 2014 15:48
An horizontal listview working just as a simple listview
import android.content.Context;
import android.database.DataSetObserver;
import android.graphics.Rect;
import android.util.AttributeSet;
import android.view.GestureDetector;
import android.view.GestureDetector.OnGestureListener;
import android.view.MotionEvent;
import android.view.View;
import android.widget.AdapterView;
@sergiandreplace
sergiandreplace / ExportDatabase.java
Created September 18, 2014 14:03
Export database to sd card
public void exportDatabse(String databaseName) {
try {
File sd = Environment.getExternalStorageDirectory();
File data = Environment.getDataDirectory();
if (sd.canWrite()) {
String currentDBPath = "//data//"+getPackageName()+"//databases//"+databaseName+"";
String backupDBPath = "backupname.db";
File currentDB = new File(data, currentDBPath);
File backupDB = new File(sd, backupDBPath);
package com.tempos21.taskexecutor;
import android.os.Handler;
import java.util.Random;
/**
* Base class for executable tasks
*/
public abstract class Task<I, O> {
@sergiandreplace
sergiandreplace / MyActivity.java
Created December 22, 2015 12:00
Making a textview with multiple lines scrollable
myTextView.setMovementMethod(new ScrollingMovementMethod());
@sergiandreplace
sergiandreplace / build.gradle
Last active April 1, 2016 07:53
Adding Rx and Retrolambda in an Android project
apply plugin: 'me.tatarka.retrolambda' //actives use of Retrolambda
buildscript {
repositories {
jcenter(); // to find plugins
}
dependencies {
classpath 'me.tatarka:gradle-retrolambda:3.3.0-beta4' //retrolambda
classpath 'me.tatarka.retrolambda.projectlombok:lombok.ast:0.2.3.a2' //lombok for that makes lint work with retrolambda
}
@sergiandreplace
sergiandreplace / Cache.java
Created August 19, 2016 06:27
Attempt to create a caching system that can be integrated into rx
package com.scmspain.bluejobs.candidateagent;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import rx.Observable;
public abstract class Cache<I, T> {
import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
public class SquareTextView extends android.support.v7.widget.AppCompatTextView {
public SquareTextView(Context context) {
super(context);
}
@sergiandreplace
sergiandreplace / httpget.dart
Created October 3, 2017 11:13
Api request on dart
import 'dart:async';
import 'dart:convert';
import 'package:flutter/services.dart';
class SWApi {
Future<Map<String, String>> getCharacter(String id) async {
var httpClient = createHttpClient();
var response = await httpClient.get('https://swapi.co/api/people/${id}/');
Map<String, Object> character = JSON.decode(response.body);
@sergiandreplace
sergiandreplace / shell.sh
Created March 20, 2018 20:43
Extract class names
find . -type f -exec grep -n "class [A-Z]" {} +^C