Skip to content

Instantly share code, notes, and snippets.

Avatar
😕
todo everything

咕咚 maoruibin

😕
todo everything
View GitHub Profile
@maoruibin
maoruibin / EditTextCountWatch.java
Last active Apr 1, 2019
EditText View 限制输入字符数,并倒计还能输入多少字符,兼容中英文字符
View EditTextCountWatch.java
/**
* EditText View 限制输入字符数,并倒计还能输入多少字符,兼容中英文字符
* author : ruibin1 (ruibin1@staff.weibo.com)
* create : 2019/3/28 - 2:12 PM.
* thanks : https://github.com/FJ917/FJEditTextCount
*/
public class EditTextCountWatch {
private EditText mEtContent;
private TextView mTvNum;
//最大字符
@maoruibin
maoruibin / DrawableBuilder.java
Last active Jul 11, 2019
提供语义化 API 用来创建 Shape Drawable
View DrawableBuilder.java
**
* author : ruibin1 (ruibin1@staff.weibo.com)
* docs : https://github.com/maoruibin/maoruibin.github.com/issues/88
* build : 2019/3/21 - 3:55 PM.
*/
public class DrawableBuilder {
//默认线条粗细 1dp
private static final int defaultLineWidth = 1;
private static final int defaultLineColor = Color.parseColor("#e9e9e9");
View gist:ecd818dd5c878bbed07feceabb6bc8ea
```java
import android.content.Context;
import android.database.ContentObserver;
import android.database.Cursor;
import android.graphics.Point;
import android.net.Uri;
import android.os.Handler;
import android.os.Looper;
import android.provider.MediaStore;
import android.text.TextUtils;
View 滑动 View 的五种方法
@Override
public boolean onTouchEvent(MotionEvent event) {
int x = (int) event.getX();
int y = (int) event.getY();
switch (event.getAction()){
case MotionEvent.ACTION_DOWN:
//记录触摸到坐标
lastX = x;
lastY = y;
break;
@maoruibin
maoruibin / gist:3044a47284312a234ae6
Created Mar 6, 2016
Create a ImageView effect when press
View gist:3044a47284312a234ae6
@Override
public boolean onTouchEvent(MotionEvent event) {
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
Drawable drawable = getDrawable();
if (drawable != null) {
drawable.mutate().setColorFilter(Color.GRAY, PorterDuff.Mode.MULTIPLY);
}
@maoruibin
maoruibin / ListenClipboardService.java
Created Feb 25, 2016
生成一个处于前台状态的通知
View ListenClipboardService.java
private void showNormalNotification(Context context) {
NotificationCompat.Builder builder = new NotificationCompat.Builder(context);
builder.setContentTitle("Title");
builder.setContentText("Description");
builder.setSmallIcon(R.mipmap.ic_launcher);
builder.setPriority(NotificationCompat.PRIORITY_MIN);
builder.setOngoing(true);
long[] vibrate = {0, 50, 0, 0};
builder.setVibrate(vibrate);
View RxUtils.txt
/**
* make a operate change to observable
* @param func
* @param <T>
* @return
*/
public static <T> Observable<T> makeObservable(final Callable<T> func) {
return Observable.create(new Observable.OnSubscribe<T>() {
@Override
public void call(Subscriber<? super T> subscriber) {
@maoruibin
maoruibin / FileUtil.java
Last active Jan 13, 2016
method of copy file
View FileUtil.java
/**
* copy file
* @param source
* @param dest
* @throws IOException
*/
public static void copyFileUsingFileChannels(File source, File dest)
throws IOException {
FileChannel inputChannel = null;
FileChannel outputChannel = null;
View git_toturial
git init # 初始化本地git仓库(创建新仓库)
git config --global user.name "xxx" # 配置用户名
git config --global user.email "xxx@xxx.com" # 配置邮件
git config --global color.ui true # git status等命令自动着色
git config --global color.status auto
git config --global color.diff auto
git config --global color.branch auto
git config --global color.interactive auto
git config --global --unset http.proxy # remove proxy configuration on Git.
git clone git+ssh://git@192.168.53.168/VT.git # clone远程仓库