- ๐ Follow the white theme.
- ๐ฅ There is no IDE ...
- ๐ง Free your memory.
- ๐ Blog
๐๐ป Open Source projects by me: ๐๐ป
Kotlin Extensions (Android extensions) and Helpers for smoother Android development
Home Page: http://funkymuse.dev/KAHelpers/
License: MIT License
๐๐ป Open Source projects by me: ๐๐ป
KAHelpers/string/src/main/java/com/crazylegend/string/StringExtensions.kt
Lines 110 to 114 in e40d6c5
Using regex for this trivial task its overengineering, by the way, numbers like "3.14" will returns false :).
Never use regex for this, you can just write return "3.14".toFloatOrNull() != null
Really? It's exactly not decrypting and not encrypting, there is not used salt, and very bad practice "return empty string at bad case" .
Your function must named decryptAESOrEmptyString by contract, returning empty string there is side effect, so this function is not pure, and it side effect not documented.
You must document this side effect, for example @returns decrypted aes string or empty string if decryption failed.
Or just made decryptOrNull function so will better.
Add documentation for locale change helper when the configuration change, locale doesn't.
override fun applyOverrideConfiguration(overrideConfiguration: Configuration?) { if (overrideConfiguration != null) { val uiMode = overrideConfiguration.uiMode overrideConfiguration.setTo(baseContext.resources.configuration) overrideConfiguration.uiMode = uiMode } super.applyOverrideConfiguration(overrideConfiguration) }
What sense of this?
kParameter.isOptional()
vs kParameter.isOptional
(left - your, right - kotlin reflection library)
I think such redundant extension methods can be removed, because its look strangely in code auto completion
gradle is unable to resolve
com.github.FunkyMuse:KAHelpers:viewbinding
the others i am using coroutine, kotlinextensions, recyclerview are fine
This function no need, kotlin have functions drop
and dropLast
.
https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/drop.html
kotlin provide nullable keyword "?" to make variable nullable so no need to use "Nullable" annotation @FunkyMuse
i am also ready to contribute on this project for this issue.
Hello,
I use viewbinding helper in my project and it is really awesome. In build.gradle I just added implementation"com.github.FunkyMuse.KAHelpers:viewbinding:2.1.19"
. After some exploration I found out that my module is using the viewbinding module's libraries (eg. fragment, activity, lifecycle deps)
Is there a way how to enforce gradle to use the versions from my module gradle? I use stable versions of androidx in my app and don't want to mix with un-stable. Ofcourse there is a way - just to copy files somewhere to my project but I am curious about posibilities of gradle.
Thanks
isDigit
function, use it instead using regex.KAHelpers/string/src/main/java/com/crazylegend/string/StringExtensions.kt
Lines 338 to 341 in e40d6c5
This bad code. Normalizing it's not a trimming, you MUST NOT trim in normalize function. By function-name contract you must do only normalizing (by the way, will better if you will accept normalizing form in this function).
Or rename this function to normalizeAndTrim
.
No need such extension function because kotlin have from std library such method equals.
"bla bla".equals("bla BLA", ignoreCase = true) // true
Lost 2-3 hours fixing compilation errors and importing new packages. :(
Hi, there, I found a framework API call needs permission, but is not annotated.
The API is MediaStore.setRequireOriginal(Uri)
, it is added in Android Q, and needs permission ACCESS_MEDIA_LOCATION
.
It is used in the library in three places
https://github.com/FunkyMuse/KAHelpers/blob/master/saf/src/main/java/com/crazylegend/saf/SafExtensions.kt#L30
https://github.com/FunkyMuse/KAHelpers/blob/master/saf/src/main/java/com/crazylegend/saf/SafExtensions.kt#L44
https://github.com/FunkyMuse/KAHelpers/blob/master/saf/src/main/java/com/crazylegend/saf/SafExtensions.kt#L56
The first API call is annotated by @RequiresPermission
, while the last two are not. Do they also need the annotations?
Besides, I have two more suggestions about improving the code:
if(context.checkSelfPermission(ACCESS_MEDIA_LOCATION)==GRANTED)
// call the API
if(SDK_INT >= 29)
// call the API
@FunkyMuse Could you help me review this? Very thanks!
KAHelpers/string/src/main/java/com/crazylegend/string/StringExtensions.kt
Lines 246 to 258 in e40d6c5
It's definitely not encryption, its hashing function, this function must be renamed to hashMD5, and provide argument for passing salt to this hashing function.
In any case, when I want hash something, I mean hash and search with hash
word, this function no one will find, because name is wrong.
CountUpTimer bug
Hello,
I've been using this library as a reference for a little while and copy/paste-ing certain extension functions when I needed them. Today I decided I would go ahead and just utilize the library as a normal gradle dependency.
However, my application will crash the first time it tries to use GlideApp.with. Details can be found here:
http://bumptech.github.io/glide/doc/configuration.html#avoid-appglidemodule-in-libraries
Is there any way this library could utilize the LibraryGlideModule variant instead or remove the Glide related extensions? Thanks!
hi. im trying to use view binding extension function but it wont work .i initilize it in my fragment like this :
** private val binding by viewBinding(FragmentHomeBinding::bind) **
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View {
return binding.root
}
but when running application it gives an error ->
** java.lang.IllegalStateException: Fragment HomeFragment{42e81c4} (b0b54e5a-4677-4e6c-90ac-40a613953041 id=0x7f09021c) did not return a View from onCreateView() or this was called before onCreateView(). **
First of all, thank you and congratulations on this wonderful library of Kotlin extensions
I have been seeing that there are Google Maps Extensions, but it would be quite good if some Mapbox were added in the future, since it is another quite powerful map service that is currently used in many projects.
I hope you can add what I said as it would be great. I thank you again
Regards
This function immediately returns false
on string ััั ะตััั ะฑัะบะฒั
, never use regex for checking is letter on not, kotlin has function isLetter
on char type.
Thanks for this library. I just integrated it into an activity with a map.
private val binding: GoogleMapSettingActivityBinding by viewBinding(GoogleMapSettingActivityBinding::inflate)
and then in onCreate, I did not called setContentView as was mentioned in the documentation.
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val mapFragment: SupportMapFragment? =
supportFragmentManager.findFragmentById(R.id.map) as? SupportMapFragment
mapFragment?.getMapAsync(this)
...
The problem here is that mapFragment is null. However, if I call setContentView(binding.root) before calling findFragmentById then mapFragment is not null, like this -
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(v.root)
...
What could be the issue?
When integrating Dokka and attempting to execute ./gradlew dokkaHtmlMultiModule, there are some compilation errors.
we need to change like this
inline fun <K : Any, V : Any> LruCache<K, V>.getOrPut(key: K, defaultValue: () -> V): V {
synchronized(this) {
this[key]?.let { return it }
return defaultValue().apply { put(key, this) }
}
}
/**
* Gets value with specific key from the cache. If the value is not present,
* calls [defaultValue] to obtain a value which is placed into the cache
* if not null, then returned.
*
* This method is thread-safe.
*/
inline fun <K : Any, V> LruCache<K, V>.getOrPutNotNull(key: K, defaultValue: () -> V?): V? {
synchronized(this) {
this[key]?.let { return it }
return defaultValue()?.apply { put(key, this) }
}
}
then it works great.
There is no docs and no examples in the README, Please consider adding them
KAHelpers/string/src/main/java/com/crazylegend/string/StringExtensions.kt
Lines 100 to 104 in e40d6c5
So, I don't know where from you found this regex, but it does not work, I don't know why need use this unknown regex, exist official generated regex by email specifications.
And as you see, its much longer than your regex.
http://www.ex-parrot.com/~pdw/Mail-RFC822-Address.html
(?:(?:\r\n)?[ \t])*(?:(?:(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t]
)+|\Z|(?=[\["()<>@,;:\\".\[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)?[ \t]))*"(?:(?:
\r\n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(
?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)?[
\t]))*"(?:(?:\r\n)?[ \t])*))*@(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\0
31]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\
](?:(?:\r\n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+
(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:
(?:\r\n)?[ \t])*))*|(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z
|(?=[\["()<>@,;:\\".\[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)?[ \t]))*"(?:(?:\r\n)
?[ \t])*)*\<(?:(?:\r\n)?[ \t])*(?:@(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\
r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[
\t])*)(?:\.(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)
?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t]
)*))*(?:,@(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[
\t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*
)(?:\.(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t]
)+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*))*)
*:(?:(?:\r\n)?[ \t])*)?(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+
|\Z|(?=[\["()<>@,;:\\".\[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)?[ \t]))*"(?:(?:\r
\n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:
\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)?[ \t
]))*"(?:(?:\r\n)?[ \t])*))*@(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031
]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](
?:(?:\r\n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?
:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?
:\r\n)?[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)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\"
.\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\
]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*))*(?:,@(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\
[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\
r\\]|\\.)*\](?:(?:\r\n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\]
\000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]
|\\.)*\](?:(?:\r\n)?[ \t])*))*)*:(?:(?:\r\n)?[ \t])*)?(?:[^()<>@,;:\\".\[\] \0
00-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|"(?:[^\"\r\\]|\\
.|(?:(?:\r\n)?[ \t]))*"(?:(?:\r\n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t])*(?:[^()<>@,
;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|"(?
:[^\"\r\\]|\\.|(?:(?:\r\n)?[ \t]))*"(?:(?:\r\n)?[ \t])*))*@(?:(?:\r\n)?[ \t])*
(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".
\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t])*(?:[
^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]
]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*))*\>(?:(?:\r\n)?[ \t])*)(?:,\s*(
?:(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\
".\[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)?[ \t]))*"(?:(?:\r\n)?[ \t])*)(?:\.(?:(
?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[
\["()<>@,;:\\".\[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)?[ \t]))*"(?:(?:\r\n)?[ \t
])*))*@(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t
])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*)(?
:\.(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|
\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*))*|(?:
[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\
]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)?[ \t]))*"(?:(?:\r\n)?[ \t])*)*\<(?:(?:\r\n)
?[ \t])*(?:@(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["
()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*)(?:\.(?:(?:\r\n)
?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>
@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*))*(?:,@(?:(?:\r\n)?[
\t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,
;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t]
)*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\
".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*))*)*:(?:(?:\r\n)?[ \t])*)?
(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".
\[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)?[ \t]))*"(?:(?:\r\n)?[ \t])*)(?:\.(?:(?:
\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\[
"()<>@,;:\\".\[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)?[ \t]))*"(?:(?:\r\n)?[ \t])
*))*@(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])
+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*)(?:\
.(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z
|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*))*\>(?:(
?:\r\n)?[ \t])*))*)?;\s*)
some modules has inspection or lint warnings, Have you considered resolving them or integrating Detekt?
this regex fully incorrect and no matches much of possible numbers. ^1([34578])\\d{9}\$
Phone always must not checked or validated by regex because not one regex for all phone number cases. Phone always validating by code, or by regex but for only one culture.
See the bottom of this answer: https://stackoverflow.com/a/24500045
Per default, java.time.Duration only gives you the entire hours, minutes, etc. Sometimes it is useful to get the minute part only.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.