Skip to content

Instantly share code, notes, and snippets.

View JeffZane's full-sized avatar

Zane JeffZane

  • Beijing, China
View GitHub Profile
@JeffZane
JeffZane / GridSpanSizeLookupHelper.java
Created June 30, 2022 02:39 — forked from homj/GridSpanSizeLookupHelper.java
A ItemDecoration to center the contents of a RecyclerView. This comes in handy when you want to build a responsive UI.
/*
* Copyright 2015 Johannes Homeier
*
* 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
@JeffZane
JeffZane / MainActivity.java
Created August 12, 2019 07:43 — forked from subinkrishna/MainActivity.java
Sample - Height animation using ObjectAnimator
import android.animation.ObjectAnimator;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v7.app.AppCompatActivity;
import android.util.Property;
import android.view.View;
import android.view.animation.DecelerateInterpolator;
import android.widget.FrameLayout;
public class MainActivity extends AppCompatActivity {
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape>
<gradient
android:angle="0"
android:endColor="#19FFFFFF"
android:startColor="#FFFFFFFF" />
<size
android:width="20dp"
@JeffZane
JeffZane / NumSpaceTextWatcher.java
Created July 5, 2018 11:57
EditText format number
package com.nestia.android.pay.utils;
import android.support.annotation.NonNull;
import android.text.Editable;
import android.text.InputType;
import android.text.Selection;
import android.text.TextWatcher;
import android.text.method.DigitsKeyListener;
import android.widget.EditText;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.RectF;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.view.View;
import com.nestia.android.uikit.UiUtils;
/*
* Copyright (C) 2017 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
/*
* Copyright (C) 2017 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
@JeffZane
JeffZane / gridLayout_weight.txt
Last active May 23, 2018 12:19
GridLayout weight
1. 动态创建等分GridLayout,需要用到layout_columnWeight/Height(对应column/RowSpec)属性,注意调用的api(下方note) (bug: 如果child count比coloum count小,UI显示有问题)
for (TopUpProduct.TopUpType.Product product : products) {
TextView textView = (TextView) mInflater.inflate(R.layout.np_item_call_charge, mGridLayout, false);
textView.setText("S$ " + product.getPrice());
mGridLayout.addView(textView);
GridLayout.LayoutParams layoutParams = (GridLayout.LayoutParams) textView.getLayoutParams();
layoutParams.columnSpec = GridLayout.spec(GridLayout.UNDEFINED, 1f); //note: 1f
layoutParams.leftMargin = UiUtils.dp2px(getContext(), 6);
layoutParams.rightMargin = UiUtils.dp2px(getContext(), 6);
layoutParams.topMargin = UiUtils.dp2px(getContext(), 16);
@JeffZane
JeffZane / git_diff.md
Created May 4, 2018 09:54 — forked from jhjguxin/git_diff.md
Git diff 比较不同版本的差异

Git 比较不同版本文件差异的常用命令格式:

git diff                                       查看尚未暂存的文件更新了哪些部分

git diff filename 查看尚未暂存的某个文件更新了哪些

git diff –cached                    查看已经暂存起来的文件和上次提交的版本之间的差异

git diff –cached filename 查看已经暂存起来的某个文件和上次提交的版本之间的差异
@JeffZane
JeffZane / 0_reuse_code.js
Created December 28, 2016 03:59
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console