Skip to content

Instantly share code, notes, and snippets.

View Folyd's full-sized avatar
🦀
Rustacean

Folyd Folyd

🦀
Rustacean
View GitHub Profile

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);
@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);
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.
*
*/
@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 / 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