Skip to content

Instantly share code, notes, and snippets.

View PsyGik's full-sized avatar
🏠
Working from home

Dhanraj Padmashali PsyGik

🏠
Working from home
View GitHub Profile
/*
* Copyright (C) 2014 Antonio Leiva Gordillo.
*
* 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.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
public abstract class EndlessRecyclerOnScrollListener extends RecyclerView.OnScrollListener {
public static String TAG = EndlessRecyclerOnScrollListener.class.getSimpleName();
private int previousTotal = 0; // The total number of items in the dataset after the last load
private boolean loading = true; // True if we are still waiting for the last set of data to load.
private int visibleThreshold = 5; // The minimum amount of items to have below your current scroll position before loading more.
int firstVisibleItem, visibleItemCount, totalItemCount;
import java.util.ArrayList;
import java.util.List;
import android.content.Context;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
public class MyFragmentPageAdapter extends FragmentPagerAdapter {

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:

@PsyGik
PsyGik / header.css
Created May 11, 2015 12:49
Header that shrinks on page scroll
#header_nav {
width:100%;
background-color:#666;
position:fixed;
top:0;
left:0;
-webkit-transition:0.5s linear all;
-moz-transition:0.5s linear all;
-o-transition:0.5s linear all;
transition:0.5s linear all;
@PsyGik
PsyGik / GetActionBarHeight
Last active September 21, 2015 05:31 — forked from laaptu/GetActionBarHeight
Android getting ActionBar Height in dip
public int getActionBarHeight() {
int actionBarHeight = 0;
TypedValue tv = new TypedValue();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
if (getTheme().resolveAttribute(android.R.attr.actionBarSize, tv,
true))
actionBarHeight = TypedValue.complexToDimensionPixelSize(
tv.data, getResources().getDisplayMetrics());
} else {
actionBarHeight = TypedValue.complexToDimensionPixelSize(tv.data,
@PsyGik
PsyGik / README.md
Created September 25, 2015 14:07
A click / long press listener for RecyclerViews. Questions? https://twitter.com/lnikkila
@PsyGik
PsyGik / RecorderService.java
Created October 23, 2015 05:51 — forked from qihnus/RecorderService.java
a minimalist example of Android accessibility service
import android.accessibilityservice.AccessibilityService;
import android.accessibilityservice.AccessibilityServiceInfo;
import android.util.Log;
import android.view.accessibility.AccessibilityEvent;
public class RecorderService extends AccessibilityService {
static final String TAG = "RecorderService";
private String getEventType(AccessibilityEvent event) {
@PsyGik
PsyGik / GoogleAPI.py
Created January 20, 2016 06:32 — forked from SalvaJ/GoogleAPI.py
Example making HTTP request to use Google API without api-client.It works in Python3 (tested ok in 3.3.5)
#!usr/bin/python3
# -*- coding: UTF-8 -*-
"""This module is a sample of the OAuth2 authentication by Python3"""
__version__ = "0.1.0"
__author__ = "shin (shin.hateblo.jp)"
__copyright__ = "(C) 2012 shin"
__email__ = "s2pch.luck@gmail.com"
__license__ = "Apache License 2.0"
@PsyGik
PsyGik / 0 Easy deployment with Grunt and git.md
Created January 27, 2016 06:17 — forked from sarahhenderson/0 Easy deployment with Grunt and git.md
Single command deploy for an Angular/Node web application to Ubuntu EC2 instance

Easy deployment with Grunt and Git

Angular/Node.js web application to Ubuntu EC2 instance

Objective

Deploy entire site to server using a single command grunt deploy

Assumptions

  1. Your web application exists on your local machine in a git repo
  2. You can log into your server via ssh without a password
  3. You are using grunt for your build process