Skip to content

Instantly share code, notes, and snippets.

View GokhanArik's full-sized avatar
👨‍💻

Gokhan Arik GokhanArik

👨‍💻
View GitHub Profile
@GokhanArik
GokhanArik / NetworkStateManager.kt
Created March 12, 2020 03:11
Check Internet Connection in Android 21+
package manager
import android.content.Context
import android.net.ConnectivityManager
import android.net.Network
import android.net.NetworkCapabilities
import android.net.NetworkRequest
import android.os.Build
import android.util.Log
import com.jakewharton.rxrelay2.BehaviorRelay
@GokhanArik
GokhanArik / commit-msg
Created September 24, 2019 04:28
Git hook to add Jira story id to the commit message.
#!/bin/sh
####################################################
# #
# DO NOT TRY ON A WINDOWS MACHINE #
# (nothing happens if you try, it just won't work) #
####################################################
# This script edits commit message and attaches story number to commit message.
@GokhanArik
GokhanArik / BottomSheetDragDownListener.java
Last active September 24, 2019 04:29
Mimics behavior of Bottom Sheet in Android. From initial position, scrolling up disabled. If user scrolls more than half of view's height, view collapses. Otherwise, it goes back to its old position.
import android.view.MotionEvent;
import android.view.View;
import android.view.animation.OvershootInterpolator;
public class BottomSheetDragDownListener implements View.OnTouchListener {
private static final float INTERPOLATOR_FACTOR = 0.5f;
private float dY, startScrollY, viewY;
@Override