Skip to content

Instantly share code, notes, and snippets.

View hardysim's full-sized avatar

Simon Hardt hardysim

  • nullcode
View GitHub Profile
@hardysim
hardysim / ble.java
Last active May 30, 2017 08:23
BLE connect
@Override
public void onServicesDiscovered(BluetoothGatt gatt, int status) {
if (status == BluetoothGatt.GATT_SUCCESS) {
bluetoothGattService = gatt.getService(UUID_SERVICE);
if (bluetoothGattService == null) {
broadcastUpdate(Constants.ACTION_GATT_UNSUPPORTED);
return;
}
@hardysim
hardysim / SmartFragmentPagerAdapter.java
Created April 4, 2017 10:14
Like a normal FragmentPagerAdapter but holds a list of instantiated fragments and the current primary fragment
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;
import android.util.SparseArray;
import android.view.ViewGroup;
import java.util.ArrayList;
import java.util.List;