-
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.
Update edittext searchOnDelay + show anchorListDialog
- Loading branch information
1 parent
8b0216f
commit 4079b54
Showing
6 changed files
with
91 additions
and
51 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
File renamed without changes.
33 changes: 33 additions & 0 deletions
33
mtlibrary/src/main/java/com/nvmt/android/mtlibrary/extension/StringEtx.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,33 @@ | ||
package com.nvmt.android.mtlibrary.extension | ||
|
||
import com.nvmt.android.mtlibrary.base.MTConstant.DESTINATION_CHARACTERS | ||
import com.nvmt.android.mtlibrary.base.MTConstant.SOURCE_CHARACTERS | ||
import java.text.NumberFormat | ||
import java.util.* | ||
import kotlin.math.roundToInt | ||
|
||
fun removeAccent(ch: Char): Char { | ||
var ch = ch | ||
val index: Int = Arrays.binarySearch(SOURCE_CHARACTERS, ch) | ||
if (index >= 0) { | ||
ch = DESTINATION_CHARACTERS[index] | ||
} | ||
return ch | ||
} | ||
|
||
fun removeAccent(str: CharSequence): String { | ||
val re = Regex("[^[^\\W_]\\d\\s]") | ||
val newStr = re.replace(str, "").toUpperCase(Locale.getDefault()) | ||
val sb = StringBuilder(newStr) | ||
for (i in sb.indices) { | ||
sb.setCharAt(i, removeAccent(sb[i])) | ||
} | ||
return sb.toString() | ||
} | ||
|
||
fun String.equalVietnamese(anotherStr: String?, ignoreCase: Boolean = false): Boolean { | ||
if (anotherStr == null) return false | ||
val newStr1 = removeAccent(this) | ||
val newStr2 = removeAccent(anotherStr) | ||
return newStr1.equals(newStr2, ignoreCase = ignoreCase) | ||
} |