nsk-mironov / kotlin-jetpack Goto Github PK
View Code? Open in Web Editor NEWA collection of useful extension methods for Android
License: Apache License 2.0
A collection of useful extension methods for Android
License: Apache License 2.0
Why do we need to have the minSdkVersion at 16?
Like the title says
Why do you add bind
before any delegation? there is not Kotlin stdlib delegation that start with bind.
val booleanOrThrow: Boolean by booleanArgument("extra_boolean")
also for resources, I think it is more readable:
val text by stringResource(R.string.text)
val number by intResource(R.integer.number)
val dimenPixelSize by dimenResource(R.dimen.size)
val color by colorResource(R.color.red)
val intArray by intArrayResource(R.array.ids)
val stringArray by stringArrayResource(R.array.options)
val drawable by drawableResource(R.drawable.background)
Early draft:
class UserArguments(extras: Bundle) : WithExtras(extras) {
var name by argument<String>()
var age by argument<Int>()
}
class UserActivity : AppCompatActivity() {
private val args by arguments<UserArguments>()
}
class UserFragment : Fragment() {
private val args by arguments<UserArguments>()
}
fun onNavigateToUserScreen(activity: Activity) {
activity.startActivity(Jetpack.newIntent<UserActivity, UserArguments>(activity) {
name = "Mike"
age = 22
})
}
inline fun <reified A : WithExtras> Activity.arguments(): ReadOnlyProperty<Activity, A> {
throw UnsupportedOperationException()
}
inline fun <reified A : WithExtras> Fragment.arguments(): ReadOnlyProperty<Fragment, A> {
throw UnsupportedOperationException()
}
open class WithExtras(val extras: Bundle) {
inline fun <reified T> argument(name: String? = null, default: T? = null): ReadWriteProperty<Any, T> {
throw UnsupportedOperationException()
}
}
object Jetpack {
inline fun <reified A : Activity, reified E : WithExtras> newIntent(context: Context, builder: E.() -> Unit): Intent {
throw UnsupportedOperationException()
}
inline fun <reified F : Fragment, reified E : WithExtras> newFragment(builder: E.() -> Unit): F {
throw UnsupportedOperationException()
}
}
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.