Skip to content
This repository was archived by the owner on Jul 13, 2020. It is now read-only.

Add Dialog.find(id) method #351

Merged
merged 1 commit into from
Apr 13, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions anko/library/static/common/src/ContextUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package org.jetbrains.anko

import android.app.Activity
import android.app.Dialog
import android.app.Fragment
import android.content.Context
import android.content.SharedPreferences
Expand Down Expand Up @@ -67,10 +68,12 @@ inline val Activity.contentView: View?
inline fun <reified T : View> View.find(@IdRes id: Int): T = findViewById(id) as T
inline fun <reified T : View> Activity.find(@IdRes id: Int): T = findViewById(id) as T
inline fun <reified T : View> Fragment.find(@IdRes id: Int): T = view?.findViewById(id) as T
inline fun <reified T : View> Dialog.find(@IdRes id: Int): T = findViewById(id) as T

inline fun <reified T : View> View.findOptional(@IdRes id: Int): T? = findViewById(id) as? T
inline fun <reified T : View> Activity.findOptional(@IdRes id: Int): T? = findViewById(id) as? T
inline fun <reified T : View> Fragment.findOptional(@IdRes id: Int): T? = view?.findViewById(id) as? T
inline fun <reified T : View> Dialog.findOptional(@IdRes id: Int): T? = findViewById(id) as? T

inline fun <T: Fragment> T.withArguments(vararg params: Pair<String, Any>): T {
arguments = bundleOf(*params)
Expand Down