Skip to content

Instantly share code, notes, and snippets.

View slightfoot's full-sized avatar
💙
Fluttering

Simon Lightfoot slightfoot

💙
Fluttering
View GitHub Profile
@slightfoot
slightfoot / ScrollingViewPager.java
Created April 27, 2013 22:59
This ScrollingViewPager lets its children determine if they want to scroll before the view pager chooses to scroll/switch pages. I also have a default override for multitouch so that we can can force the view pager to ignore the touch events if multiple pointers are in use on the down action.Helpful if you have a horizontally scrolling view in a…
import android.content.Context;
import android.support.v4.view.MotionEventCompat;
import android.support.v4.view.ViewPager;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
public class ScrollingViewPager extends ViewPager
{
@slightfoot
slightfoot / MainActivity.java
Last active March 7, 2019 11:40
ContextMenu's in Fragments within a ViewPager
import java.util.ArrayList;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.app.ListFragment;
import android.support.v4.view.ViewPager;
import android.view.ContextMenu;
@slightfoot
slightfoot / SearchActivity.java
Last active October 26, 2023 12:28
SearchView example
import java.util.ArrayList;
import java.util.Iterator;
import java.util.Locale;
import android.content.Context;
import android.content.Intent;
import android.database.AbstractCursor;
import android.database.Cursor;
import android.support.v4.app.FragmentActivity;
import android.text.TextUtils;
@slightfoot
slightfoot / TestActivity.java
Last active February 10, 2018 22:31
Example of the use of a ListView with associated empty View.
import java.util.ArrayList;
import java.util.Random;
import android.app.ListActivity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
@slightfoot
slightfoot / ParallelogramDrawable.java
Last active February 8, 2022 12:34
ParallelogramDrawable
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.drawable.ShapeDrawable;
import android.graphics.drawable.shapes.Shape;
public class ParallelogramDrawable extends ShapeDrawable
{
private double mAngle;
@slightfoot
slightfoot / decor_adview.xml
Created May 21, 2013 11:29
Adding some view as the decor to a ViewPager
<?xml version="1.0" encoding="utf-8"?>
<com.example.myapp.adview
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/ad_view"
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_gravity="bottom|fill_horizontal"
android:background="#000000"
/>
@slightfoot
slightfoot / HttpDigestAuth.java
Last active May 11, 2023 05:56
HTTP Digest Auth for Android (incomplete and probably hackable, but works!)
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.HttpURLConnection;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.HashMap;
import com.google.common.base.CharMatcher;
import com.google.common.base.Joiner;
import com.google.common.base.Splitter;
@slightfoot
slightfoot / FlingableViewPager.java
Created June 11, 2013 18:20
Start of a Flingable ViewPager
import android.content.Context;
import android.support.v4.view.MotionEventCompat;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.support.v4.widget.ScrollerCompat;
import android.support.v4.view.ViewCompat;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.VelocityTracker;
import android.view.ViewConfiguration;
@slightfoot
slightfoot / ActionButton.java
Last active December 18, 2015 19:49
Action Button with no padding example.
package com.example.actionbutton;
import android.annotation.SuppressLint;
import android.content.Context;
import android.util.AttributeSet;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.ImageView;
import android.widget.Toast;
@slightfoot
slightfoot / ContactsPhotoCameraCallback.java
Created July 12, 2013 16:46
Example of creating a contact from taking a picture with the camera on Android.
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import android.annotation.TargetApi;
import android.content.ContentProviderOperation;
import android.content.ContentProviderResult;
import android.content.ContentResolver;