Skip to content

Instantly share code, notes, and snippets.

@jozn
jozn / README.md
Created Aug 23, 2016 — forked from gabrielemariotti/README.md
A SectionedGridRecyclerViewAdapter: use this class to realize a simple sectioned grid `RecyclerView.Adapter`.
View README.md

You can use this class to realize a simple sectioned grid RecyclerView.Adapter without changing your code.

Screen

The RecyclerView has to use a GridLayoutManager.

This is a porting of the class SimpleSectionedListAdapter provided by Google

If you are looking for a sectioned list RecyclerView.Adapter you can take a look here

@jozn
jozn / HeaderFooterRecyclerViewAdapter.java
Created Aug 4, 2016 — forked from kustra/HeaderFooterRecyclerViewAdapter.java
Header & footer support for RecyclerView.Adapter, with custom ViewHolder types for the content, header and footer
View HeaderFooterRecyclerViewAdapter.java
import android.support.v7.widget.RecyclerView;
import android.view.ViewGroup;
public abstract class HeaderFooterRecyclerViewAdapter<
ContentViewHolder extends RecyclerView.ViewHolder,
HeaderViewHolder extends RecyclerView.ViewHolder,
FooterViewHolder extends RecyclerView.ViewHolder>
extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
@jozn
jozn / Readme.md
Created Jul 25, 2016 — forked from gabrielemariotti/Readme.md
A SimpleSectionedRecyclerViewAdapter: use this class to realize a simple sectioned `RecyclerView.Adapter`.
View Readme.md

You can use this class to realize a simple sectioned RecyclerView.Adapter without changing your code.

The RecyclerView should use a LinearLayoutManager. You can use this code also with the TwoWayView with the ListLayoutManager (https://github.com/lucasr/twoway-view)

This is a porting of the class SimpleSectionedListAdapter provided by Google

Screen

Example:

@jozn
jozn / HeaderFooterRecyclerViewAdapter.java
Created Jul 25, 2016 — forked from mheras/HeaderFooterRecyclerViewAdapter.java
Header & footer support for RecyclerView.Adapter
View HeaderFooterRecyclerViewAdapter.java
public abstract class HeaderFooterRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
private static final int VIEW_TYPE_MAX_COUNT = 1000;
private static final int HEADER_VIEW_TYPE_OFFSET = 0;
private static final int FOOTER_VIEW_TYPE_OFFSET = HEADER_VIEW_TYPE_OFFSET + VIEW_TYPE_MAX_COUNT;
private static final int CONTENT_VIEW_TYPE_OFFSET = FOOTER_VIEW_TYPE_OFFSET + VIEW_TYPE_MAX_COUNT;
private int headerItemCount;
private int contentItemCount;
private int footerItemCount;
@jozn
jozn / alexa.js
Created Jul 21, 2016 — forked from chilts/alexa.js
Getting the Alexa top 1 million sites directly from the server, unzipping it, parsing the csv and getting each line as an array.
View alexa.js
var request = require('request');
var unzip = require('unzip');
var csv2 = require('csv2');
request.get('http://s3.amazonaws.com/alexa-static/top-1m.csv.zip')
.pipe(unzip.Parse())
.on('entry', function (entry) {
entry.pipe(csv2()).on('data', console.log);
})
;
@jozn
jozn / Gzip.java
Created Mar 31, 2016
Java gzip compress/decompress string
View Gzip.java
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.zip.GZIPInputStream;
import java.util.zip.GZIPOutputStream;
public class Gzip {
@jozn
jozn / react-native.d.ts
Created Oct 25, 2015 — forked from bparadie/react-native.d.ts
Incomplete react-native.d.ts, requires react.d.ts from DefinitelyTyped
View react-native.d.ts
declare module "react-native" {
import * as React from 'react';
import {ComponentClass, ReactType, ReactNode, ReactElement} from 'react';
export * from 'react';
/**
* Represents the completion of an asynchronous operation
* @see lib.es6.d.ts