Skip to content

Instantly share code, notes, and snippets.

View eleddie's full-sized avatar

Eduardo Sanchez eleddie

View GitHub Profile
@eleddie
eleddie / delayTiming.ts
Created April 18, 2020 12:16
Delay a timing function using React Native Reanimated
import Animated, { Easing } from 'react-native-reanimated';
const { and, cond, block, set, eq, neq, not, clockRunning, startClock, Clock, timing, stopClock, Value } = Animated;
type ResetParams = {
state: Animated.TimingState;
from?: Animated.Adaptable<number>;
to?: Animated.Adaptable<number>;
config: Animated.TimingConfig;
clock: Animated.Clock;
@eleddie
eleddie / ObjectSerializer.kt
Created June 26, 2017 05:37
ObjectSerializer written in Kotlin
import java.io.ByteArrayInputStream
import java.io.ByteArrayOutputStream
import java.io.IOException
import java.io.ObjectInputStream
import java.io.ObjectOutputStream
import java.io.Serializable
import kotlin.experimental.and
object ObjectSerializer {
@eleddie
eleddie / RecyclerViewTouchListener.kt
Created June 26, 2017 00:04
Class to handle single tap and long press on the RecyclerView in Android using Kotlin
class RecyclerTouchListener(context: Context, recyclerView: RecyclerView, val clickListener: ClickListener) : RecyclerView.OnItemTouchListener {
val gestureDetector: GestureDetector = GestureDetector(context, object : GestureDetector.SimpleOnGestureListener() {
override fun onSingleTapUp(e: MotionEvent?): Boolean = true
override fun onLongPress(e: MotionEvent) {
val child: View? = recyclerView.findChildViewUnder(e.x, e.y)
if (child != null)
clickListener.onLongClick(child, recyclerView.getChildAdapterPosition(child).toLong())
super.onLongPress(e)
}
})