Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/idapgroup/ArgumentDelegate
Property binding for Android Bundle arguments.
https://github.com/idapgroup/ArgumentDelegate
android arguments bundle intent kotlin property-delegate
Last synced: about 2 months ago
JSON representation
Property binding for Android Bundle arguments.
- Host: GitHub
- URL: https://github.com/idapgroup/ArgumentDelegate
- Owner: idapgroup
- License: bsd-3-clause
- Created: 2019-04-11T20:23:32.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2022-02-18T15:57:50.000Z (over 2 years ago)
- Last Synced: 2024-07-11T15:47:12.994Z (3 months ago)
- Topics: android, arguments, bundle, intent, kotlin, property-delegate
- Language: Kotlin
- Homepage:
- Size: 140 KB
- Stars: 25
- Watchers: 8
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-list - idapgroup/ArgumentDelegate - Property binding for Android Bundle arguments. (Kotlin)
README
Argument Delegate
============Property binding for Android Bundle arguments. Written for simple bundle unpacking for Kotlin users.
Download
--------[ ![Download](https://api.bintray.com/packages/idapgroup/kotlin/argument-delegate/images/download.svg?version=1.0.3) ](https://bintray.com/idapgroup/kotlin/argument-delegate/1.0.3/link)
Add repository to your root `build.gradle`
```groovy
repositories {
jcenter()
}
``````groovy
dependencies {
implementation 'com.idapgroup:argument-delegate:latest-version'
}
```Usage sample
-------------```kotlin
class ExampleActivity : Activity {val userName: String by argumentDelegate()
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
// your activity setup code
Log.d("ExampleActivity", "userName - $userName")
}}
```__Remember: Bundled argument name must have the same name as property have. For current example:__
```kotlin
val bundle = Bundle().apply {
putString("userName", "John")
}
```Additional info
-------------__argumentDelegate__ is an extension function for Fragment and Activity. If you want to use it
out of the Activity/Fragment then you should implement _argumentWrapper_ block.
Example:```kotlin
class Example {
private lateinit var bundle: Bundle
private val wrapper = { a: Example -> a.bundle }
val userName: String by argumentDelegate(wrapper)
}
```