├── .gitignore ├── .idea ├── caches │ └── build_file_checksums.ser ├── codeStyles │ └── Project.xml ├── compiler.xml ├── encodings.xml ├── gradle.xml ├── misc.xml ├── runConfigurations.xml └── vcs.xml ├── README.md ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── com │ │ └── kd │ │ └── kotlin │ │ └── extend │ │ └── utils │ │ ├── ActivityExtends.kt │ │ ├── BitmapExtends.kt │ │ ├── ContextExtends.kt │ │ ├── FileExtends.kt │ │ ├── ImageViewExtends.kt │ │ ├── MainActivity.kt │ │ ├── SharedPreferencesExtends.kt │ │ ├── TextViewExtends.kt │ │ └── ViewExtends.kt │ └── res │ ├── drawable-v24 │ └── ic_launcher_foreground.xml │ ├── drawable │ └── ic_launcher_background.xml │ ├── layout │ └── activity_main.xml │ ├── mipmap-anydpi-v26 │ ├── ic_launcher.xml │ └── ic_launcher_round.xml │ ├── mipmap-hdpi │ ├── ic_launcher.png │ └── ic_launcher_round.png │ ├── mipmap-mdpi │ ├── ic_launcher.png │ └── ic_launcher_round.png │ ├── mipmap-xhdpi │ ├── ic_launcher.png │ └── ic_launcher_round.png │ ├── mipmap-xxhdpi │ ├── ic_launcher.png │ └── ic_launcher_round.png │ ├── mipmap-xxxhdpi │ ├── ic_launcher.png │ └── ic_launcher_round.png │ └── values │ ├── colors.xml │ ├── strings.xml │ └── styles.xml ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/libraries 5 | /.idea/modules.xml 6 | /.idea/workspace.xml 7 | .DS_Store 8 | /build 9 | /captures 10 | .externalNativeBuild 11 | -------------------------------------------------------------------------------- /.idea/caches/build_file_checksums.ser: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shiweibsw/Android-kotlin-extend-utils/c98f17e4c346c5905a93a9300d590fe9e254bd6a/.idea/caches/build_file_checksums.ser -------------------------------------------------------------------------------- /.idea/codeStyles/Project.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 15 | 16 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 17 | 18 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 10 | 11 | 24 | 34 | 35 | 36 | 37 | 38 | 39 | 41 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Kotlin 常用扩展函数总结 2 | 3 | ## 1.ImageViewExtends(Glide) 4 | 5 | | 名称 | 描述| 6 | | --- |:---:| 7 | | loadImage| 加载图片| 8 | | loadCircleImage | 加载圆形图片 | 9 | | loadRoundCornerImage | 加载圆角图片 | 10 | | loadImageByProportion | 按照图片的宽高比加载 | 11 | | loadClear | 取消加载 | 12 | 13 | ## 2.ViewExtends 14 | 15 | | 名称 | 描述| 16 | | --- |:---:| 17 | | view2Bitmap | View 转 bitmap | 18 | | bottomMargin | 底部Margin | 19 | | leftMargin | 左侧Margin | 20 | | topMargin | 上部Margin | 21 | | rightMargin | 右侧Margin | 22 | 23 | ## 3.TextViewExtends 24 | 25 | | 名称 | 描述| 26 | | --- |:---:| 27 | | setColor | 设置颜色 | 28 | | setDrawableLeft | 左侧Drawable | 29 | | setDrawableTop | 上部Drawable | 30 | | setDrawableRight | 右侧Drawable | 31 | | setDrawableBottom | 下部Drawable | 32 | 33 | ## 4.ContextExtends 34 | 35 | | 名称 | 描述| 36 | | --- |:---:| 37 | | toast | 展示toast | 38 | | centerToast | 中心展示toast | 39 | | dp2px | dp转px | 40 | | px2dp | px转dp | 41 | | sp2px | sp转px | 42 | | px2sp | px转sp | 43 | | getScreenWidth | 屏幕宽度 | 44 | | getScreenHeight | 屏幕高度 | 45 | | openWirelessSettings | 打开网络设置界面 | 46 | | isConnected | 网络是否连接 | 47 | | isMobileData | 判断网络是否是移动数据 | 48 | | startHomeActivity | 退回到桌面 | 49 | 50 | ## 5.ActivityExtends 51 | 52 | | 名称 | 描述| 53 | | --- |:---:| 54 | | screenShot | 屏幕截图 | 55 | | isPortrait | 是否竖屏 | 56 | | isLandscape | 是否横屏 | 57 | | setPortrait | 设置竖屏 | 58 | | setLandscape | 设置横屏 | 59 | | setFullScreen | 设置全屏 | 60 | | showKeyboard | 显示软键盘 | 61 | | hideKeyboard | 隐藏软键盘 | 62 | 63 | ## 6.BitmapExtends 64 | 65 | | 名称 | 描述| 66 | | --- |:---:| 67 | | scale | bitmap 缩放 | 68 | 69 | ## 7.FileExtends 70 | 71 | | 名称 | 描述| 72 | | --- |:---:| 73 | | getBitmap | file 转 bitmap | 74 | 75 | 76 | 77 | 78 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | apply plugin: 'kotlin-android' 4 | 5 | apply plugin: 'kotlin-android-extensions' 6 | 7 | android { 8 | compileSdkVersion 27 9 | defaultConfig { 10 | applicationId "com.kd.kotlin.extend.utils" 11 | minSdkVersion 21 12 | targetSdkVersion 27 13 | versionCode 1 14 | versionName "1.0" 15 | } 16 | buildTypes { 17 | release { 18 | minifyEnabled false 19 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 20 | } 21 | } 22 | } 23 | 24 | dependencies { 25 | implementation fileTree(dir: 'libs', include: ['*.jar']) 26 | implementation"org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version" 27 | implementation 'com.android.support:appcompat-v7:27.0.2' 28 | implementation 'com.android.support.constraint:constraint-layout:1.0.2' 29 | 30 | implementation 'com.github.bumptech.glide:glide:4.7.1' 31 | } 32 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /app/src/main/java/com/kd/kotlin/extend/utils/ActivityExtends.kt: -------------------------------------------------------------------------------- 1 | package com.kd.kotlin.extend.utils 2 | 3 | import android.app.Activity 4 | import android.content.pm.ActivityInfo 5 | import android.content.res.Configuration 6 | import android.graphics.Bitmap 7 | import android.util.DisplayMetrics 8 | import android.view.View 9 | import android.view.WindowManager 10 | import android.view.inputmethod.InputMethodManager 11 | 12 | 13 | 14 | /** 15 | * 屏幕截图 16 | */ 17 | fun Activity.screenShot(activity: Activity, isDeleteStatusBar: Boolean = true): Bitmap { 18 | val decorView = activity.window.decorView 19 | decorView.isDrawingCacheEnabled = true 20 | decorView.buildDrawingCache() 21 | val bmp = decorView.drawingCache 22 | val dm = DisplayMetrics() 23 | activity.windowManager.defaultDisplay.getMetrics(dm) 24 | var ret: Bitmap? = null 25 | if (isDeleteStatusBar) { 26 | val resources = activity.resources 27 | val resourceId = resources.getIdentifier("status_bar_height", "dimen", "android") 28 | val statusBarHeight = resources.getDimensionPixelSize(resourceId) 29 | ret = Bitmap.createBitmap(bmp, 0, statusBarHeight, dm.widthPixels, dm.heightPixels - statusBarHeight) 30 | } else { 31 | ret = Bitmap.createBitmap(bmp, 0, 0, dm.widthPixels, dm.heightPixels) 32 | } 33 | decorView.destroyDrawingCache() 34 | return ret!! 35 | } 36 | 37 | /** 38 | * 是否竖屏 39 | */ 40 | fun Activity.isPortrait(): Boolean { 41 | return resources.configuration.orientation === Configuration.ORIENTATION_PORTRAIT 42 | } 43 | 44 | /** 45 | * 是否横屏 46 | */ 47 | fun Activity.isLandscape(): Boolean { 48 | return resources.configuration.orientation === Configuration.ORIENTATION_LANDSCAPE 49 | } 50 | 51 | 52 | /** 53 | * 设置竖屏 54 | */ 55 | fun Activity.setPortrait() { 56 | this.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT 57 | } 58 | 59 | /** 60 | * 设置横屏 61 | */ 62 | fun Activity.setLandscape() { 63 | this.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE 64 | } 65 | 66 | /** 67 | * 设置全屏 68 | */ 69 | fun Activity.setFullScreen() { 70 | this.window.addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN or WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS) 71 | } 72 | 73 | /** 74 | * 显示软键盘 75 | */ 76 | fun Activity.showKeyboard() { 77 | var imm: InputMethodManager = this.getSystemService(Activity.INPUT_METHOD_SERVICE) as InputMethodManager 78 | ?: return 79 | var view = this.currentFocus 80 | if (view == null) { 81 | view = View(this) 82 | view!!.isFocusable = true 83 | view!!.isFocusableInTouchMode = true 84 | view!!.requestFocus() 85 | } 86 | imm.showSoftInput(view, InputMethodManager.SHOW_FORCED) 87 | } 88 | 89 | /** 90 | * 隐藏软键盘 91 | */ 92 | fun Activity.hideKeyboard() { 93 | var imm: InputMethodManager = this.getSystemService(Activity.INPUT_METHOD_SERVICE) as InputMethodManager 94 | ?: return 95 | var view = this.currentFocus 96 | if (view == null) { 97 | view = View(this) 98 | } 99 | imm.hideSoftInputFromWindow(view.windowToken, 0) 100 | } 101 | 102 | 103 | 104 | -------------------------------------------------------------------------------- /app/src/main/java/com/kd/kotlin/extend/utils/BitmapExtends.kt: -------------------------------------------------------------------------------- 1 | package com.kd.kotlin.extend.utils 2 | 3 | import android.graphics.Bitmap 4 | 5 | /** 6 | * bitmap 缩放 7 | */ 8 | fun Bitmap.scale(newWidth: Int, newHeight: Int, recycle: Boolean = false): Bitmap { 9 | var ret = Bitmap.createScaledBitmap(this, newWidth, newHeight, true) 10 | if (recycle && !this.isRecycled) this.recycle() 11 | return ret 12 | } 13 | 14 | -------------------------------------------------------------------------------- /app/src/main/java/com/kd/kotlin/extend/utils/ContextExtends.kt: -------------------------------------------------------------------------------- 1 | package com.kd.kotlin.extend.utils 2 | 3 | import android.annotation.SuppressLint 4 | import android.content.Context 5 | import android.content.Intent 6 | import android.graphics.Point 7 | import android.net.ConnectivityManager 8 | import android.net.NetworkInfo 9 | import android.os.Build 10 | import android.view.Gravity 11 | import android.view.WindowManager 12 | import android.widget.Toast 13 | 14 | 15 | //----------toast---------- 16 | fun Context.toast(text: CharSequence, duration: Int = Toast.LENGTH_SHORT) { 17 | Toast.makeText(this, text, duration).show() 18 | } 19 | 20 | fun Context.toast(resId: Int, duration: Int = Toast.LENGTH_SHORT) { 21 | Toast.makeText(this, resId, duration).show() 22 | } 23 | 24 | fun Context.centerToast(resId: Int, duration: Int = Toast.LENGTH_SHORT) { 25 | var t = Toast.makeText(this, resId, duration) 26 | t.setGravity(Gravity.CENTER, 0, 0) 27 | t.show() 28 | } 29 | 30 | //----------尺寸转换---------- 31 | 32 | fun Context.dp2px(dpValue: Float): Int { 33 | val scale = resources.displayMetrics.density 34 | return (dpValue * scale + 0.5f).toInt() 35 | } 36 | 37 | fun Context.px2dp(pxValue: Float): Int { 38 | val scale = resources.displayMetrics.density 39 | return (pxValue / scale + 0.5f).toInt() 40 | } 41 | 42 | fun Context.sp2px(spValue: Float): Int { 43 | val scale = resources.displayMetrics.scaledDensity 44 | return (spValue * scale + 0.5f).toInt() 45 | } 46 | 47 | fun Context.px2sp(pxValue: Float): Int { 48 | val scale = resources.displayMetrics.scaledDensity 49 | return (pxValue / scale + 0.5f).toInt() 50 | } 51 | 52 | //----------屏幕尺寸---------- 53 | 54 | fun Context.getScreenWidth(): Int { 55 | var wm: WindowManager = this.getSystemService(Context.WINDOW_SERVICE) as WindowManager 56 | ?: return resources.displayMetrics.widthPixels 57 | var point = Point() 58 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { 59 | wm.defaultDisplay.getRealSize(point) 60 | } else { 61 | wm.defaultDisplay.getSize(point) 62 | } 63 | return point.x 64 | } 65 | 66 | fun Context.getScreenHeight(): Int { 67 | var wm: WindowManager = this.getSystemService(Context.WINDOW_SERVICE) as WindowManager 68 | ?: return resources.displayMetrics.heightPixels 69 | var point = Point() 70 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { 71 | wm.defaultDisplay.getRealSize(point) 72 | } else { 73 | wm.defaultDisplay.getSize(point) 74 | } 75 | return point.y 76 | } 77 | 78 | 79 | //----------NetWork---------- 80 | 81 | /** 82 | * 打开网络设置 83 | */ 84 | fun Context.openWirelessSettings() { 85 | startActivity(Intent(android.provider.Settings.ACTION_WIRELESS_SETTINGS).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK)) 86 | } 87 | 88 | /** 89 | * 网络是否连接 90 | */ 91 | fun Context.isConnected(): Boolean { 92 | var info = this.getActiveNetworkInfo() 93 | return info.isConnected 94 | } 95 | 96 | /** 97 | * 判断网络是否是移动数据 98 | */ 99 | fun Context.isMobileData(): Boolean { 100 | var info = this.getActiveNetworkInfo() 101 | return (null != info 102 | && info.isAvailable 103 | && info.type == ConnectivityManager.TYPE_MOBILE) 104 | } 105 | 106 | /** 107 | * 退回到桌面 108 | */ 109 | fun Context.startHomeActivity() { 110 | val homeIntent = Intent(Intent.ACTION_MAIN) 111 | homeIntent.addCategory(Intent.CATEGORY_HOME) 112 | startActivity(homeIntent) 113 | } 114 | 115 | 116 | @SuppressLint("MissingPermission") 117 | private fun Context.getActiveNetworkInfo(): NetworkInfo { 118 | var manager = this.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager 119 | return manager.activeNetworkInfo 120 | } 121 | 122 | 123 | -------------------------------------------------------------------------------- /app/src/main/java/com/kd/kotlin/extend/utils/FileExtends.kt: -------------------------------------------------------------------------------- 1 | package com.kd.kotlin.extend.utils 2 | 3 | import android.graphics.Bitmap 4 | import android.graphics.BitmapFactory 5 | import java.io.File 6 | 7 | /** 8 | * file 转 bitmap 9 | */ 10 | fun File.getBitmap(): Bitmap { 11 | return BitmapFactory.decodeFile(this.absolutePath) 12 | } -------------------------------------------------------------------------------- /app/src/main/java/com/kd/kotlin/extend/utils/ImageViewExtends.kt: -------------------------------------------------------------------------------- 1 | package com.kd.kotlin.extend.utils 2 | 3 | import android.content.Context 4 | import android.graphics.Point 5 | import android.os.Build 6 | import android.support.annotation.IntRange 7 | import android.view.ViewGroup 8 | import android.view.WindowManager 9 | import android.widget.ImageView 10 | import com.bumptech.glide.Glide 11 | import com.bumptech.glide.Priority 12 | import com.bumptech.glide.load.engine.DiskCacheStrategy 13 | import com.bumptech.glide.load.resource.bitmap.RoundedCorners 14 | import com.bumptech.glide.request.RequestOptions 15 | 16 | 17 | /** 18 | * 加载图片 19 | */ 20 | fun ImageView.loadImage(context: Context, path: String, placeholder: Int = R.mipmap.ic_launcher, useCache: Boolean = false) { 21 | var options = getOptions(placeholder, useCache) 22 | Glide.with(context).load(path).apply(options).into(this) 23 | } 24 | 25 | /** 26 | * 加载圆形图片 27 | */ 28 | fun ImageView.loadCircleImage(context: Context, path: String, placeholder: Int = R.mipmap.ic_launcher, useCache: Boolean = false) { 29 | var options = getOptions(placeholder, useCache) 30 | options.circleCrop() 31 | Glide.with(context).load(path).apply(options).into(this) 32 | } 33 | 34 | /** 35 | * 加载圆角图片 36 | */ 37 | fun ImageView.loadRoundCornerImage(context: Context, path: String, roundingRadius: Int = 20, placeholder: Int = R.mipmap.ic_launcher, useCache: Boolean = false) { 38 | var options = getOptions(placeholder, useCache) 39 | Glide.with(context).load(path).apply(RequestOptions.bitmapTransform(RoundedCorners(roundingRadius))).apply(options).into(this) 40 | } 41 | 42 | /** 43 | * 取消加载 44 | */ 45 | fun ImageView.loadClear(context: Context) { 46 | Glide.with(context).clear(this) 47 | } 48 | 49 | /** 50 | * 按照图片的宽高比加载 51 | * 使用本属性的ImageView在xml布局中的width及height属性必须为WRAP_CONTENT 52 | * widthProportion 为相对于屏幕宽度的比例取值范围为0.0-1.0,当widthProportion=1.0时,ImageView的宽度为屏幕宽度 53 | * heightProportion为相对于图片宽度的显示比例 54 | */ 55 | fun ImageView.loadImageByProportion(@IntRange(from = 0, to = 1) widthProportion: Float, heightProportion: Float) { 56 | this.adjustViewBounds = true 57 | var screenWidth = 0 58 | var wm: WindowManager = this.context.getSystemService(Context.WINDOW_SERVICE) as WindowManager 59 | if (wm == null) { 60 | screenWidth = this.context.resources.displayMetrics.widthPixels - leftMargin - rightMargin 61 | } else { 62 | var point = Point() 63 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { 64 | wm.defaultDisplay.getRealSize(point) 65 | } else { 66 | wm.defaultDisplay.getSize(point) 67 | } 68 | screenWidth = point.x - leftMargin - rightMargin 69 | } 70 | var para = this.layoutParams 71 | para.width = (screenWidth * widthProportion).toInt() 72 | para.height = ViewGroup.LayoutParams.WRAP_CONTENT 73 | layoutParams = para 74 | maxWidth = (screenWidth * widthProportion).toInt() 75 | maxHeight = (screenWidth * widthProportion * heightProportion).toInt() 76 | scaleType = ImageView.ScaleType.CENTER_CROP 77 | } 78 | 79 | 80 | private fun ImageView.getOptions(placeholder: Int = R.mipmap.ic_launcher, useCache: Boolean = false): RequestOptions { 81 | var options = RequestOptions() 82 | options.placeholder(placeholder) 83 | options.priority(Priority.HIGH) 84 | if (useCache) 85 | options.diskCacheStrategy(DiskCacheStrategy.AUTOMATIC) 86 | return options 87 | } 88 | 89 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /app/src/main/java/com/kd/kotlin/extend/utils/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package com.kd.kotlin.extend.utils 2 | 3 | import android.os.Bundle 4 | import android.support.v7.app.AppCompatActivity 5 | import kotlinx.android.synthetic.main.activity_main.* 6 | 7 | class MainActivity : AppCompatActivity() { 8 | override fun onCreate(savedInstanceState: Bundle?) { 9 | super.onCreate(savedInstanceState) 10 | setContentView(R.layout.activity_main) 11 | 12 | img.loadImage(this, "http://c.hiphotos.baidu.com/image/pic/item/fd039245d688d43ffdcaed06711ed21b0ff43be6.jpg") 13 | img.loadImageByProportion(1/3f, 9/16f) 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /app/src/main/java/com/kd/kotlin/extend/utils/SharedPreferencesExtends.kt: -------------------------------------------------------------------------------- 1 | package com.kd.kotlin.extend.utils 2 | 3 | import android.content.Context 4 | import android.content.SharedPreferences 5 | import java.lang.IllegalArgumentException 6 | import kotlin.properties.ReadWriteProperty 7 | import kotlin.reflect.KProperty 8 | 9 | object SharedPreferencesExtends { 10 | 11 | val PREFS_NAME: String = "SP_EXTENDS" 12 | 13 | fun notNullSingleValue() = NotNullSingleValueVar() 14 | 15 | fun preference(context: Context, name: String, default: T) = Preference(context, name, default) 16 | 17 | class NotNullSingleValueVar : ReadWriteProperty { 18 | private var value: T? = null 19 | override fun getValue(thisRef: Any?, property: KProperty<*>): T { 20 | return value ?: throw IllegalStateException("${property.name} not initialized") 21 | } 22 | 23 | override fun setValue(thisRef: Any?, property: KProperty<*>, value: T) { 24 | this.value = if (this.value == null) value else throw IllegalStateException("${property.name} already initialized") 25 | } 26 | } 27 | 28 | class Preference(val context: Context, val name: String, val default: T) : ReadWriteProperty { 29 | val prefs: SharedPreferences by lazy { context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE) } 30 | 31 | override fun getValue(thisRef: Any?, property: KProperty<*>): T { 32 | return findPreference(name, default) 33 | } 34 | 35 | override fun setValue(thisRef: Any?, property: KProperty<*>, value: T) { 36 | putPreference(name, value) 37 | } 38 | 39 | @Suppress("UNCHECKED_CAST") 40 | private fun findPreference(name: String, default: T): T = with(prefs) { 41 | val res: Any = when (default) { 42 | is Long -> getLong(name, default) 43 | is String -> getString(name, default) 44 | is Int -> getInt(name, default) 45 | is Boolean -> getBoolean(name, default) 46 | is Float -> getFloat(name, default) 47 | else -> throw IllegalArgumentException("This type can be saved into Preferences") 48 | } 49 | res as T 50 | } 51 | 52 | private fun putPreference(name: String, value: T) = with(prefs.edit()) { 53 | when (value) { 54 | is Long -> putLong(name, value) 55 | is String -> putString(name, value) 56 | is Int -> putInt(name, value) 57 | is Boolean -> putBoolean(name, value) 58 | is Float -> putFloat(name, value) 59 | else -> throw IllegalArgumentException("This type can't be saved into Preferences") 60 | }.apply() 61 | } 62 | 63 | } 64 | 65 | } -------------------------------------------------------------------------------- /app/src/main/java/com/kd/kotlin/extend/utils/TextViewExtends.kt: -------------------------------------------------------------------------------- 1 | package com.kd.kotlin.extend.utils 2 | 3 | import android.widget.TextView 4 | 5 | /** 6 | * 设置颜色直接使用colors.xml中定义的颜色即可 7 | */ 8 | fun TextView.setColor(resId: Int) { 9 | this.setTextColor(resources.getColor(resId)) 10 | } 11 | 12 | fun TextView.setDrawableLeft(resId: Int) { 13 | var drawable = this.context.resources.getDrawable(resId) 14 | drawable.setBounds(0, 0, drawable.minimumWidth, drawable.minimumHeight) 15 | this.setCompoundDrawables(drawable, null, null, null) 16 | } 17 | 18 | fun TextView.setDrawableRight(resId: Int) { 19 | var drawable = this.context.resources.getDrawable(resId) 20 | drawable.setBounds(0, 0, drawable.minimumWidth, drawable.minimumHeight) 21 | this.setCompoundDrawables(null, null, drawable, null) 22 | } 23 | 24 | fun TextView.setDrawableTop(resId: Int) { 25 | var drawable = this.context.resources.getDrawable(resId) 26 | drawable.setBounds(0, 0, drawable.minimumWidth, drawable.minimumHeight) 27 | this.setCompoundDrawables(null, drawable, null, null) 28 | } 29 | 30 | fun TextView.setDrawableBottom(resId: Int) { 31 | var drawable = this.context.resources.getDrawable(resId) 32 | drawable.setBounds(0, 0, drawable.minimumWidth, drawable.minimumHeight) 33 | this.setCompoundDrawables(null, null, null, drawable) 34 | } 35 | 36 | -------------------------------------------------------------------------------- /app/src/main/java/com/kd/kotlin/extend/utils/ViewExtends.kt: -------------------------------------------------------------------------------- 1 | package com.kd.kotlin.extend.utils 2 | 3 | import android.graphics.Bitmap 4 | import android.graphics.Canvas 5 | import android.graphics.Color 6 | import android.view.View 7 | import android.view.ViewGroup 8 | 9 | /** 10 | * View 转 bitmap 11 | */ 12 | fun View.view2Bitmap(): Bitmap { 13 | var ret = Bitmap.createBitmap(this.width, this.height, Bitmap.Config.ARGB_8888) 14 | var canvas = Canvas(ret) 15 | var bgDrawable = this.background 16 | bgDrawable?.draw(canvas) ?: canvas.drawColor(Color.WHITE) 17 | this.draw(canvas) 18 | return ret 19 | } 20 | 21 | 22 | //-----扩展属性----- 23 | 24 | var View.bottomMargin: Int 25 | get():Int { 26 | return (layoutParams as ViewGroup.MarginLayoutParams).bottomMargin 27 | } 28 | set(value) { 29 | (layoutParams as ViewGroup.MarginLayoutParams).bottomMargin = value 30 | } 31 | 32 | 33 | var View.topMargin: Int 34 | get():Int { 35 | return (layoutParams as ViewGroup.MarginLayoutParams).topMargin 36 | } 37 | set(value) { 38 | (layoutParams as ViewGroup.MarginLayoutParams).topMargin = value 39 | } 40 | 41 | 42 | var View.rightMargin: Int 43 | get():Int { 44 | return (layoutParams as ViewGroup.MarginLayoutParams).rightMargin 45 | } 46 | set(value) { 47 | (layoutParams as ViewGroup.MarginLayoutParams).rightMargin = value 48 | } 49 | 50 | var View.leftMargin: Int 51 | get():Int { 52 | return (layoutParams as ViewGroup.MarginLayoutParams).leftMargin 53 | } 54 | set(value) { 55 | (layoutParams as ViewGroup.MarginLayoutParams).leftMargin = value 56 | } -------------------------------------------------------------------------------- /app/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 12 | 13 | 19 | 22 | 25 | 26 | 27 | 28 | 34 | 35 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 11 | 16 | 21 | 26 | 31 | 36 | 41 | 46 | 51 | 56 | 61 | 66 | 71 | 76 | 81 | 86 | 91 | 96 | 101 | 106 | 111 | 116 | 121 | 126 | 131 | 136 | 141 | 146 | 151 | 156 | 161 | 166 | 171 | 172 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shiweibsw/Android-kotlin-extend-utils/c98f17e4c346c5905a93a9300d590fe9e254bd6a/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shiweibsw/Android-kotlin-extend-utils/c98f17e4c346c5905a93a9300d590fe9e254bd6a/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shiweibsw/Android-kotlin-extend-utils/c98f17e4c346c5905a93a9300d590fe9e254bd6a/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shiweibsw/Android-kotlin-extend-utils/c98f17e4c346c5905a93a9300d590fe9e254bd6a/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shiweibsw/Android-kotlin-extend-utils/c98f17e4c346c5905a93a9300d590fe9e254bd6a/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shiweibsw/Android-kotlin-extend-utils/c98f17e4c346c5905a93a9300d590fe9e254bd6a/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shiweibsw/Android-kotlin-extend-utils/c98f17e4c346c5905a93a9300d590fe9e254bd6a/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shiweibsw/Android-kotlin-extend-utils/c98f17e4c346c5905a93a9300d590fe9e254bd6a/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shiweibsw/Android-kotlin-extend-utils/c98f17e4c346c5905a93a9300d590fe9e254bd6a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shiweibsw/Android-kotlin-extend-utils/c98f17e4c346c5905a93a9300d590fe9e254bd6a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | Kotlin扩展函数 3 | 确定 4 | 取消 5 | 提交 6 | 编辑 7 | 加入 8 | 创建 9 | 提示 10 | 11 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | ext.kotlin_version = '1.2.30' 5 | repositories { 6 | google() 7 | jcenter() 8 | mavenCentral() 9 | } 10 | dependencies { 11 | classpath 'com.android.tools.build:gradle:3.1.2' 12 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 13 | 14 | // NOTE: Do not place your application dependencies here; they belong 15 | // in the individual module build.gradle files 16 | } 17 | } 18 | 19 | allprojects { 20 | repositories { 21 | google() 22 | jcenter() 23 | mavenCentral() 24 | } 25 | } 26 | 27 | task clean(type: Delete) { 28 | delete rootProject.buildDir 29 | } 30 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | # IDE (e.g. Android Studio) users: 3 | # Gradle settings configured through the IDE *will override* 4 | # any settings specified in this file. 5 | # For more details on how to configure your build environment visit 6 | # http://www.gradle.org/docs/current/userguide/build_environment.html 7 | # Specifies the JVM arguments used for the daemon process. 8 | # The setting is particularly useful for tweaking memory settings. 9 | org.gradle.jvmargs=-Xmx1536m 10 | # When configured, Gradle will run in incubating parallel mode. 11 | # This option should only be used with decoupled projects. More details, visit 12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 13 | # org.gradle.parallel=true 14 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shiweibsw/Android-kotlin-extend-utils/c98f17e4c346c5905a93a9300d590fe9e254bd6a/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Sat Jun 30 13:18:02 CST 2018 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-4.4-all.zip 7 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Attempt to set APP_HOME 10 | # Resolve links: $0 may be a link 11 | PRG="$0" 12 | # Need this for relative symlinks. 13 | while [ -h "$PRG" ] ; do 14 | ls=`ls -ld "$PRG"` 15 | link=`expr "$ls" : '.*-> \(.*\)$'` 16 | if expr "$link" : '/.*' > /dev/null; then 17 | PRG="$link" 18 | else 19 | PRG=`dirname "$PRG"`"/$link" 20 | fi 21 | done 22 | SAVED="`pwd`" 23 | cd "`dirname \"$PRG\"`/" >/dev/null 24 | APP_HOME="`pwd -P`" 25 | cd "$SAVED" >/dev/null 26 | 27 | APP_NAME="Gradle" 28 | APP_BASE_NAME=`basename "$0"` 29 | 30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 31 | DEFAULT_JVM_OPTS="" 32 | 33 | # Use the maximum available, or set MAX_FD != -1 to use that value. 34 | MAX_FD="maximum" 35 | 36 | warn () { 37 | echo "$*" 38 | } 39 | 40 | die () { 41 | echo 42 | echo "$*" 43 | echo 44 | exit 1 45 | } 46 | 47 | # OS specific support (must be 'true' or 'false'). 48 | cygwin=false 49 | msys=false 50 | darwin=false 51 | nonstop=false 52 | case "`uname`" in 53 | CYGWIN* ) 54 | cygwin=true 55 | ;; 56 | Darwin* ) 57 | darwin=true 58 | ;; 59 | MINGW* ) 60 | msys=true 61 | ;; 62 | NONSTOP* ) 63 | nonstop=true 64 | ;; 65 | esac 66 | 67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 68 | 69 | # Determine the Java command to use to start the JVM. 70 | if [ -n "$JAVA_HOME" ] ; then 71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 72 | # IBM's JDK on AIX uses strange locations for the executables 73 | JAVACMD="$JAVA_HOME/jre/sh/java" 74 | else 75 | JAVACMD="$JAVA_HOME/bin/java" 76 | fi 77 | if [ ! -x "$JAVACMD" ] ; then 78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 79 | 80 | Please set the JAVA_HOME variable in your environment to match the 81 | location of your Java installation." 82 | fi 83 | else 84 | JAVACMD="java" 85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 86 | 87 | Please set the JAVA_HOME variable in your environment to match the 88 | location of your Java installation." 89 | fi 90 | 91 | # Increase the maximum file descriptors if we can. 92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 93 | MAX_FD_LIMIT=`ulimit -H -n` 94 | if [ $? -eq 0 ] ; then 95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 96 | MAX_FD="$MAX_FD_LIMIT" 97 | fi 98 | ulimit -n $MAX_FD 99 | if [ $? -ne 0 ] ; then 100 | warn "Could not set maximum file descriptor limit: $MAX_FD" 101 | fi 102 | else 103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 104 | fi 105 | fi 106 | 107 | # For Darwin, add options to specify how the application appears in the dock 108 | if $darwin; then 109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 110 | fi 111 | 112 | # For Cygwin, switch paths to Windows format before running java 113 | if $cygwin ; then 114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 116 | JAVACMD=`cygpath --unix "$JAVACMD"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Escape application args 158 | save () { 159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 160 | echo " " 161 | } 162 | APP_ARGS=$(save "$@") 163 | 164 | # Collect all arguments for the java command, following the shell quoting and substitution rules 165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 166 | 167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong 168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then 169 | cd "$(dirname "$0")" 170 | fi 171 | 172 | exec "$JAVACMD" "$@" 173 | -------------------------------------------------------------------------------- /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 | set DIRNAME=%~dp0 12 | if "%DIRNAME%" == "" set DIRNAME=. 13 | set APP_BASE_NAME=%~n0 14 | set APP_HOME=%DIRNAME% 15 | 16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 17 | set DEFAULT_JVM_OPTS= 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 Windows variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | 53 | :win9xME_args 54 | @rem Slurp the command line arguments. 55 | set CMD_LINE_ARGS= 56 | set _SKIP=2 57 | 58 | :win9xME_args_slurp 59 | if "x%~1" == "x" goto execute 60 | 61 | set CMD_LINE_ARGS=%* 62 | 63 | :execute 64 | @rem Setup the command line 65 | 66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 67 | 68 | @rem Execute Gradle 69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 70 | 71 | :end 72 | @rem End local scope for the variables with windows NT shell 73 | if "%ERRORLEVEL%"=="0" goto mainEnd 74 | 75 | :fail 76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 77 | rem the _cmd.exe /c_ return code! 78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 79 | exit /b 1 80 | 81 | :mainEnd 82 | if "%OS%"=="Windows_NT" endlocal 83 | 84 | :omega 85 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | --------------------------------------------------------------------------------