-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
shang_dong
committed
Sep 23, 2023
1 parent
15ac566
commit e9c2f50
Showing
7 changed files
with
62 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package com.zhangjian.samp | ||
|
||
import android.graphics.Color | ||
import java.util.Locale | ||
import java.util.Random | ||
|
||
/** | ||
* Create by shang_dong on 2023/9/23 | ||
*/ | ||
fun getRandColor(): String { | ||
var r: String | ||
var g: String | ||
var b: String | ||
val random = Random() | ||
r = Integer.toHexString(random.nextInt(256)).uppercase(Locale.getDefault()) | ||
g = Integer.toHexString(random.nextInt(256)).uppercase(Locale.getDefault()) | ||
b = Integer.toHexString(random.nextInt(256)).uppercase(Locale.getDefault()) | ||
r = if (r.length == 1) "0$r" else r | ||
g = if (g.length == 1) "0$g" else g | ||
b = if (b.length == 1) "0$b" else b | ||
return "#$r$g$b" | ||
} | ||
|
||
fun getRandColorInt() : Int{ | ||
return Color.parseColor(getRandColor()) | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters