Skip to content

Instantly share code, notes, and snippets.

View Folyd's full-sized avatar
🦀
Rustacean

Folyd Folyd

🦀
Rustacean
View GitHub Profile
@Folyd
Folyd / IncrementTimer.java
Created November 2, 2015 12:06
IncrementTimer similar to CountdownTimer in android framework
public abstract class IncrementTimer {
/**
* Millis since epoch when alarm should stop.
*/
private final long mMillisInFuture;
/**
* The interval in millis that the user receives callbacks
*/
private final long mIncrementInterval;
/*
* Copyright 2014 The Android Open Source Project
*
* 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
@Folyd
Folyd / VideoPickerActivity.java
Last active October 8, 2015 08:32
A video picker activity
public class VideoPickerActivity extends Activity{
private final int REQUEST_PICK_VIDEO = 1;
public void onVideoPickClick(View view) {
Intent intent = new Intent(Intent.ACTION_PICK, MediaStore.Video.Media.EXTERNAL_CONTENT_URI);
startActivityForResult(intent, REQUEST_PICK_VIDEO);
}
@Override
@Folyd
Folyd / LoadMoreView.java
Last active September 16, 2015 08:03
Load more view for ListView to load more data by page or cursor
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 September 15, 2015 09:12
Common Utility class
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 September 15, 2015 09:05
Abstract Download AsyncTask
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;
@Folyd
Folyd / CircleProgressBar.java
Created September 15, 2015 09:03
Circle ProgressBar
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 September 15, 2015 09:01
Toggle visibility helper class
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 / NonSwipeableViewPager.java
Last active September 9, 2015 11:52
A Custom ViewPager which can been disable swipe.
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 September 9, 2015 07:12
A Piano Keyboarad View in Android
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;