Skip to content

Instantly share code, notes, and snippets.

Avatar
😃
Ceart go leor

Eoin Fogarty eoinfogarty

😃
Ceart go leor
  • Pinch
  • Utrecht, Netherlands
  • Twitter @_modge_
View GitHub Profile
@eoinfogarty
eoinfogarty / Recycler.kt
Created Jul 21, 2017
Kotlin extension methods to simplify saving and restoring a recyclerviews scroll postion
View Recycler.kt
import android.os.Bundle
import android.os.Parcelable
import android.support.v7.widget.RecyclerView
/**
* We have to handle restoring a recyclerviews scroll position oneself.
* Add a extension field so we don't have to handle the key ourselves anymore
* Add a post to avoid some bug where recyclerview does not restore scroll position
*
@eoinfogarty
eoinfogarty / Intent.kt
Created Jul 19, 2017
Kotlin extension to add extras as pairs
View Intent.kt
import android.content.Intent
import android.os.Bundle
import android.os.Parcelable
import java.io.Serializable
/**
* Intent(context, MyActivity::class.java).withExtras(
* KEY_HOGE to "hoge",
* KEY_FOO to "foo"
* )
@eoinfogarty
eoinfogarty / SelectorTouchListener.java
Created Jun 3, 2016
Touch listener to use with a selector
View SelectorTouchListener.java
package com.example.app;
import android.view.MotionEvent;
import android.view.View;
public final class SelectorTouchListener implements View.OnTouchListener {
@Override
public boolean onTouch(View v, MotionEvent event) {
switch (event.getAction()) {
@eoinfogarty
eoinfogarty / RatioImageView.java
Created Nov 9, 2015
imageview with ratio that can be set based on width
View RatioImageView.java
import android.content.Context;
import android.support.annotation.NonNull;
import android.util.AttributeSet;
import android.widget.ImageView;
/**
* Created by Eoin Fogarty on 2015/11/06.
*
* Clamps an image ratio