Skip to content

Instantly share code, notes, and snippets.

View penkzhou's full-sized avatar
🎯
Focusing

Old Autumn penkzhou

🎯
Focusing
  • China
View GitHub Profile
@mttkay
mttkay / Pager.java
Created November 4, 2015 15:46
A simple Rx based pager
public class Pager<I, O> {
private static final Observable FINISH_SEQUENCE = Observable.never();
private PublishSubject<Observable<I>> pages;
private Observable<I> nextPage = finish();
private Subscription subscription = Subscriptions.empty();
private final PagingFunction<I> pagingFunction;
private final Func1<I, O> pageTransformer;
@imminent
imminent / Api.java
Last active June 13, 2023 02:50
Call retrying with Retrofit 2.0
package com.example.api;
import java.util.Map;
import retrofit.Call;
import retrofit.http.Body;
import retrofit.http.GET;
import retrofit.http.POST;
public interface Api {
/**
* configures the code driving the build.
* In this case, this declares that it uses the Maven Central repository,
* and that there is a classpath dependency on a Maven artifact.
* Note: This only affects the code running the build, not the project.
* The project itself needs to declare its own repositories and dependencies. This will be covered later.
*/
buildscript {
repositories {
mavenCentral()
@f2prateek
f2prateek / HttpRequestAdapter.java
Created June 4, 2014 05:44
Signing Requests with Retrofit and SignPost
package com.f2prateek.five00px.data.api.auth;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import oauth.signpost.http.HttpRequest;
import retrofit.client.Header;
import retrofit.client.Request;
@aprock
aprock / RoundedTransformation.java
Created August 12, 2013 18:08
Rounded Corner Image Transformation for square's Picasso
import android.graphics.Bitmap;
import android.graphics.Bitmap.Config;
import android.graphics.BitmapShader;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.RectF;
import android.graphics.Shader;
// enables hardware accelerated rounded corners
// original idea here : http://www.curious-creature.org/2012/12/11/android-recipe-1-image-with-rounded-corners/