Skip to content

Instantly share code, notes, and snippets.

View JMPergar's full-sized avatar
👾
Goonies never say die

José Manuel Pereira García JMPergar

👾
Goonies never say die
View GitHub Profile
@JMPergar
JMPergar / ScrollViewWithMaxHeight.java
Created November 5, 2014 13:28
ScrollView that can be configured with max height
public class ScrollViewWithMaxHeight extends ScrollView {
public static int WITHOUT_MAX_HEIGHT_VALUE = -1;
private int maxHeight = WITHOUT_MAX_HEIGHT_VALUE;
public ScrollViewWithMaxHeight(Context context) {
super(context);
}
@JMPergar
JMPergar / BaseApiCallback.java
Created June 2, 2014 11:36
Base Callback to centralize the management of errors if you use Appsly Android REST.
public abstract class BaseApiCallback<Result> extends Callback<Result> {
private final static String CLASS_NAME = "BaseApiCallback";
@Override
public final void onResponse(Response<Result> response) {
if (response.getStatusCode() == 0) {
LogManager.error(CLASS_NAME, "onResponse", response.getError().getMessage());
notifyError(ErrorType.ERROR_CONECTION);
return;
}
@JMPergar
JMPergar / LogManager.java
Last active August 29, 2015 14:02
LogManager.java
import android.util.Log;
public final class LogManager {
public static final int VERBOSE = 0;
public static final int DEBUG = 1;
public static final int INFO = 2;
public static final int WARN = 3;
public static final int ERROR = 4;
public static final int WTF = 5;
@JMPergar
JMPergar / FlipPageViewTransformer.java
Last active November 7, 2019 05:33
Flip animation for ViewPager
import android.support.v4.view.ViewPager;
import android.view.View;
public class FlipPageViewTransformer implements ViewPager.PageTransformer {
@Override
public void transformPage(View page, float position) {
float percentage = 1 - Math.abs(position);
page.setCameraDistance(12000);
setVisibility(page, position);
setTranslation(page);
@JMPergar
JMPergar / Software Keyboard Event
Last active December 26, 2015 19:29
Hide/Show Software Keyboard Event
mCVRoot.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
int heightDiff = mCVRoot.getRootView().getHeight() - mCVRoot.getHeight();
if (heightDiff > mDiffLimit) {
mOpenKeyboard = true;
// TODO
} else {