Skip to content

Instantly share code, notes, and snippets.

View interchen's full-sized avatar

Chen Yanjun interchen

  • Xiamen Fujian China
View GitHub Profile
@interchen
interchen / kotlin_reflection.kt
Created May 18, 2017 07:06
The way to use class reflection in Kotlin
package com.homeking365.kotlindemo
import android.content.Intent
import android.os.Bundle
import android.support.v7.app.AppCompatActivity
import android.support.v7.widget.LinearLayoutManager
import android.support.v7.widget.RecyclerView
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
@interchen
interchen / emoji.java
Created May 17, 2017 08:12
encrypt some chars of a string
public static String encryptString(String str, String encryptStr) {
String resultStr;
int startIndex = indexOfNormalText(str, false);
int endIndex = indexOfNormalText(str, true);
if (startIndex == NOT_FOUND) {
resultStr = str + encryptStr;
} else {
if (str.length() == 1) {
@interchen
interchen / README.md
Created December 16, 2015 13:54 — forked from FokkeZB/README.md
URL schemes for iOS and Android (2/2)
@interchen
interchen / gist:f22a87df7d35c7e1179d
Created November 16, 2015 12:28
Sublime跳出括号或引号
[
{"keys": ["enter"], "command": "move", "args": {"by": "characters", "forward": true}, "context":
[
{ "key": "following_text", "operator": "regex_contains", "operand": "^[)\\]\\>\\'\\\"\\ %>\\}\\;\\,]", "match_all": true },
{ "key": "preceding_text", "operator": "not_regex_match", "operand": "^.*\\{$", "match_all": true },
{ "key": "auto_complete_visible", "operator": "equal", "operand": false }
]
}
]
@interchen
interchen / SystemUtil.java
Created October 29, 2014 12:24
判断是debug环境还是release环境
/**
* 判断是否是debug环境
* @param context 上下文
* @return true: debug, false: release
*/
public static boolean isDebugMode(Context context) {
return (context.getApplicationInfo().flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0;
}
@interchen
interchen / android get statusbar height
Created October 13, 2014 07:03
android get statusbar height
public static int getStatusBarHeight(Context context){
Class<?> c = null;
Object obj = null;
Field field = null;
int x = 0, statusBarHeight = 0;
try {
c = Class.forName("com.android.internal.R$dimen");
obj = c.newInstance();
field = c.getField("status_bar_height");
x = Integer.parseInt(field.get(obj).toString());
@interchen
interchen / android target version
Created October 11, 2014 01:08
android target version
/**
* Shows the progress UI and hides the login form.
*/
@TargetApi(Build.VERSION_CODES.HONEYCOMB_MR2)
public void showProgress(final boolean show) {
// On Honeycomb MR2 we have the ViewPropertyAnimator APIs, which allow
// for very easy animations. If available, use these APIs to fade-in
// the progress spinner.
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) {
int shortAnimTime = getResources().getInteger(android.R.integer.config_shortAnimTime);
@interchen
interchen / AutoIncreaseBuildNumber
Created September 30, 2014 02:46
Auto increase build number
buildNumber=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "$INFOPLIST_FILE")
buildNumber=$(($buildNumber + 1))
buildNumber=$(printf "%04d" $buildNumber)
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $buildNumber" "$INFOPLIST_FILE"
UIStoryboard *storyBoard;
if ([language isEqualToString:@"ar"]) {
lan = [[NSLocale preferredLanguages] objectAtIndex:0];
storyBoard = [UIStoryboard storyboardWithName:@"MainStoryboard_iPhone5Arabic" bundle:bnd];
}
else if([language isEqualToString:@"en"]) {
NSLog(@"DDD ");
lan = [[NSLocale preferredLanguages] objectAtIndex:20];
storyBoard = [UIStoryboard storyboardWithName:@"MainStoryboard_iPhone5English" bundle:bnd];
}
@interchen
interchen / convertNullObject
Created June 26, 2014 14:52
Delete NSNull object in Json object
/**
* 把response中的NSNull对象删除掉
*
* @param response 要处理的对象
*
* @return 删除掉NSNull后的新对象
*/
- (id)convertNullObject:(id)response
{
if (response == nil || [response isKindOfClass:[NSNull class]]) {