Skip to content

Instantly share code, notes, and snippets.

View flyfire's full-sized avatar
🎯
Focusing

flyfire flyfire

🎯
Focusing
View GitHub Profile
@flyfire
flyfire / brew_symlink_error_sierra.md
Created March 2, 2019 01:08 — forked from dalegaspi/brew_symlink_error_sierra.md
Homebrew Symlink errors in Mac OSX High Sierra
@flyfire
flyfire / SnappyRecyclerView.java
Created February 20, 2019 03:53 — forked from nesquena/SnappyRecyclerView.java
Snap-to-Center RecyclerView Extension
// From: http://stackoverflow.com/a/37816976
public class SnappyRecyclerView extends RecyclerView {
// Use it with a horizontal LinearLayoutManager
// Based on http://stackoverflow.com/a/29171652/4034572
public SnappyRecyclerView(Context context) {
super(context);
}
@flyfire
flyfire / Contact.java
Created February 20, 2019 03:37 — forked from rogerhu/Contact.java
Endless scrolling with RecyclerVIew
package codepath.com.recyclerviewfun;
import java.util.ArrayList;
import java.util.List;
public class Contact {
private String mName;
private boolean mOnline;
public Contact(String name, boolean online) {
@flyfire
flyfire / keybase.md
Created February 15, 2019 09:52
keybase

Keybase proof

I hereby claim:

  • I am flyfire on github.
  • I am solarex (https://keybase.io/solarex) on keybase.
  • I have a public key whose fingerprint is 6716 5DAB 435F C31D 9A9F A798 3623 0BDE A178 0DC4

To claim this, I am signing this object:

@flyfire
flyfire / FlexibleUnderLinePageIndicator.java
Created February 14, 2019 07:10
[FlexibleUnderLinePageIndicator] ViewPagerIndicator #flexible #pageindicator
package bakerj.flexibleunderlinepageindicator;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.support.v4.view.ViewPager;
import android.util.AttributeSet;
import android.view.View;
@flyfire
flyfire / CircleImageView.java
Created February 12, 2019 09:29
[CircleImageView] 圆角图片 #抗锯齿 #Xfermode
package com.open.circleimageview.widget;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.PaintFlagsDrawFilter;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffXfermode;
@flyfire
flyfire / script.sh
Created January 31, 2019 09:11 — forked from dlew/script.sh
Simple AndroidX Migration Script
#!/usr/bin/env bash
# I've found that the "Migrate to AndroidX" converter in Android Studio doesn't work very
# well, so I wrote my own script to do the simple job of converting package names.
#
# You can download a CSV of package names here: https://developer.android.com/topic/libraries/support-library/downloads/androidx-class-mapping.csv
#
# It'll run faster on a clean build because then there are fewer files to scan over.
#
# Uses `gsed` because I'm on a Mac. Can easily replace with `sed` if you don't have `gsed`.
@flyfire
flyfire / MathHelper.java
Created December 17, 2018 07:24
[MathHelper] #math
public class MathHelper {
public static double distance(double dx, double dy) {
return Math.sqrt(dx * dx + dy * dy);
}
public static double distance(double x0, double y0, double x1, double y1) {
double dx = x1 - x0;
double dy = y1 - y0;
return distance(dx, dy);
@flyfire
flyfire / getClassesInPackaget.kt
Created December 5, 2018 07:11
[得到同一包名下的所有Class] #DexFile
private fun getClassesNameListInPackage(packageName: String, context: Context): List<String> {
val realPackageName = "${context.packageName}.$packageName"
val df = DexFile(context.packageCodePath)
val enumration = df.entries()
val list = mutableListOf<String>()
while (enumration.hasMoreElements()) {
val className = enumration.nextElement()
if (className.contains(realPackageName)) {
list.add(className)
}
@flyfire
flyfire / ScaledBitmap.java
Created November 27, 2018 09:42
[ScaleBitmap] scale bitmap #bitmap #scale
//缩放图片大小
public Bitmap scaleBitmap(Bitmap bitmap, int newWidth, int newHeight) {
Bitmap b = bitmap;
int width = b.getWidth();
int height = b.getHeight();
// 计算缩放比例
float scaleWidth = ((float) newWidth) / width;
float scaleHeight = ((float) newHeight) / height;
// 取得想要缩放的matrix参数
Matrix matrix = new Matrix();