Skip to content

Instantly share code, notes, and snippets.

View Folyd's full-sized avatar
🦀
Rustacean

Folyd Folyd

🦀
Rustacean
View GitHub Profile
@Folyd
Folyd / WrapGridView.java
Last active January 31, 2024 20:54
A custom GridView which can wrap content.
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 / StatusApplication.java
Last active January 28, 2022 02:39
Custom Application which can detect application state of whether it enter background or enter foreground.
/**
* Custom Application which can detect application state of whether it enter
* background or enter foreground.
*
* @author shuang
* @reference http://www.vardhan-justlikethat.blogspot.sg/2014/02/android-solution-to-detect-when-android.html
*/
public abstract class StatusApplication extends Application implements ActivityLifecycleCallbacks {
public static final int STATE_UNKNOWN = 0x00;
@Folyd
Folyd / debug_via_wifi.sh
Created September 17, 2015 11:36
A shell script let you debug android device via WI-FI.
#!/usr/bin/env bash
#Notice: if unable to connect to [ip]:5555,
#try adb kill-server then try again.
adb shell ip route > addrs.txt
#Case 1:Nexus 7
#192.168.88.0/23 dev wlan0 proto kernel scope link src 192.168.89.48
#Case 2: Smartsian T1,Huawei C8813
#default via 192.168.88.1 dev eth0 metric 30
@Folyd
Folyd / DownloadManagerResolver.java
Last active December 21, 2017 20:12
A helper class to detect whether DownloadManager is disabled in Android device,if true show AlertDialog to tell user to enable it.
import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.Build;
import android.support.v7.app.AlertDialog;
import android.support.v7.widget.AppCompatTextView;
@Folyd
Folyd / VideoSurfaceView.java
Created November 12, 2015 11:31
A enhance SurfaceView which support scale content size according to aspect ratio.
public class VideoSurfaceView extends SurfaceView implements MediaPlayer.OnVideoSizeChangedListener {
private int mVideoWidth;
private int mVideoHeight;
public VideoSurfaceView(Context context) {
super(context);
}
public VideoSurfaceView(Context context, AttributeSet attrs) {
super(context, attrs);

Keybase proof

I hereby claim:

  • I am Folyd on github.
  • I am wichna (https://keybase.io/wichna) on keybase.
  • I have a public key whose fingerprint is DF25 E39D 5B47 5708 901F 15DA 0A8F BCAD D5DD 3A9A

To claim this, I am signing this object:

@Folyd
Folyd / LevelFilterView.java
Created March 28, 2016 08:48
Level filter view
public class LevelFilterView extends TextView implements View.OnClickListener {
private LevelFilterPopup mFilterPopup;
private OnLevelFilteredListener mOnLevelFilteredListener;
private int mItemBackgroundId;
private String[] mEntries;
public LevelFilterView(Context context) {
super(context);
@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);
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
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.
*
*/