Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View Folyd's full-sized avatar
🦀
Rustacean

Folyd Folyd

🦀
Rustacean
View GitHub Profile
@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 / 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 / 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 / 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 / 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
/*
* 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 / 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;
import android.content.Context;
import android.util.AttributeSet;
import android.view.KeyEvent;
import android.widget.SeekBar;
/**
* This is workaround version for SeekBar which didn't detect the progress changed
* by arrow key pressed.
*
*/
import android.os.AsyncTask;
import java.lang.ref.WeakReference;
public abstract class WeakAsyncTask<Params, Progress, Result, WeakTarget> extends
AsyncTask<Params, Progress, Result> {
protected WeakReference<WeakTarget> mTarget;
public WeakAsyncTask(WeakTarget target) {
mTarget = new WeakReference<WeakTarget>(target);
}
/** {@inheritDoc} */
@Override
@Folyd
Folyd / TextBadgeDrawable.java
Created March 11, 2016 11:13
Text badge drawable
public class TextBadgeDrawable extends Drawable {
private Paint mPaint;
private Rect mBounds;
private Rect mTextBounds;
private RectF mRectF;
private int mColor;
private String mText;
public TextBadgeDrawable() {
mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);