├── README-EN.md ├── library ├── .gitignore ├── src │ ├── main │ │ ├── res │ │ │ └── values │ │ │ │ └── strings.xml │ │ ├── AndroidManifest.xml │ │ └── java │ │ │ └── com │ │ │ └── sloop │ │ │ ├── animation │ │ │ ├── AnimationListener.java │ │ │ ├── AnimatorListener.java │ │ │ └── Rotate3dAnimation.java │ │ │ ├── io │ │ │ └── utils │ │ │ │ ├── CloseUtils.java │ │ │ │ ├── StreamUtils.java │ │ │ │ └── FileUtils.java │ │ │ ├── utils │ │ │ ├── MathUtils.java │ │ │ ├── DataCheck.java │ │ │ ├── ToastUtils.java │ │ │ ├── ActivityUtils.java │ │ │ └── AppUtils.java │ │ │ ├── view │ │ │ └── utils │ │ │ │ ├── DensityUtils.java │ │ │ │ └── ViewUtils.java │ │ │ ├── net │ │ │ └── utils │ │ │ │ └── NetUtils.java │ │ │ ├── async │ │ │ └── utils │ │ │ │ └── SHandler.java │ │ │ └── adapter │ │ │ └── utils │ │ │ ├── ViewHolder.java │ │ │ └── CommonAdapter.java │ └── androidTest │ │ └── java │ │ └── com │ │ └── sloop │ │ └── library │ │ └── ApplicationTest.java ├── proguard-rules.pro ├── build.gradle └── library.iml ├── settings.gradle ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── .gitignore ├── gradle.properties ├── gradlew.bat ├── README.md ├── gradlew └── LICENSE /README-EN.md: -------------------------------------------------------------------------------- 1 | # Sutil 2 | -------------------------------------------------------------------------------- /library/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':library' 2 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GcsSloop/SUtil/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /library/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | Library 3 | 4 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Mon Dec 28 10:00:20 PST 2015 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip 7 | -------------------------------------------------------------------------------- /library/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Built application files 2 | *.apk 3 | *.ap_ 4 | 5 | # Files for the Dalvik VM 6 | *.dex 7 | 8 | # Java class files 9 | *.class 10 | 11 | # Generated files 12 | bin/ 13 | gen/ 14 | 15 | # Gradle files 16 | .gradle/ 17 | build/ 18 | /*/build/ 19 | 20 | # Local configuration file (sdk path, etc) 21 | local.properties 22 | 23 | # Proguard folder generated by Eclipse 24 | proguard/ 25 | 26 | # Log Files 27 | *.log 28 | -------------------------------------------------------------------------------- /library/src/androidTest/java/com/sloop/library/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package com.sloop.library; 2 | 3 | import android.app.Application; 4 | import android.test.ApplicationTestCase; 5 | 6 | /** 7 | * Testing Fundamentals 8 | */ 9 | public class ApplicationTest extends ApplicationTestCase { 10 | public ApplicationTest() { 11 | super(Application.class); 12 | } 13 | } -------------------------------------------------------------------------------- /library/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in D:\Program\Android\SDK/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /library/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | // JitPack Maven 3 | apply plugin: 'com.github.dcendents.android-maven' 4 | // Your Group 5 | group='com.github.GcsSloop' 6 | 7 | android { 8 | compileSdkVersion 23 9 | buildToolsVersion "23.0.2" 10 | 11 | defaultConfig { 12 | minSdkVersion 7 13 | targetSdkVersion 23 14 | versionCode 1 15 | versionName "1.0" 16 | } 17 | buildTypes { 18 | release { 19 | minifyEnabled false 20 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 21 | } 22 | } 23 | } 24 | 25 | dependencies { 26 | compile fileTree(dir: 'libs', include: ['*.jar']) 27 | testCompile 'junit:junit:4.12' 28 | compile 'com.android.support:appcompat-v7:23.1.1' 29 | } 30 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m 13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 14 | 15 | # When configured, Gradle will run in incubating parallel mode. 16 | # This option should only be used with decoupled projects. More details, visit 17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 18 | # org.gradle.parallel=true -------------------------------------------------------------------------------- /library/src/main/java/com/sloop/animation/AnimationListener.java: -------------------------------------------------------------------------------- 1 | package com.sloop.animation; 2 | 3 | import android.view.animation.Animation; 4 | 5 | /** 6 | * AnimationListener默认实现类 7 | * 16 | */ 17 | public class AnimationListener implements Animation.AnimationListener { 18 | 19 | @Override 20 | public void onAnimationStart(Animation animation) { 21 | 22 | } 23 | 24 | @Override 25 | public void onAnimationEnd(Animation animation) { 26 | 27 | } 28 | 29 | @Override 30 | public void onAnimationRepeat(Animation animation) { 31 | 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /library/src/main/java/com/sloop/io/utils/CloseUtils.java: -------------------------------------------------------------------------------- 1 | package com.sloop.io.utils; 2 | 3 | import java.io.Closeable; 4 | 5 | /** 6 | * 15 | */ 16 | public class CloseUtils { 17 | private CloseUtils() { 18 | } 19 | 20 | /** 21 | * 关闭Closeable对象 22 | * 23 | * @param closeable 可关闭的对象 24 | */ 25 | public static void closeQuietly(Closeable closeable) { 26 | if (null != closeable) { 27 | try { 28 | closeable.close(); 29 | } catch (Exception e) { 30 | e.printStackTrace(); 31 | } 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /library/src/main/java/com/sloop/utils/MathUtils.java: -------------------------------------------------------------------------------- 1 | package com.sloop.utils; 2 | 3 | /** 4 | * 13 | */ 14 | public class MathUtils { 15 | private MathUtils() { 16 | } 17 | 18 | /** 19 | * 角度转弧度 20 | * 21 | * @param angle 角度 22 | * @return 弧度 23 | */ 24 | public static double angle2Radian(double angle) { 25 | return angle / 180 * Math.PI; 26 | } 27 | 28 | /** 29 | * 弧度转角度 30 | * 31 | * @param radian 弧度 32 | * @return 角度 33 | */ 34 | public static double radian2Angle(double radian) { 35 | return radian / Math.PI * 180; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /library/src/main/java/com/sloop/utils/DataCheck.java: -------------------------------------------------------------------------------- 1 | package com.sloop.utils; 2 | 3 | /** 4 | * 数据检查 5 | * Sloop 创建于 2015/10/21. 6 | * 11 | */ 12 | public class DataCheck { 13 | 14 | /** 15 | * 验证密码是否符合规则(6到16位的数字或者字母) 16 | * @param password 需要校验的密码 17 | * @return true(正确) false(不正确) 18 | */ 19 | public static boolean checkPassword(String password) { 20 | String regex = "[\\w]{6,16}"; 21 | return password.matches(regex); 22 | } 23 | 24 | /** 25 | * 验证邮箱是否正确 26 | * @param email 邮箱地址 27 | * @return true(正确) false(不正确) 28 | */ 29 | public static boolean checkMail(String email) { 30 | //数字或者字母或者_出现3到12次 @ 数字或者字母出现一次或多次 (.字母出现一次或多次)出现1次到5次 31 | String reg = "[\\w]{3,20}@[\\w&&[^_]]+(\\.[a-zA-Z]+){1,5}"; 32 | return email.matches(reg); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /library/src/main/java/com/sloop/animation/AnimatorListener.java: -------------------------------------------------------------------------------- 1 | package com.sloop.animation; 2 | 3 | import android.animation.Animator; 4 | import android.annotation.TargetApi; 5 | import android.os.Build; 6 | 7 | /** 8 | * AnimatorListener默认实现类 9 | * 18 | */ 19 | @TargetApi(Build.VERSION_CODES.HONEYCOMB) 20 | public class AnimatorListener implements Animator.AnimatorListener{ 21 | @Override 22 | public void onAnimationStart(Animator animation) { 23 | 24 | } 25 | 26 | @Override 27 | public void onAnimationEnd(Animator animation) { 28 | 29 | } 30 | 31 | @Override 32 | public void onAnimationCancel(Animator animation) { 33 | 34 | } 35 | 36 | @Override 37 | public void onAnimationRepeat(Animator animation) { 38 | 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /library/src/main/java/com/sloop/utils/ToastUtils.java: -------------------------------------------------------------------------------- 1 | package com.sloop.utils; 2 | 3 | import android.app.Activity; 4 | import android.widget.Toast; 5 | 6 | /** 7 | * Toast工具 8 | * 17 | */ 18 | public class ToastUtils { 19 | 20 | /** 21 | * @param context Context 22 | * @param string 内容 23 | */ 24 | public static void show(final Activity context, final String string) { 25 | //判断是否为主线程 26 | if ("main".equals(Thread.currentThread().getName())) { 27 | Toast.makeText(context, string, Toast.LENGTH_SHORT).show(); 28 | } else {//如果不是,就用该方法使其在ui线程中运行 29 | context.runOnUiThread(new Runnable() { 30 | @Override 31 | public void run() { 32 | Toast.makeText(context, string, Toast.LENGTH_SHORT).show(); 33 | } 34 | }); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /library/src/main/java/com/sloop/utils/ActivityUtils.java: -------------------------------------------------------------------------------- 1 | package com.sloop.utils; 2 | 3 | import android.app.ActivityManager; 4 | import android.content.Context; 5 | 6 | import java.util.List; 7 | 8 | /** 9 | * Author: Sloop 10 | * Version: v1.0 11 | * Date: 2015/11/12 12 | * 17 | */ 18 | public class ActivityUtils { 19 | /** 20 | * 判断程序是否处于后台 21 | * 22 | * @param context 上下文 23 | * @return true表示程序当前处于后台,false表示程序当前处于前台 24 | */ 25 | public static boolean isBackground(Context context) { 26 | 27 | ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); 28 | List appProcesses = activityManager.getRunningAppProcesses(); 29 | 30 | for (ActivityManager.RunningAppProcessInfo appProcess : appProcesses) { 31 | if (appProcess.processName.equals(context.getPackageName())) { 32 | if (appProcess.importance == ActivityManager.RunningAppProcessInfo.IMPORTANCE_BACKGROUND) { 33 | return true; 34 | } else { 35 | return false; 36 | } 37 | } 38 | } 39 | return false; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /library/src/main/java/com/sloop/view/utils/DensityUtils.java: -------------------------------------------------------------------------------- 1 | package com.sloop.view.utils; 2 | 3 | import android.view.ContextThemeWrapper; 4 | 5 | /** 6 | * 15 | */ 16 | public class DensityUtils { 17 | /** 18 | * 根据手机的分辨率从 dp 的单位 转成为 px(像素) 19 | * 20 | * @param context 上下文 21 | * @param dpValue dp 22 | * @return px 23 | */ 24 | public static int dip2px(ContextThemeWrapper context, float dpValue) { 25 | return (int) (dpValue * getDensity(context) + 0.5f); 26 | } 27 | 28 | /** 29 | * 根据手机的分辨率从 px(像素) 的单位 转成为 dp 30 | * 31 | * @param context 上下文 32 | * @param pxValue px 33 | * @return dp 34 | */ 35 | public static int px2dip(ContextThemeWrapper context, float pxValue) { 36 | return (int) (pxValue / getDensity(context) + 0.5f); 37 | } 38 | 39 | /** 40 | * 获取当前手机的屏幕像素密度 41 | * 42 | * @param context 上下文 43 | * @return 像素密度 44 | */ 45 | public static float getDensity(ContextThemeWrapper context) { 46 | return context.getResources().getDisplayMetrics().density; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /library/src/main/java/com/sloop/net/utils/NetUtils.java: -------------------------------------------------------------------------------- 1 | package com.sloop.net.utils; 2 | 3 | import android.content.Context; 4 | import android.net.ConnectivityManager; 5 | import android.net.NetworkInfo; 6 | 7 | /** 8 | * 16 | */ 17 | public class NetUtils { 18 | 19 | /** 20 | * 用户是否连接网络 21 | * @param context Context 22 | */ 23 | public static boolean isNetConnection(Context context) { 24 | final ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); 25 | final NetworkInfo networkInfo = connectivityManager.getActiveNetworkInfo(); 26 | return (networkInfo != null && networkInfo.isAvailable()); 27 | } 28 | 29 | /** 30 | * 是否连接Wifi 31 | * @param context Context 32 | */ 33 | public static boolean isWifiConnection(Context context) { 34 | ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); 35 | NetworkInfo wifiNetworkInfo = connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI); 36 | if (wifiNetworkInfo.isConnected()) { 37 | return true; 38 | } 39 | return false; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /library/src/main/java/com/sloop/io/utils/StreamUtils.java: -------------------------------------------------------------------------------- 1 | package com.sloop.io.utils; 2 | 3 | import java.io.ByteArrayOutputStream; 4 | import java.io.IOException; 5 | import java.io.InputStream; 6 | 7 | /** 8 | * 数据流工具类 9 | * Author: Sloop 10 | * Version: v1.2 11 | * Date: 2015/11/10 12 | * 17 | */ 18 | public class StreamUtils { 19 | private StreamUtils() { 20 | } 21 | 22 | /** 23 | * 将输入流转化为字符串 24 | * 25 | * @param is 输入流 26 | * @param encode 编码格式 27 | * @return 字符串 28 | * @throws IOException IO异常 29 | */ 30 | public static String readStream(InputStream is, String encode) throws IOException { 31 | return new String(readStream(is), encode); 32 | } 33 | 34 | /** 35 | * 将输入流转化为Byte数组 36 | * 37 | * @param is 输入流 38 | * @return byte数组 39 | * @throws IOException IO异常 40 | */ 41 | public static byte[] readStream(InputStream is) throws IOException { 42 | ByteArrayOutputStream baos = new ByteArrayOutputStream(); 43 | byte[] buff = new byte[1024]; 44 | int len = 0; 45 | while ((len = is.read(buff)) != -1) { 46 | baos.write(buff, 0, len); 47 | } 48 | byte[] result = baos.toByteArray(); 49 | is.close(); 50 | baos.close(); 51 | return result; 52 | } 53 | 54 | 55 | } 56 | -------------------------------------------------------------------------------- /library/src/main/java/com/sloop/async/utils/SHandler.java: -------------------------------------------------------------------------------- 1 | package com.sloop.async.utils; 2 | 3 | import android.os.Handler; 4 | import android.os.Message; 5 | 6 | /** 7 | * 回调函数 8 | * Author: Sloop 9 | * Version: v1.1 10 | * Date: 2015/11/30 11 | * 16 | */ 17 | public abstract class SHandler extends Handler { 18 | public static final int SUCCESS = 1; //成功 19 | public static final int FAILURE = 2; //失败 20 | 21 | /** 22 | * 执行成功时调用 23 | * 24 | * @param content 内容 25 | */ 26 | public abstract void onSuccess(T content); 27 | 28 | 29 | /** 30 | * 执行失败时调用 31 | * 32 | * @param content 内容 33 | */ 34 | public abstract void onFailure(T content); 35 | 36 | /** 37 | * 消息处理器 38 | */ 39 | @Override 40 | public void handleMessage(Message msg) { 41 | Object content = msg.obj; 42 | switch (msg.what) { 43 | case SUCCESS: 44 | onSuccess((T) content); 45 | break; 46 | case FAILURE: 47 | onFailure((T) content); 48 | break; 49 | } 50 | super.handleMessage(msg); 51 | } 52 | 53 | /** 54 | * 发送消息函数 55 | * 56 | * @param style 类型 57 | * @param message 信息 58 | */ 59 | public void sendMsg(int style, T message) { 60 | Message msg = Message.obtain(); 61 | msg.what = style; 62 | msg.obj = message; 63 | this.sendMessage(msg); 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /library/src/main/java/com/sloop/utils/AppUtils.java: -------------------------------------------------------------------------------- 1 | package com.sloop.utils; 2 | 3 | import android.content.Context; 4 | import android.content.pm.PackageManager; 5 | 6 | /** 7 | * 应用程序工具包 8 | * Author: Sloop 9 | * Version: v1.0 10 | * Date: 2015/11/18 11 | * 16 | */ 17 | public class AppUtils { 18 | /** 19 | * 获取当前程序包名 20 | * 21 | * @param context 上下文 22 | * @return 程序包名 23 | */ 24 | public static String getPackageName(Context context) { 25 | return context.getPackageName(); 26 | } 27 | 28 | /** 29 | * 获取程序版本信息 30 | * 31 | * @param context 上下文 32 | * @return 版本名称 33 | */ 34 | public static String getVersionName(Context context) { 35 | String versionName = null; 36 | String pkName = context.getPackageName(); 37 | try { 38 | versionName = context.getPackageManager().getPackageInfo(pkName, 0).versionName; 39 | } catch (PackageManager.NameNotFoundException e) { 40 | e.printStackTrace(); 41 | } 42 | return versionName; 43 | } 44 | 45 | /** 46 | * 获取程序版本号 47 | * 48 | * @param context 上下文 49 | * @return 版本号 50 | */ 51 | public static int getVersionCode(Context context) { 52 | int versionCode = -1; 53 | String pkName = context.getPackageName(); 54 | try { 55 | versionCode = context.getPackageManager().getPackageInfo(pkName, 0).versionCode; 56 | } catch (PackageManager.NameNotFoundException e) { 57 | e.printStackTrace(); 58 | } 59 | return versionCode; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /library/src/main/java/com/sloop/adapter/utils/ViewHolder.java: -------------------------------------------------------------------------------- 1 | package com.sloop.adapter.utils; 2 | 3 | import android.content.Context; 4 | import android.util.SparseArray; 5 | import android.view.LayoutInflater; 6 | import android.view.View; 7 | import android.view.ViewGroup; 8 | 9 | /** 10 | * Author: Sloop 11 | * Version: v1.0 12 | * Date: 2015/11/17 13 | * 18 | */ 19 | public class ViewHolder { 20 | 21 | private SparseArray mViews; 22 | private View mConvertView; 23 | 24 | private ViewHolder(Context context, ViewGroup parent, int layoutId, int position) { 25 | this.mViews = new SparseArray(); 26 | mConvertView = LayoutInflater.from(context).inflate(layoutId, parent, false); 27 | mConvertView.setTag(this); //setTag 28 | } 29 | 30 | /** 31 | * 获取ViewHolder的实例 32 | * 33 | * @param context 上下文 34 | * @param convertView 布局 35 | * @param parent 父布局 36 | * @param layoutId 布局ID 37 | * @param position 位置 38 | * @return ViewHolder实例 39 | */ 40 | public static ViewHolder getInstance(Context context, View convertView, ViewGroup parent, int layoutId, int 41 | position) { 42 | if (convertView == null) { 43 | return new ViewHolder(context, parent, layoutId, position); 44 | } else { 45 | return (ViewHolder) convertView.getTag(); 46 | } 47 | } 48 | 49 | /** 50 | * 通过View的id来获取子View 51 | * 52 | * @param resId view的id 53 | * @param 泛型 54 | * @return 子View 55 | */ 56 | public T getView(int resId) { 57 | View view = mViews.get(resId); 58 | 59 | //如果该View没有缓存过,则查找View并缓存 60 | if (view == null) { 61 | view = mConvertView.findViewById(resId); 62 | mViews.put(resId, view); 63 | } 64 | 65 | return (T) view; 66 | } 67 | 68 | /** 69 | * 获取布局View 70 | * 71 | * @return 布局View 72 | */ 73 | public View getConvertView() { 74 | return mConvertView; 75 | } 76 | } -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /library/src/main/java/com/sloop/adapter/utils/CommonAdapter.java: -------------------------------------------------------------------------------- 1 | package com.sloop.adapter.utils; 2 | 3 | import android.content.Context; 4 | import android.support.annotation.NonNull; 5 | import android.view.LayoutInflater; 6 | import android.view.View; 7 | import android.view.ViewGroup; 8 | import android.widget.BaseAdapter; 9 | 10 | import java.util.ArrayList; 11 | import java.util.List; 12 | 13 | /** 14 | * ListView 的通用适配器 15 | * Author: Sloop 16 | * Version: v1.1 17 | * Date: 2015/11/17 18 | * 23 | */ 24 | public abstract class CommonAdapter extends BaseAdapter { 25 | 26 | private LayoutInflater mInflater; 27 | private Context mContext; 28 | private List mDatas = new ArrayList<>(); 29 | private int mLayoutId; 30 | 31 | /** 32 | * @param context 上下文 33 | * @param datas 数据集 34 | * @param layoutId 布局ID 35 | */ 36 | public CommonAdapter(@NonNull Context context, List datas, @NonNull int layoutId) { 37 | mInflater = LayoutInflater.from(context); 38 | this.mContext = context; 39 | this.mLayoutId = layoutId; 40 | if(datas!=null){ 41 | this.mDatas = datas; 42 | } 43 | } 44 | 45 | public void addDatas(List datas){ 46 | this.mDatas.addAll(datas); 47 | notifyDataSetChanged(); 48 | } 49 | 50 | public void clearDatas(){ 51 | this.mDatas.clear(); 52 | notifyDataSetChanged(); 53 | } 54 | 55 | public T getDataById(int position){ 56 | return mDatas.get(position); 57 | } 58 | 59 | @Override 60 | public int getCount() { 61 | return mDatas.size(); 62 | } 63 | 64 | @Override 65 | public T getItem(int position) { 66 | return mDatas.get(position); 67 | } 68 | 69 | @Override 70 | public long getItemId(int position) { 71 | return position; 72 | } 73 | 74 | @Override 75 | public View getView(int position, View convertView, ViewGroup parent) { 76 | //实例化一个ViewHolder 77 | ViewHolder holder = ViewHolder.getInstance(mContext, convertView, parent, mLayoutId, position); 78 | //需要自定义的部分 79 | convert(position, holder, getItem(position)); 80 | 81 | return holder.getConvertView(); 82 | } 83 | 84 | /** 85 | * 需要处理的部分,在这里给View设置值 86 | * 87 | * @param holder ViewHolder 88 | * @param bean 数据集 89 | */ 90 | public abstract void convert(int position, ViewHolder holder, T bean); 91 | } -------------------------------------------------------------------------------- /library/src/main/java/com/sloop/animation/Rotate3dAnimation.java: -------------------------------------------------------------------------------- 1 | package com.sloop.animation; 2 | 3 | import android.graphics.Camera; 4 | import android.graphics.Matrix; 5 | import android.view.ContextThemeWrapper; 6 | import android.view.animation.Animation; 7 | import android.view.animation.Transformation; 8 | 9 | /** 10 | * 3D翻转特效 11 | * author sloop 12 | * date 2015年3月10日 上午11:20:10 13 | */ 14 | public class Rotate3dAnimation extends Animation { 15 | 16 | private final float mFromDegrees; // 开始角度 17 | private final float mToDegrees; // 结束角度 18 | private final float mCenterX, mCenterY; // 中心点 19 | private final float mDepthZ; // 深度 20 | private final boolean mReverse; // 是否需要扭曲 21 | private Camera mCamera; // 摄像头 22 | ContextThemeWrapper context; // 上下文 23 | float scale = 1; // 屏幕密度(默认值为1) 24 | 25 | /** 26 | * 创建一个新的实例 Rotate3dAnimation. 27 | * 28 | * @param fromDegrees 开始角度 29 | * @param toDegrees 结束角度 30 | * @param centerX 中心点x坐标 31 | * @param centerY 中心点y坐标 32 | * @param depthZ 深度 33 | * @param reverse 是否扭曲 34 | */ 35 | public Rotate3dAnimation(ContextThemeWrapper context, float fromDegrees, float toDegrees, float centerX, float 36 | centerY, float depthZ, boolean reverse) { 37 | this.context = context; 38 | mFromDegrees = fromDegrees; 39 | mToDegrees = toDegrees; 40 | mCenterX = centerX; 41 | mCenterY = centerY; 42 | mDepthZ = depthZ; 43 | mReverse = reverse; 44 | //获取手机像素比 (即dp与px的比例) 45 | scale = context.getResources().getDisplayMetrics().density; 46 | } 47 | 48 | @Override 49 | public void initialize(int width, int height, int parentWidth, int parentHeight) { 50 | 51 | super.initialize(width, height, parentWidth, parentHeight); 52 | mCamera = new Camera(); 53 | } 54 | 55 | // 生成Transformation 56 | @Override 57 | protected void applyTransformation(float interpolatedTime, Transformation t) { 58 | final float fromDegrees = mFromDegrees; 59 | // 生成中间角度 60 | float degrees = fromDegrees + ((mToDegrees - fromDegrees) * interpolatedTime); 61 | 62 | 63 | final float centerX = mCenterX; 64 | final float centerY = mCenterY; 65 | final Camera camera = mCamera; 66 | 67 | final Matrix matrix = t.getMatrix(); 68 | 69 | camera.save(); 70 | if (mReverse) { 71 | camera.translate(0.0f, 0.0f, mDepthZ * interpolatedTime); 72 | } else { 73 | camera.translate(0.0f, 0.0f, mDepthZ * (1.0f - interpolatedTime)); 74 | } 75 | camera.rotateY(degrees); 76 | // 取得变换后的矩阵 77 | camera.getMatrix(matrix); 78 | camera.restore(); 79 | float[] mValues = {0, 0, 0, 0, 0, 0, 0, 0, 0}; 80 | matrix.getValues(mValues); //获取数值 81 | mValues[6] = mValues[6] / scale; //数值修正 82 | matrix.setValues(mValues); //重新赋值 83 | 84 | matrix.preTranslate(-centerX, -centerY); 85 | matrix.postTranslate(centerX, centerY); 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /library/src/main/java/com/sloop/view/utils/ViewUtils.java: -------------------------------------------------------------------------------- 1 | package com.sloop.view.utils; 2 | 3 | import android.view.View; 4 | import android.view.ViewGroup; 5 | 6 | /** 7 | * 与视图相关的工具类 8 | * Author: Sloop 9 | * Version: v1.0 10 | * Date: 2015/12/2 11 | * 16 | */ 17 | public class ViewUtils { 18 | 19 | 20 | //*****测量布局相关函数******************************************************************************** 21 | 22 | /** 23 | * 手动测量布局大小 24 | * 25 | * @param view 被测量的布局 26 | * @param width 布局默认宽度 27 | * @param height 布局默认高度 28 | * 示例: measureView(view, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); 29 | */ 30 | public static void measureView(View view, int width, int height) { 31 | ViewGroup.LayoutParams params = view.getLayoutParams(); 32 | if (params == null) { 33 | params = new ViewGroup.LayoutParams(width, height); 34 | } 35 | int mWidth = ViewGroup.getChildMeasureSpec(0, 0, params.width); 36 | 37 | int mHeight; 38 | int tempHeight = params.height; 39 | if (tempHeight > 0) { 40 | mHeight = View.MeasureSpec.makeMeasureSpec(tempHeight, View.MeasureSpec.EXACTLY); 41 | } else { 42 | mHeight = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED); 43 | } 44 | view.measure(mWidth, mHeight); 45 | } 46 | 47 | //*****设置外边距相关函数******************************************************************************* 48 | 49 | /** 50 | * 设置View的左侧外边距 51 | * 52 | * @param view 要设置外边距的View 53 | * @param left 左侧外边距 54 | */ 55 | public static void setMarginLeft(View view, int left) { 56 | setMargins(view, left, 0, 0, 0); 57 | } 58 | 59 | /** 60 | * 设置View的顶部外边距 61 | * 62 | * @param view 要设置外边距的View 63 | * @param top 顶部外边距 64 | */ 65 | public static void setMarginTop(View view, int top) { 66 | setMargins(view, 0, top, 0, 0); 67 | } 68 | 69 | /** 70 | * 设置View的右侧外边距 71 | * 72 | * @param view 要设置外边距的View 73 | * @param right 右侧外边距 74 | */ 75 | public static void setMarginRight(View view, int right) { 76 | setMargins(view, 0, 0, right, 0); 77 | } 78 | 79 | /** 80 | * 设置View的底部外边距 81 | * 82 | * @param view 要设置外边距的View 83 | * @param bottom 底部外边距 84 | */ 85 | public static void setMarginBottom(View view, int bottom) { 86 | setMargins(view, 0, 0, 0, bottom); 87 | } 88 | 89 | /** 90 | * 设置View的外边距(Margins) 91 | * 92 | * @param view 要设置外边距的View 93 | * @param left 左侧外边距 94 | * @param top 顶部外边距 95 | * @param right 右侧外边距 96 | * @param bottom 底部外边距 97 | */ 98 | public static void setMargins(View view, int left, int top, int right, int bottom) { 99 | if (view.getLayoutParams() instanceof ViewGroup.MarginLayoutParams) { 100 | ViewGroup.MarginLayoutParams p = (ViewGroup.MarginLayoutParams) view.getLayoutParams(); 101 | p.setMargins(left, top, right, bottom); 102 | view.requestLayout(); //请求重绘 103 | } 104 | } 105 | 106 | 107 | } 108 | -------------------------------------------------------------------------------- /library/src/main/java/com/sloop/io/utils/FileUtils.java: -------------------------------------------------------------------------------- 1 | package com.sloop.io.utils; 2 | 3 | import android.content.Context; 4 | import android.os.Environment; 5 | 6 | import java.io.File; 7 | 8 | /** 9 | * 与文件相关的工具类 10 | * Author: Sloop 11 | * Version: v1.1 12 | * Date: 2015/11/18 13 | * 18 | */ 19 | public class FileUtils { 20 | private FileUtils() { 21 | } 22 | 23 | //****系统文件目录********************************************************************************************** 24 | 25 | /** 26 | * @return 程序系统文件目录 27 | */ 28 | public static String getFileDir(Context context) { 29 | return String.valueOf(context.getFilesDir()); 30 | } 31 | 32 | /** 33 | * @param context 上下文 34 | * @param customPath 自定义路径 35 | * @return 程序系统文件目录绝对路径 36 | */ 37 | public static String getFileDir(Context context, String customPath) { 38 | String path = context.getFilesDir() + formatPath(customPath); 39 | mkdir(path); 40 | return path; 41 | } 42 | 43 | //****系统缓存目录********************************************************************************************** 44 | 45 | /** 46 | * @return 程序系统缓存目录 47 | */ 48 | public static String getCacheDir(Context context) { 49 | return String.valueOf(context.getCacheDir()); 50 | } 51 | 52 | /** 53 | * @param context 上下文 54 | * @param customPath 自定义路径 55 | * @return 程序系统缓存目录 56 | */ 57 | public static String getCacheDir(Context context, String customPath) { 58 | String path = context.getCacheDir() + formatPath(customPath); 59 | mkdir(path); 60 | return path; 61 | } 62 | 63 | //****Sdcard文件目录********************************************************************************************** 64 | 65 | /** 66 | * @return 内存卡文件目录 67 | */ 68 | public static String getExternalFileDir(Context context) { 69 | return String.valueOf(context.getExternalFilesDir("")); 70 | } 71 | 72 | /** 73 | * @param context 上下文 74 | * @param customPath 自定义路径 75 | * @return 内存卡文件目录 76 | */ 77 | public static String getExternalFileDir(Context context, String customPath) { 78 | String path = context.getExternalFilesDir("") + formatPath(customPath); 79 | mkdir(path); 80 | return path; 81 | } 82 | 83 | //****Sdcard缓存目录********************************************************************************************** 84 | 85 | /** 86 | * @return 内存卡缓存目录 87 | */ 88 | public static String getExternalCacheDir(Context context) { 89 | return String.valueOf(context.getExternalCacheDir()); 90 | } 91 | 92 | /** 93 | * @param context 上下文 94 | * @param customPath 自定义路径 95 | * @return 内存卡缓存目录 96 | */ 97 | public static String getExternalCacheDir(Context context, String customPath) { 98 | String path = context.getExternalCacheDir() + formatPath(customPath); 99 | mkdir(path); 100 | return path; 101 | } 102 | 103 | //****公共文件夹********************************************************************************************** 104 | 105 | /** 106 | * @return 公共下载文件夹 107 | */ 108 | public static String getPublicDownloadDir() { 109 | return Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).getAbsolutePath(); 110 | } 111 | 112 | //****相关工具********************************************************************************************** 113 | 114 | /** 115 | * 创建文件夹 116 | * 117 | * @param DirPath 文件夹路径 118 | */ 119 | public static void mkdir(String DirPath) { 120 | File file = new File(DirPath); 121 | if (!(file.exists() && file.isDirectory())) { 122 | file.mkdirs(); 123 | } 124 | } 125 | 126 | /** 127 | * 格式化文件路径 128 | * 示例: 传入 "sloop" "/sloop" "sloop/" "/sloop/" 129 | * 返回 "/sloop" 130 | */ 131 | private static String formatPath(String path) { 132 | if (!path.startsWith("/")) 133 | path = "/" + path; 134 | while (path.endsWith("/")) 135 | path = new String(path.toCharArray(), 0, path.length() - 1); 136 | return path; 137 | } 138 | 139 | /** 140 | * @return 存储卡是否挂载(存在) 141 | */ 142 | public static boolean isMountSdcard() { 143 | String status = Environment.getExternalStorageState(); 144 | return status.equals(Environment.MEDIA_MOUNTED); 145 | } 146 | 147 | } 148 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # SUtil 2 | 3 | [![License](https://img.shields.io/badge/license-Apache%202-green.svg)](https://www.apache.org/licenses/LICENSE-2.0) 4 | [![](https://jitpack.io/v/GcsSloop/SUtil.svg)](https://jitpack.io/#GcsSloop/SUtil) 5 | 6 | ## Sloop的工具箱 7 | ### 作者微博: [@GcsSloop](http://weibo.com/GcsSloop) 8 | 9 | # 如何添加 10 | ### Gradle 11 | #### 1.在Project的build.gradle 中添加仓库地址 12 | ``` gradle 13 | // JitPack仓库地址 14 | maven { url "https://jitpack.io" } 15 | ``` 16 | 17 | 示例: 18 | ``` gradle 19 | allprojects { 20 | repositories { 21 | jcenter() 22 | // JitPack仓库地址 23 | maven { url "https://jitpack.io" } 24 | } 25 | } 26 | ``` 27 | #### 2.在Module目录下的build.gradle中添加依赖 28 | ```gradle 29 | //sutil 30 | compile 'com.github.GcsSloop:SUtil:v1.0.2' 31 | ``` 32 | 33 | 示例: 34 | ``` gradle 35 | dependencies { 36 | compile fileTree(dir: 'libs', include: ['*.jar']) 37 | testCompile 'junit:junit:4.12' 38 | compile 'com.android.support:appcompat-v7:23.0.1' 39 | //sutil 40 | compile 'com.github.GcsSloop:SUtil:v1.0.1' 41 | } 42 | ``` 43 | 44 | # 内容说明 45 | 46 | 包名 | 工具 | 描述 | 所需权限 47 | -----------------------|------|------|--------- 48 | com.sloop.adapter.utils | [CommonAdapter](https://github.com/GcsSloop/SUtil/blob/master/library/src/main/java/com/sloop/adapter/utils/CommonAdapter.java) | ListView万能适配器 | 49 | com.sloop.adapter.utils | [ViewHolder](https://github.com/GcsSloop/SUtil/blob/master/library/src/main/java/com/sloop/adapter/utils/ViewHolder.java) | ViewHolder | 50 | com.sloop.animation | [Rotate3dAnimation](https://github.com/GcsSloop/SUtil/blob/master/library/src/main/java/com/sloop/animation/Rotate3dAnimation.java) | 3D翻转动画 | 51 | com.sloop.animation | [AnimationListener](https://github.com/GcsSloop/SUtil/blob/master/library/src/main/java/com/sloop/animation/AnimationListener.java) | 动画监听器默认实现类 | 52 | com.sloop.animation | [AnimatorListener](https://github.com/GcsSloop/SUtil/blob/master/library/src/main/java/com/sloop/animation/AnimatorListener.java) | 属性动画监听器默认实现类 | 53 | com.sloop.async.utils | [SHandler](https://github.com/GcsSloop/SUtil/blob/master/library/src/main/java/com/sloop/async/utils/SHandler.java) | 回调函数 | 54 | com.sloop.io.utils | [CloseUtils](https://github.com/GcsSloop/SUtil/blob/master/library/src/main/java/com/sloop/io/utils/CloseUtils.java) | 关闭函数 | 55 | com.sloop.io.utils | [FileUtils](https://github.com/GcsSloop/SUtil/blob/master/library/src/main/java/com/sloop/io/utils/FileUtils.java) | 文件夹工具 | 存储卡读取(READ_EXTERNAL_STORAGE)
存储卡写入(WRITE_EXTERNAL_STORAGE) 56 | com.sloop.io.utils | [StreamUtils](https://github.com/GcsSloop/SUtil/blob/master/library/src/main/java/com/sloop/io/utils/StreamUtils.java) | 数据流工具 | 57 | com.sloop.net.utils | [NetUtils](https://github.com/GcsSloop/SUtil/blob/master/library/src/main/java/com/sloop/net/utils/NetUtils.java) | 网络相关工具 | 网络访问(INTERNET)
查看网络状态(ACCESS_NETWORK_STATE) 58 | com.sloop.utils | [ActivityUtils](https://github.com/GcsSloop/SUtil/blob/master/library/src/main/java/com/sloop/utils/ActivityUtils.java) | Activity相关工具 | 59 | com.sloop.utils | [AppUtils](https://github.com/GcsSloop/SUtil/blob/master/library/src/main/java/com/sloop/utils/AppUtils.java) | Application相关工具 | 60 | com.sloop.utils | [DataCheck](https://github.com/GcsSloop/SUtil/blob/master/library/src/main/java/com/sloop/utils/DataCheck.java) | 数据检查 | 61 | com.sloop.utils | [MathUtils](https://github.com/GcsSloop/SUtil/blob/master/library/src/main/java/com/sloop/utils/MathUtils.java) | 数学工具 | 62 | com.sloop.utils | [ToastUtils](https://github.com/GcsSloop/SUtil/blob/master/library/src/main/java/com/sloop/utils/ToastUtils.java) | Toast工具 | 63 | com.sloop.view.utils | [DensityUtils](https://github.com/GcsSloop/SUtil/blob/master/library/src/main/java/com/sloop/view/utils/DensityUtils.java) | 屏幕密度相关工具 | 64 | com.sloop.view.utils | [ViewUtils](https://github.com/GcsSloop/SUtil/blob/master/library/src/main/java/com/sloop/view/utils/ViewUtils.java) | 视图相关工具 | 65 | 66 | ## 版本更新: 67 | 版本号 | 更新内容 68 | :-----:| ------------ 69 | v1.0.2 | 为通用适配器增加追加数据功能,删除WiFiUtils,添加NetUtils 70 | v1.0.1 | 降低minSdkVersion,提高兼容性 71 | v1.0.0 | 从jCenter迁移到JitPack,以前版本作废 72 | 73 | 74 | 75 | ## About Me 76 | 77 | 78 | 79 | # License 80 | ``` 81 | Copyright (c) 2016 GcsSloop 82 | 83 | Licensed under the Apache License, Version 2.0 (the "License"); 84 | you may not use this file except in compliance with the License. 85 | You may obtain a copy of the License at 86 | 87 | http://www.apache.org/licenses/LICENSE-2.0 88 | 89 | Unless required by applicable law or agreed to in writing, software 90 | distributed under the License is distributed on an "AS IS" BASIS, 91 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 92 | See the License for the specific language governing permissions and 93 | limitations under the License. 94 | ``` 95 | 96 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # Attempt to set APP_HOME 46 | # Resolve links: $0 may be a link 47 | PRG="$0" 48 | # Need this for relative symlinks. 49 | while [ -h "$PRG" ] ; do 50 | ls=`ls -ld "$PRG"` 51 | link=`expr "$ls" : '.*-> \(.*\)$'` 52 | if expr "$link" : '/.*' > /dev/null; then 53 | PRG="$link" 54 | else 55 | PRG=`dirname "$PRG"`"/$link" 56 | fi 57 | done 58 | SAVED="`pwd`" 59 | cd "`dirname \"$PRG\"`/" >/dev/null 60 | APP_HOME="`pwd -P`" 61 | cd "$SAVED" >/dev/null 62 | 63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 64 | 65 | # Determine the Java command to use to start the JVM. 66 | if [ -n "$JAVA_HOME" ] ; then 67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 68 | # IBM's JDK on AIX uses strange locations for the executables 69 | JAVACMD="$JAVA_HOME/jre/sh/java" 70 | else 71 | JAVACMD="$JAVA_HOME/bin/java" 72 | fi 73 | if [ ! -x "$JAVACMD" ] ; then 74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 75 | 76 | Please set the JAVA_HOME variable in your environment to match the 77 | location of your Java installation." 78 | fi 79 | else 80 | JAVACMD="java" 81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 82 | 83 | Please set the JAVA_HOME variable in your environment to match the 84 | location of your Java installation." 85 | fi 86 | 87 | # Increase the maximum file descriptors if we can. 88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 89 | MAX_FD_LIMIT=`ulimit -H -n` 90 | if [ $? -eq 0 ] ; then 91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 92 | MAX_FD="$MAX_FD_LIMIT" 93 | fi 94 | ulimit -n $MAX_FD 95 | if [ $? -ne 0 ] ; then 96 | warn "Could not set maximum file descriptor limit: $MAX_FD" 97 | fi 98 | else 99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 100 | fi 101 | fi 102 | 103 | # For Darwin, add options to specify how the application appears in the dock 104 | if $darwin; then 105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 106 | fi 107 | 108 | # For Cygwin, switch paths to Windows format before running java 109 | if $cygwin ; then 110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 112 | JAVACMD=`cygpath --unix "$JAVACMD"` 113 | 114 | # We build the pattern for arguments to be converted via cygpath 115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 116 | SEP="" 117 | for dir in $ROOTDIRSRAW ; do 118 | ROOTDIRS="$ROOTDIRS$SEP$dir" 119 | SEP="|" 120 | done 121 | OURCYGPATTERN="(^($ROOTDIRS))" 122 | # Add a user-defined pattern to the cygpath arguments 123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 125 | fi 126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 127 | i=0 128 | for arg in "$@" ; do 129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 131 | 132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 134 | else 135 | eval `echo args$i`="\"$arg\"" 136 | fi 137 | i=$((i+1)) 138 | done 139 | case $i in 140 | (0) set -- ;; 141 | (1) set -- "$args0" ;; 142 | (2) set -- "$args0" "$args1" ;; 143 | (3) set -- "$args0" "$args1" "$args2" ;; 144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 150 | esac 151 | fi 152 | 153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 154 | function splitJvmOpts() { 155 | JVM_OPTS=("$@") 156 | } 157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 159 | 160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 161 | -------------------------------------------------------------------------------- /library/library.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 8 | 9 | 10 | 11 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The Artistic License 2.0 2 | 3 | Copyright (c) 2015 sloop 4 | 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | This license establishes the terms under which a given free software 11 | Package may be copied, modified, distributed, and/or redistributed. 12 | The intent is that the Copyright Holder maintains some artistic 13 | control over the development of that Package while still keeping the 14 | Package available as open source and free software. 15 | 16 | You are always permitted to make arrangements wholly outside of this 17 | license directly with the Copyright Holder of a given Package. If the 18 | terms of this license do not permit the full use that you propose to 19 | make of the Package, you should contact the Copyright Holder and seek 20 | a different licensing arrangement. 21 | 22 | Definitions 23 | 24 | "Copyright Holder" means the individual(s) or organization(s) 25 | named in the copyright notice for the entire Package. 26 | 27 | "Contributor" means any party that has contributed code or other 28 | material to the Package, in accordance with the Copyright Holder's 29 | procedures. 30 | 31 | "You" and "your" means any person who would like to copy, 32 | distribute, or modify the Package. 33 | 34 | "Package" means the collection of files distributed by the 35 | Copyright Holder, and derivatives of that collection and/or of 36 | those files. A given Package may consist of either the Standard 37 | Version, or a Modified Version. 38 | 39 | "Distribute" means providing a copy of the Package or making it 40 | accessible to anyone else, or in the case of a company or 41 | organization, to others outside of your company or organization. 42 | 43 | "Distributor Fee" means any fee that you charge for Distributing 44 | this Package or providing support for this Package to another 45 | party. It does not mean licensing fees. 46 | 47 | "Standard Version" refers to the Package if it has not been 48 | modified, or has been modified only in ways explicitly requested 49 | by the Copyright Holder. 50 | 51 | "Modified Version" means the Package, if it has been changed, and 52 | such changes were not explicitly requested by the Copyright 53 | Holder. 54 | 55 | "Original License" means this Artistic License as Distributed with 56 | the Standard Version of the Package, in its current version or as 57 | it may be modified by The Perl Foundation in the future. 58 | 59 | "Source" form means the source code, documentation source, and 60 | configuration files for the Package. 61 | 62 | "Compiled" form means the compiled bytecode, object code, binary, 63 | or any other form resulting from mechanical transformation or 64 | translation of the Source form. 65 | 66 | 67 | Permission for Use and Modification Without Distribution 68 | 69 | (1) You are permitted to use the Standard Version and create and use 70 | Modified Versions for any purpose without restriction, provided that 71 | you do not Distribute the Modified Version. 72 | 73 | 74 | Permissions for Redistribution of the Standard Version 75 | 76 | (2) You may Distribute verbatim copies of the Source form of the 77 | Standard Version of this Package in any medium without restriction, 78 | either gratis or for a Distributor Fee, provided that you duplicate 79 | all of the original copyright notices and associated disclaimers. At 80 | your discretion, such verbatim copies may or may not include a 81 | Compiled form of the Package. 82 | 83 | (3) You may apply any bug fixes, portability changes, and other 84 | modifications made available from the Copyright Holder. The resulting 85 | Package will still be considered the Standard Version, and as such 86 | will be subject to the Original License. 87 | 88 | 89 | Distribution of Modified Versions of the Package as Source 90 | 91 | (4) You may Distribute your Modified Version as Source (either gratis 92 | or for a Distributor Fee, and with or without a Compiled form of the 93 | Modified Version) provided that you clearly document how it differs 94 | from the Standard Version, including, but not limited to, documenting 95 | any non-standard features, executables, or modules, and provided that 96 | you do at least ONE of the following: 97 | 98 | (a) make the Modified Version available to the Copyright Holder 99 | of the Standard Version, under the Original License, so that the 100 | Copyright Holder may include your modifications in the Standard 101 | Version. 102 | 103 | (b) ensure that installation of your Modified Version does not 104 | prevent the user installing or running the Standard Version. In 105 | addition, the Modified Version must bear a name that is different 106 | from the name of the Standard Version. 107 | 108 | (c) allow anyone who receives a copy of the Modified Version to 109 | make the Source form of the Modified Version available to others 110 | under 111 | 112 | (i) the Original License or 113 | 114 | (ii) a license that permits the licensee to freely copy, 115 | modify and redistribute the Modified Version using the same 116 | licensing terms that apply to the copy that the licensee 117 | received, and requires that the Source form of the Modified 118 | Version, and of any works derived from it, be made freely 119 | available in that license fees are prohibited but Distributor 120 | Fees are allowed. 121 | 122 | 123 | Distribution of Compiled Forms of the Standard Version 124 | or Modified Versions without the Source 125 | 126 | (5) You may Distribute Compiled forms of the Standard Version without 127 | the Source, provided that you include complete instructions on how to 128 | get the Source of the Standard Version. Such instructions must be 129 | valid at the time of your distribution. If these instructions, at any 130 | time while you are carrying out such distribution, become invalid, you 131 | must provide new instructions on demand or cease further distribution. 132 | If you provide valid instructions or cease distribution within thirty 133 | days after you become aware that the instructions are invalid, then 134 | you do not forfeit any of your rights under this license. 135 | 136 | (6) You may Distribute a Modified Version in Compiled form without 137 | the Source, provided that you comply with Section 4 with respect to 138 | the Source of the Modified Version. 139 | 140 | 141 | Aggregating or Linking the Package 142 | 143 | (7) You may aggregate the Package (either the Standard Version or 144 | Modified Version) with other packages and Distribute the resulting 145 | aggregation provided that you do not charge a licensing fee for the 146 | Package. Distributor Fees are permitted, and licensing fees for other 147 | components in the aggregation are permitted. The terms of this license 148 | apply to the use and Distribution of the Standard or Modified Versions 149 | as included in the aggregation. 150 | 151 | (8) You are permitted to link Modified and Standard Versions with 152 | other works, to embed the Package in a larger work of your own, or to 153 | build stand-alone binary or bytecode versions of applications that 154 | include the Package, and Distribute the result without restriction, 155 | provided the result does not expose a direct interface to the Package. 156 | 157 | 158 | Items That are Not Considered Part of a Modified Version 159 | 160 | (9) Works (including, but not limited to, modules and scripts) that 161 | merely extend or make use of the Package, do not, by themselves, cause 162 | the Package to be a Modified Version. In addition, such works are not 163 | considered parts of the Package itself, and are not subject to the 164 | terms of this license. 165 | 166 | 167 | General Provisions 168 | 169 | (10) Any use, modification, and distribution of the Standard or 170 | Modified Versions is governed by this Artistic License. By using, 171 | modifying or distributing the Package, you accept this license. Do not 172 | use, modify, or distribute the Package, if you do not accept this 173 | license. 174 | 175 | (11) If your Modified Version has been derived from a Modified 176 | Version made by someone other than you, you are nevertheless required 177 | to ensure that your Modified Version complies with the requirements of 178 | this license. 179 | 180 | (12) This license does not grant you the right to use any trademark, 181 | service mark, tradename, or logo of the Copyright Holder. 182 | 183 | (13) This license includes the non-exclusive, worldwide, 184 | free-of-charge patent license to make, have made, use, offer to sell, 185 | sell, import and otherwise transfer the Package with respect to any 186 | patent claims licensable by the Copyright Holder that are necessarily 187 | infringed by the Package. If you institute patent litigation 188 | (including a cross-claim or counterclaim) against any party alleging 189 | that the Package constitutes direct or contributory patent 190 | infringement, then this Artistic License to you shall terminate on the 191 | date that such litigation is filed. 192 | 193 | (14) Disclaimer of Warranty: 194 | THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS 195 | IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. THE IMPLIED 196 | WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR 197 | NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY YOUR LOCAL 198 | LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR CONTRIBUTOR WILL 199 | BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL 200 | DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE, EVEN IF 201 | ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 202 | 203 | --------------------------------------------------------------------------------