-
-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Update Android release timeline dialog
Signed-off-by: Hu Shenghao <[email protected]>
- Loading branch information
1 parent
794ef45
commit 1ba4de8
Showing
15 changed files
with
267 additions
and
147 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
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
49 changes: 49 additions & 0 deletions
49
basic/src/main/java/com/dede/basic/utils/AppLocaleDateFormatter.kt
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,49 @@ | ||
package com.dede.basic.utils | ||
|
||
import android.icu.text.SimpleDateFormat | ||
import android.os.Build | ||
import androidx.appcompat.app.AppCompatDelegate | ||
import java.text.DateFormat | ||
import java.text.FieldPosition | ||
import java.text.Format | ||
import java.text.ParsePosition | ||
import java.util.Date | ||
import java.util.Locale | ||
|
||
|
||
class AppLocaleDateFormatter private constructor(pattern: String, locale: Locale) : DateFormat() { | ||
|
||
companion object { | ||
fun getInstance(pattern: String): AppLocaleDateFormatter { | ||
return AppLocaleDateFormatter(pattern, getApplicationLocale()) | ||
} | ||
|
||
private fun getApplicationLocale(): Locale { | ||
val locales = AppCompatDelegate.getApplicationLocales() | ||
return if (locales.isEmpty) { | ||
Locale.getDefault() | ||
} else { | ||
locales.get(0) ?: Locale.getDefault() | ||
} | ||
} | ||
} | ||
|
||
private val format: Format = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { | ||
SimpleDateFormat(pattern, locale) | ||
} else { | ||
java.text.SimpleDateFormat(pattern, locale) | ||
} | ||
|
||
override fun format( | ||
date: Date, | ||
toAppendTo: StringBuffer, | ||
fieldPosition: FieldPosition | ||
): StringBuffer { | ||
return format.format(date, toAppendTo, fieldPosition) | ||
} | ||
|
||
override fun parse(source: String, pos: ParsePosition): Date? { | ||
return format.parseObject(source, pos) as? Date | ||
} | ||
|
||
} |
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
Oops, something went wrong.