Skip to content

Instantly share code, notes, and snippets.

Avatar
🦀
Rustacean

Folyd Folyd

🦀
Rustacean
View GitHub Profile
@Folyd
Folyd / LoadMoreView.java
Last active Sep 16, 2015
Load more view for ListView to load more data by page or cursor
View LoadMoreView.java
public class LoadMoreView extends LinearLayout {
private TextView mTipText;
private ProgressBar mProgressBar;
private boolean mIsLoading;
private boolean mIsDone;
private int mLimit = 20;
private String mCursor = null;
private int mPage = 1;
@Folyd
Folyd / Utils.java
Last active Sep 15, 2015
Common Utility class
View Utils.java
public class Utils {
/**
* To record the user click time.
*/
private static long sLastClickTime = 0L;
/**
* Get device unique identify.
*
* @param context
@Folyd
Folyd / AbstractDownloadAsyncTask.java
Created Sep 15, 2015
Abstract Download AsyncTask
View AbstractDownloadAsyncTask.java
import android.os.AsyncTask;
import android.text.TextUtils;
import android.util.Log;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
View CircleProgressBar.java
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.RectF;
import android.support.annotation.NonNull;
import android.util.AttributeSet;
import android.view.View;
@Folyd
Folyd / ToggleVisibilityHelper.java
Created Sep 15, 2015
Toggle visibility helper class
View ToggleVisibilityHelper.java
import android.os.Handler;
/**
* A helper class can toggle target object visibility automatically.
* It is very useful for MediaController (or ActionBar) when play video in Activity.
*/
public abstract class ToggleVisibilityHelper {
/**
* Record the time while user lasted click.
@Folyd
Folyd / WrapGridView.java
Last active Sep 15, 2015
A custom GridView which can wrap content.
View WrapGridView.java
import android.content.Context;
import android.util.AttributeSet;
import android.widget.GridView;
/**
* A custom GridView which can wrap content.
*/
public class WrapGridView extends GridView {
public WrapGridView(Context context) {
@Folyd
Folyd / NonSwipeableViewPager.java
Last active Sep 9, 2015
A Custom ViewPager which can been disable swipe.
View NonSwipeableViewPager.java
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.res.TypedArray;
import android.support.v4.view.ViewPager;
import android.util.AttributeSet;
import android.view.MotionEvent;
import com.folyd.app.R;
public class NonSwipeableViewPager extends ViewPager {
@Folyd
Folyd / Keyboard.java
Created Sep 9, 2015
A Piano Keyboarad View in Android
View Keyboard.java
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.RectF;
import android.util.AttributeSet;
import android.view.View;
import com.theonepiano.smartpiano.R;
View SimpleBitmapAsyncTask.java
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.AsyncTask;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
public class SimpleBitmapAsyncTask extends AsyncTask<String, Void, Bitmap> {
@Folyd
Folyd / OnLastItemVisibleListener.java
Created Sep 9, 2015
A OnLastItemVisibleListener for ListView
View OnLastItemVisibleListener.java
import android.widget.AbsListView;
import android.widget.AbsListView.OnScrollListener;
public abstract class OnLastItemVisibleListener implements AbsListView.OnScrollListener {
private boolean mLastItemVisible = false;
@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {
/**
* Check that the scrolling has stopped, and that the last item is