Skip to content

Instantly share code, notes, and snippets.

Chen Xihong unclechen

Block or report user

Report or block unclechen

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@unclechen
unclechen / getDate.js
Created May 2, 2017
js获取`yymmdd`格式的日期
View getDate.js
var path = require("path");
var currentDate = new Date();
var year = currentDate.getFullYear();
var month = currentDate.getMonth() + 1;
month = month < 10 ? '0' + month : month;
var day = currentDate.getDate();
day = day < 10 ? '0' + day : day;
var date = year + month + day;
console.log(date);
@unclechen
unclechen / AndroidMacAddress.java
Created Oct 12, 2016
Android上读取MAC地址的方法,兼容Android M
View AndroidMacAddress.java
// hacking mac
public static String getMacAddress(Context context) {
String macAddress = null;
try {
String wifiInterfaceName = "wlan0";
Enumeration<NetworkInterface> interfaces = NetworkInterface.getNetworkInterfaces();
while (interfaces.hasMoreElements()) {
NetworkInterface iF = interfaces.nextElement();
if (iF.getName().equalsIgnoreCase(wifiInterfaceName)) {
byte[] addr = iF.getHardwareAddress();
View GetWifiSsid.java
/**
* 获取当前连接到的WiFi名称
*
* 注意:当“APILevel >=17”时,返回的字符串会多一对双引号
* https://code.google.com/p/android/issues/detail?id=40144
* http://stackoverflow.com/questions/13563032/jelly-bean-issue-wifimanager-getconnectioninfo-getssid-extra
*/
public String getWifiSsid() {
String ssid = null;
try {
@unclechen
unclechen / workspace.xml
Created Mar 31, 2016
通过修改“yourproject/.idea/workspace.xml”来配置ignore文件
View workspace.xml
/** 手动到项目下的”./idea"文件夹中配置 */
<component name="ChangeListManager">
...
<ignored path="android.iws" />
<ignored path=".idea/workspace.xml" />
<ignored mask="*.iml" />
<ignored path="gradle/" />
<ignored path="build/" />
<ignored path=".idea/" />
<ignored path="YourModuleA/build/" />
View BitmapUtil.java
/**
* 检查图片是否损坏:通过指定inJustDecodeBounds = true来得到解析图片以后的Options
*
* @param filePath
* @return
*/
public static boolean checkImgDamage(String filePath) {
BitmapFactory.Options options = null;
if (options == null) {
options = new BitmapFactory.Options();
@unclechen
unclechen / RoundRectShapeBackground.java
Created Feb 29, 2016
动态设置圆角矩形背景,可以给TextView或者ViewGroup绘制圆角矩形背景,并设置颜色
View RoundRectShapeBackground.java
//1. 先新建一个圆角矩形,并包装成一个ShapeDrawable
ShapeDrawable backgroundDrawable = new ShapeDrawable(new RoundRectShape(new float[] {10, 10, 10, 10, 10, 10, 10, 10},
null, null));
//2. 设置背景颜色
backgroundDrawable.getPaint().setColor(Color.parseColor("#1fbaf3"));
//3. 设置透明度
backgroundDrawable.setsetAlpha(100);
View PxUtils.java
package com.tiktokview.utils;
import android.content.Context;
/**
* dp,sp和px互转工具类
* Created by noughtchen on 2015/12/2.
*/
public class PxUtils {
You can’t perform that action at this time.