File tree Expand file tree Collapse file tree 2 files changed +26
-0
lines changed
utils-ktx/src/main/java/me/shouheng/utils/ktx Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,8 @@ import androidx.annotation.FloatRange
55import androidx.annotation.IntRange
66import me.shouheng.utils.ui.ColorUtils
77
8+ // The kotlin extensions for basic data types.
9+
810/* * Get color with alpha from given color. */
911@ColorInt fun Int.withAlpha (@FloatRange(from = .0 , to = 1.0 ) alpha : Float , override : Boolean = true): Int {
1012 return ColorUtils .setColorAlpha(this , alpha, override )
Original file line number Diff line number Diff line change 1+ package me.shouheng.utils.ktx
2+
3+ import me.shouheng.utils.store.FileUtils
4+ import java.io.File
5+
6+ /* *
7+ * The kotlin extensions for [File].
8+ *
9+ * @Author wangshouheng
10+ * @Time 2021/12/19
11+ */
12+ fun File?.md5 (): String = FileUtils .getFileMD5ToString(this )
13+
14+ fun File?.isFile (): Boolean = FileUtils .isFile(this )
15+
16+ fun File?.isDir (): Boolean = FileUtils .isDir(this )
17+
18+ fun File?.rename (name : String ): Boolean = FileUtils .rename(this , name)
19+
20+ fun File?.copyTo (dest : File ): Boolean = FileUtils .copyFile(this , dest)
21+
22+ fun File?.moveTo (dest : File ): Boolean = FileUtils .moveFile(this , dest)
23+
24+ fun File?.delete (): Boolean = FileUtils .delete(this )
You can’t perform that action at this time.
0 commit comments