Skip to content

Instantly share code, notes, and snippets.

@aballano
aballano / WrapHeightViewPager.java
Created October 23, 2015 23:50
Dynamic view pager which sets it´s height to the maximum size of it´s children if set to wrap_content.
import android.content.Context;
import android.support.v4.view.ViewPager;
import android.util.AttributeSet;
import android.view.Gravity;
import android.view.MotionEvent;
import android.view.View;
/**
* Created by Shyish on 11/10/2015.
*/
@yqritc
yqritc / gist:ccca77dc42f2364777e1
Last active January 25, 2025 17:43
Equal column spacing for Android RecyclerView GridLayoutManager by using custom ItemDecoration

ItemOffsetDecoration

public class ItemOffsetDecoration extends RecyclerView.ItemDecoration {

    private int mItemOffset;

    public ItemOffsetDecoration(int itemOffset) {
        mItemOffset = itemOffset;
    }
@quynguyen3490
quynguyen3490 / GPSTracking.java
Created April 4, 2015 05:50
Get Current Location Android
package com.quynguyenblog.mymap;
import android.app.AlertDialog;
import android.app.Service;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
@ssinss
ssinss / EndlessRecyclerOnScrollListener.java
Last active January 19, 2024 08:52
Endless RecyclerView OnScrollListener
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;
@fenda
fenda / .htaccess (file extension)
Last active June 6, 2023 13:27
remove file extension from url
# The following will allow you to use URLs such as the following:
#
# example.com/link
# example.com/link/
#
# Which will actually serve files such as the following:
#
# example.com/link.html
# example.com/link.php
#
@mrclay
mrclay / .htaccess
Created March 7, 2012 15:01
Remove PHP extension from URLs
<IfModule mod_rewrite.c>
RewriteEngine on
# Redirect /index.php (and /index) to /
RewriteCond %{THE_REQUEST} ^GET\ /(.*/)?index(\.php)?(\?.*)?\ HTTP/
RewriteRule ^ http://%{HTTP_HOST}/%1 [L,R=301]
# Redirect /foo.php to /foo
RewriteCond %{THE_REQUEST} ^GET\ /(.*)\.php(\?.*)?\ HTTP/
RewriteRule ^ http://%{HTTP_HOST}/%1 [L,R=301]