Skip to content

Instantly share code, notes, and snippets.

@yunnywu
yunnywu / deep_copy
Created November 3, 2017 06:50
use android Parcel deep copy
public static List<Track> copyList(List<Track> list){
Parcel p = Parcel.obtain();
p.writeTypedList(list);
p.setDataPosition(0);
List<Track> result = null;
try{
result = p.createTypedArrayList(Track.CREATOR);
}catch (Exception e){
e.printStackTrace();
}
BigDecimal re = new BigDecimal("1.256");
//向上取值 1.26
Log.d("wcy", "re ROUND_CEILING = " + re.setScale(2, BigDecimal.ROUND_CEILING));
//向下取值 1.25
Log.d("wcy", "re ROUND_FLOOR = " + re.setScale(2, BigDecimal.ROUND_FLOOR));
re = new BigDecimal("1.256");
//向 0 的方向 舍去后面 1.25
Log.d("wcy", "re ROUND_DOWN = " + re.setScale(2, BigDecimal.ROUND_DOWN));
re = new BigDecimal("-1.256");
@yunnywu
yunnywu / MultiDexUtil.java
Created November 4, 2016 03:13
get classes is loaded in secondary dexes files
public class MultiDexUtil {
private static final String EXTRACTED_NAME_EXT = ".classes";
private static final String EXTRACTED_SUFFIX = ".zip";
private static final String SECONDARY_FOLDER_NAME = "code_cache" + File.separator +
"secondary-dexes";
private static final String PREFS_FILE = "multidex.version";
private static final String KEY_DEX_NUMBER = "dex.number";
@yunnywu
yunnywu / SystemPropertiesProxy
Created October 31, 2016 09:17 — forked from crossle/SystemPropertiesProxy
Use the reflection invoke SystemProperites
import java.lang.reflect.Method;
public class SystemPropertiesProxy {
/**
* This class cannot be instantiated
*/
private SystemPropertiesProxy() {
}
@yunnywu
yunnywu / Readme.md
Created September 8, 2016 07:44 — forked from gabrielemariotti/Readme.md
A SimpleSectionedRecyclerViewAdapter: use this class to realize a simple sectioned `RecyclerView.Adapter`.

You can use this class to realize a simple sectioned RecyclerView.Adapter without changing your code.

The RecyclerView should use a LinearLayoutManager. You can use this code also with the TwoWayView with the ListLayoutManager (https://github.com/lucasr/twoway-view)

This is a porting of the class SimpleSectionedListAdapter provided by Google

Screen

Example:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE module PUBLIC "-//Puppy Crawl//DTD Check Configuration 1.2//EN" "http://www.puppycrawl.com/dtds/configuration_1_2.dtd">
<!-- Generated by RHY @will_awoke -->
<module name="Checker">
<property name="charset" value="UTF-8"/>
<property name="severity" value="warning"/>
@yunnywu
yunnywu / three_line_rect
Created August 12, 2016 05:52
android three line rect drawable
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<solid android:color="#d6d6d6" />
</shape>
</item>
<item android:top="1dp"
android:bottom="1dp"
android:left="1dp"
@yunnywu
yunnywu / RootUtil,java
Created August 8, 2016 09:27
check isDeviceRooted
public class RootUtil {
public static boolean isDeviceRooted() {
return checkRootMethod1() || checkRootMethod2() || checkRootMethod3();
}
private static boolean checkRootMethod1() {
String buildTags = android.os.Build.TAGS;
return buildTags != null && buildTags.contains("test-keys");
}
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="your.package.name" >
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<application
android:allowBackup="true"