Skip to content

Instantly share code, notes, and snippets.

View dron247's full-sized avatar

dron247 dron247

View GitHub Profile
@dron247
dron247 / NoInflateAdapterExample.java
Created March 21, 2017 05:00
Example implementation of an recycler adapter without xml markup used. No inflate - no problemo
// this is an internal class in example activity
// check file name and access modifiers before use
static class ExampleAdapter extends RecyclerView.Adapter<ExampleAdapter.ViewHolder> {
List<TodoListItem> items;
ClickListener clickListener;
Resources resources;
int DP16;
ExampleAdapter(Context context, List<TodoListItem> items) {
// multicallback example
namespace com.example {
class Runner {
var devices = new List<Item>();
void foo(){
devices.Add(new Item());
devices.Add(new Item(Handler));
}
@dron247
dron247 / SessionExpiredInterceptor.java
Created January 23, 2017 04:28
Okhttp 401 interceptor, handles session expired error
package com.company.product.net.interceptor;
import java.io.IOException;
import okhttp3.Interceptor;
import okhttp3.Request;
import okhttp3.Response;
/**
* Connect this interceptor to okhttp3 line to intercept all 401 answers from service and get callback