Skip to content

Instantly share code, notes, and snippets.

View thuytrinh's full-sized avatar
💭
${null}

Thuý thuytrinh

💭
${null}
  • Frankfurt, Germany
  • 18:15 (UTC +02:00)
View GitHub Profile
import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
/**
* NOTE: Please remove this class if we decide to integrate with RoboSpice.
* RoboSpice does implement a DefaultNetworkStateChecker class which takes care of everything NetworkUtils does.
*/
public class NetworkUtils {
@thuytrinh
thuytrinh / CustomSwipeRefreshLayout.java
Last active August 25, 2016 04:39
A custom SwipeRefreshLayout that fixes the scroll-up issue with StickyListHeadersListView
import android.content.Context;
import android.support.v4.widget.SwipeRefreshLayout;
import android.util.AttributeSet;
import se.emilsjolander.stickylistheaders.StickyListHeadersListView;
public class CustomSwipeRefreshLayout extends SwipeRefreshLayout {
/**
* A StickyListHeadersListView whose parent view should be this SwipeRefreshLayout
@thuytrinh
thuytrinh / OnVerticalScrollDirectionListener.java
Created July 15, 2014 04:26
A custom AbsListView.OnScrollListener that can help us detect vertical scroll direction (in pixels) in ListView
import android.view.View;
import android.widget.AbsListView;
public abstract class OnVerticalScrollDirectionListener implements AbsListView.OnScrollListener {
/**
* TODO: Make it changeable
*/
public static final int DEFAULT_SCROLL_OFFSET_THRESHOLD = 6; /* In pixels */
@thuytrinh
thuytrinh / ObservableProperty.java
Created January 11, 2015 09:08
A reactivex-based class to represent a mutable property of an object
import rx.Observable;
import rx.functions.Action1;
import rx.subjects.BehaviorSubject;
public class ObservableProperty<T> implements Action1<T> {
private final BehaviorSubject<T> valueSubject;
private T value;
public ObservableProperty() {
valueSubject = BehaviorSubject.create();
import android.database.Cursor;
import java.util.Iterator;
public class IterableCursor implements Iterable<Cursor> {
private Cursor cursor;
public IterableCursor(Cursor cursor) {
this.cursor = cursor;
this.cursor.moveToPosition(-1);
@thuytrinh
thuytrinh / OkioTest.kt
Last active September 21, 2018 13:56
A sample usage of GzipSink & GzipSource from Okio
import okio.GzipSink
import okio.GzipSource
import okio.Okio
import org.assertj.core.api.Assertions.assertThat
import org.junit.Test
import java.io.File
class OkioTest {
@Test
fun `should compress file properly`() {
const { danger, warn } = require("danger");
// No pull request is too small to include a description of why you made a change.
if (danger.github.pr.body.length < 10) {
warn("Please include a description of your PR changes.");
}
@thuytrinh
thuytrinh / MainActivity.java
Last active September 21, 2020 01:22
Create carousel view with ViewPager
package com.thuytrinh.cardselectordemo;
import android.os.Bundle;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.support.v4.view.ViewPager.OnPageChangeListener;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.app.Activity;