Anko Commons - Intents fun startActivity(context: Context) { val intent = Intent(context, MainActivity::class.java) intent.putExtra(EXTRA_STATE, "3") context.startActivity(intent) } fun startActivity(context: Context) { context.startActivity(EXTRA_STATE to 3) } fun startActivity(context: Context) = context.startActivity(EXTRA_STATE to 3) context.share("url to a new podcast!”)
Anko Commons - Dialogs context.alert("Hi, I'm Roy", "Have you tried turning it off and on again?") { yesButton { context.toast("Oh…") } noButton {} }.show()
Anko Commons - Logging class EpisodesPresenter(private val callback: WeakReference): AnkoLogger { fun someFunction(item: Item) { info("clicked on $item") warn("This is a warning") } }
Anko Coroutines - before object GetRssFeedRequest { fun getFeed(callback: Callback) { val retrofit = RetrofitUtils.getRetrofit() val service = retrofit.create(RssFeedService::class.java) val feed = service.getFeed() feed.enqueue(callback) } }
Anko Coroutines - after object GetRssFeedRequest { fun getFeed(): Response? { val retrofit = RetrofitUtils.getRetrofit() val service = retrofit.create(RssFeedService::class.java) val feed = service.getFeed() return feed.execute() } }