Skip to content

Instantly share code, notes, and snippets.

View aftabsikander's full-sized avatar

Aftab aftabsikander

  • Karachi,Pakistan
View GitHub Profile
@aftabsikander
aftabsikander / Readme.md
Last active September 20, 2015 17:57 — forked from gabrielemariotti/Readme.md
A SimpleSectionedRecyclerViewAdapter: use this class to realize a simple sectioned `RecyclerView.Adapter`.

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:

@aftabsikander
aftabsikander / README.md
Last active September 20, 2015 17:58 — forked from gabrielemariotti/README.md
A SectionedGridRecyclerViewAdapter: use this class to realize a simple sectioned grid `RecyclerView.Adapter`.

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

@aftabsikander
aftabsikander / RoundedDrawable
Last active September 22, 2015 10:28
Modified RoundedDrawable class using for vinc3m1/RoundedImageView Library
/*
* Copyright (C) 2015 Vincent Mi
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.ViewGroup;
public abstract class HeaderFooterRecyclerViewWrapperAdapter<HeaderViewHolder extends RecyclerView.ViewHolder,
FooterViewHolder extends RecyclerView.ViewHolder> extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
private static final int VIEW_TYPE_MASK = 0xfffffff;
private static final int VIEW_TYPE_HEADER = 0x10000000;
private static final int VIEW_TYPE_FOOTER = 0x20000000;
import android.content.Context;
import android.support.v4.content.AsyncTaskLoader;
public abstract class AsyncLoader<T> extends AsyncTaskLoader<T> {
private T mResult;
public AsyncLoader(Context context) {
super(context);
}
@aftabsikander
aftabsikander / WebUtil
Created October 8, 2015 12:53
How to oauth url request using SignPost Android
public static WebRequestTimeout sendGetRequestToServer(Context mContext, URL para_URL)
{
HttpURLConnection getRequest = null;
WebRequestTimeout webRequestTimeout = new WebRequestTimeout();
try
{
getRequest = (HttpURLConnection) para_URL.openConnection();
String authtoken = PrefUtils.getAuthToken(mContext);
DefaultOAuthConsumer consumer = new DefaultOAuthConsumer(WebUtils.CONSUMER_KEY, WebUtils.CONSUMER_SECERT);
// sign the request (consumer is a Signpost DefaultOAuthConsumer)
@aftabsikander
aftabsikander / QuickReturnUtils
Created October 14, 2015 21:21
This file is taken from "Quick Return" library made by Lawloretienee link: https://github.com/lawloretienne/QuickReturn
package com.etiennelawlor.quickreturn.library.utils;
import android.content.Context;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.DisplayMetrics;
import android.util.Log;
import android.util.TypedValue;
import android.view.Display;
import android.view.View;
@aftabsikander
aftabsikander / RecycleEmptyErrorView.java
Created August 17, 2016 06:41 — forked from henrytao-me/RecycleEmptyErrorView.java
Empty and Error in RecycleView
/*
* Copyright 2015 "Henry Tao <hi@henrytao.me>"
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@aftabsikander
aftabsikander / CircularRevealingFragment.java
Created September 21, 2016 11:21 — forked from ferdy182/CircularRevealingFragment.java
Make circular reveal animations on a fragment
/**
* Our demo fragment
*/
public static class CircularRevealingFragment extends Fragment {
OnFragmentTouched listener;
public CircularRevealingFragment() {
}
@aftabsikander
aftabsikander / CountingFileRequestBody.java
Created November 13, 2016 16:58 — forked from eduardb/CountingFileRequestBody.java
Uploading a file with a progress displayed using OkHttp
public class CountingFileRequestBody extends RequestBody {
private static final int SEGMENT_SIZE = 2048; // okio.Segment.SIZE
private final File file;
private final ProgressListener listener;
private final String contentType;
public CountingFileRequestBody(File file, String contentType, ProgressListener listener) {
this.file = file;