This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<templateSet group="AndroidLogKotlin"> | |
<template name="logm" value="android.util.Log.d(TAG, $FORMAT$)" description="Log method name and its arguments" toReformat="true" toShortenFQNames="true"> | |
<variable name="FORMAT" expression="groovyScript("def params = _2.collect {it + ' = [$' + it + ']'}.join(', '); return '\"' + _1 + '() called' + (params.empty ? '' : ' with: ' + params) + '\"'", kotlinFunctionName(), functionParameters())" defaultValue="" alwaysStopAt="false" /> | |
<context> | |
<option name="KOTLIN_STATEMENT" value="true" /> | |
</context> | |
</template> | |
<template name="logd" value="android.util.Log.d(TAG, "$METHOD_NAME$: $content$")" description="Log.d(String)" toReformat="true" toShortenFQNames="true"> | |
<variable name="METHOD_NAME" expression="kotlinFunctionName()" defaultValue="" alwaysStopAt="false" /> | |
<variable name="content" expression="" defaultValue="" alwaysStopAt="true" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Pick Audio file from Gallery: | |
//Use MediaStore.Audio.Media.EXTERNAL_CONTENT_URI | |
Intent intent = new Intent(Intent.ACTION_PICK, MediaStore.Audio.Media.EXTERNAL_CONTENT_URI); | |
Pick Video file from Gallery: | |
//Use MediaStore.Audio.Media.EXTERNAL_CONTENT_URI | |
Intent intent = new Intent(Intent.ACTION_PICK, MediaStore.Video.Media.EXTERNAL_CONTENT_URI); | |
Pick Image from gallery: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Created by chensuilun on 2017/12/08. | |
*/ | |
public class DownloadManagerRx implements IDownloadListener { | |
private static final String TAG = "DownloadManagerRx"; | |
private static DownloadManagerRx mInstance; | |
private HashMap<Object, Disposable> mRunningRequest; | |
private Map<Object, Float> mProgress; | |
private List<IDownloadListener> mIDownloadListeners; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Created by chensuilun on 2017/7/4. | |
*/ | |
public class NTUSUtils { | |
private static final String TAG = "NTUSUtils"; | |
private static final String NTP_TRUSTED_TIME = "android.util.NtpTrustedTime"; | |
private static final String GET_INSTANCE = "getInstance";//private NtpTrustedTime getInstance(Context context) | |
private static final String FORCE_REFRESH = "forceRefresh"; //public boolean forceRefresh() | |
private static final String GET_CACHED_NTP_TIME = "getCachedNtpTime";//public long getCachedNtpTime() | |
private static Context sContext = AppApplication.getContext(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.app.Activity; | |
import android.app.Application; | |
import android.content.Context; | |
import android.content.ContextWrapper; | |
import android.os.Bundle; | |
import android.os.Looper; | |
import android.os.MessageQueue; | |
import android.util.Log; | |
import android.view.View; | |
import android.view.ViewTreeObserver; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.xinghui.notificationlistenerservicedemo; | |
import android.app.ActivityManager; | |
import android.app.Service; | |
import android.content.ComponentName; | |
import android.content.Context; | |
import android.content.Intent; | |
import android.content.pm.PackageManager; | |
import android.os.IBinder; | |
import android.os.Process; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 在内存重启的时候自动恢复可见状态的Fragment,避免重叠现象 | |
* 但同时不要忘了在Activity中判断`savedInstanceState`为null的时候才操作Fragment | |
* Created by chensuilun on 16-8-9. | |
*/ | |
public abstract class BaseRestoreFragment extends Fragment { | |
public static final String IS_SHOW = "is_show"; | |
protected View mRootView; | |
@Override | |
public void onCreate(@Nullable Bundle savedInstanceState) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static int lighten(int color, double fraction) { | |
int red = Color.red(color); | |
int green = Color.green(color); | |
int blue = Color.blue(color); | |
red = lightenColor(red, fraction); | |
green = lightenColor(green, fraction); | |
blue = lightenColor(blue, fraction); | |
int alpha = Color.alpha(color); | |
return Color.argb(alpha, red, green, blue); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def supportLibraryVersion = '24.2.1' | |
ext.deps = [ | |
supportCompat: "com.android.support:support-compat:$supportLibraryVersion", | |
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ColorStateGenerate{ | |
// 灰度 | |
public static int greyer(int color) { | |
int blue = (color & 0x000000FF) >> 0; | |
int green = (color & 0x0000FF00) >> 8; | |
int red = (color & 0x00FF0000) >> 16; | |
int grey = Math.round(red * 0.299f + green * 0.587f + blue * 0.114f); | |
return Color.argb(0xff, grey, grey, grey); | |
} |
NewerOlder