Skip to content

Instantly share code, notes, and snippets.

@andrewhanks
andrewhanks / CompatUtils.java
Created November 17, 2023 04:00 — forked from Thorsten1976/CompatUtils.java
Detect the interaction mode of the navigation bar (i.e. full screen gesture mode, 2-button navigation, 3-button navigation) in Android: navBarInteractionMode
import android.content.Context;
import android.content.res.Resources;
import androidx.annotation.IntDef;
import androidx.annotation.NonNull;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
public final class CompatUtils {
@Retention(RetentionPolicy.SOURCE)
package com.cobocn.hdms.app.ui.widget;
/**
* Created by benny on 14-9-19.
*/
import android.content.Context;
import android.view.GestureDetector;
import android.view.MotionEvent;
import android.view.View;
@andrewhanks
andrewhanks / AdjustingViewGlobalLayoutListener.java
Created October 12, 2017 02:49 — forked from ryandt/AdjustingViewGlobalLayoutListener.java
An OnGlobalLayoutListener interface that will adjust and resize a fullscreen scene's view when the soft keyboard is shown or hidden. This interface provides custom layout behavior to the 'adjustResize' windowSoftInputMode for a View layout by enforcing an adjustable container with the option of a static footer view.
import android.animation.ObjectAnimator;
import android.graphics.Rect;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
/**
* An OnGlobalLayoutListener interface that will adjust and resize a fullscreen scene's view when the soft keyboard is shown
* or hidden.
*
@andrewhanks
andrewhanks / YouTubeHelper.java
Created September 27, 2017 10:07 — forked from jvanderwee/YouTubeHelper.java
Extract video id from YouTube url in java
import com.google.inject.Singleton;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@Singleton
public class YouTubeHelper {
final String youTubeUrlRegEx = "^(https?)?(://)?(www.)?(m.)?((youtube.com)|(youtu.be))/";
final String[] videoIdRegex = { "\\?vi?=([^&]*)","watch\\?.*v=([^&]*)", "(?:embed|vi?)/([^/?]*)", "^([A-Za-z0-9\\-]*)"};
@andrewhanks
andrewhanks / Connectivity.java
Created October 12, 2015 04:33 — forked from emil2k/Connectivity.java
Android utility class for checking device's network connectivity and speed.
package com.emil.android.util;
import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.telephony.TelephonyManager;
/**
* Check device's network connectivity and speed
* @author emil http://stackoverflow.com/users/220710/emil