Skip to content

Instantly share code, notes, and snippets.

@SoulAuctioneer
SoulAuctioneer / Bluetooth.java
Created May 1, 2015 16:55
Bluetooth Low Energy (BLE) helper class for Android, including a queue for characteristic writes. See http://stackoverflow.com/questions/18011816/has-native-android-ble-gatt-implementation-synchronous-nature
package com.nojack;
import android.app.Activity;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothGatt;
import android.bluetooth.BluetoothGattCallback;
import android.bluetooth.BluetoothGattCharacteristic;
import android.bluetooth.BluetoothGattDescriptor;
import android.bluetooth.BluetoothGattService;
@yqritc
yqritc / gist:ccca77dc42f2364777e1
Last active March 29, 2024 10:25
Equal column spacing for Android RecyclerView GridLayoutManager by using custom ItemDecoration

ItemOffsetDecoration

public class ItemOffsetDecoration extends RecyclerView.ItemDecoration {

    private int mItemOffset;

    public ItemOffsetDecoration(int itemOffset) {
        mItemOffset = itemOffset;
    }
@yitz-grocerkey
yitz-grocerkey / ErrorInterceptor.kt
Created June 13, 2017 19:32
Retrofit RxJava global error handling in Kotlin
// for any errors that should be handled before being handed off to RxJava.
// In other words global error logic.
// An example might be 401 when not logging in
import okhttp3.Interceptor
import okhttp3.Response
class ErrorInterceptor: Interceptor {
override fun intercept(chain: Interceptor.Chain?): Response {