Skip to content

Instantly share code, notes, and snippets.

View rubenpla-develop's full-sized avatar

Ruben Pla Ferrero rubenpla-develop

  • Barcelona, Spain.
View GitHub Profile
/*
* Copyright 2014 Chris Banes
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
/*
* Copyright 2014 Chris Banes
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
/*
* Copyright (C) 2006 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@rubenpla-develop
rubenpla-develop / WebviewArticlePresenter.java
Created September 12, 2016 14:45 — forked from rupertbates/WebviewArticlePresenter.java
Work out the maximum scroll extent of an Android WebView
int maxScrollExtent = (int) ((mOverlayTop.getContentHeight() * mOverlayTop.getScale()) - mOverlayTop.getHeight());
@rubenpla-develop
rubenpla-develop / introrx.md
Created December 26, 2017 16:51 — forked from staltz/introrx.md
The introduction to Reactive Programming you've been missing
@rubenpla-develop
rubenpla-develop / ScaleToFitWHTransformation.java
Created May 14, 2018 22:12 — forked from jpardogo/ScaleToFitWHTransformation.java
Resize a bitmap respecting the aspect radio. I use a custom transformations with Picasso library. This transformation calculate the new dimension of the bitmap scaling it to fit a specific width or height that we pass as a parameter (usually the biggest size of the imageView where we wanna set the bitmap).
public class ScaleToFitWidthHeightTransform implements Transformation {
private int mSize;
private boolean isHeightScale;
public ScaleToFitWidthHeightTransform(int size, boolean isHeightScale){
mSize =size;
this.isHeightScale = isHeightScale;
}
@rubenpla-develop
rubenpla-develop / EncryptionKeyStore.java
Created October 15, 2018 16:08 — forked from mgiaccone/EncryptionKeyStore.java
Securely generate and store Realm (or any other) encryption key with Android Keystore (API 18+)
package com.ubiqueworks.android.security;
import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.content.Context;
import android.content.SharedPreferences;
import android.os.Build;
import android.security.KeyPairGeneratorSpec;
import android.security.keystore.KeyGenParameterSpec;
import android.security.keystore.KeyProperties;
@rubenpla-develop
rubenpla-develop / KoinJavaUtils.kt
Created October 24, 2018 16:35 — forked from fredy-mederos/KoinJavaUtils.kt
Koin java utility functions to inject components and properties in java classes.
package com.common.utils
import org.koin.KoinContext
import org.koin.standalone.StandAloneContext
import kotlin.jvm.internal.Reflection
/**
* @author @fredy_mederos
*/
@rubenpla-develop
rubenpla-develop / IRealmCascade.java
Created October 30, 2018 15:21
Realm Delete Cascade
/**
2) Add interface to your project. If your Realm object implement this interface all child objects will be deleted
after call deleteCascade. If interface not implemented this function delete Realm object but don't delete child objects.
*/
public interface IRealmCascade {
}
@rubenpla-develop
rubenpla-develop / KeyboardUtils.java
Created February 12, 2019 15:00 — forked from lopspower/KeyboardUtils.java
Force Hide Keyboard Android
import android.app.Activity;
import android.content.Context;
import android.graphics.Rect;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
public class KeyboardUtils {
public static void hideKeyboard(Activity activity) {
View view = activity.findViewById(android.R.id.content);