Skip to content

Instantly share code, notes, and snippets.

View aftabsikander's full-sized avatar

Aftab aftabsikander

  • Karachi,Pakistan
View GitHub Profile
@aftabsikander
aftabsikander / DateTimeHelper.java
Created December 14, 2016 17:18
java/android date time helper
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.TimeZone;
import android.util.Log;
/**
* Utility class for parsing and formatting dates and times.
*
@aftabsikander
aftabsikander / TimeUtils.java
Created December 14, 2016 17:18 — forked from fazlurr/TimeUtils.java
Time Utility Class i'm using for one of my Android Project
import android.content.Context;
import android.text.TextUtils;
import android.text.format.DateUtils;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
/**
@aftabsikander
aftabsikander / EmptyRecyclerView.java
Created December 13, 2016 15:48 — forked from meoyawn/EmptyRecyclerView.java
RecyclerView doesn't have an emptyView support, we gotta fix that
import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.util.AttributeSet;
import android.view.View;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public class EmptyRecyclerView extends RecyclerView {
@Nullable View emptyView;
@aftabsikander
aftabsikander / ExcellentAdventure.java
Created December 2, 2016 19:09 — forked from jonfhancock/ExcellentAdventure.java
This set of classes demonstrates what a Not Dumb ViewHolder should look like. It lightens the load on the Adapter, and places decisions about what to do with user interactions on the Activity where it belongs.
public class ExcellentAdventure {
@Retention(SOURCE)
@StringDef({ERA_BC, ERA_AD})
public @interface Era {
}
public static final String ERA_BC = "BC";
public static final String ERA_AD = "AD";
@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;
@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 / 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 / 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 / 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)
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);
}