Skip to content

Instantly share code, notes, and snippets.

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

Thuý thuytrinh

💭
${null}
  • Frankfurt, Germany
  • 20:54 (UTC +02:00)
View GitHub Profile
@thuytrinh
thuytrinh / RequestMoreListView.java
Last active August 29, 2015 14:03
A StickyListHeadersListView that notifies us when we should load (or request) more data
import android.content.Context;
import android.util.AttributeSet;
import android.widget.AbsListView;
import se.emilsjolander.stickylistheaders.StickyListHeadersListView;
public class RequestMoreListView extends StickyListHeadersListView implements AbsListView.OnScrollListener {
private OnRequestMoreListener mOnRequestMoreListener;
private boolean mIsRequesting;
@thuytrinh
thuytrinh / ParcelableModelTest.java
Created July 11, 2014 06:25
Unit test for parcelling a parcelable model in AndroidDev
public class ParcelableModelTest extends TestCase {
public void testShouldParcelProperly() {
/* Prepare data */
ParcelableModel expectedModel = new ParcelableModel();
expectedModel.setProperty0(123);
expectedModel.setProperty1("LOL");
/* Perform parcelling */
@thuytrinh
thuytrinh / colors-java.md
Last active August 29, 2015 14:04
A dumb java file in IntelliJ's Preferences used to show Colors and Fonts
/* Block comment */
import java.util.Date;
/**
 * Doc comment here for <code>SomeClass</code>
 * @see Math#sin(double)
 */
@Annotation (name=value)
public class SomeClass<T extends Runnable> { // some comment
 private T field = null;
@thuytrinh
thuytrinh / junit-in-action-questions.md
Last active August 29, 2015 14:04
Các câu hỏi phát sinh khi đọc JUnit in Action (2nd Edition)
  • Tại sao nói "On the other hand, black box tests can bring more value than white box tests."? Có những ví dụ cụ thể nào để chứng minh điều này?
  • Tại sao mình phải measure test coverage?
@thuytrinh
thuytrinh / MapBoxTileProvider.java
Created September 10, 2014 04:00
Replace Google-based tile layer with MapBox-based tile layer
import com.google.android.gms.maps.model.UrlTileProvider;
import java.net.MalformedURLException;
import java.net.URL;
public class MapBoxTileProvider extends UrlTileProvider {
private String mBaseTileUrl;
private String mMapId;
private String mAccessToken;
Observable.from(Arrays.array(1, 2, 3, 4, 5))
        .groupBy(new Func1<Integer, Boolean>() {
            @Override
            public Boolean call(Integer number) {
                return number % 2 == 0;
            }
        })
        .flatMap(new Func1<GroupedObservable<Boolean, Integer>, GroupedObservable<Boolean, Integer>>() {
            @Override
@thuytrinh
thuytrinh / MainThreadBus.java
Created December 27, 2014 04:15
A custom Otto bus that posts events from any thread and lets subscribers receive them on the main thread
import android.os.Handler;
import android.os.Looper;
import com.squareup.otto.Bus;
import com.squareup.otto.ThreadEnforcer;
/**
* A custom {@link Bus} that posts events from any thread and
* lets subscribers receive them on the main thread.
*/
public class DbField {
public final String name;
public final String type;
public final String constraint;
public DbField(String name, String type) {
this(name, type, null);
}
public DbField(String name, String type, String constraint) {
public class GistFetcherTest extends InstrumentationTestCase {
public void testFetch() throws IOException {
final InputStream mockResponseStream = getInstrumentation().getContext().getAssets().open("mock_response.json");
OkHttpClient httpClient = new OkHttpClient();
httpClient.interceptors().add(new Interceptor() {
@Override
public Response intercept(Chain chain) throws IOException {
return new Response.Builder()
.protocol(Protocol.HTTP_2)
@thuytrinh
thuytrinh / GzipTest.java
Created March 21, 2015 01:39
Write/read gzip stream properly
import android.content.Context;
import android.test.InstrumentationTestCase;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.google.gson.stream.JsonReader;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;