Skip to content

Instantly share code, notes, and snippets.

View 1zaman's full-sized avatar

Ibraheem Zaman 1zaman

View GitHub Profile
@1zaman
1zaman / ResultHolder.java
Last active December 18, 2018 18:23
Loader for Retrofit 2.0 API. This uses the framework implementation, but it can be adapted to use the support library implementation without much modification.
package com.example.retrofit.loader;
import retrofit.Response;
/**
* A wrapper around the Retrofit {@link Response} that will
* throw any loading errors upon retrieval.
*
* @param <T> The data type that was loaded.
*/
@1zaman
1zaman / OkHttpDelegator.java
Last active March 2, 2021 20:31
Delegator class to use as the HTTP stack layer for Volley and Retrofit, that enables some features that are not supported in OkHttp's API: 1) Disabling retries on non-idempotent methods (see https://github.com/square/okhttp/issues/1043). 2) Automatically serving the response from the cache when offline (see https://github.com/square/okhttp/issue…
package com.example.android;
import android.content.ComponentCallbacks2;
import android.content.Context;
import android.content.res.Configuration;
import android.os.StatFs;
import android.support.annotation.NonNull;
import com.android.volley.AuthFailureError;
import com.android.volley.Request;