いろいろ調整
This commit is contained in:
parent
492995dc40
commit
ffdd474c73
|
@ -1,119 +0,0 @@
|
|||
/*
|
||||
* Copyright 2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
@file:Suppress("NOTHING_TO_INLINE", "unused")
|
||||
|
||||
package org.jetbrains.anko
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.content.DialogInterface
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.view.KeyEvent
|
||||
import android.view.View
|
||||
import android.view.ViewManager
|
||||
import androidx.annotation.DrawableRes
|
||||
import androidx.annotation.StringRes
|
||||
import org.jetbrains.anko.internals.AnkoInternals.NO_GETTER
|
||||
import kotlin.DeprecationLevel.ERROR
|
||||
|
||||
@SuppressLint("SupportAnnotationUsage")
|
||||
interface AlertBuilder<out D : DialogInterface> {
|
||||
val ctx: Context
|
||||
|
||||
var title: CharSequence
|
||||
@Deprecated(NO_GETTER, level = ERROR) get
|
||||
|
||||
var titleResource: Int
|
||||
@Deprecated(NO_GETTER, level = ERROR) get
|
||||
|
||||
var message: CharSequence
|
||||
@Deprecated(NO_GETTER, level = ERROR) get
|
||||
|
||||
var messageResource: Int
|
||||
@Deprecated(NO_GETTER, level = ERROR) get
|
||||
|
||||
var icon: Drawable
|
||||
@Deprecated(NO_GETTER, level = ERROR) get
|
||||
|
||||
@setparam:DrawableRes
|
||||
var iconResource: Int
|
||||
@Deprecated(NO_GETTER, level = ERROR) get
|
||||
|
||||
var customTitle: View
|
||||
@Deprecated(NO_GETTER, level = ERROR) get
|
||||
|
||||
var customView: View
|
||||
@Deprecated(NO_GETTER, level = ERROR) get
|
||||
|
||||
var isCancelable: Boolean
|
||||
@Deprecated(NO_GETTER, level = ERROR) get
|
||||
|
||||
fun onCancelled(handler: (dialog: DialogInterface) -> Unit)
|
||||
|
||||
fun onKeyPressed(handler: (dialog: DialogInterface, keyCode: Int, e: KeyEvent) -> Boolean)
|
||||
|
||||
fun positiveButton(buttonText: String, onClicked: (dialog: DialogInterface) -> Unit)
|
||||
fun positiveButton(
|
||||
@StringRes buttonTextResource: Int,
|
||||
onClicked: (dialog: DialogInterface) -> Unit,
|
||||
)
|
||||
|
||||
fun negativeButton(buttonText: String, onClicked: (dialog: DialogInterface) -> Unit)
|
||||
fun negativeButton(
|
||||
@StringRes buttonTextResource: Int,
|
||||
onClicked: (dialog: DialogInterface) -> Unit,
|
||||
)
|
||||
|
||||
fun neutralPressed(buttonText: String, onClicked: (dialog: DialogInterface) -> Unit)
|
||||
fun neutralPressed(
|
||||
@StringRes buttonTextResource: Int,
|
||||
onClicked: (dialog: DialogInterface) -> Unit,
|
||||
)
|
||||
|
||||
fun items(
|
||||
items: List<CharSequence>,
|
||||
onItemSelected: (dialog: DialogInterface, index: Int) -> Unit,
|
||||
)
|
||||
|
||||
fun <T> items(
|
||||
items: List<T>,
|
||||
onItemSelected: (dialog: DialogInterface, item: T, index: Int) -> Unit,
|
||||
)
|
||||
|
||||
fun build(): D
|
||||
fun show(): D
|
||||
}
|
||||
|
||||
fun AlertBuilder<*>.customTitle(dsl: ViewManager.() -> Unit) {
|
||||
customTitle = ctx.UI(dsl).view
|
||||
}
|
||||
|
||||
fun AlertBuilder<*>.customView(dsl: ViewManager.() -> Unit) {
|
||||
customView = ctx.UI(dsl).view
|
||||
}
|
||||
|
||||
inline fun AlertBuilder<*>.okButton(noinline handler: (dialog: DialogInterface) -> Unit) =
|
||||
positiveButton(android.R.string.ok, handler)
|
||||
|
||||
inline fun AlertBuilder<*>.cancelButton(noinline handler: (dialog: DialogInterface) -> Unit) =
|
||||
negativeButton(android.R.string.cancel, handler)
|
||||
|
||||
inline fun AlertBuilder<*>.yesButton(noinline handler: (dialog: DialogInterface) -> Unit) =
|
||||
positiveButton(android.R.string.yes, handler)
|
||||
|
||||
inline fun AlertBuilder<*>.noButton(noinline handler: (dialog: DialogInterface) -> Unit) =
|
||||
negativeButton(android.R.string.no, handler)
|
|
@ -1,304 +0,0 @@
|
|||
/*
|
||||
* Copyright 2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
@file:Suppress("unused")
|
||||
|
||||
package org.jetbrains.anko
|
||||
|
||||
//import android.app.AlertDialog
|
||||
//import android.content.Context
|
||||
//import android.content.DialogInterface
|
||||
//import android.database.Cursor
|
||||
//import android.graphics.drawable.Drawable
|
||||
//import android.view.KeyEvent
|
||||
//import android.view.View
|
||||
//import android.view.ViewManager
|
||||
//import android.widget.ListAdapter
|
||||
//
|
||||
//@Deprecated("Use AlertBuilder class instead.")
|
||||
//class AlertDialogBuilder(val ctx: Context) {
|
||||
// private var builder: AlertDialog.Builder? = AlertDialog.Builder(ctx)
|
||||
//
|
||||
// /**
|
||||
// * Returns the [AlertDialog] instance if created.
|
||||
// * Returns null until the [show] function is called.
|
||||
// */
|
||||
// var dialog: AlertDialog? = null
|
||||
// private set
|
||||
//
|
||||
// constructor(ankoContext: AnkoContext<*>) : this(ankoContext.ctx)
|
||||
//
|
||||
// fun dismiss() {
|
||||
// dialog?.dismiss()
|
||||
// }
|
||||
//
|
||||
// private fun checkBuilder() {
|
||||
// if (builder == null) {
|
||||
// throw IllegalStateException("show() was already called for this AlertDialogBuilder")
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Create the [AlertDialog] and display it on screen.
|
||||
// *
|
||||
// */
|
||||
// fun show(): AlertDialogBuilder {
|
||||
// checkBuilder()
|
||||
// dialog = builder!!.create()
|
||||
// builder = null
|
||||
// dialog!!.show()
|
||||
// return this
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Set the [title] displayed in the dialog.
|
||||
// */
|
||||
// fun title(title: CharSequence) {
|
||||
// checkBuilder()
|
||||
// builder!!.setTitle(title)
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Set the title using the given [title] resource id.
|
||||
// */
|
||||
// fun title(title: Int) {
|
||||
// checkBuilder()
|
||||
// builder!!.setTitle(title)
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Set the [message] to display.
|
||||
// */
|
||||
// fun message(message: CharSequence) {
|
||||
// checkBuilder()
|
||||
// builder!!.setMessage(message)
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Set the message to display using the given [message] resource id.
|
||||
// */
|
||||
// fun message(message: Int) {
|
||||
// checkBuilder()
|
||||
// builder!!.setMessage(message)
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Set the resource id of the [Drawable] to be used in the title.
|
||||
// */
|
||||
// fun icon(icon: Int) {
|
||||
// checkBuilder()
|
||||
// builder!!.setIcon(icon)
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Set the [icon] Drawable to be used in the title.
|
||||
// */
|
||||
// fun icon(icon: Drawable) {
|
||||
// checkBuilder()
|
||||
// builder!!.setIcon(icon)
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Set the title using the custom [view].
|
||||
// */
|
||||
// fun customTitle(view: View) {
|
||||
// checkBuilder()
|
||||
// builder!!.setCustomTitle(view)
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Set the title using the custom DSL view.
|
||||
// */
|
||||
// fun customTitle(dsl: ViewManager.() -> Unit) {
|
||||
// checkBuilder()
|
||||
// val view = ctx.UI(dsl).view
|
||||
// builder!!.setCustomTitle(view)
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Set a custom [view] to be the contents of the Dialog.
|
||||
// */
|
||||
// fun customView(view: View) {
|
||||
// checkBuilder()
|
||||
// builder!!.setView(view)
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Set a custom DSL view to be the contents of the Dialog.
|
||||
// */
|
||||
// fun customView(dsl: ViewManager.() -> Unit) {
|
||||
// checkBuilder()
|
||||
// val view = ctx.UI(dsl).view
|
||||
// builder!!.setView(view)
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Set if the dialog is cancellable.
|
||||
// *
|
||||
// * @param cancellable if true, the created dialog will be cancellable.
|
||||
// */
|
||||
// fun cancellable(cancellable: Boolean = true) {
|
||||
// checkBuilder()
|
||||
// builder!!.setCancelable(cancellable)
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Sets the [callback] that will be called if the dialog is canceled.
|
||||
// */
|
||||
// fun onCancel(callback: () -> Unit) {
|
||||
// checkBuilder()
|
||||
// builder!!.setOnCancelListener { callback() }
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Sets the [callback] that will be called if a key is dispatched to the dialog.
|
||||
// */
|
||||
// fun onKey(callback: (keyCode: Int, e: KeyEvent) -> Boolean) {
|
||||
// checkBuilder()
|
||||
// builder!!.setOnKeyListener({ dialog, keyCode, event -> callback(keyCode, event) })
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Set a listener to be invoked when the neutral button of the dialog is pressed.
|
||||
// *
|
||||
// * @param neutralText the text resource to display in the neutral button.
|
||||
// * @param callback the callback that will be called if the neutral button is pressed.
|
||||
// */
|
||||
// fun neutralButton(
|
||||
// neutralText: Int = android.R.string.ok,
|
||||
// callback: DialogInterface.() -> Unit = { dismiss() },
|
||||
// ) {
|
||||
// neutralButton(ctx.getString(neutralText), callback)
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Set a listener to be invoked when the neutral button of the dialog is pressed.
|
||||
// *
|
||||
// * @param neutralText the text to display in the neutral button.
|
||||
// * @param callback the callback that will be called if the neutral button is pressed.
|
||||
// */
|
||||
// fun neutralButton(
|
||||
// neutralText: CharSequence,
|
||||
// callback: DialogInterface.() -> Unit = { dismiss() },
|
||||
// ) {
|
||||
// checkBuilder()
|
||||
// builder!!.setNeutralButton(neutralText, { dialog, which -> dialog.callback() })
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Set a listener to be invoked when the positive button of the dialog is pressed.
|
||||
// *
|
||||
// * @param positiveText the text to display in the positive button.
|
||||
// * @param callback the callback that will be called if the positive button is pressed.
|
||||
// */
|
||||
// fun positiveButton(positiveText: Int, callback: DialogInterface.() -> Unit) {
|
||||
// positiveButton(ctx.getString(positiveText), callback)
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Set a listener to be invoked when the positive button of the dialog is pressed.
|
||||
// *
|
||||
// * @param callback the callback that will be called if the positive button is pressed.
|
||||
// */
|
||||
// fun okButton(callback: DialogInterface.() -> Unit) {
|
||||
// positiveButton(ctx.getString(android.R.string.ok), callback)
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Set a listener to be invoked when the positive button of the dialog is pressed.
|
||||
// *
|
||||
// * @param callback the callback that will be called if the positive button is pressed.
|
||||
// */
|
||||
// fun yesButton(callback: DialogInterface.() -> Unit) {
|
||||
// positiveButton(ctx.getString(android.R.string.yes), callback)
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Set a listener to be invoked when the positive button of the dialog is pressed.
|
||||
// *
|
||||
// * @param positiveText the text to display in the positive button.
|
||||
// * @param callback the callback that will be called if the positive button is pressed.
|
||||
// */
|
||||
// fun positiveButton(positiveText: CharSequence, callback: DialogInterface.() -> Unit) {
|
||||
// checkBuilder()
|
||||
// builder!!.setPositiveButton(positiveText, { dialog, which -> dialog.callback() })
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Set a listener to be invoked when the negative button of the dialog is pressed.
|
||||
// *
|
||||
// * @param negativeText the text to display in the negative button.
|
||||
// * @param callback the callback that will be called if the negative button is pressed.
|
||||
// */
|
||||
// fun negativeButton(negativeText: Int, callback: DialogInterface.() -> Unit = { dismiss() }) {
|
||||
// negativeButton(ctx.getString(negativeText), callback)
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Set a listener to be invoked when the negative button of the dialog is pressed.
|
||||
// *
|
||||
// * @param callback the callback that will be called if the negative button is pressed.
|
||||
// */
|
||||
// fun cancelButton(callback: DialogInterface.() -> Unit = { dismiss() }) {
|
||||
// negativeButton(ctx.getString(android.R.string.cancel), callback)
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Set a listener to be invoked when the negative button of the dialog is pressed.
|
||||
// *
|
||||
// * @param callback the callback that will be called if the negative button is pressed.
|
||||
// */
|
||||
// fun noButton(callback: DialogInterface.() -> Unit = { dismiss() }) {
|
||||
// negativeButton(ctx.getString(android.R.string.no), callback)
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Set a listener to be invoked when the negative button of the dialog is pressed.
|
||||
// *
|
||||
// * @param negativeText the text to display in the negative button.
|
||||
// * @param callback the callback that will be called if the negative button is pressed.
|
||||
// */
|
||||
// fun negativeButton(
|
||||
// negativeText: CharSequence,
|
||||
// callback: DialogInterface.() -> Unit = { dismiss() },
|
||||
// ) {
|
||||
// checkBuilder()
|
||||
// builder!!.setNegativeButton(negativeText, { dialog, which -> dialog.callback() })
|
||||
// }
|
||||
//
|
||||
// fun items(itemsId: Int, callback: (which: Int) -> Unit) {
|
||||
// items(ctx.resources!!.getTextArray(itemsId), callback)
|
||||
// }
|
||||
//
|
||||
// fun items(items: List<CharSequence>, callback: (which: Int) -> Unit) {
|
||||
// items(items.toTypedArray(), callback)
|
||||
// }
|
||||
//
|
||||
// fun items(items: Array<CharSequence>, callback: (which: Int) -> Unit) {
|
||||
// checkBuilder()
|
||||
// builder!!.setItems(items, { dialog, which -> callback(which) })
|
||||
// }
|
||||
//
|
||||
// fun adapter(adapter: ListAdapter, callback: (which: Int) -> Unit) {
|
||||
// checkBuilder()
|
||||
// builder!!.setAdapter(adapter, { dialog, which -> callback(which) })
|
||||
// }
|
||||
//
|
||||
// fun adapter(cursor: Cursor, labelColumn: String, callback: (which: Int) -> Unit) {
|
||||
// checkBuilder()
|
||||
// builder!!.setCursor(cursor, { dialog, which -> callback(which) }, labelColumn)
|
||||
// }
|
||||
//}
|
|
@ -1,117 +0,0 @@
|
|||
/*
|
||||
* Copyright 2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.anko
|
||||
|
||||
import android.app.AlertDialog
|
||||
import android.content.Context
|
||||
import android.content.DialogInterface
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.view.KeyEvent
|
||||
import android.view.View
|
||||
import org.jetbrains.anko.internals.AnkoInternals
|
||||
import org.jetbrains.anko.internals.AnkoInternals.NO_GETTER
|
||||
import kotlin.DeprecationLevel.ERROR
|
||||
|
||||
val Android: AlertBuilderFactory<AlertDialog> = ::AndroidAlertBuilder
|
||||
|
||||
internal class AndroidAlertBuilder(override val ctx: Context) : AlertBuilder<AlertDialog> {
|
||||
private val builder = AlertDialog.Builder(ctx)
|
||||
|
||||
override var title: CharSequence
|
||||
@Deprecated(NO_GETTER, level = ERROR) get() = AnkoInternals.noGetter()
|
||||
set(value) { builder.setTitle(value) }
|
||||
|
||||
override var titleResource: Int
|
||||
@Deprecated(NO_GETTER, level = ERROR) get() = AnkoInternals.noGetter()
|
||||
set(value) { builder.setTitle(value) }
|
||||
|
||||
override var message: CharSequence
|
||||
@Deprecated(NO_GETTER, level = ERROR) get() = AnkoInternals.noGetter()
|
||||
set(value) { builder.setMessage(value) }
|
||||
|
||||
override var messageResource: Int
|
||||
@Deprecated(NO_GETTER, level = ERROR) get() = AnkoInternals.noGetter()
|
||||
set(value) { builder.setMessage(value) }
|
||||
|
||||
override var icon: Drawable
|
||||
@Deprecated(NO_GETTER, level = ERROR) get() = AnkoInternals.noGetter()
|
||||
set(value) { builder.setIcon(value) }
|
||||
|
||||
override var iconResource: Int
|
||||
@Deprecated(NO_GETTER, level = ERROR) get() = AnkoInternals.noGetter()
|
||||
set(value) { builder.setIcon(value) }
|
||||
|
||||
override var customTitle: View
|
||||
@Deprecated(NO_GETTER, level = ERROR) get() = AnkoInternals.noGetter()
|
||||
set(value) { builder.setCustomTitle(value) }
|
||||
|
||||
override var customView: View
|
||||
@Deprecated(NO_GETTER, level = ERROR) get() = AnkoInternals.noGetter()
|
||||
set(value) { builder.setView(value) }
|
||||
|
||||
override var isCancelable: Boolean
|
||||
@Deprecated(NO_GETTER, level = ERROR) get() = AnkoInternals.noGetter()
|
||||
set(value) { builder.setCancelable(value) }
|
||||
|
||||
override fun onCancelled(handler: (DialogInterface) -> Unit) {
|
||||
builder.setOnCancelListener(handler)
|
||||
}
|
||||
|
||||
override fun onKeyPressed(handler: (dialog: DialogInterface, keyCode: Int, e: KeyEvent) -> Boolean) {
|
||||
builder.setOnKeyListener(handler)
|
||||
}
|
||||
|
||||
override fun positiveButton(buttonText: String, onClicked: (dialog: DialogInterface) -> Unit) {
|
||||
builder.setPositiveButton(buttonText) { dialog, _ -> onClicked(dialog) }
|
||||
}
|
||||
|
||||
override fun positiveButton(buttonTextResource: Int, onClicked: (dialog: DialogInterface) -> Unit) {
|
||||
builder.setPositiveButton(buttonTextResource) { dialog, _ -> onClicked(dialog) }
|
||||
}
|
||||
|
||||
override fun negativeButton(buttonText: String, onClicked: (dialog: DialogInterface) -> Unit) {
|
||||
builder.setNegativeButton(buttonText) { dialog, _ -> onClicked(dialog) }
|
||||
}
|
||||
|
||||
override fun negativeButton(buttonTextResource: Int, onClicked: (dialog: DialogInterface) -> Unit) {
|
||||
builder.setNegativeButton(buttonTextResource) { dialog, _ -> onClicked(dialog) }
|
||||
}
|
||||
|
||||
override fun neutralPressed(buttonText: String, onClicked: (dialog: DialogInterface) -> Unit) {
|
||||
builder.setNeutralButton(buttonText) { dialog, _ -> onClicked(dialog) }
|
||||
}
|
||||
|
||||
override fun neutralPressed(buttonTextResource: Int, onClicked: (dialog: DialogInterface) -> Unit) {
|
||||
builder.setNeutralButton(buttonTextResource) { dialog, _ -> onClicked(dialog) }
|
||||
}
|
||||
|
||||
override fun items(items: List<CharSequence>, onItemSelected: (dialog: DialogInterface, index: Int) -> Unit) {
|
||||
builder.setItems(Array(items.size) { i -> items[i].toString() }) { dialog, which ->
|
||||
onItemSelected(dialog, which)
|
||||
}
|
||||
}
|
||||
|
||||
override fun <T> items(items: List<T>, onItemSelected: (dialog: DialogInterface, item: T, index: Int) -> Unit) {
|
||||
builder.setItems(Array(items.size) { i -> items[i].toString() }) { dialog, which ->
|
||||
onItemSelected(dialog, items[which], which)
|
||||
}
|
||||
}
|
||||
|
||||
override fun build(): AlertDialog = builder.create()
|
||||
|
||||
override fun show(): AlertDialog = builder.show()
|
||||
}
|
|
@ -1,184 +0,0 @@
|
|||
/*
|
||||
* Copyright 2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
@file:Suppress("NOTHING_TO_INLINE", "unused")
|
||||
|
||||
package org.jetbrains.anko
|
||||
|
||||
import android.app.AlertDialog
|
||||
import android.content.Context
|
||||
import android.content.DialogInterface
|
||||
import androidx.fragment.app.Fragment
|
||||
|
||||
inline fun AnkoContext<*>.alert(
|
||||
message: CharSequence,
|
||||
title: CharSequence? = null,
|
||||
noinline init: (AlertBuilder<DialogInterface>.() -> Unit)? = null,
|
||||
) = ctx.alert(message, title, init)
|
||||
|
||||
inline fun Fragment.alert(
|
||||
message: CharSequence,
|
||||
title: CharSequence? = null,
|
||||
noinline init: (AlertBuilder<DialogInterface>.() -> Unit)? = null,
|
||||
) = requireActivity().alert(message, title, init)
|
||||
|
||||
fun Context.alert(
|
||||
message: CharSequence,
|
||||
title: CharSequence? = null,
|
||||
init: (AlertBuilder<DialogInterface>.() -> Unit)? = null,
|
||||
): AlertBuilder<AlertDialog> {
|
||||
return AndroidAlertBuilder(this).apply {
|
||||
if (title != null) {
|
||||
this.title = title
|
||||
}
|
||||
this.message = message
|
||||
if (init != null) init()
|
||||
}
|
||||
}
|
||||
|
||||
inline fun AnkoContext<*>.alert(
|
||||
message: Int,
|
||||
title: Int? = null,
|
||||
noinline init: (AlertBuilder<DialogInterface>.() -> Unit)? = null,
|
||||
) = ctx.alert(message, title, init)
|
||||
|
||||
inline fun Fragment.alert(
|
||||
message: Int,
|
||||
title: Int? = null,
|
||||
noinline init: (AlertBuilder<DialogInterface>.() -> Unit)? = null,
|
||||
) = requireActivity().alert(message, title, init)
|
||||
|
||||
fun Context.alert(
|
||||
messageResource: Int,
|
||||
titleResource: Int? = null,
|
||||
init: (AlertBuilder<DialogInterface>.() -> Unit)? = null,
|
||||
): AlertBuilder<DialogInterface> {
|
||||
return AndroidAlertBuilder(this).apply {
|
||||
if (titleResource != null) {
|
||||
this.titleResource = titleResource
|
||||
}
|
||||
this.messageResource = messageResource
|
||||
if (init != null) init()
|
||||
}
|
||||
}
|
||||
|
||||
inline fun AnkoContext<*>.alert(noinline init: AlertBuilder<DialogInterface>.() -> Unit) =
|
||||
ctx.alert(init)
|
||||
|
||||
inline fun Fragment.alert(noinline init: AlertBuilder<DialogInterface>.() -> Unit) =
|
||||
requireActivity().alert(init)
|
||||
|
||||
fun Context.alert(init: AlertBuilder<DialogInterface>.() -> Unit): AlertBuilder<DialogInterface> =
|
||||
AndroidAlertBuilder(this).apply { init() }
|
||||
|
||||
//@Deprecated(message = "Android progress dialogs are deprecated")
|
||||
//inline fun AnkoContext<*>.progressDialog(
|
||||
// message: Int? = null,
|
||||
// title: Int? = null,
|
||||
// noinline init: (ProgressDialog.() -> Unit)? = null,
|
||||
//) = ctx.progressDialog(message, title, init)
|
||||
//
|
||||
//@Deprecated(message = "Android progress dialogs are deprecated")
|
||||
//inline fun Fragment.progressDialog(
|
||||
// message: Int? = null,
|
||||
// title: Int? = null,
|
||||
// noinline init: (ProgressDialog.() -> Unit)? = null,
|
||||
//) = requireActivity().progressDialog(message, title, init)
|
||||
//
|
||||
//@Deprecated(message = "Android progress dialogs are deprecated")
|
||||
//fun Context.progressDialog(
|
||||
// message: Int? = null,
|
||||
// title: Int? = null,
|
||||
// init: (ProgressDialog.() -> Unit)? = null,
|
||||
//) = progressDialog(false, message?.let { getString(it) }, title?.let { getString(it) }, init)
|
||||
//
|
||||
//@Deprecated(message = "Android progress dialogs are deprecated")
|
||||
//inline fun AnkoContext<*>.indeterminateProgressDialog(
|
||||
// message: Int? = null,
|
||||
// title: Int? = null,
|
||||
// noinline init: (ProgressDialog.() -> Unit)? = null,
|
||||
//) = ctx.indeterminateProgressDialog(message, title, init)
|
||||
//
|
||||
//@Deprecated(message = "Android progress dialogs are deprecated")
|
||||
//inline fun Fragment.indeterminateProgressDialog(
|
||||
// message: Int? = null,
|
||||
// title: Int? = null,
|
||||
// noinline init: (ProgressDialog.() -> Unit)? = null,
|
||||
//) = requireActivity().indeterminateProgressDialog(message, title, init)
|
||||
//
|
||||
//@Deprecated(message = "Android progress dialogs are deprecated")
|
||||
//fun Context.indeterminateProgressDialog(
|
||||
// message: Int? = null,
|
||||
// title: Int? = null,
|
||||
// init: (ProgressDialog.() -> Unit)? = null,
|
||||
//) = progressDialog(true, message?.let { getString(it) }, title?.let { getString(it) }, init)
|
||||
//
|
||||
//@Deprecated(message = "Android progress dialogs are deprecated")
|
||||
//inline fun AnkoContext<*>.progressDialog(
|
||||
// message: CharSequence? = null,
|
||||
// title: CharSequence? = null,
|
||||
// noinline init: (ProgressDialog.() -> Unit)? = null,
|
||||
//) = ctx.progressDialog(message, title, init)
|
||||
//
|
||||
//@Deprecated(message = "Android progress dialogs are deprecated")
|
||||
//inline fun Fragment.progressDialog(
|
||||
// message: CharSequence? = null,
|
||||
// title: CharSequence? = null,
|
||||
// noinline init: (ProgressDialog.() -> Unit)? = null,
|
||||
//) = requireActivity().progressDialog(message, title, init)
|
||||
//
|
||||
//@Deprecated(message = "Android progress dialogs are deprecated")
|
||||
//fun Context.progressDialog(
|
||||
// message: CharSequence? = null,
|
||||
// title: CharSequence? = null,
|
||||
// init: (ProgressDialog.() -> Unit)? = null,
|
||||
//) = progressDialog(false, message, title, init)
|
||||
//
|
||||
//@Deprecated(message = "Android progress dialogs are deprecated")
|
||||
//inline fun AnkoContext<*>.indeterminateProgressDialog(
|
||||
// message: CharSequence? = null,
|
||||
// title: CharSequence? = null,
|
||||
// noinline init: (ProgressDialog.() -> Unit)? = null,
|
||||
//) = ctx.indeterminateProgressDialog(message, title, init)
|
||||
//
|
||||
//@Deprecated(message = "Android progress dialogs are deprecated")
|
||||
//inline fun Fragment.indeterminateProgressDialog(
|
||||
// message: CharSequence? = null,
|
||||
// title: CharSequence? = null,
|
||||
// noinline init: (ProgressDialog.() -> Unit)? = null,
|
||||
//) = requireActivity().indeterminateProgressDialog(message, title, init)
|
||||
//
|
||||
//@Deprecated(message = "Android progress dialogs are deprecated")
|
||||
//fun Context.indeterminateProgressDialog(
|
||||
// message: CharSequence? = null,
|
||||
// title: CharSequence? = null,
|
||||
// init: (ProgressDialog.() -> Unit)? = null,
|
||||
//) = progressDialog(true, message, title, init)
|
||||
//
|
||||
//@Deprecated(message = "Android progress dialogs are deprecated")
|
||||
//private fun Context.progressDialog(
|
||||
// indeterminate: Boolean,
|
||||
// message: CharSequence? = null,
|
||||
// title: CharSequence? = null,
|
||||
// init: (ProgressDialog.() -> Unit)? = null,
|
||||
//) = ProgressDialog(this).apply {
|
||||
// isIndeterminate = indeterminate
|
||||
// if (!indeterminate) setProgressStyle(ProgressDialog.STYLE_HORIZONTAL)
|
||||
// if (message != null) setMessage(message)
|
||||
// if (title != null) setTitle(title)
|
||||
// if (init != null) init()
|
||||
// show()
|
||||
//}
|
|
@ -1,49 +0,0 @@
|
|||
/*
|
||||
* Copyright 2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
@file:Suppress("NOTHING_TO_INLINE", "unused")
|
||||
|
||||
package org.jetbrains.anko
|
||||
|
||||
import android.content.Context
|
||||
import android.content.DialogInterface
|
||||
import androidx.fragment.app.Fragment
|
||||
|
||||
inline fun AnkoContext<*>.selector(
|
||||
title: CharSequence? = null,
|
||||
items: List<CharSequence>,
|
||||
noinline onClick: (DialogInterface, Int) -> Unit,
|
||||
) = ctx.selector(title, items, onClick)
|
||||
|
||||
inline fun Fragment.selector(
|
||||
title: CharSequence? = null,
|
||||
items: List<CharSequence>,
|
||||
noinline onClick: (DialogInterface, Int) -> Unit,
|
||||
) = requireActivity().selector(title, items, onClick)
|
||||
|
||||
fun Context.selector(
|
||||
title: CharSequence? = null,
|
||||
items: List<CharSequence>,
|
||||
onClick: (DialogInterface, Int) -> Unit,
|
||||
) {
|
||||
with(AndroidAlertBuilder(this)) {
|
||||
if (title != null) {
|
||||
this.title = title
|
||||
}
|
||||
items(items, onClick)
|
||||
show()
|
||||
}
|
||||
}
|
|
@ -1,209 +1,209 @@
|
|||
/*
|
||||
* Copyright 2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
@file:Suppress("unused")
|
||||
|
||||
package org.jetbrains.anko
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.Context
|
||||
import android.os.Handler
|
||||
import android.os.Looper
|
||||
import androidx.fragment.app.Fragment
|
||||
import java.lang.ref.WeakReference
|
||||
import java.util.concurrent.ExecutorService
|
||||
import java.util.concurrent.Executors
|
||||
import java.util.concurrent.Future
|
||||
|
||||
/**
|
||||
* Execute [f] on the application UI thread.
|
||||
*/
|
||||
fun Context.runOnUiThread(f: Context.() -> Unit) {
|
||||
if (Looper.getMainLooper() === Looper.myLooper()) f() else ContextHelper.handler.post { f() }
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute [f] on the application UI thread.
|
||||
*/
|
||||
inline fun Fragment.runOnUiThread(crossinline f: () -> Unit) {
|
||||
requireContext().runOnUiThread { f() }
|
||||
}
|
||||
|
||||
class AnkoAsyncContext<T>(val weakRef: WeakReference<T>)
|
||||
|
||||
/**
|
||||
* Execute [f] on the application UI thread.
|
||||
* If the [doAsync] receiver still exists (was not collected by GC),
|
||||
* [f] gets it as a parameter ([f] gets null if the receiver does not exist anymore).
|
||||
*/
|
||||
fun <T> AnkoAsyncContext<T>.onComplete(f: (T?) -> Unit) {
|
||||
val ref = weakRef.get()
|
||||
if (Looper.getMainLooper() === Looper.myLooper()) {
|
||||
f(ref)
|
||||
} else {
|
||||
ContextHelper.handler.post { f(ref) }
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute [f] on the application UI thread.
|
||||
* [doAsync] receiver will be passed to [f].
|
||||
* If the receiver does not exist anymore (it was collected by GC), [f] will not be executed.
|
||||
*/
|
||||
fun <T> AnkoAsyncContext<T>.uiThread(f: (T) -> Unit): Boolean {
|
||||
val ref = weakRef.get() ?: return false
|
||||
if (Looper.getMainLooper() === Looper.myLooper()) {
|
||||
f(ref)
|
||||
} else {
|
||||
ContextHelper.handler.post { f(ref) }
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute [f] on the application UI thread if the underlying [Activity] still exists and is not finished.
|
||||
* The receiver [Activity] will be passed to [f].
|
||||
* If it is not exist anymore or if it was finished, [f] will not be called.
|
||||
*/
|
||||
fun <T : Activity> AnkoAsyncContext<T>.activityUiThread(f: (T) -> Unit): Boolean {
|
||||
val activity = weakRef.get() ?: return false
|
||||
if (activity.isFinishing) return false
|
||||
activity.runOnUiThread { f(activity) }
|
||||
return true
|
||||
}
|
||||
|
||||
fun <T : Activity> AnkoAsyncContext<T>.activityUiThreadWithContext(f: Context.(T) -> Unit): Boolean {
|
||||
val activity = weakRef.get() ?: return false
|
||||
if (activity.isFinishing) return false
|
||||
activity.runOnUiThread { activity.f(activity) }
|
||||
return true
|
||||
}
|
||||
|
||||
@JvmName("activityContextUiThread")
|
||||
fun <T : Activity> AnkoAsyncContext<AnkoContext<T>>.activityUiThread(f: (T) -> Unit): Boolean {
|
||||
val activity = weakRef.get()?.owner ?: return false
|
||||
if (activity.isFinishing) return false
|
||||
activity.runOnUiThread { f(activity) }
|
||||
return true
|
||||
}
|
||||
|
||||
@JvmName("activityContextUiThreadWithContext")
|
||||
fun <T : Activity> AnkoAsyncContext<AnkoContext<T>>.activityUiThreadWithContext(f: Context.(T) -> Unit): Boolean {
|
||||
val activity = weakRef.get()?.owner ?: return false
|
||||
if (activity.isFinishing) return false
|
||||
activity.runOnUiThread { activity.f(activity) }
|
||||
return true
|
||||
}
|
||||
|
||||
@Deprecated(message = "Use support library fragments instead. Framework fragments were deprecated in API 28.")
|
||||
fun <T : Fragment> AnkoAsyncContext<T>.fragmentUiThread(f: (T) -> Unit): Boolean {
|
||||
val fragment = weakRef.get() ?: return false
|
||||
if (fragment.isDetached) return false
|
||||
val activity = fragment.activity ?: return false
|
||||
activity.runOnUiThread { f(fragment) }
|
||||
return true
|
||||
}
|
||||
|
||||
@Deprecated(message = "Use support library fragments instead. Framework fragments were deprecated in API 28.")
|
||||
fun <T : Fragment> AnkoAsyncContext<T>.fragmentUiThreadWithContext(f: Context.(T) -> Unit): Boolean {
|
||||
val fragment = weakRef.get() ?: return false
|
||||
if (fragment.isDetached) return false
|
||||
val activity = fragment.activity ?: return false
|
||||
activity.runOnUiThread { activity.f(fragment) }
|
||||
return true
|
||||
}
|
||||
|
||||
private val crashLogger = { throwable: Throwable -> throwable.printStackTrace() }
|
||||
|
||||
/**
|
||||
* Execute [task] asynchronously.
|
||||
*
|
||||
* @param exceptionHandler optional exception handler.
|
||||
* If defined, any exceptions thrown inside [task] will be passed to it. If not, exceptions will be ignored.
|
||||
* @param task the code to execute asynchronously.
|
||||
*/
|
||||
fun <T> T.doAsync(
|
||||
exceptionHandler: ((Throwable) -> Unit)? = crashLogger,
|
||||
task: AnkoAsyncContext<T>.() -> Unit,
|
||||
): Future<Unit> {
|
||||
val context = AnkoAsyncContext(WeakReference(this))
|
||||
return BackgroundExecutor.submit {
|
||||
return@submit try {
|
||||
context.task()
|
||||
} catch (thr: Throwable) {
|
||||
val result = exceptionHandler?.invoke(thr)
|
||||
result ?: Unit
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun <T> T.doAsync(
|
||||
exceptionHandler: ((Throwable) -> Unit)? = crashLogger,
|
||||
executorService: ExecutorService,
|
||||
task: AnkoAsyncContext<T>.() -> Unit,
|
||||
): Future<Unit> {
|
||||
val context = AnkoAsyncContext(WeakReference(this))
|
||||
return executorService.submit<Unit> {
|
||||
try {
|
||||
context.task()
|
||||
} catch (thr: Throwable) {
|
||||
exceptionHandler?.invoke(thr)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun <T, R> T.doAsyncResult(
|
||||
exceptionHandler: ((Throwable) -> Unit)? = crashLogger,
|
||||
task: AnkoAsyncContext<T>.() -> R,
|
||||
): Future<R> {
|
||||
val context = AnkoAsyncContext(WeakReference(this))
|
||||
return BackgroundExecutor.submit {
|
||||
try {
|
||||
context.task()
|
||||
} catch (thr: Throwable) {
|
||||
exceptionHandler?.invoke(thr)
|
||||
throw thr
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun <T, R> T.doAsyncResult(
|
||||
exceptionHandler: ((Throwable) -> Unit)? = crashLogger,
|
||||
executorService: ExecutorService,
|
||||
task: AnkoAsyncContext<T>.() -> R,
|
||||
): Future<R> {
|
||||
val context = AnkoAsyncContext(WeakReference(this))
|
||||
return executorService.submit<R> {
|
||||
try {
|
||||
context.task()
|
||||
} catch (thr: Throwable) {
|
||||
exceptionHandler?.invoke(thr)
|
||||
throw thr
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal object BackgroundExecutor {
|
||||
@Suppress("MemberVisibilityCanBePrivate")
|
||||
var executor: ExecutorService =
|
||||
Executors.newScheduledThreadPool(2 * Runtime.getRuntime().availableProcessors())
|
||||
|
||||
fun <T> submit(task: () -> T): Future<T> = executor.submit(task)
|
||||
}
|
||||
|
||||
private object ContextHelper {
|
||||
val handler = Handler(Looper.getMainLooper())
|
||||
}
|
||||
///*
|
||||
// * Copyright 2016 JetBrains s.r.o.
|
||||
// *
|
||||
// * Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// * you may not use this file except in compliance with the License.
|
||||
// * You may obtain a copy of the License at
|
||||
// *
|
||||
// * http://www.apache.org/licenses/LICENSE-2.0
|
||||
// *
|
||||
// * Unless required by applicable law or agreed to in writing, software
|
||||
// * distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// * See the License for the specific language governing permissions and
|
||||
// * limitations under the License.
|
||||
// */
|
||||
//
|
||||
//@file:Suppress("unused")
|
||||
//
|
||||
//package org.jetbrains.anko
|
||||
//
|
||||
//import android.app.Activity
|
||||
//import android.content.Context
|
||||
//import android.os.Handler
|
||||
//import android.os.Looper
|
||||
//import androidx.fragment.app.Fragment
|
||||
//import java.lang.ref.WeakReference
|
||||
//import java.util.concurrent.ExecutorService
|
||||
//import java.util.concurrent.Executors
|
||||
//import java.util.concurrent.Future
|
||||
//
|
||||
///**
|
||||
// * Execute [f] on the application UI thread.
|
||||
// */
|
||||
//fun Context.runOnUiThread(f: Context.() -> Unit) {
|
||||
// if (Looper.getMainLooper() === Looper.myLooper()) f() else ContextHelper.handler.post { f() }
|
||||
//}
|
||||
//
|
||||
///**
|
||||
// * Execute [f] on the application UI thread.
|
||||
// */
|
||||
//inline fun Fragment.runOnUiThread(crossinline f: () -> Unit) {
|
||||
// requireContext().runOnUiThread { f() }
|
||||
//}
|
||||
//
|
||||
//class AnkoAsyncContext<T>(val weakRef: WeakReference<T>)
|
||||
//
|
||||
///**
|
||||
// * Execute [f] on the application UI thread.
|
||||
// * If the [doAsync] receiver still exists (was not collected by GC),
|
||||
// * [f] gets it as a parameter ([f] gets null if the receiver does not exist anymore).
|
||||
// */
|
||||
//fun <T> AnkoAsyncContext<T>.onComplete(f: (T?) -> Unit) {
|
||||
// val ref = weakRef.get()
|
||||
// if (Looper.getMainLooper() === Looper.myLooper()) {
|
||||
// f(ref)
|
||||
// } else {
|
||||
// ContextHelper.handler.post { f(ref) }
|
||||
// }
|
||||
//}
|
||||
//
|
||||
///**
|
||||
// * Execute [f] on the application UI thread.
|
||||
// * [doAsync] receiver will be passed to [f].
|
||||
// * If the receiver does not exist anymore (it was collected by GC), [f] will not be executed.
|
||||
// */
|
||||
//fun <T> AnkoAsyncContext<T>.uiThread(f: (T) -> Unit): Boolean {
|
||||
// val ref = weakRef.get() ?: return false
|
||||
// if (Looper.getMainLooper() === Looper.myLooper()) {
|
||||
// f(ref)
|
||||
// } else {
|
||||
// ContextHelper.handler.post { f(ref) }
|
||||
// }
|
||||
// return true
|
||||
//}
|
||||
//
|
||||
///**
|
||||
// * Execute [f] on the application UI thread if the underlying [Activity] still exists and is not finished.
|
||||
// * The receiver [Activity] will be passed to [f].
|
||||
// * If it is not exist anymore or if it was finished, [f] will not be called.
|
||||
// */
|
||||
//fun <T : Activity> AnkoAsyncContext<T>.activityUiThread(f: (T) -> Unit): Boolean {
|
||||
// val activity = weakRef.get() ?: return false
|
||||
// if (activity.isFinishing) return false
|
||||
// activity.runOnUiThread { f(activity) }
|
||||
// return true
|
||||
//}
|
||||
//
|
||||
//fun <T : Activity> AnkoAsyncContext<T>.activityUiThreadWithContext(f: Context.(T) -> Unit): Boolean {
|
||||
// val activity = weakRef.get() ?: return false
|
||||
// if (activity.isFinishing) return false
|
||||
// activity.runOnUiThread { activity.f(activity) }
|
||||
// return true
|
||||
//}
|
||||
//
|
||||
//@JvmName("activityContextUiThread")
|
||||
//fun <T : Activity> AnkoAsyncContext<AnkoContext<T>>.activityUiThread(f: (T) -> Unit): Boolean {
|
||||
// val activity = weakRef.get()?.owner ?: return false
|
||||
// if (activity.isFinishing) return false
|
||||
// activity.runOnUiThread { f(activity) }
|
||||
// return true
|
||||
//}
|
||||
//
|
||||
//@JvmName("activityContextUiThreadWithContext")
|
||||
//fun <T : Activity> AnkoAsyncContext<AnkoContext<T>>.activityUiThreadWithContext(f: Context.(T) -> Unit): Boolean {
|
||||
// val activity = weakRef.get()?.owner ?: return false
|
||||
// if (activity.isFinishing) return false
|
||||
// activity.runOnUiThread { activity.f(activity) }
|
||||
// return true
|
||||
//}
|
||||
//
|
||||
//@Deprecated(message = "Use support library fragments instead. Framework fragments were deprecated in API 28.")
|
||||
//fun <T : Fragment> AnkoAsyncContext<T>.fragmentUiThread(f: (T) -> Unit): Boolean {
|
||||
// val fragment = weakRef.get() ?: return false
|
||||
// if (fragment.isDetached) return false
|
||||
// val activity = fragment.activity ?: return false
|
||||
// activity.runOnUiThread { f(fragment) }
|
||||
// return true
|
||||
//}
|
||||
//
|
||||
//@Deprecated(message = "Use support library fragments instead. Framework fragments were deprecated in API 28.")
|
||||
//fun <T : Fragment> AnkoAsyncContext<T>.fragmentUiThreadWithContext(f: Context.(T) -> Unit): Boolean {
|
||||
// val fragment = weakRef.get() ?: return false
|
||||
// if (fragment.isDetached) return false
|
||||
// val activity = fragment.activity ?: return false
|
||||
// activity.runOnUiThread { activity.f(fragment) }
|
||||
// return true
|
||||
//}
|
||||
//
|
||||
//private val crashLogger = { throwable: Throwable -> throwable.printStackTrace() }
|
||||
//
|
||||
///**
|
||||
// * Execute [task] asynchronously.
|
||||
// *
|
||||
// * @param exceptionHandler optional exception handler.
|
||||
// * If defined, any exceptions thrown inside [task] will be passed to it. If not, exceptions will be ignored.
|
||||
// * @param task the code to execute asynchronously.
|
||||
// */
|
||||
//fun <T> T.doAsync(
|
||||
// exceptionHandler: ((Throwable) -> Unit)? = crashLogger,
|
||||
// task: AnkoAsyncContext<T>.() -> Unit,
|
||||
//): Future<Unit> {
|
||||
// val context = AnkoAsyncContext(WeakReference(this))
|
||||
// return BackgroundExecutor.submit {
|
||||
// return@submit try {
|
||||
// context.task()
|
||||
// } catch (thr: Throwable) {
|
||||
// val result = exceptionHandler?.invoke(thr)
|
||||
// result ?: Unit
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//fun <T> T.doAsync(
|
||||
// exceptionHandler: ((Throwable) -> Unit)? = crashLogger,
|
||||
// executorService: ExecutorService,
|
||||
// task: AnkoAsyncContext<T>.() -> Unit,
|
||||
//): Future<Unit> {
|
||||
// val context = AnkoAsyncContext(WeakReference(this))
|
||||
// return executorService.submit<Unit> {
|
||||
// try {
|
||||
// context.task()
|
||||
// } catch (thr: Throwable) {
|
||||
// exceptionHandler?.invoke(thr)
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//fun <T, R> T.doAsyncResult(
|
||||
// exceptionHandler: ((Throwable) -> Unit)? = crashLogger,
|
||||
// task: AnkoAsyncContext<T>.() -> R,
|
||||
//): Future<R> {
|
||||
// val context = AnkoAsyncContext(WeakReference(this))
|
||||
// return BackgroundExecutor.submit {
|
||||
// try {
|
||||
// context.task()
|
||||
// } catch (thr: Throwable) {
|
||||
// exceptionHandler?.invoke(thr)
|
||||
// throw thr
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//fun <T, R> T.doAsyncResult(
|
||||
// exceptionHandler: ((Throwable) -> Unit)? = crashLogger,
|
||||
// executorService: ExecutorService,
|
||||
// task: AnkoAsyncContext<T>.() -> R,
|
||||
//): Future<R> {
|
||||
// val context = AnkoAsyncContext(WeakReference(this))
|
||||
// return executorService.submit<R> {
|
||||
// try {
|
||||
// context.task()
|
||||
// } catch (thr: Throwable) {
|
||||
// exceptionHandler?.invoke(thr)
|
||||
// throw thr
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//internal object BackgroundExecutor {
|
||||
// @Suppress("MemberVisibilityCanBePrivate")
|
||||
// var executor: ExecutorService =
|
||||
// Executors.newScheduledThreadPool(2 * Runtime.getRuntime().availableProcessors())
|
||||
//
|
||||
// fun <T> submit(task: () -> T): Future<T> = executor.submit(task)
|
||||
//}
|
||||
//
|
||||
//private object ContextHelper {
|
||||
// val handler = Handler(Looper.getMainLooper())
|
||||
//}
|
||||
|
|
|
@ -13,9 +13,6 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
@file:Suppress("unused", "NOTHING_TO_INLINE")
|
||||
|
||||
package org.jetbrains.anko
|
||||
|
||||
import android.app.Activity
|
||||
|
|
|
@ -13,9 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
@file:Suppress("NOTHING_TO_INLINE", "unused", "TopLevelPropertyNaming")
|
||||
|
||||
@file:Suppress("TopLevelPropertyNaming")
|
||||
package org.jetbrains.anko
|
||||
|
||||
import android.view.ViewGroup
|
||||
|
|
|
@ -13,9 +13,6 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
@file:Suppress("unused")
|
||||
|
||||
package org.jetbrains.anko
|
||||
|
||||
import android.graphics.drawable.Drawable
|
||||
|
|
|
@ -13,8 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
@file:Suppress("NOTHING_TO_INLINE", "unused", "MatchingDeclarationName", "ClassNaming")
|
||||
@file:Suppress("MatchingDeclarationName", "ClassNaming")
|
||||
|
||||
package org.jetbrains.anko
|
||||
|
||||
|
@ -43,7 +42,7 @@ internal object `$$Anko$Factories$CustomViews` {
|
|||
}
|
||||
}
|
||||
|
||||
inline fun ViewManager.verticalLayout(theme: Int = 0): LinearLayout = verticalLayout(theme) {}
|
||||
fun ViewManager.verticalLayout(theme: Int = 0): LinearLayout = verticalLayout(theme) {}
|
||||
inline fun ViewManager.verticalLayout(
|
||||
theme: Int = 0,
|
||||
init: (@AnkoViewDslMarker _LinearLayout).() -> Unit,
|
||||
|
@ -51,7 +50,7 @@ inline fun ViewManager.verticalLayout(
|
|||
return ankoView(`$$Anko$Factories$CustomViews`.VERTICAL_LAYOUT_FACTORY, theme, init)
|
||||
}
|
||||
|
||||
inline fun Context.verticalLayout(theme: Int = 0): LinearLayout = verticalLayout(theme) {}
|
||||
fun Context.verticalLayout(theme: Int = 0): LinearLayout = verticalLayout(theme) {}
|
||||
inline fun Context.verticalLayout(
|
||||
theme: Int = 0,
|
||||
init: (@AnkoViewDslMarker _LinearLayout).() -> Unit,
|
||||
|
@ -59,7 +58,7 @@ inline fun Context.verticalLayout(
|
|||
return ankoView(`$$Anko$Factories$CustomViews`.VERTICAL_LAYOUT_FACTORY, theme, init)
|
||||
}
|
||||
|
||||
inline fun Activity.verticalLayout(theme: Int = 0): LinearLayout = verticalLayout(theme) {}
|
||||
fun Activity.verticalLayout(theme: Int = 0): LinearLayout = verticalLayout(theme) {}
|
||||
inline fun Activity.verticalLayout(
|
||||
theme: Int = 0,
|
||||
init: (@AnkoViewDslMarker _LinearLayout).() -> Unit,
|
||||
|
@ -67,7 +66,7 @@ inline fun Activity.verticalLayout(
|
|||
return ankoView(`$$Anko$Factories$CustomViews`.VERTICAL_LAYOUT_FACTORY, theme, init)
|
||||
}
|
||||
|
||||
inline fun ViewManager.editText(constraints: InputConstraints, theme: Int = 0): EditText =
|
||||
fun ViewManager.editText(constraints: InputConstraints, theme: Int = 0): EditText =
|
||||
editText(constraints, theme) {}
|
||||
|
||||
inline fun ViewManager.editText(
|
||||
|
@ -80,7 +79,7 @@ inline fun ViewManager.editText(
|
|||
return v
|
||||
}
|
||||
|
||||
inline fun Context.editText(constraints: InputConstraints, theme: Int = 0): EditText =
|
||||
fun Context.editText(constraints: InputConstraints, theme: Int = 0): EditText =
|
||||
editText(constraints, theme) {}
|
||||
|
||||
inline fun Context.editText(
|
||||
|
@ -93,7 +92,7 @@ inline fun Context.editText(
|
|||
return v
|
||||
}
|
||||
|
||||
inline fun Activity.editText(constraints: InputConstraints, theme: Int = 0): EditText =
|
||||
fun Activity.editText(constraints: InputConstraints, theme: Int = 0): EditText =
|
||||
editText(constraints, theme) {}
|
||||
|
||||
inline fun Activity.editText(
|
||||
|
@ -106,7 +105,7 @@ inline fun Activity.editText(
|
|||
return v
|
||||
}
|
||||
|
||||
inline fun ViewManager.horizontalProgressBar(theme: Int = 0): ProgressBar =
|
||||
fun ViewManager.horizontalProgressBar(theme: Int = 0): ProgressBar =
|
||||
horizontalProgressBar(theme) {}
|
||||
|
||||
inline fun ViewManager.horizontalProgressBar(
|
||||
|
@ -116,7 +115,7 @@ inline fun ViewManager.horizontalProgressBar(
|
|||
return ankoView(`$$Anko$Factories$CustomViews`.HORIZONTAL_PROGRESS_BAR_FACTORY, theme, init)
|
||||
}
|
||||
|
||||
inline fun Context.horizontalProgressBar(theme: Int = 0): ProgressBar =
|
||||
fun Context.horizontalProgressBar(theme: Int = 0): ProgressBar =
|
||||
horizontalProgressBar(theme) {}
|
||||
|
||||
inline fun Context.horizontalProgressBar(
|
||||
|
@ -126,7 +125,7 @@ inline fun Context.horizontalProgressBar(
|
|||
return ankoView(`$$Anko$Factories$CustomViews`.HORIZONTAL_PROGRESS_BAR_FACTORY, theme, init)
|
||||
}
|
||||
|
||||
inline fun Activity.horizontalProgressBar(theme: Int = 0): ProgressBar =
|
||||
fun Activity.horizontalProgressBar(theme: Int = 0): ProgressBar =
|
||||
horizontalProgressBar(theme) {}
|
||||
|
||||
inline fun Activity.horizontalProgressBar(
|
||||
|
@ -136,7 +135,7 @@ inline fun Activity.horizontalProgressBar(
|
|||
return ankoView(`$$Anko$Factories$CustomViews`.HORIZONTAL_PROGRESS_BAR_FACTORY, theme, init)
|
||||
}
|
||||
|
||||
inline fun <T : View> ViewManager.include(layoutId: Int): T = include(layoutId, {})
|
||||
fun <T : View> ViewManager.include(layoutId: Int): T = include(layoutId, {})
|
||||
inline fun <T : View> ViewManager.include(
|
||||
layoutId: Int,
|
||||
init: (@AnkoViewDslMarker T).() -> Unit,
|
||||
|
@ -145,20 +144,20 @@ inline fun <T : View> ViewManager.include(
|
|||
return ankoView({ ctx -> ctx.layoutInflater.inflate(layoutId, null) as T }, 0) { init() }
|
||||
}
|
||||
|
||||
inline fun <T : View> ViewGroup.include(layoutId: Int): T = include(layoutId, {})
|
||||
fun <T : View> ViewGroup.include(layoutId: Int): T = include(layoutId, {})
|
||||
inline fun <T : View> ViewGroup.include(layoutId: Int, init: (@AnkoViewDslMarker T).() -> Unit): T {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
return ankoView({ ctx -> ctx.layoutInflater.inflate(layoutId, this, false) as T }, 0) { init() }
|
||||
}
|
||||
|
||||
inline fun <T : View> Context.include(layoutId: Int): T = include(layoutId, {})
|
||||
fun <T : View> Context.include(layoutId: Int): T = include(layoutId, {})
|
||||
inline fun <T : View> Context.include(layoutId: Int, init: (@AnkoViewDslMarker T).() -> Unit): T {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
return ankoView({ ctx -> ctx.layoutInflater.inflate(layoutId, null) as T }, 0) { init() }
|
||||
}
|
||||
|
||||
inline fun <T : View> Activity.include(layoutId: Int): T = include(layoutId, {})
|
||||
fun <T : View> Activity.include(layoutId: Int): T = include(layoutId, {})
|
||||
inline fun <T : View> Activity.include(layoutId: Int, init: (@AnkoViewDslMarker T).() -> Unit): T {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
return ankoView({ ctx -> ctx.layoutInflater.inflate(layoutId, null) as T }, 0) { init() }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,98 +0,0 @@
|
|||
/*
|
||||
* Copyright 2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
@file:Suppress("NOTHING_TO_INLINE", "unused")
|
||||
|
||||
package org.jetbrains.anko
|
||||
|
||||
import android.content.Context
|
||||
import android.content.DialogInterface
|
||||
import androidx.fragment.app.Fragment
|
||||
|
||||
typealias AlertBuilderFactory<D> = (Context) -> AlertBuilder<D>
|
||||
|
||||
inline fun <D : DialogInterface> AnkoContext<*>.alert(
|
||||
noinline factory: AlertBuilderFactory<D>,
|
||||
message: String,
|
||||
title: String? = null,
|
||||
noinline init: (AlertBuilder<D>.() -> Unit)? = null,
|
||||
) = ctx.alert(factory, message, title, init)
|
||||
|
||||
inline fun <D : DialogInterface> Fragment.alert(
|
||||
noinline factory: AlertBuilderFactory<D>,
|
||||
message: String,
|
||||
title: String? = null,
|
||||
noinline init: (AlertBuilder<D>.() -> Unit)? = null,
|
||||
) = requireActivity().alert(factory, message, title, init)
|
||||
|
||||
fun <D : DialogInterface> Context.alert(
|
||||
factory: AlertBuilderFactory<D>,
|
||||
message: String,
|
||||
title: String? = null,
|
||||
init: (AlertBuilder<D>.() -> Unit)? = null,
|
||||
): AlertBuilder<D> {
|
||||
return factory(this).apply {
|
||||
if (title != null) {
|
||||
this.title = title
|
||||
}
|
||||
this.message = message
|
||||
if (init != null) init()
|
||||
}
|
||||
}
|
||||
|
||||
inline fun <D : DialogInterface> AnkoContext<*>.alert(
|
||||
noinline factory: AlertBuilderFactory<D>,
|
||||
message: Int,
|
||||
title: Int? = null,
|
||||
noinline init: (AlertBuilder<D>.() -> Unit)? = null,
|
||||
) = ctx.alert(factory, message, title, init)
|
||||
|
||||
inline fun <D : DialogInterface> Fragment.alert(
|
||||
noinline factory: AlertBuilderFactory<D>,
|
||||
message: Int,
|
||||
title: Int? = null,
|
||||
noinline init: (AlertBuilder<D>.() -> Unit)? = null,
|
||||
) = requireActivity().alert(factory, message, title, init)
|
||||
|
||||
fun <D : DialogInterface> Context.alert(
|
||||
factory: AlertBuilderFactory<D>,
|
||||
messageResource: Int,
|
||||
titleResource: Int? = null,
|
||||
init: (AlertBuilder<D>.() -> Unit)? = null,
|
||||
): AlertBuilder<D> {
|
||||
return factory(this).apply {
|
||||
if (titleResource != null) {
|
||||
this.titleResource = titleResource
|
||||
}
|
||||
this.messageResource = messageResource
|
||||
if (init != null) init()
|
||||
}
|
||||
}
|
||||
|
||||
inline fun <D : DialogInterface> AnkoContext<*>.alert(
|
||||
noinline factory: AlertBuilderFactory<D>,
|
||||
noinline init: AlertBuilder<D>.() -> Unit,
|
||||
) = ctx.alert(factory, init)
|
||||
|
||||
inline fun <D : DialogInterface> Fragment.alert(
|
||||
noinline factory: AlertBuilderFactory<D>,
|
||||
noinline init: AlertBuilder<D>.() -> Unit,
|
||||
) = requireActivity().alert(factory, init)
|
||||
|
||||
fun <D : DialogInterface> Context.alert(
|
||||
factory: AlertBuilderFactory<D>,
|
||||
init: AlertBuilder<D>.() -> Unit,
|
||||
): AlertBuilder<D> = factory(this).apply { init() }
|
|
@ -13,9 +13,6 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
@file:Suppress("NOTHING_TO_INLINE", "unused")
|
||||
|
||||
package org.jetbrains.anko
|
||||
|
||||
import android.content.Context
|
||||
|
@ -50,28 +47,28 @@ fun Context.px2sp(px: Int): Float = px.toFloat() / resources.displayMetrics.scal
|
|||
fun Context.dimen(@DimenRes resource: Int): Int = resources.getDimensionPixelSize(resource)
|
||||
|
||||
//the same for nested DSL components
|
||||
inline fun AnkoContext<*>.dip(value: Int): Int = ctx.dip(value)
|
||||
inline fun AnkoContext<*>.dip(value: Float): Int = ctx.dip(value)
|
||||
inline fun AnkoContext<*>.sp(value: Int): Int = ctx.sp(value)
|
||||
inline fun AnkoContext<*>.sp(value: Float): Int = ctx.sp(value)
|
||||
inline fun AnkoContext<*>.px2dip(px: Int): Float = ctx.px2dip(px)
|
||||
inline fun AnkoContext<*>.px2sp(px: Int): Float = ctx.px2sp(px)
|
||||
inline fun AnkoContext<*>.dimen(@DimenRes resource: Int): Int = ctx.dimen(resource)
|
||||
fun AnkoContext<*>.dip(value: Int): Int = ctx.dip(value)
|
||||
fun AnkoContext<*>.dip(value: Float): Int = ctx.dip(value)
|
||||
fun AnkoContext<*>.sp(value: Int): Int = ctx.sp(value)
|
||||
fun AnkoContext<*>.sp(value: Float): Int = ctx.sp(value)
|
||||
fun AnkoContext<*>.px2dip(px: Int): Float = ctx.px2dip(px)
|
||||
fun AnkoContext<*>.px2sp(px: Int): Float = ctx.px2sp(px)
|
||||
fun AnkoContext<*>.dimen(@DimenRes resource: Int): Int = ctx.dimen(resource)
|
||||
|
||||
//the same for the views
|
||||
inline fun View.dip(value: Int): Int = context.dip(value)
|
||||
inline fun View.dip(value: Float): Int = context.dip(value)
|
||||
inline fun View.sp(value: Int): Int = context.sp(value)
|
||||
inline fun View.sp(value: Float): Int = context.sp(value)
|
||||
inline fun View.px2dip(px: Int): Float = context.px2dip(px)
|
||||
inline fun View.px2sp(px: Int): Float = context.px2sp(px)
|
||||
inline fun View.dimen(@DimenRes resource: Int): Int = context.dimen(resource)
|
||||
fun View.dip(value: Int): Int = context.dip(value)
|
||||
fun View.dip(value: Float): Int = context.dip(value)
|
||||
fun View.sp(value: Int): Int = context.sp(value)
|
||||
fun View.sp(value: Float): Int = context.sp(value)
|
||||
fun View.px2dip(px: Int): Float = context.px2dip(px)
|
||||
fun View.px2sp(px: Int): Float = context.px2sp(px)
|
||||
fun View.dimen(@DimenRes resource: Int): Int = context.dimen(resource)
|
||||
|
||||
//the same for Fragments
|
||||
inline fun Fragment.dip(value: Int): Int = requireContext().dip(value)
|
||||
inline fun Fragment.dip(value: Float): Int = requireContext().dip(value)
|
||||
inline fun Fragment.sp(value: Int): Int = requireContext().sp(value)
|
||||
inline fun Fragment.sp(value: Float): Int = requireContext().sp(value)
|
||||
inline fun Fragment.px2dip(px: Int): Float = requireContext().px2dip(px)
|
||||
inline fun Fragment.px2sp(px: Int): Float = requireContext().px2sp(px)
|
||||
inline fun Fragment.dimen(@DimenRes resource: Int): Int = requireContext().dimen(resource)
|
||||
fun Fragment.dip(value: Int): Int = requireContext().dip(value)
|
||||
fun Fragment.dip(value: Float): Int = requireContext().dip(value)
|
||||
fun Fragment.sp(value: Int): Int = requireContext().sp(value)
|
||||
fun Fragment.sp(value: Float): Int = requireContext().sp(value)
|
||||
fun Fragment.px2dip(px: Int): Float = requireContext().px2dip(px)
|
||||
fun Fragment.px2sp(px: Int): Float = requireContext().px2sp(px)
|
||||
fun Fragment.dimen(@DimenRes resource: Int): Int = requireContext().dimen(resource)
|
||||
|
|
|
@ -13,9 +13,6 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
@file:Suppress("unused")
|
||||
|
||||
package org.jetbrains.anko
|
||||
|
||||
import android.app.Activity
|
||||
|
|
|
@ -13,12 +13,10 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
@file:Suppress("unused")
|
||||
package org.jetbrains.anko
|
||||
|
||||
import android.text.InputType
|
||||
|
||||
enum class InputConstraints(val value: Int) {
|
||||
PASSWORD(InputType.TYPE_CLASS_TEXT or InputType.TYPE_TEXT_VARIATION_PASSWORD)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,9 +13,6 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
@file:Suppress("NOTHING_TO_INLINE", "unused")
|
||||
|
||||
package org.jetbrains.anko
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
|
@ -50,11 +47,10 @@ inline fun <reified T : Activity> Activity.startActivityForResult(
|
|||
inline fun <reified T : Activity> Fragment.startActivityForResult(
|
||||
requestCode: Int,
|
||||
vararg params: Pair<String, Any?>,
|
||||
) =
|
||||
startActivityForResult(
|
||||
AnkoInternals.createIntent(requireActivity(), T::class.java, params),
|
||||
requestCode
|
||||
)
|
||||
) = startActivityForResult(
|
||||
AnkoInternals.createIntent(requireActivity(), T::class.java, params),
|
||||
requestCode
|
||||
)
|
||||
|
||||
inline fun <reified T : Service> Context.startService(vararg params: Pair<String, Any?>) =
|
||||
AnkoInternals.internalStartService(this, T::class.java, params)
|
||||
|
@ -88,14 +84,14 @@ inline fun <reified T : Any> Fragment.intentFor(vararg params: Pair<String, Any?
|
|||
*
|
||||
* @return the same intent with the flag applied.
|
||||
*/
|
||||
inline fun Intent.clearTask(): Intent = apply { addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK) }
|
||||
fun Intent.clearTask(): Intent = apply { addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK) }
|
||||
|
||||
/**
|
||||
* Add the [Intent.FLAG_ACTIVITY_CLEAR_TOP] flag to the [Intent].
|
||||
*
|
||||
* @return the same intent with the flag applied.
|
||||
*/
|
||||
inline fun Intent.clearTop(): Intent = apply { addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP) }
|
||||
fun Intent.clearTop(): Intent = apply { addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP) }
|
||||
|
||||
/**
|
||||
* Add the [Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET] flag to the [Intent].
|
||||
|
@ -106,7 +102,7 @@ inline fun Intent.clearTop(): Intent = apply { addFlags(Intent.FLAG_ACTIVITY_CLE
|
|||
message = "Deprecated in Android",
|
||||
replaceWith = ReplaceWith("org.jetbrains.anko.newDocument")
|
||||
)
|
||||
inline fun Intent.clearWhenTaskReset(): Intent = apply {
|
||||
fun Intent.clearWhenTaskReset(): Intent = apply {
|
||||
@Suppress("DEPRECATION")
|
||||
addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET)
|
||||
}
|
||||
|
@ -116,7 +112,7 @@ inline fun Intent.clearWhenTaskReset(): Intent = apply {
|
|||
*
|
||||
* @return the same intent with the flag applied.
|
||||
*/
|
||||
inline fun Intent.newDocument(): Intent = apply {
|
||||
fun Intent.newDocument(): Intent = apply {
|
||||
addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT)
|
||||
}
|
||||
|
||||
|
@ -125,7 +121,7 @@ inline fun Intent.newDocument(): Intent = apply {
|
|||
*
|
||||
* @return the same intent with the flag applied.
|
||||
*/
|
||||
inline fun Intent.excludeFromRecents(): Intent =
|
||||
fun Intent.excludeFromRecents(): Intent =
|
||||
apply { addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS) }
|
||||
|
||||
/**
|
||||
|
@ -133,39 +129,39 @@ inline fun Intent.excludeFromRecents(): Intent =
|
|||
*
|
||||
* @return the same intent with the flag applied.
|
||||
*/
|
||||
inline fun Intent.multipleTask(): Intent = apply { addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK) }
|
||||
fun Intent.multipleTask(): Intent = apply { addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK) }
|
||||
|
||||
/**
|
||||
* Add the [Intent.FLAG_ACTIVITY_NEW_TASK] flag to the [Intent].
|
||||
*
|
||||
* @return the same intent with the flag applied.
|
||||
*/
|
||||
inline fun Intent.newTask(): Intent = apply { addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) }
|
||||
fun Intent.newTask(): Intent = apply { addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) }
|
||||
|
||||
/**
|
||||
* Add the [Intent.FLAG_ACTIVITY_NO_ANIMATION] flag to the [Intent].
|
||||
*
|
||||
* @return the same intent with the flag applied.
|
||||
*/
|
||||
inline fun Intent.noAnimation(): Intent = apply { addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION) }
|
||||
fun Intent.noAnimation(): Intent = apply { addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION) }
|
||||
|
||||
/**
|
||||
* Add the [Intent.FLAG_ACTIVITY_NO_HISTORY] flag to the [Intent].
|
||||
*
|
||||
* @return the same intent with the flag applied.
|
||||
*/
|
||||
inline fun Intent.noHistory(): Intent = apply { addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY) }
|
||||
fun Intent.noHistory(): Intent = apply { addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY) }
|
||||
|
||||
/**
|
||||
* Add the [Intent.FLAG_ACTIVITY_SINGLE_TOP] flag to the [Intent].
|
||||
*
|
||||
* @return the same intent with the flag applied.
|
||||
*/
|
||||
inline fun Intent.singleTop(): Intent = apply { addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP) }
|
||||
fun Intent.singleTop(): Intent = apply { addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP) }
|
||||
|
||||
inline fun AnkoContext<*>.browse(url: String, newTask: Boolean = false) = ctx.browse(url, newTask)
|
||||
fun AnkoContext<*>.browse(url: String, newTask: Boolean = false) = ctx.browse(url, newTask)
|
||||
|
||||
inline fun Fragment.browse(url: String, newTask: Boolean = false) =
|
||||
fun Fragment.browse(url: String, newTask: Boolean = false) =
|
||||
requireActivity().browse(url, newTask)
|
||||
|
||||
fun Context.browse(url: String, newTask: Boolean = false) {
|
||||
|
@ -178,10 +174,10 @@ fun Context.browse(url: String, newTask: Boolean = false) {
|
|||
// ActivityNotFoundException
|
||||
}
|
||||
|
||||
inline fun AnkoContext<*>.share(text: String, subject: String = "", title: String? = null) =
|
||||
fun AnkoContext<*>.share(text: String, subject: String = "", title: String? = null) =
|
||||
ctx.share(text, subject, title)
|
||||
|
||||
inline fun Fragment.share(text: String, subject: String = "", title: String? = null) =
|
||||
fun Fragment.share(text: String, subject: String = "", title: String? = null) =
|
||||
requireActivity().share(text, subject, title)
|
||||
|
||||
fun Context.share(text: String, subject: String = "", title: String? = null) {
|
||||
|
@ -193,10 +189,10 @@ fun Context.share(text: String, subject: String = "", title: String? = null) {
|
|||
// ActivityNotFoundException
|
||||
}
|
||||
|
||||
inline fun AnkoContext<*>.email(email: String, subject: String = "", text: String = "") =
|
||||
fun AnkoContext<*>.email(email: String, subject: String = "", text: String = "") =
|
||||
ctx.email(email, subject, text)
|
||||
|
||||
inline fun Fragment.email(email: String, subject: String = "", text: String = "") =
|
||||
fun Fragment.email(email: String, subject: String = "", text: String = "") =
|
||||
requireActivity().email(email, subject, text)
|
||||
|
||||
@SuppressLint("QueryPermissionsNeeded")
|
||||
|
@ -215,9 +211,9 @@ fun Context.email(email: String, subject: String = "", text: String = ""): Boole
|
|||
return false
|
||||
}
|
||||
|
||||
inline fun AnkoContext<*>.makeCall(number: String) = ctx.makeCall(number)
|
||||
fun AnkoContext<*>.makeCall(number: String) = ctx.makeCall(number)
|
||||
|
||||
inline fun Fragment.makeCall(number: String) = requireActivity().makeCall(number)
|
||||
fun Fragment.makeCall(number: String) = requireActivity().makeCall(number)
|
||||
|
||||
fun Context.makeCall(number: String) {
|
||||
val intent = Intent(Intent.ACTION_CALL, Uri.parse("tel:$number"))
|
||||
|
@ -225,10 +221,10 @@ fun Context.makeCall(number: String) {
|
|||
// ActivityNotFoundException
|
||||
}
|
||||
|
||||
inline fun AnkoContext<*>.sendSMS(number: String, text: String = "") =
|
||||
fun AnkoContext<*>.sendSMS(number: String, text: String = "") =
|
||||
ctx.sendSMS(number, text)
|
||||
|
||||
inline fun Fragment.sendSMS(number: String, text: String = "") =
|
||||
fun Fragment.sendSMS(number: String, text: String = "") =
|
||||
requireActivity().sendSMS(number, text)
|
||||
|
||||
fun Context.sendSMS(number: String, text: String = "") {
|
||||
|
|
|
@ -10,6 +10,7 @@ import android.util.AttributeSet
|
|||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.*
|
||||
import androidx.appcompat.widget.Toolbar
|
||||
|
||||
@Suppress("ClassNaming")
|
||||
open class _AppWidgetHostView(ctx: Context) : AppWidgetHostView(ctx) {
|
||||
|
@ -198,7 +199,7 @@ open class _AppWidgetHostView(ctx: Context) : AppWidgetHostView(ctx) {
|
|||
//}
|
||||
|
||||
@Suppress("ClassNaming")
|
||||
open class _ActionMenuView(ctx: Context) : ActionMenuView(ctx) {
|
||||
open class _ActionMenuView(ctx: Context) : androidx.appcompat.widget.ActionMenuView(ctx) {
|
||||
|
||||
inline fun <T : View> T.lparams(
|
||||
c: Context?,
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
@file:Suppress("unused", "NOTHING_TO_INLINE", "MatchingDeclarationName", "NAME_SHADOWING")
|
||||
@file:Suppress("MatchingDeclarationName", "NAME_SHADOWING")
|
||||
@file:JvmName("Logging")
|
||||
|
||||
package org.jetbrains.anko
|
||||
|
@ -275,4 +275,4 @@ private fun getTag(clazz: Class<*>): String {
|
|||
} else {
|
||||
tag.substring(0, 23)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,9 +13,6 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
@file:Suppress("NOTHING_TO_INLINE", "unused")
|
||||
|
||||
package org.jetbrains.anko
|
||||
|
||||
import android.view.View
|
||||
|
@ -63,7 +60,7 @@ fun LayoutParams.below(view: View) {
|
|||
/**
|
||||
* Place the current View to the left of [view].
|
||||
*/
|
||||
inline fun LayoutParams.leftOf(view: View) {
|
||||
fun LayoutParams.leftOf(view: View) {
|
||||
val id = view.id
|
||||
if (id == View.NO_ID) throw AnkoException("Id is not set for $view")
|
||||
addRule(LEFT_OF, id)
|
||||
|
@ -72,7 +69,7 @@ inline fun LayoutParams.leftOf(view: View) {
|
|||
/**
|
||||
* Place the current View to the start of [view].
|
||||
*/
|
||||
inline fun LayoutParams.startOf(view: View) {
|
||||
fun LayoutParams.startOf(view: View) {
|
||||
val id = view.id
|
||||
if (id == View.NO_ID) throw AnkoException("Id is not set for $view")
|
||||
addRule(START_OF, id)
|
||||
|
@ -81,7 +78,7 @@ inline fun LayoutParams.startOf(view: View) {
|
|||
/**
|
||||
* Place the current View to the right of [view].
|
||||
*/
|
||||
inline fun LayoutParams.rightOf(view: View) {
|
||||
fun LayoutParams.rightOf(view: View) {
|
||||
val id = view.id
|
||||
if (id == View.NO_ID) throw AnkoException("Id is not set for $view")
|
||||
addRule(RIGHT_OF, id)
|
||||
|
@ -90,7 +87,7 @@ inline fun LayoutParams.rightOf(view: View) {
|
|||
/**
|
||||
* Place the current View to the end of [view].
|
||||
*/
|
||||
inline fun LayoutParams.endOf(view: View) {
|
||||
fun LayoutParams.endOf(view: View) {
|
||||
val id = view.id
|
||||
if (id == View.NO_ID) throw AnkoException("Id is not set for $view")
|
||||
addRule(END_OF, id)
|
||||
|
@ -99,7 +96,7 @@ inline fun LayoutParams.endOf(view: View) {
|
|||
/**
|
||||
* Set the current View left attribute the same as for [view].
|
||||
*/
|
||||
inline fun LayoutParams.sameLeft(view: View) {
|
||||
fun LayoutParams.sameLeft(view: View) {
|
||||
val id = view.id
|
||||
if (id == View.NO_ID) throw AnkoException("Id is not set for $view")
|
||||
addRule(ALIGN_LEFT, id)
|
||||
|
@ -108,7 +105,7 @@ inline fun LayoutParams.sameLeft(view: View) {
|
|||
/**
|
||||
* Set the current View start attribute the same as for [view].
|
||||
*/
|
||||
inline fun LayoutParams.sameStart(view: View) {
|
||||
fun LayoutParams.sameStart(view: View) {
|
||||
val id = view.id
|
||||
if (id == View.NO_ID) throw AnkoException("Id is not set for $view")
|
||||
addRule(ALIGN_START, id)
|
||||
|
@ -117,7 +114,7 @@ inline fun LayoutParams.sameStart(view: View) {
|
|||
/**
|
||||
* Set the current View top attribute the same as for [view].
|
||||
*/
|
||||
inline fun LayoutParams.sameTop(view: View) {
|
||||
fun LayoutParams.sameTop(view: View) {
|
||||
val id = view.id
|
||||
if (id == View.NO_ID) throw AnkoException("Id is not set for $view")
|
||||
addRule(ALIGN_TOP, id)
|
||||
|
@ -126,7 +123,7 @@ inline fun LayoutParams.sameTop(view: View) {
|
|||
/**
|
||||
* Set the current View right attribute the same as for [view].
|
||||
*/
|
||||
inline fun LayoutParams.sameRight(view: View) {
|
||||
fun LayoutParams.sameRight(view: View) {
|
||||
val id = view.id
|
||||
if (id == View.NO_ID) throw AnkoException("Id is not set for $view")
|
||||
addRule(ALIGN_RIGHT, id)
|
||||
|
@ -135,7 +132,7 @@ inline fun LayoutParams.sameRight(view: View) {
|
|||
/**
|
||||
* Set the current View end attribute the same as for [view].
|
||||
*/
|
||||
inline fun LayoutParams.sameEnd(view: View) {
|
||||
fun LayoutParams.sameEnd(view: View) {
|
||||
val id = view.id
|
||||
if (id == View.NO_ID) throw AnkoException("Id is not set for $view")
|
||||
addRule(ALIGN_END, id)
|
||||
|
@ -144,7 +141,7 @@ inline fun LayoutParams.sameEnd(view: View) {
|
|||
/**
|
||||
* Set the current View bottom attribute the same as for [view].
|
||||
*/
|
||||
inline fun LayoutParams.sameBottom(view: View) {
|
||||
fun LayoutParams.sameBottom(view: View) {
|
||||
val id = view.id
|
||||
if (id == View.NO_ID) throw AnkoException("Id is not set for $view")
|
||||
addRule(ALIGN_BOTTOM, id)
|
||||
|
@ -154,133 +151,133 @@ inline fun LayoutParams.sameBottom(view: View) {
|
|||
* Place the current View above the View with a given [id].
|
||||
* It is an alias for [above].
|
||||
*/
|
||||
inline fun LayoutParams.topOf(@IdRes id: Int) = addRule(ABOVE, id)
|
||||
fun LayoutParams.topOf(@IdRes id: Int) = addRule(ABOVE, id)
|
||||
|
||||
/**
|
||||
* Place the current View above the View with a given [id].
|
||||
*/
|
||||
inline fun LayoutParams.above(@IdRes id: Int) = addRule(ABOVE, id)
|
||||
fun LayoutParams.above(@IdRes id: Int) = addRule(ABOVE, id)
|
||||
|
||||
/**
|
||||
* Place the current View below the View with a given [id].
|
||||
*/
|
||||
inline fun LayoutParams.below(@IdRes id: Int) = addRule(BELOW, id)
|
||||
fun LayoutParams.below(@IdRes id: Int) = addRule(BELOW, id)
|
||||
|
||||
/**
|
||||
* Place the current View below the View with a given [id].
|
||||
* It is an alias for [below].
|
||||
*/
|
||||
inline fun LayoutParams.bottomOf(@IdRes id: Int) = addRule(BELOW, id)
|
||||
fun LayoutParams.bottomOf(@IdRes id: Int) = addRule(BELOW, id)
|
||||
|
||||
/**
|
||||
* Place the current View to the left of the View with a given [id].
|
||||
*/
|
||||
inline fun LayoutParams.leftOf(@IdRes id: Int) = addRule(LEFT_OF, id)
|
||||
fun LayoutParams.leftOf(@IdRes id: Int) = addRule(LEFT_OF, id)
|
||||
|
||||
/**
|
||||
* Place the current View to the start of the View with a given [id].
|
||||
*/
|
||||
inline fun LayoutParams.startOf(@IdRes id: Int): Unit = addRule(START_OF, id)
|
||||
fun LayoutParams.startOf(@IdRes id: Int): Unit = addRule(START_OF, id)
|
||||
|
||||
/**
|
||||
* Place the current View to the left of the View with a given [id].
|
||||
*/
|
||||
inline fun LayoutParams.rightOf(@IdRes id: Int) = addRule(RIGHT_OF, id)
|
||||
fun LayoutParams.rightOf(@IdRes id: Int) = addRule(RIGHT_OF, id)
|
||||
|
||||
/**
|
||||
* Place the current View to the end of the View with a given [id].
|
||||
*/
|
||||
inline fun LayoutParams.endOf(@IdRes id: Int): Unit = addRule(END_OF, id)
|
||||
fun LayoutParams.endOf(@IdRes id: Int): Unit = addRule(END_OF, id)
|
||||
|
||||
/**
|
||||
* Set the current View left attribute the same as for View with a given [id].
|
||||
*/
|
||||
inline fun LayoutParams.sameLeft(@IdRes id: Int) = addRule(ALIGN_LEFT, id)
|
||||
fun LayoutParams.sameLeft(@IdRes id: Int) = addRule(ALIGN_LEFT, id)
|
||||
|
||||
/**
|
||||
* Set the current View start attribute the same as for View with a given [id].
|
||||
*/
|
||||
inline fun LayoutParams.sameStart(@IdRes id: Int): Unit = addRule(ALIGN_START, id)
|
||||
fun LayoutParams.sameStart(@IdRes id: Int): Unit = addRule(ALIGN_START, id)
|
||||
|
||||
/**
|
||||
* Set the current View top attribute the same as for View with a given [id].
|
||||
*/
|
||||
inline fun LayoutParams.sameTop(@IdRes id: Int) = addRule(ALIGN_TOP, id)
|
||||
fun LayoutParams.sameTop(@IdRes id: Int) = addRule(ALIGN_TOP, id)
|
||||
|
||||
/**
|
||||
* Set the current View right attribute the same as for View with a given [id].
|
||||
*/
|
||||
inline fun LayoutParams.sameRight(@IdRes id: Int) = addRule(ALIGN_RIGHT, id)
|
||||
fun LayoutParams.sameRight(@IdRes id: Int) = addRule(ALIGN_RIGHT, id)
|
||||
|
||||
/**
|
||||
* Set the current View end attribute the same as for View with a given [id].
|
||||
*/
|
||||
inline fun LayoutParams.sameEnd(@IdRes id: Int): Unit = addRule(ALIGN_END, id)
|
||||
fun LayoutParams.sameEnd(@IdRes id: Int): Unit = addRule(ALIGN_END, id)
|
||||
|
||||
/**
|
||||
* Set the current View bottom attribute the same as for View with a given [id].
|
||||
*/
|
||||
inline fun LayoutParams.sameBottom(@IdRes id: Int) = addRule(ALIGN_BOTTOM, id)
|
||||
fun LayoutParams.sameBottom(@IdRes id: Int) = addRule(ALIGN_BOTTOM, id)
|
||||
|
||||
/**
|
||||
* Align the current View's start edge with another child's start edge.
|
||||
*/
|
||||
inline fun LayoutParams.alignStart(@IdRes id: Int): Unit = addRule(ALIGN_START, id)
|
||||
fun LayoutParams.alignStart(@IdRes id: Int): Unit = addRule(ALIGN_START, id)
|
||||
|
||||
/**
|
||||
* Align the current View's end edge with another child's end edge.
|
||||
*/
|
||||
inline fun LayoutParams.alignEnd(@IdRes id: Int): Unit = addRule(ALIGN_END, id)
|
||||
fun LayoutParams.alignEnd(@IdRes id: Int): Unit = addRule(ALIGN_END, id)
|
||||
|
||||
/**
|
||||
* Align the current View's top edge with its parent's top edge.
|
||||
*/
|
||||
inline fun LayoutParams.alignParentTop() = addRule(ALIGN_PARENT_TOP)
|
||||
fun LayoutParams.alignParentTop() = addRule(ALIGN_PARENT_TOP)
|
||||
|
||||
/**
|
||||
* Align the current View's right edge with its parent's right edge.
|
||||
*/
|
||||
inline fun LayoutParams.alignParentRight() = addRule(ALIGN_PARENT_RIGHT)
|
||||
fun LayoutParams.alignParentRight() = addRule(ALIGN_PARENT_RIGHT)
|
||||
|
||||
/**
|
||||
* Align the current View's bottom edge with its parent's bottom edge.
|
||||
*/
|
||||
inline fun LayoutParams.alignParentBottom() = addRule(ALIGN_PARENT_BOTTOM)
|
||||
fun LayoutParams.alignParentBottom() = addRule(ALIGN_PARENT_BOTTOM)
|
||||
|
||||
/**
|
||||
* Align the current View's left edge with its parent's left edge.
|
||||
*/
|
||||
inline fun LayoutParams.alignParentLeft() = addRule(ALIGN_PARENT_LEFT)
|
||||
fun LayoutParams.alignParentLeft() = addRule(ALIGN_PARENT_LEFT)
|
||||
|
||||
/**
|
||||
* Center the child horizontally in its parent.
|
||||
*/
|
||||
inline fun LayoutParams.centerHorizontally() = addRule(CENTER_HORIZONTAL)
|
||||
fun LayoutParams.centerHorizontally() = addRule(CENTER_HORIZONTAL)
|
||||
|
||||
/**
|
||||
* Center the child vertically in its parent.
|
||||
*/
|
||||
inline fun LayoutParams.centerVertically() = addRule(CENTER_VERTICAL)
|
||||
fun LayoutParams.centerVertically() = addRule(CENTER_VERTICAL)
|
||||
|
||||
/**
|
||||
* Center the child horizontally and vertically in its parent.
|
||||
*/
|
||||
inline fun LayoutParams.centerInParent() = addRule(CENTER_IN_PARENT)
|
||||
fun LayoutParams.centerInParent() = addRule(CENTER_IN_PARENT)
|
||||
|
||||
/**
|
||||
* Align the current View's start edge with its parent's start edge.
|
||||
*/
|
||||
inline fun LayoutParams.alignParentStart(): Unit = addRule(ALIGN_PARENT_START)
|
||||
fun LayoutParams.alignParentStart(): Unit = addRule(ALIGN_PARENT_START)
|
||||
|
||||
/**
|
||||
* Align the current View's end edge with its parent's end edge.
|
||||
*/
|
||||
inline fun LayoutParams.alignParentEnd(): Unit = addRule(ALIGN_PARENT_END)
|
||||
fun LayoutParams.alignParentEnd(): Unit = addRule(ALIGN_PARENT_END)
|
||||
|
||||
/**
|
||||
* Positions the baseline of this view on the baseline of the given anchor [view].
|
||||
*/
|
||||
inline fun LayoutParams.baselineOf(view: View) {
|
||||
fun LayoutParams.baselineOf(view: View) {
|
||||
val id = view.id
|
||||
if (id == View.NO_ID) throw AnkoException("Id is not set for $view")
|
||||
addRule(ALIGN_BASELINE, id)
|
||||
|
@ -289,4 +286,4 @@ inline fun LayoutParams.baselineOf(view: View) {
|
|||
/**
|
||||
* Positions the baseline of this view on the baseline of the anchor View with a given [id].
|
||||
*/
|
||||
inline fun LayoutParams.baselineOf(@IdRes id: Int) = addRule(ALIGN_BASELINE, id)
|
||||
fun LayoutParams.baselineOf(@IdRes id: Int) = addRule(ALIGN_BASELINE, id)
|
||||
|
|
|
@ -1,52 +0,0 @@
|
|||
/*
|
||||
* Copyright 2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
@file:Suppress("NOTHING_TO_INLINE", "unused")
|
||||
|
||||
package org.jetbrains.anko
|
||||
|
||||
import android.content.Context
|
||||
import android.content.DialogInterface
|
||||
import androidx.fragment.app.Fragment
|
||||
|
||||
inline fun <D : DialogInterface> AnkoContext<*>.selector(
|
||||
noinline factory: AlertBuilderFactory<D>,
|
||||
title: CharSequence? = null,
|
||||
items: List<CharSequence>,
|
||||
noinline onClick: (DialogInterface, CharSequence, Int) -> Unit,
|
||||
) = ctx.selector(factory, title, items, onClick)
|
||||
|
||||
inline fun <D : DialogInterface> Fragment.selector(
|
||||
noinline factory: AlertBuilderFactory<D>,
|
||||
title: CharSequence? = null,
|
||||
items: List<CharSequence>,
|
||||
noinline onClick: (DialogInterface, CharSequence, Int) -> Unit,
|
||||
) = requireActivity().selector(factory, title, items, onClick)
|
||||
|
||||
fun <D : DialogInterface> Context.selector(
|
||||
factory: AlertBuilderFactory<D>,
|
||||
title: CharSequence? = null,
|
||||
items: List<CharSequence>,
|
||||
onClick: (DialogInterface, CharSequence, Int) -> Unit,
|
||||
) {
|
||||
with(factory(this)) {
|
||||
if (title != null) {
|
||||
this.title = title
|
||||
}
|
||||
items(items, onClick)
|
||||
show()
|
||||
}
|
||||
}
|
|
@ -1,40 +0,0 @@
|
|||
|
||||
/*
|
||||
* Copyright 2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.anko
|
||||
|
||||
import android.content.SharedPreferences
|
||||
|
||||
/**
|
||||
* Opens the [SharedPreferences.Editor], applies the [modifer] to it and then applies the changes asynchronously
|
||||
*/
|
||||
@Deprecated(message = "Use the Android KTX version", replaceWith = ReplaceWith("edit(modifier)", "androidx.core.content.edit"))
|
||||
inline fun SharedPreferences.apply(modifier: SharedPreferences.Editor.() -> Unit) {
|
||||
val editor = this.edit()
|
||||
editor.modifier()
|
||||
editor.apply()
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens the [SharedPreferences.Editor], applies the [modifer] to it and then applies the changes synchronously
|
||||
*/
|
||||
@Deprecated(message = "Use the Android KTX version", replaceWith = ReplaceWith("edit(true, modifier)", "androidx.core.content.edit"))
|
||||
inline fun SharedPreferences.commit(modifier: SharedPreferences.Editor.() -> Unit) {
|
||||
val editor = this.edit()
|
||||
editor.modifier()
|
||||
editor.commit()
|
||||
}
|
|
@ -1,5 +1,3 @@
|
|||
@file:Suppress("NOTHING_TO_INLINE", "unused")
|
||||
|
||||
package org.jetbrains.anko
|
||||
|
||||
import android.content.Context
|
||||
|
@ -40,24 +38,24 @@ fun Context.dimenAttr(@AttrRes attribute: Int): Int =
|
|||
fun Context.colorAttr(@AttrRes attribute: Int): Int = theme.color(attribute)
|
||||
|
||||
@Dimension(unit = Dimension.PX)
|
||||
inline fun AnkoContext<*>.dimenAttr(@AttrRes attribute: Int): Int = ctx.dimenAttr(attribute)
|
||||
fun AnkoContext<*>.dimenAttr(@AttrRes attribute: Int): Int = ctx.dimenAttr(attribute)
|
||||
|
||||
@ColorInt
|
||||
inline fun AnkoContext<*>.colorAttr(@AttrRes attribute: Int): Int = ctx.colorAttr(attribute)
|
||||
fun AnkoContext<*>.colorAttr(@AttrRes attribute: Int): Int = ctx.colorAttr(attribute)
|
||||
|
||||
inline fun AnkoContext<*>.attr(@AttrRes attribute: Int): TypedValue = ctx.attr(attribute)
|
||||
fun AnkoContext<*>.attr(@AttrRes attribute: Int): TypedValue = ctx.attr(attribute)
|
||||
|
||||
@Dimension(unit = Dimension.PX)
|
||||
inline fun View.dimenAttr(@AttrRes attribute: Int): Int = context.dimenAttr(attribute)
|
||||
fun View.dimenAttr(@AttrRes attribute: Int): Int = context.dimenAttr(attribute)
|
||||
|
||||
@ColorInt
|
||||
inline fun View.colorAttr(@AttrRes attribute: Int): Int = context.colorAttr(attribute)
|
||||
fun View.colorAttr(@AttrRes attribute: Int): Int = context.colorAttr(attribute)
|
||||
|
||||
inline fun View.attr(@AttrRes attribute: Int): TypedValue = context.attr(attribute)
|
||||
fun View.attr(@AttrRes attribute: Int): TypedValue = context.attr(attribute)
|
||||
|
||||
@Dimension(unit = Dimension.PX)
|
||||
inline fun Fragment.dimenAttr(@AttrRes attribute: Int): Int = requireContext().dimenAttr(attribute)
|
||||
fun Fragment.dimenAttr(@AttrRes attribute: Int): Int = requireContext().dimenAttr(attribute)
|
||||
|
||||
@ColorInt
|
||||
inline fun Fragment.colorAttr(@AttrRes attribute: Int): Int = requireContext().colorAttr(attribute)
|
||||
inline fun Fragment.attr(@AttrRes attribute: Int): TypedValue = requireContext().attr(attribute)
|
||||
fun Fragment.colorAttr(@AttrRes attribute: Int): Int = requireContext().colorAttr(attribute)
|
||||
fun Fragment.attr(@AttrRes attribute: Int): TypedValue = requireContext().attr(attribute)
|
||||
|
|
|
@ -13,9 +13,6 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
@file:Suppress("NOTHING_TO_INLINE", "unused")
|
||||
|
||||
package org.jetbrains.anko
|
||||
|
||||
import android.content.Context
|
||||
|
@ -27,21 +24,21 @@ import androidx.fragment.app.Fragment
|
|||
*
|
||||
* @param message the message text resource.
|
||||
*/
|
||||
inline fun AnkoContext<*>.toast(message: Int) = ctx.toast(message)
|
||||
fun AnkoContext<*>.toast(message: Int) = ctx.toast(message)
|
||||
|
||||
/**
|
||||
* Display the simple Toast message with the [Toast.LENGTH_SHORT] duration.
|
||||
*
|
||||
* @param message the message text resource.
|
||||
*/
|
||||
inline fun Fragment.toast(message: Int) = requireContext().toast(message)
|
||||
fun Fragment.toast(message: Int) = requireContext().toast(message)
|
||||
|
||||
/**
|
||||
* Display the simple Toast message with the [Toast.LENGTH_SHORT] duration.
|
||||
*
|
||||
* @param message the message text resource.
|
||||
*/
|
||||
inline fun Context.toast(message: Int): Toast = Toast
|
||||
fun Context.toast(message: Int): Toast = Toast
|
||||
.makeText(this, message, Toast.LENGTH_SHORT)
|
||||
.apply {
|
||||
show()
|
||||
|
@ -52,21 +49,21 @@ inline fun Context.toast(message: Int): Toast = Toast
|
|||
*
|
||||
* @param message the message text.
|
||||
*/
|
||||
inline fun AnkoContext<*>.toast(message: CharSequence) = ctx.toast(message)
|
||||
fun AnkoContext<*>.toast(message: CharSequence) = ctx.toast(message)
|
||||
|
||||
/**
|
||||
* Display the simple Toast message with the [Toast.LENGTH_SHORT] duration.
|
||||
*
|
||||
* @param message the message text.
|
||||
*/
|
||||
inline fun Fragment.toast(message: CharSequence) = requireContext().toast(message)
|
||||
fun Fragment.toast(message: CharSequence) = requireContext().toast(message)
|
||||
|
||||
/**
|
||||
* Display the simple Toast message with the [Toast.LENGTH_SHORT] duration.
|
||||
*
|
||||
* @param message the message text.
|
||||
*/
|
||||
inline fun Context.toast(message: CharSequence): Toast = Toast
|
||||
fun Context.toast(message: CharSequence): Toast = Toast
|
||||
.makeText(this, message, Toast.LENGTH_SHORT)
|
||||
.apply {
|
||||
show()
|
||||
|
@ -77,21 +74,21 @@ inline fun Context.toast(message: CharSequence): Toast = Toast
|
|||
*
|
||||
* @param message the message text resource.
|
||||
*/
|
||||
inline fun AnkoContext<*>.longToast(message: Int) = ctx.longToast(message)
|
||||
fun AnkoContext<*>.longToast(message: Int) = ctx.longToast(message)
|
||||
|
||||
/**
|
||||
* Display the simple Toast message with the [Toast.LENGTH_LONG] duration.
|
||||
*
|
||||
* @param message the message text resource.
|
||||
*/
|
||||
inline fun Fragment.longToast(message: Int) = requireContext().longToast(message)
|
||||
fun Fragment.longToast(message: Int) = requireContext().longToast(message)
|
||||
|
||||
/**
|
||||
* Display the simple Toast message with the [Toast.LENGTH_LONG] duration.
|
||||
*
|
||||
* @param message the message text resource.
|
||||
*/
|
||||
inline fun Context.longToast(message: Int): Toast = Toast
|
||||
fun Context.longToast(message: Int): Toast = Toast
|
||||
.makeText(this, message, Toast.LENGTH_LONG)
|
||||
.apply {
|
||||
show()
|
||||
|
@ -102,21 +99,21 @@ inline fun Context.longToast(message: Int): Toast = Toast
|
|||
*
|
||||
* @param message the message text.
|
||||
*/
|
||||
inline fun AnkoContext<*>.longToast(message: CharSequence) = ctx.longToast(message)
|
||||
fun AnkoContext<*>.longToast(message: CharSequence) = ctx.longToast(message)
|
||||
|
||||
/**
|
||||
* Display the simple Toast message with the [Toast.LENGTH_LONG] duration.
|
||||
*
|
||||
* @param message the message text.
|
||||
*/
|
||||
inline fun Fragment.longToast(message: CharSequence) = requireContext().longToast(message)
|
||||
fun Fragment.longToast(message: CharSequence) = requireContext().longToast(message)
|
||||
|
||||
/**
|
||||
* Display the simple Toast message with the [Toast.LENGTH_LONG] duration.
|
||||
*
|
||||
* @param message the message text.
|
||||
*/
|
||||
inline fun Context.longToast(message: CharSequence): Toast = Toast
|
||||
fun Context.longToast(message: CharSequence): Toast = Toast
|
||||
.makeText(this, message, Toast.LENGTH_LONG)
|
||||
.apply {
|
||||
show()
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
@file:Suppress("unused", "NOTHING_TO_INLINE", "MatchingDeclarationName")
|
||||
@file:Suppress("MatchingDeclarationName")
|
||||
|
||||
package org.jetbrains.anko
|
||||
|
||||
|
@ -30,7 +30,7 @@ annotation class AnkoViewDslMarker
|
|||
*
|
||||
* @return the receiver.
|
||||
*/
|
||||
inline fun <T : View> T.applyRecursively(noinline f: (View) -> Unit): T {
|
||||
fun <T : View> T.applyRecursively(f: (View) -> Unit): T {
|
||||
AnkoInternals.applyRecursively(this, f)
|
||||
return this
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,895 @@
|
|||
@file:Suppress("TooManyFunctions", "ClassNaming")
|
||||
@file:JvmName("Sdk28ViewGroupsKt")
|
||||
|
||||
package org.jetbrains.anko
|
||||
|
||||
import android.app.*
|
||||
import android.content.Context
|
||||
import android.view.ViewManager
|
||||
import android.widget.*
|
||||
import androidx.appcompat.widget.*
|
||||
import androidx.appcompat.widget.ActionMenuView
|
||||
import androidx.appcompat.widget.Toolbar
|
||||
import org.jetbrains.anko.custom.*
|
||||
|
||||
@PublishedApi
|
||||
internal object `$$Anko$Factories$Sdk28ViewGroup` {
|
||||
val APP_WIDGET_HOST_VIEW = { ctx: Context -> _AppWidgetHostView(ctx) }
|
||||
|
||||
//val ABSOLUTE_LAYOUT = { ctx: Context -> _AbsoluteLayout(ctx) }
|
||||
val ACTION_MENU_VIEW = { ctx: Context -> _ActionMenuView(ctx) }
|
||||
val FRAME_LAYOUT = { ctx: Context -> _FrameLayout(ctx) }
|
||||
|
||||
//val GALLERY = { ctx: Context -> _Gallery(ctx) }
|
||||
val GRID_LAYOUT = { ctx: Context -> _GridLayout(ctx) }
|
||||
val GRID_VIEW = { ctx: Context -> _GridView(ctx) }
|
||||
val HORIZONTAL_SCROLL_VIEW = { ctx: Context -> _HorizontalScrollView(ctx) }
|
||||
val IMAGE_SWITCHER = { ctx: Context -> _ImageSwitcher(ctx) }
|
||||
val LINEAR_LAYOUT = { ctx: Context -> _LinearLayout(ctx) }
|
||||
val RADIO_GROUP = { ctx: Context -> _RadioGroup(ctx) }
|
||||
val RELATIVE_LAYOUT = { ctx: Context -> _RelativeLayout(ctx) }
|
||||
val SCROLL_VIEW = { ctx: Context -> _ScrollView(ctx) }
|
||||
val TABLE_LAYOUT = { ctx: Context -> _TableLayout(ctx) }
|
||||
val TABLE_ROW = { ctx: Context -> _TableRow(ctx) }
|
||||
val TEXT_SWITCHER = { ctx: Context -> _TextSwitcher(ctx) }
|
||||
val TOOLBAR = { ctx: Context -> _Toolbar(ctx) }
|
||||
val VIEW_ANIMATOR = { ctx: Context -> _ViewAnimator(ctx) }
|
||||
val VIEW_SWITCHER = { ctx: Context -> _ViewSwitcher(ctx) }
|
||||
}
|
||||
|
||||
fun ViewManager.appWidgetHostView(): android.appwidget.AppWidgetHostView =
|
||||
appWidgetHostView {}
|
||||
|
||||
inline fun ViewManager.appWidgetHostView(init: (@AnkoViewDslMarker _AppWidgetHostView).() -> Unit): android.appwidget.AppWidgetHostView {
|
||||
return ankoView(`$$Anko$Factories$Sdk28ViewGroup`.APP_WIDGET_HOST_VIEW, theme = 0) { init() }
|
||||
}
|
||||
|
||||
fun ViewManager.themedAppWidgetHostView(theme: Int = 0): android.appwidget.AppWidgetHostView =
|
||||
themedAppWidgetHostView(theme) {}
|
||||
|
||||
inline fun ViewManager.themedAppWidgetHostView(
|
||||
theme: Int = 0,
|
||||
init: (@AnkoViewDslMarker _AppWidgetHostView).() -> Unit,
|
||||
): android.appwidget.AppWidgetHostView {
|
||||
return ankoView(`$$Anko$Factories$Sdk28ViewGroup`.APP_WIDGET_HOST_VIEW, theme) { init() }
|
||||
}
|
||||
|
||||
fun Context.appWidgetHostView(): android.appwidget.AppWidgetHostView = appWidgetHostView {}
|
||||
inline fun Context.appWidgetHostView(init: (@AnkoViewDslMarker _AppWidgetHostView).() -> Unit): android.appwidget.AppWidgetHostView {
|
||||
return ankoView(`$$Anko$Factories$Sdk28ViewGroup`.APP_WIDGET_HOST_VIEW, theme = 0) { init() }
|
||||
}
|
||||
|
||||
fun Context.themedAppWidgetHostView(theme: Int = 0): android.appwidget.AppWidgetHostView =
|
||||
themedAppWidgetHostView(theme) {}
|
||||
|
||||
inline fun Context.themedAppWidgetHostView(
|
||||
theme: Int = 0,
|
||||
init: (@AnkoViewDslMarker _AppWidgetHostView).() -> Unit,
|
||||
): android.appwidget.AppWidgetHostView {
|
||||
return ankoView(`$$Anko$Factories$Sdk28ViewGroup`.APP_WIDGET_HOST_VIEW, theme) { init() }
|
||||
}
|
||||
|
||||
fun Activity.appWidgetHostView(): android.appwidget.AppWidgetHostView =
|
||||
appWidgetHostView {}
|
||||
|
||||
inline fun Activity.appWidgetHostView(init: (@AnkoViewDslMarker _AppWidgetHostView).() -> Unit): android.appwidget.AppWidgetHostView {
|
||||
return ankoView(`$$Anko$Factories$Sdk28ViewGroup`.APP_WIDGET_HOST_VIEW, theme = 0) { init() }
|
||||
}
|
||||
|
||||
fun Activity.themedAppWidgetHostView(theme: Int = 0): android.appwidget.AppWidgetHostView =
|
||||
themedAppWidgetHostView(theme) {}
|
||||
|
||||
inline fun Activity.themedAppWidgetHostView(
|
||||
theme: Int = 0,
|
||||
init: (@AnkoViewDslMarker _AppWidgetHostView).() -> Unit,
|
||||
): android.appwidget.AppWidgetHostView {
|
||||
return ankoView(`$$Anko$Factories$Sdk28ViewGroup`.APP_WIDGET_HOST_VIEW, theme) { init() }
|
||||
}
|
||||
|
||||
//inline fun ViewManager.absoluteLayout(): android.widget.AbsoluteLayout = absoluteLayout() {}
|
||||
//inline fun ViewManager.absoluteLayout(init: (@AnkoViewDslMarker _AbsoluteLayout).() -> Unit): android.widget.AbsoluteLayout {
|
||||
// return ankoView(`$$Anko$Factories$Sdk28ViewGroup`.ABSOLUTE_LAYOUT, theme = 0) { init() }
|
||||
//}
|
||||
//
|
||||
//inline fun ViewManager.themedAbsoluteLayout(theme: Int = 0): android.widget.AbsoluteLayout =
|
||||
// themedAbsoluteLayout(theme) {}
|
||||
//
|
||||
//inline fun ViewManager.themedAbsoluteLayout(
|
||||
// theme: Int = 0,
|
||||
// init: (@AnkoViewDslMarker _AbsoluteLayout).() -> Unit,
|
||||
//): android.widget.AbsoluteLayout {
|
||||
// return ankoView(`$$Anko$Factories$Sdk28ViewGroup`.ABSOLUTE_LAYOUT, theme) { init() }
|
||||
//}
|
||||
//
|
||||
//inline fun Context.absoluteLayout(): android.widget.AbsoluteLayout = absoluteLayout() {}
|
||||
//inline fun Context.absoluteLayout(init: (@AnkoViewDslMarker _AbsoluteLayout).() -> Unit): android.widget.AbsoluteLayout {
|
||||
// return ankoView(`$$Anko$Factories$Sdk28ViewGroup`.ABSOLUTE_LAYOUT, theme = 0) { init() }
|
||||
//}
|
||||
//
|
||||
//inline fun Context.themedAbsoluteLayout(theme: Int = 0): android.widget.AbsoluteLayout =
|
||||
// themedAbsoluteLayout(theme) {}
|
||||
//
|
||||
//inline fun Context.themedAbsoluteLayout(
|
||||
// theme: Int = 0,
|
||||
// init: (@AnkoViewDslMarker _AbsoluteLayout).() -> Unit,
|
||||
//): android.widget.AbsoluteLayout {
|
||||
// return ankoView(`$$Anko$Factories$Sdk28ViewGroup`.ABSOLUTE_LAYOUT, theme) { init() }
|
||||
//}
|
||||
//
|
||||
//inline fun Activity.absoluteLayout(): android.widget.AbsoluteLayout = absoluteLayout() {}
|
||||
//inline fun Activity.absoluteLayout(init: (@AnkoViewDslMarker _AbsoluteLayout).() -> Unit): android.widget.AbsoluteLayout {
|
||||
// return ankoView(`$$Anko$Factories$Sdk28ViewGroup`.ABSOLUTE_LAYOUT, theme = 0) { init() }
|
||||
//}
|
||||
//
|
||||
//inline fun Activity.themedAbsoluteLayout(theme: Int = 0): android.widget.AbsoluteLayout =
|
||||
// themedAbsoluteLayout(theme) {}
|
||||
//
|
||||
//inline fun Activity.themedAbsoluteLayout(
|
||||
// theme: Int = 0,
|
||||
// init: (@AnkoViewDslMarker _AbsoluteLayout).() -> Unit,
|
||||
//): android.widget.AbsoluteLayout {
|
||||
// return ankoView(`$$Anko$Factories$Sdk28ViewGroup`.ABSOLUTE_LAYOUT, theme) { init() }
|
||||
//}
|
||||
|
||||
fun ViewManager.actionMenuView(): ActionMenuView = actionMenuView {}
|
||||
inline fun ViewManager.actionMenuView(init: (@AnkoViewDslMarker _ActionMenuView).() -> Unit): ActionMenuView {
|
||||
return ankoView(`$$Anko$Factories$Sdk28ViewGroup`.ACTION_MENU_VIEW, theme = 0) { init() }
|
||||
}
|
||||
|
||||
fun ViewManager.themedActionMenuView(theme: Int = 0): ActionMenuView =
|
||||
themedActionMenuView(theme) {}
|
||||
|
||||
inline fun ViewManager.themedActionMenuView(
|
||||
theme: Int = 0,
|
||||
init: (@AnkoViewDslMarker _ActionMenuView).() -> Unit,
|
||||
): ActionMenuView {
|
||||
return ankoView(`$$Anko$Factories$Sdk28ViewGroup`.ACTION_MENU_VIEW, theme) { init() }
|
||||
}
|
||||
|
||||
fun Context.actionMenuView(): ActionMenuView = actionMenuView {}
|
||||
inline fun Context.actionMenuView(init: (@AnkoViewDslMarker _ActionMenuView).() -> Unit): ActionMenuView {
|
||||
return ankoView(`$$Anko$Factories$Sdk28ViewGroup`.ACTION_MENU_VIEW, theme = 0) { init() }
|
||||
}
|
||||
|
||||
fun Context.themedActionMenuView(theme: Int = 0): ActionMenuView =
|
||||
themedActionMenuView(theme) {}
|
||||
|
||||
inline fun Context.themedActionMenuView(
|
||||
theme: Int = 0,
|
||||
init: (@AnkoViewDslMarker _ActionMenuView).() -> Unit,
|
||||
): ActionMenuView {
|
||||
return ankoView(`$$Anko$Factories$Sdk28ViewGroup`.ACTION_MENU_VIEW, theme) { init() }
|
||||
}
|
||||
|
||||
fun Activity.actionMenuView(): ActionMenuView = actionMenuView {}
|
||||
inline fun Activity.actionMenuView(init: (@AnkoViewDslMarker _ActionMenuView).() -> Unit): ActionMenuView {
|
||||
return ankoView(`$$Anko$Factories$Sdk28ViewGroup`.ACTION_MENU_VIEW, theme = 0) { init() }
|
||||
}
|
||||
|
||||
fun Activity.themedActionMenuView(theme: Int = 0): ActionMenuView =
|
||||
themedActionMenuView(theme) {}
|
||||
|
||||
inline fun Activity.themedActionMenuView(
|
||||
theme: Int = 0,
|
||||
init: (@AnkoViewDslMarker _ActionMenuView).() -> Unit,
|
||||
): ActionMenuView {
|
||||
return ankoView(`$$Anko$Factories$Sdk28ViewGroup`.ACTION_MENU_VIEW, theme) { init() }
|
||||
}
|
||||
|
||||
fun ViewManager.frameLayout(): FrameLayout = frameLayout {}
|
||||
inline fun ViewManager.frameLayout(init: (@AnkoViewDslMarker _FrameLayout).() -> Unit): FrameLayout {
|
||||
return ankoView(`$$Anko$Factories$Sdk28ViewGroup`.FRAME_LAYOUT, theme = 0) { init() }
|
||||
}
|
||||
|
||||
fun ViewManager.themedFrameLayout(theme: Int = 0): FrameLayout =
|
||||
themedFrameLayout(theme) {}
|
||||
|
||||
inline fun ViewManager.themedFrameLayout(
|
||||
theme: Int = 0,
|
||||
init: (@AnkoViewDslMarker _FrameLayout).() -> Unit,
|
||||
): FrameLayout {
|
||||
return ankoView(`$$Anko$Factories$Sdk28ViewGroup`.FRAME_LAYOUT, theme) { init() }
|
||||
}
|
||||
|
||||
fun Context.frameLayout(): FrameLayout = frameLayout {}
|
||||
inline fun Context.frameLayout(init: (@AnkoViewDslMarker _FrameLayout).() -> Unit): FrameLayout {
|
||||
return ankoView(`$$Anko$Factories$Sdk28ViewGroup`.FRAME_LAYOUT, theme = 0) { init() }
|
||||
}
|
||||
|
||||
fun Context.themedFrameLayout(theme: Int = 0): FrameLayout =
|
||||
themedFrameLayout(theme) {}
|
||||
|
||||
inline fun Context.themedFrameLayout(
|
||||
theme: Int = 0,
|
||||
init: (@AnkoViewDslMarker _FrameLayout).() -> Unit,
|
||||
): FrameLayout {
|
||||
return ankoView(`$$Anko$Factories$Sdk28ViewGroup`.FRAME_LAYOUT, theme) { init() }
|
||||
}
|
||||
|
||||
fun Activity.frameLayout(): FrameLayout = frameLayout {}
|
||||
inline fun Activity.frameLayout(init: (@AnkoViewDslMarker _FrameLayout).() -> Unit): FrameLayout {
|
||||
return ankoView(`$$Anko$Factories$Sdk28ViewGroup`.FRAME_LAYOUT, theme = 0) { init() }
|
||||
}
|
||||
|
||||
fun Activity.themedFrameLayout(theme: Int = 0): FrameLayout =
|
||||
themedFrameLayout(theme) {}
|
||||
|
||||
inline fun Activity.themedFrameLayout(
|
||||
theme: Int = 0,
|
||||
init: (@AnkoViewDslMarker _FrameLayout).() -> Unit,
|
||||
): FrameLayout {
|
||||
return ankoView(`$$Anko$Factories$Sdk28ViewGroup`.FRAME_LAYOUT, theme) { init() }
|
||||
}
|
||||
|
||||
//inline fun ViewManager.gallery(): android.widget.Gallery = gallery() {}
|
||||
//inline fun ViewManager.gallery(init: (@AnkoViewDslMarker _Gallery).() -> Unit): android.widget.Gallery {
|
||||
// return ankoView(`$$Anko$Factories$Sdk28ViewGroup`.GALLERY, theme = 0) { init() }
|
||||
//}
|
||||
//
|
||||
//inline fun ViewManager.themedGallery(theme: Int = 0): android.widget.Gallery =
|
||||
// themedGallery(theme) {}
|
||||
//
|
||||
//inline fun ViewManager.themedGallery(
|
||||
// theme: Int = 0,
|
||||
// init: (@AnkoViewDslMarker _Gallery).() -> Unit,
|
||||
//): android.widget.Gallery {
|
||||
// return ankoView(`$$Anko$Factories$Sdk28ViewGroup`.GALLERY, theme) { init() }
|
||||
//}
|
||||
|
||||
//inline fun Context.gallery(): android.widget.Gallery = gallery() {}
|
||||
//inline fun Context.gallery(init: (@AnkoViewDslMarker _Gallery).() -> Unit): android.widget.Gallery {
|
||||
// return ankoView(`$$Anko$Factories$Sdk28ViewGroup`.GALLERY, theme = 0) { init() }
|
||||
//}
|
||||
//
|
||||
//inline fun Context.themedGallery(theme: Int = 0): android.widget.Gallery = themedGallery(theme) {}
|
||||
//inline fun Context.themedGallery(
|
||||
// theme: Int = 0,
|
||||
// init: (@AnkoViewDslMarker _Gallery).() -> Unit,
|
||||
//): android.widget.Gallery {
|
||||
// return ankoView(`$$Anko$Factories$Sdk28ViewGroup`.GALLERY, theme) { init() }
|
||||
//}
|
||||
|
||||
//inline fun Activity.gallery(): android.widget.Gallery = gallery() {}
|
||||
//inline fun Activity.gallery(init: (@AnkoViewDslMarker _Gallery).() -> Unit): android.widget.Gallery {
|
||||
// return ankoView(`$$Anko$Factories$Sdk28ViewGroup`.GALLERY, theme = 0) { init() }
|
||||
//}
|
||||
//
|
||||
//inline fun Activity.themedGallery(theme: Int = 0): android.widget.Gallery = themedGallery(theme) {}
|
||||
//inline fun Activity.themedGallery(
|
||||
// theme: Int = 0,
|
||||
// init: (@AnkoViewDslMarker _Gallery).() -> Unit,
|
||||
//): android.widget.Gallery {
|
||||
// return ankoView(`$$Anko$Factories$Sdk28ViewGroup`.GALLERY, theme) { init() }
|
||||
//}
|
||||
|
||||
fun ViewManager.gridLayout(): GridLayout = gridLayout {}
|
||||
inline fun ViewManager.gridLayout(init: (@AnkoViewDslMarker _GridLayout).() -> Unit): GridLayout {
|
||||
return ankoView(`$$Anko$Factories$Sdk28ViewGroup`.GRID_LAYOUT, theme = 0) { init() }
|
||||
}
|
||||
|
||||
fun ViewManager.themedGridLayout(theme: Int = 0): GridLayout =
|
||||
themedGridLayout(theme) {}
|
||||
|
||||
inline fun ViewManager.themedGridLayout(
|
||||
theme: Int = 0,
|
||||
init: (@AnkoViewDslMarker _GridLayout).() -> Unit,
|
||||
): GridLayout {
|
||||
return ankoView(`$$Anko$Factories$Sdk28ViewGroup`.GRID_LAYOUT, theme) { init() }
|
||||
}
|
||||
|
||||
fun Context.gridLayout(): GridLayout = gridLayout {}
|
||||
inline fun Context.gridLayout(init: (@AnkoViewDslMarker _GridLayout).() -> Unit): GridLayout {
|
||||
return ankoView(`$$Anko$Factories$Sdk28ViewGroup`.GRID_LAYOUT, theme = 0) { init() }
|
||||
}
|
||||
|
||||
fun Context.themedGridLayout(theme: Int = 0): GridLayout =
|
||||
themedGridLayout(theme) {}
|
||||
|
||||
inline fun Context.themedGridLayout(
|
||||
theme: Int = 0,
|
||||
init: (@AnkoViewDslMarker _GridLayout).() -> Unit,
|
||||
): GridLayout {
|
||||
return ankoView(`$$Anko$Factories$Sdk28ViewGroup`.GRID_LAYOUT, theme) { init() }
|
||||
}
|
||||
|
||||
fun Activity.gridLayout(): GridLayout = gridLayout {}
|
||||
inline fun Activity.gridLayout(init: (@AnkoViewDslMarker _GridLayout).() -> Unit): GridLayout {
|
||||
return ankoView(`$$Anko$Factories$Sdk28ViewGroup`.GRID_LAYOUT, theme = 0) { init() }
|
||||
}
|
||||
|
||||
fun Activity.themedGridLayout(theme: Int = 0): GridLayout =
|
||||
themedGridLayout(theme) {}
|
||||
|
||||
inline fun Activity.themedGridLayout(
|
||||
theme: Int = 0,
|
||||
init: (@AnkoViewDslMarker _GridLayout).() -> Unit,
|
||||
): GridLayout {
|
||||
return ankoView(`$$Anko$Factories$Sdk28ViewGroup`.GRID_LAYOUT, theme) { init() }
|
||||
}
|
||||
|
||||
fun ViewManager.gridView(): GridView = gridView {}
|
||||
inline fun ViewManager.gridView(init: (@AnkoViewDslMarker _GridView).() -> Unit): GridView {
|
||||
return ankoView(`$$Anko$Factories$Sdk28ViewGroup`.GRID_VIEW, theme = 0) { init() }
|
||||
}
|
||||
|
||||
fun ViewManager.themedGridView(theme: Int = 0): GridView =
|
||||
themedGridView(theme) {}
|
||||
|
||||
inline fun ViewManager.themedGridView(
|
||||
theme: Int = 0,
|
||||
init: (@AnkoViewDslMarker _GridView).() -> Unit,
|
||||
): GridView {
|
||||
return ankoView(`$$Anko$Factories$Sdk28ViewGroup`.GRID_VIEW, theme) { init() }
|
||||
}
|
||||
|
||||
fun Context.gridView(): GridView = gridView {}
|
||||
inline fun Context.gridView(init: (@AnkoViewDslMarker _GridView).() -> Unit): GridView {
|
||||
return ankoView(`$$Anko$Factories$Sdk28ViewGroup`.GRID_VIEW, theme = 0) { init() }
|
||||
}
|
||||
|
||||
fun Context.themedGridView(theme: Int = 0): GridView =
|
||||
themedGridView(theme) {}
|
||||
|
||||
inline fun Context.themedGridView(
|
||||
theme: Int = 0,
|
||||
init: (@AnkoViewDslMarker _GridView).() -> Unit,
|
||||
): GridView {
|
||||
return ankoView(`$$Anko$Factories$Sdk28ViewGroup`.GRID_VIEW, theme) { init() }
|
||||
}
|
||||
|
||||
fun Activity.gridView(): GridView = gridView {}
|
||||
inline fun Activity.gridView(init: (@AnkoViewDslMarker _GridView).() -> Unit): GridView {
|
||||
return ankoView(`$$Anko$Factories$Sdk28ViewGroup`.GRID_VIEW, theme = 0) { init() }
|
||||
}
|
||||
|
||||
fun Activity.themedGridView(theme: Int = 0): GridView =
|
||||
themedGridView(theme) {}
|
||||
|
||||
inline fun Activity.themedGridView(
|
||||
theme: Int = 0,
|
||||
init: (@AnkoViewDslMarker _GridView).() -> Unit,
|
||||
): GridView {
|
||||
return ankoView(`$$Anko$Factories$Sdk28ViewGroup`.GRID_VIEW, theme) { init() }
|
||||
}
|
||||
|
||||
fun ViewManager.horizontalScrollView(): HorizontalScrollView =
|
||||
horizontalScrollView {}
|
||||
|
||||
inline fun ViewManager.horizontalScrollView(init: (@AnkoViewDslMarker _HorizontalScrollView).() -> Unit): HorizontalScrollView {
|
||||
return ankoView(`$$Anko$Factories$Sdk28ViewGroup`.HORIZONTAL_SCROLL_VIEW, theme = 0) { init() }
|
||||
}
|
||||
|
||||
fun ViewManager.themedHorizontalScrollView(theme: Int = 0): HorizontalScrollView =
|
||||
themedHorizontalScrollView(theme) {}
|
||||
|
||||
inline fun ViewManager.themedHorizontalScrollView(
|
||||
theme: Int = 0,
|
||||
init: (@AnkoViewDslMarker _HorizontalScrollView).() -> Unit,
|
||||
): HorizontalScrollView {
|
||||
return ankoView(`$$Anko$Factories$Sdk28ViewGroup`.HORIZONTAL_SCROLL_VIEW, theme) { init() }
|
||||
}
|
||||
|
||||
fun Context.horizontalScrollView(): HorizontalScrollView =
|
||||
horizontalScrollView {}
|
||||
|
||||
inline fun Context.horizontalScrollView(init: (@AnkoViewDslMarker _HorizontalScrollView).() -> Unit): HorizontalScrollView {
|
||||
return ankoView(`$$Anko$Factories$Sdk28ViewGroup`.HORIZONTAL_SCROLL_VIEW, theme = 0) { init() }
|
||||
}
|
||||
|
||||
fun Context.themedHorizontalScrollView(theme: Int = 0): HorizontalScrollView =
|
||||
themedHorizontalScrollView(theme) {}
|
||||
|
||||
inline fun Context.themedHorizontalScrollView(
|
||||
theme: Int = 0,
|
||||
init: (@AnkoViewDslMarker _HorizontalScrollView).() -> Unit,
|
||||
): HorizontalScrollView {
|
||||
return ankoView(`$$Anko$Factories$Sdk28ViewGroup`.HORIZONTAL_SCROLL_VIEW, theme) { init() }
|
||||
}
|
||||
|
||||
fun Activity.horizontalScrollView(): HorizontalScrollView =
|
||||
horizontalScrollView {}
|
||||
|
||||
inline fun Activity.horizontalScrollView(init: (@AnkoViewDslMarker _HorizontalScrollView).() -> Unit): HorizontalScrollView {
|
||||
return ankoView(`$$Anko$Factories$Sdk28ViewGroup`.HORIZONTAL_SCROLL_VIEW, theme = 0) { init() }
|
||||
}
|
||||
|
||||
fun Activity.themedHorizontalScrollView(theme: Int = 0): HorizontalScrollView =
|
||||
themedHorizontalScrollView(theme) {}
|
||||
|
||||
inline fun Activity.themedHorizontalScrollView(
|
||||
theme: Int = 0,
|
||||
init: (@AnkoViewDslMarker _HorizontalScrollView).() -> Unit,
|
||||
): HorizontalScrollView {
|
||||
return ankoView(`$$Anko$Factories$Sdk28ViewGroup`.HORIZONTAL_SCROLL_VIEW, theme) { init() }
|
||||
}
|
||||
|
||||
fun ViewManager.imageSwitcher(): ImageSwitcher = imageSwitcher {}
|
||||
inline fun ViewManager.imageSwitcher(init: (@AnkoViewDslMarker _ImageSwitcher).() -> Unit): ImageSwitcher {
|
||||
return ankoView(`$$Anko$Factories$Sdk28ViewGroup`.IMAGE_SWITCHER, theme = 0) { init() }
|
||||
}
|
||||
|
||||
fun ViewManager.themedImageSwitcher(theme: Int = 0): ImageSwitcher =
|
||||
themedImageSwitcher(theme) {}
|
||||
|
||||
inline fun ViewManager.themedImageSwitcher(
|
||||
theme: Int = 0,
|
||||
init: (@AnkoViewDslMarker _ImageSwitcher).() -> Unit,
|
||||
): ImageSwitcher {
|
||||
return ankoView(`$$Anko$Factories$Sdk28ViewGroup`.IMAGE_SWITCHER, theme) { init() }
|
||||
}
|
||||
|
||||
fun Context.imageSwitcher(): ImageSwitcher = imageSwitcher {}
|
||||
inline fun Context.imageSwitcher(init: (@AnkoViewDslMarker _ImageSwitcher).() -> Unit): ImageSwitcher {
|
||||
return ankoView(`$$Anko$Factories$Sdk28ViewGroup`.IMAGE_SWITCHER, theme = 0) { init() }
|
||||
}
|
||||
|
||||
fun Context.themedImageSwitcher(theme: Int = 0): ImageSwitcher =
|
||||
themedImageSwitcher(theme) {}
|
||||
|
||||
inline fun Context.themedImageSwitcher(
|
||||
theme: Int = 0,
|
||||
init: (@AnkoViewDslMarker _ImageSwitcher).() -> Unit,
|
||||
): ImageSwitcher {
|
||||
return ankoView(`$$Anko$Factories$Sdk28ViewGroup`.IMAGE_SWITCHER, theme) { init() }
|
||||
}
|
||||
|
||||
fun Activity.imageSwitcher(): ImageSwitcher = imageSwitcher {}
|
||||
inline fun Activity.imageSwitcher(init: (@AnkoViewDslMarker _ImageSwitcher).() -> Unit): ImageSwitcher {
|
||||
return ankoView(`$$Anko$Factories$Sdk28ViewGroup`.IMAGE_SWITCHER, theme = 0) { init() }
|
||||
}
|
||||
|
||||
fun Activity.themedImageSwitcher(theme: Int = 0): ImageSwitcher =
|
||||
themedImageSwitcher(theme) {}
|
||||
|
||||
inline fun Activity.themedImageSwitcher(
|
||||
theme: Int = 0,
|
||||
init: (@AnkoViewDslMarker _ImageSwitcher).() -> Unit,
|
||||
): ImageSwitcher {
|
||||
return ankoView(`$$Anko$Factories$Sdk28ViewGroup`.IMAGE_SWITCHER, theme) { init() }
|
||||
}
|
||||
|
||||
fun ViewManager.linearLayout(): LinearLayout = linearLayout {}
|
||||
inline fun ViewManager.linearLayout(init: (@AnkoViewDslMarker _LinearLayout).() -> Unit): LinearLayout {
|
||||
return ankoView(`$$Anko$Factories$Sdk28ViewGroup`.LINEAR_LAYOUT, theme = 0) { init() }
|
||||
}
|
||||
|
||||
fun ViewManager.themedLinearLayout(theme: Int = 0): LinearLayout =
|
||||
themedLinearLayout(theme) {}
|
||||
|
||||
inline fun ViewManager.themedLinearLayout(
|
||||
theme: Int = 0,
|
||||
init: (@AnkoViewDslMarker _LinearLayout).() -> Unit,
|
||||
): LinearLayout {
|
||||
return ankoView(`$$Anko$Factories$Sdk28ViewGroup`.LINEAR_LAYOUT, theme) { init() }
|
||||
}
|
||||
|
||||
fun Context.linearLayout(): LinearLayout = linearLayout {}
|
||||
inline fun Context.linearLayout(init: (@AnkoViewDslMarker _LinearLayout).() -> Unit): LinearLayout {
|
||||
return ankoView(`$$Anko$Factories$Sdk28ViewGroup`.LINEAR_LAYOUT, theme = 0) { init() }
|
||||
}
|
||||
|
||||
fun Context.themedLinearLayout(theme: Int = 0): LinearLayout =
|
||||
themedLinearLayout(theme) {}
|
||||
|
||||
inline fun Context.themedLinearLayout(
|
||||
theme: Int = 0,
|
||||
init: (@AnkoViewDslMarker _LinearLayout).() -> Unit,
|
||||
): LinearLayout {
|
||||
return ankoView(`$$Anko$Factories$Sdk28ViewGroup`.LINEAR_LAYOUT, theme) { init() }
|
||||
}
|
||||
|
||||
fun Activity.linearLayout(): LinearLayout = linearLayout {}
|
||||
inline fun Activity.linearLayout(init: (@AnkoViewDslMarker _LinearLayout).() -> Unit): LinearLayout {
|
||||
return ankoView(`$$Anko$Factories$Sdk28ViewGroup`.LINEAR_LAYOUT, theme = 0) { init() }
|
||||
}
|
||||
|
||||
fun Activity.themedLinearLayout(theme: Int = 0): LinearLayout =
|
||||
themedLinearLayout(theme) {}
|
||||
|
||||
inline fun Activity.themedLinearLayout(
|
||||
theme: Int = 0,
|
||||
init: (@AnkoViewDslMarker _LinearLayout).() -> Unit,
|
||||
): LinearLayout {
|
||||
return ankoView(`$$Anko$Factories$Sdk28ViewGroup`.LINEAR_LAYOUT, theme) { init() }
|
||||
}
|
||||
|
||||
fun ViewManager.radioGroup(): RadioGroup = radioGroup {}
|
||||
inline fun ViewManager.radioGroup(init: (@AnkoViewDslMarker _RadioGroup).() -> Unit): RadioGroup {
|
||||
return ankoView(`$$Anko$Factories$Sdk28ViewGroup`.RADIO_GROUP, theme = 0) { init() }
|
||||
}
|
||||
|
||||
fun ViewManager.themedRadioGroup(theme: Int = 0): RadioGroup =
|
||||
themedRadioGroup(theme) {}
|
||||
|
||||
inline fun ViewManager.themedRadioGroup(
|
||||
theme: Int = 0,
|
||||
init: (@AnkoViewDslMarker _RadioGroup).() -> Unit,
|
||||
): RadioGroup {
|
||||
return ankoView(`$$Anko$Factories$Sdk28ViewGroup`.RADIO_GROUP, theme) { init() }
|
||||
}
|
||||
|
||||
fun Context.radioGroup(): RadioGroup = radioGroup {}
|
||||
inline fun Context.radioGroup(init: (@AnkoViewDslMarker _RadioGroup).() -> Unit): RadioGroup {
|
||||
return ankoView(`$$Anko$Factories$Sdk28ViewGroup`.RADIO_GROUP, theme = 0) { init() }
|
||||
}
|
||||
|
||||
fun Context.themedRadioGroup(theme: Int = 0): RadioGroup =
|
||||
themedRadioGroup(theme) {}
|
||||
|
||||
inline fun Context.themedRadioGroup(
|
||||
theme: Int = 0,
|
||||
init: (@AnkoViewDslMarker _RadioGroup).() -> Unit,
|
||||
): RadioGroup {
|
||||
return ankoView(`$$Anko$Factories$Sdk28ViewGroup`.RADIO_GROUP, theme) { init() }
|
||||
}
|
||||
|
||||
fun Activity.radioGroup(): RadioGroup = radioGroup {}
|
||||
inline fun Activity.radioGroup(init: (@AnkoViewDslMarker _RadioGroup).() -> Unit): RadioGroup {
|
||||
return ankoView(`$$Anko$Factories$Sdk28ViewGroup`.RADIO_GROUP, theme = 0) { init() }
|
||||
}
|
||||
|
||||
fun Activity.themedRadioGroup(theme: Int = 0): RadioGroup =
|
||||
themedRadioGroup(theme) {}
|
||||
|
||||
inline fun Activity.themedRadioGroup(
|
||||
theme: Int = 0,
|
||||
init: (@AnkoViewDslMarker _RadioGroup).() -> Unit,
|
||||
): RadioGroup {
|
||||
return ankoView(`$$Anko$Factories$Sdk28ViewGroup`.RADIO_GROUP, theme) { init() }
|
||||
}
|
||||
|
||||
fun ViewManager.relativeLayout(): RelativeLayout = relativeLayout {}
|
||||
inline fun ViewManager.relativeLayout(init: (@AnkoViewDslMarker _RelativeLayout).() -> Unit): RelativeLayout {
|
||||
return ankoView(`$$Anko$Factories$Sdk28ViewGroup`.RELATIVE_LAYOUT, theme = 0) { init() }
|
||||
}
|
||||
|
||||
fun ViewManager.themedRelativeLayout(theme: Int = 0): RelativeLayout =
|
||||
themedRelativeLayout(theme) {}
|
||||
|
||||
inline fun ViewManager.themedRelativeLayout(
|
||||
theme: Int = 0,
|
||||
init: (@AnkoViewDslMarker _RelativeLayout).() -> Unit,
|
||||
): RelativeLayout {
|
||||
return ankoView(`$$Anko$Factories$Sdk28ViewGroup`.RELATIVE_LAYOUT, theme) { init() }
|
||||
}
|
||||
|
||||
fun Context.relativeLayout(): RelativeLayout = relativeLayout {}
|
||||
inline fun Context.relativeLayout(init: (@AnkoViewDslMarker _RelativeLayout).() -> Unit): RelativeLayout {
|
||||
return ankoView(`$$Anko$Factories$Sdk28ViewGroup`.RELATIVE_LAYOUT, theme = 0) { init() }
|
||||
}
|
||||
|
||||
fun Context.themedRelativeLayout(theme: Int = 0): RelativeLayout =
|
||||
themedRelativeLayout(theme) {}
|
||||
|
||||
inline fun Context.themedRelativeLayout(
|
||||
theme: Int = 0,
|
||||
init: (@AnkoViewDslMarker _RelativeLayout).() -> Unit,
|
||||
): RelativeLayout {
|
||||
return ankoView(`$$Anko$Factories$Sdk28ViewGroup`.RELATIVE_LAYOUT, theme) { init() }
|
||||
}
|
||||
|
||||
fun Activity.relativeLayout(): RelativeLayout = relativeLayout {}
|
||||
inline fun Activity.relativeLayout(init: (@AnkoViewDslMarker _RelativeLayout).() -> Unit): RelativeLayout {
|
||||
return ankoView(`$$Anko$Factories$Sdk28ViewGroup`.RELATIVE_LAYOUT, theme = 0) { init() }
|
||||
}
|
||||
|
||||
fun Activity.themedRelativeLayout(theme: Int = 0): RelativeLayout =
|
||||
themedRelativeLayout(theme) {}
|
||||
|
||||
inline fun Activity.themedRelativeLayout(
|
||||
theme: Int = 0,
|
||||
init: (@AnkoViewDslMarker _RelativeLayout).() -> Unit,
|
||||
): RelativeLayout {
|
||||
return ankoView(`$$Anko$Factories$Sdk28ViewGroup`.RELATIVE_LAYOUT, theme) { init() }
|
||||
}
|
||||
|
||||
fun ViewManager.scrollView(): ScrollView = scrollView {}
|
||||
inline fun ViewManager.scrollView(init: (@AnkoViewDslMarker _ScrollView).() -> Unit): ScrollView {
|
||||
return ankoView(`$$Anko$Factories$Sdk28ViewGroup`.SCROLL_VIEW, theme = 0) { init() }
|
||||
}
|
||||
|
||||
fun ViewManager.themedScrollView(theme: Int = 0): ScrollView =
|
||||
themedScrollView(theme) {}
|
||||
|
||||
inline fun ViewManager.themedScrollView(
|
||||
theme: Int = 0,
|
||||
init: (@AnkoViewDslMarker _ScrollView).() -> Unit,
|
||||
): ScrollView {
|
||||
return ankoView(`$$Anko$Factories$Sdk28ViewGroup`.SCROLL_VIEW, theme) { init() }
|
||||
}
|
||||
|
||||
fun Context.scrollView(): ScrollView = scrollView {}
|
||||
inline fun Context.scrollView(init: (@AnkoViewDslMarker _ScrollView).() -> Unit): ScrollView {
|
||||
return ankoView(`$$Anko$Factories$Sdk28ViewGroup`.SCROLL_VIEW, theme = 0) { init() }
|
||||
}
|
||||
|
||||
fun Context.themedScrollView(theme: Int = 0): ScrollView =
|
||||
themedScrollView(theme) {}
|
||||
|
||||
inline fun Context.themedScrollView(
|
||||
theme: Int = 0,
|
||||
init: (@AnkoViewDslMarker _ScrollView).() -> Unit,
|
||||
): ScrollView {
|
||||
return ankoView(`$$Anko$Factories$Sdk28ViewGroup`.SCROLL_VIEW, theme) { init() }
|
||||
}
|
||||
|
||||
fun Activity.scrollView(): ScrollView = scrollView {}
|
||||
inline fun Activity.scrollView(init: (@AnkoViewDslMarker _ScrollView).() -> Unit): ScrollView {
|
||||
return ankoView(`$$Anko$Factories$Sdk28ViewGroup`.SCROLL_VIEW, theme = 0) { init() }
|
||||
}
|
||||
|
||||
fun Activity.themedScrollView(theme: Int = 0): ScrollView =
|
||||
themedScrollView(theme) {}
|
||||
|
||||
inline fun Activity.themedScrollView(
|
||||
theme: Int = 0,
|
||||
init: (@AnkoViewDslMarker _ScrollView).() -> Unit,
|
||||
): ScrollView {
|
||||
return ankoView(`$$Anko$Factories$Sdk28ViewGroup`.SCROLL_VIEW, theme) { init() }
|
||||
}
|
||||
|
||||
fun ViewManager.tableLayout(): TableLayout = tableLayout {}
|
||||
inline fun ViewManager.tableLayout(init: (@AnkoViewDslMarker _TableLayout).() -> Unit): TableLayout {
|
||||
return ankoView(`$$Anko$Factories$Sdk28ViewGroup`.TABLE_LAYOUT, theme = 0) { init() }
|
||||
}
|
||||
|
||||
fun ViewManager.themedTableLayout(theme: Int = 0): TableLayout =
|
||||
themedTableLayout(theme) {}
|
||||
|
||||
inline fun ViewManager.themedTableLayout(
|
||||
theme: Int = 0,
|
||||
init: (@AnkoViewDslMarker _TableLayout).() -> Unit,
|
||||
): TableLayout {
|
||||
return ankoView(`$$Anko$Factories$Sdk28ViewGroup`.TABLE_LAYOUT, theme) { init() }
|
||||
}
|
||||
|
||||
fun Context.tableLayout(): TableLayout = tableLayout {}
|
||||
inline fun Context.tableLayout(init: (@AnkoViewDslMarker _TableLayout).() -> Unit): TableLayout {
|
||||
return ankoView(`$$Anko$Factories$Sdk28ViewGroup`.TABLE_LAYOUT, theme = 0) { init() }
|
||||
}
|
||||
|
||||
fun Context.themedTableLayout(theme: Int = 0): TableLayout =
|
||||
themedTableLayout(theme) {}
|
||||
|
||||
inline fun Context.themedTableLayout(
|
||||
theme: Int = 0,
|
||||
init: (@AnkoViewDslMarker _TableLayout).() -> Unit,
|
||||
): TableLayout {
|
||||
return ankoView(`$$Anko$Factories$Sdk28ViewGroup`.TABLE_LAYOUT, theme) { init() }
|
||||
}
|
||||
|
||||
fun Activity.tableLayout(): TableLayout = tableLayout {}
|
||||
inline fun Activity.tableLayout(init: (@AnkoViewDslMarker _TableLayout).() -> Unit): TableLayout {
|
||||
return ankoView(`$$Anko$Factories$Sdk28ViewGroup`.TABLE_LAYOUT, theme = 0) { init() }
|
||||
}
|
||||
|
||||
fun Activity.themedTableLayout(theme: Int = 0): TableLayout =
|
||||
themedTableLayout(theme) {}
|
||||
|
||||
inline fun Activity.themedTableLayout(
|
||||
theme: Int = 0,
|
||||
init: (@AnkoViewDslMarker _TableLayout).() -> Unit,
|
||||
): TableLayout {
|
||||
return ankoView(`$$Anko$Factories$Sdk28ViewGroup`.TABLE_LAYOUT, theme) { init() }
|
||||
}
|
||||
|
||||
fun ViewManager.tableRow(): TableRow = tableRow {}
|
||||
inline fun ViewManager.tableRow(init: (@AnkoViewDslMarker _TableRow).() -> Unit): TableRow {
|
||||
return ankoView(`$$Anko$Factories$Sdk28ViewGroup`.TABLE_ROW, theme = 0) { init() }
|
||||
}
|
||||
|
||||
fun ViewManager.themedTableRow(theme: Int = 0): TableRow =
|
||||
themedTableRow(theme) {}
|
||||
|
||||
inline fun ViewManager.themedTableRow(
|
||||
theme: Int = 0,
|
||||
init: (@AnkoViewDslMarker _TableRow).() -> Unit,
|
||||
): TableRow {
|
||||
return ankoView(`$$Anko$Factories$Sdk28ViewGroup`.TABLE_ROW, theme) { init() }
|
||||
}
|
||||
|
||||
fun Context.tableRow(): TableRow = tableRow {}
|
||||
inline fun Context.tableRow(init: (@AnkoViewDslMarker _TableRow).() -> Unit): TableRow {
|
||||
return ankoView(`$$Anko$Factories$Sdk28ViewGroup`.TABLE_ROW, theme = 0) { init() }
|
||||
}
|
||||
|
||||
fun Context.themedTableRow(theme: Int = 0): TableRow =
|
||||
themedTableRow(theme) {}
|
||||
|
||||
inline fun Context.themedTableRow(
|
||||
theme: Int = 0,
|
||||
init: (@AnkoViewDslMarker _TableRow).() -> Unit,
|
||||
): TableRow {
|
||||
return ankoView(`$$Anko$Factories$Sdk28ViewGroup`.TABLE_ROW, theme) { init() }
|
||||
}
|
||||
|
||||
fun Activity.tableRow(): TableRow = tableRow {}
|
||||
inline fun Activity.tableRow(init: (@AnkoViewDslMarker _TableRow).() -> Unit): TableRow {
|
||||
return ankoView(`$$Anko$Factories$Sdk28ViewGroup`.TABLE_ROW, theme = 0) { init() }
|
||||
}
|
||||
|
||||
fun Activity.themedTableRow(theme: Int = 0): TableRow =
|
||||
themedTableRow(theme) {}
|
||||
|
||||
inline fun Activity.themedTableRow(
|
||||
theme: Int = 0,
|
||||
init: (@AnkoViewDslMarker _TableRow).() -> Unit,
|
||||
): TableRow {
|
||||
return ankoView(`$$Anko$Factories$Sdk28ViewGroup`.TABLE_ROW, theme) { init() }
|
||||
}
|
||||
|
||||
fun ViewManager.textSwitcher(): TextSwitcher = textSwitcher {}
|
||||
inline fun ViewManager.textSwitcher(init: (@AnkoViewDslMarker _TextSwitcher).() -> Unit): TextSwitcher {
|
||||
return ankoView(`$$Anko$Factories$Sdk28ViewGroup`.TEXT_SWITCHER, theme = 0) { init() }
|
||||
}
|
||||
|
||||
fun ViewManager.themedTextSwitcher(theme: Int = 0): TextSwitcher =
|
||||
themedTextSwitcher(theme) {}
|
||||
|
||||
inline fun ViewManager.themedTextSwitcher(
|
||||
theme: Int = 0,
|
||||
init: (@AnkoViewDslMarker _TextSwitcher).() -> Unit,
|
||||
): TextSwitcher {
|
||||
return ankoView(`$$Anko$Factories$Sdk28ViewGroup`.TEXT_SWITCHER, theme) { init() }
|
||||
}
|
||||
|
||||
fun Context.textSwitcher(): TextSwitcher = textSwitcher {}
|
||||
inline fun Context.textSwitcher(init: (@AnkoViewDslMarker _TextSwitcher).() -> Unit): TextSwitcher {
|
||||
return ankoView(`$$Anko$Factories$Sdk28ViewGroup`.TEXT_SWITCHER, theme = 0) { init() }
|
||||
}
|
||||
|
||||
fun Context.themedTextSwitcher(theme: Int = 0): TextSwitcher =
|
||||
themedTextSwitcher(theme) {}
|
||||
|
||||
inline fun Context.themedTextSwitcher(
|
||||
theme: Int = 0,
|
||||
init: (@AnkoViewDslMarker _TextSwitcher).() -> Unit,
|
||||
): TextSwitcher {
|
||||
return ankoView(`$$Anko$Factories$Sdk28ViewGroup`.TEXT_SWITCHER, theme) { init() }
|
||||
}
|
||||
|
||||
fun Activity.textSwitcher(): TextSwitcher = textSwitcher {}
|
||||
inline fun Activity.textSwitcher(init: (@AnkoViewDslMarker _TextSwitcher).() -> Unit): TextSwitcher {
|
||||
return ankoView(`$$Anko$Factories$Sdk28ViewGroup`.TEXT_SWITCHER, theme = 0) { init() }
|
||||
}
|
||||
|
||||
fun Activity.themedTextSwitcher(theme: Int = 0): TextSwitcher =
|
||||
themedTextSwitcher(theme) {}
|
||||
|
||||
inline fun Activity.themedTextSwitcher(
|
||||
theme: Int = 0,
|
||||
init: (@AnkoViewDslMarker _TextSwitcher).() -> Unit,
|
||||
): TextSwitcher {
|
||||
return ankoView(`$$Anko$Factories$Sdk28ViewGroup`.TEXT_SWITCHER, theme) { init() }
|
||||
}
|
||||
|
||||
fun ViewManager.toolbar(): Toolbar = toolbar {}
|
||||
inline fun ViewManager.toolbar(init: (@AnkoViewDslMarker _Toolbar).() -> Unit): Toolbar {
|
||||
return ankoView(`$$Anko$Factories$Sdk28ViewGroup`.TOOLBAR, theme = 0) { init() }
|
||||
}
|
||||
|
||||
fun ViewManager.themedToolbar(theme: Int = 0): Toolbar =
|
||||
themedToolbar(theme) {}
|
||||
|
||||
inline fun ViewManager.themedToolbar(
|
||||
theme: Int = 0,
|
||||
init: (@AnkoViewDslMarker _Toolbar).() -> Unit,
|
||||
): Toolbar {
|
||||
return ankoView(`$$Anko$Factories$Sdk28ViewGroup`.TOOLBAR, theme) { init() }
|
||||
}
|
||||
|
||||
fun Context.toolbar(): Toolbar = toolbar {}
|
||||
inline fun Context.toolbar(init: (@AnkoViewDslMarker _Toolbar).() -> Unit): Toolbar {
|
||||
return ankoView(`$$Anko$Factories$Sdk28ViewGroup`.TOOLBAR, theme = 0) { init() }
|
||||
}
|
||||
|
||||
fun Context.themedToolbar(theme: Int = 0): Toolbar = themedToolbar(theme) {}
|
||||
inline fun Context.themedToolbar(
|
||||
theme: Int = 0,
|
||||
init: (@AnkoViewDslMarker _Toolbar).() -> Unit,
|
||||
): Toolbar {
|
||||
return ankoView(`$$Anko$Factories$Sdk28ViewGroup`.TOOLBAR, theme) { init() }
|
||||
}
|
||||
|
||||
fun Activity.toolbar(): Toolbar = toolbar {}
|
||||
inline fun Activity.toolbar(init: (@AnkoViewDslMarker _Toolbar).() -> Unit): Toolbar {
|
||||
return ankoView(`$$Anko$Factories$Sdk28ViewGroup`.TOOLBAR, theme = 0) { init() }
|
||||
}
|
||||
|
||||
fun Activity.themedToolbar(theme: Int = 0): Toolbar = themedToolbar(theme) {}
|
||||
inline fun Activity.themedToolbar(
|
||||
theme: Int = 0,
|
||||
init: (@AnkoViewDslMarker _Toolbar).() -> Unit,
|
||||
): Toolbar {
|
||||
return ankoView(`$$Anko$Factories$Sdk28ViewGroup`.TOOLBAR, theme) { init() }
|
||||
}
|
||||
|
||||
fun ViewManager.viewAnimator(): ViewAnimator = viewAnimator {}
|
||||
inline fun ViewManager.viewAnimator(init: (@AnkoViewDslMarker _ViewAnimator).() -> Unit): ViewAnimator {
|
||||
return ankoView(`$$Anko$Factories$Sdk28ViewGroup`.VIEW_ANIMATOR, theme = 0) { init() }
|
||||
}
|
||||
|
||||
fun ViewManager.themedViewAnimator(theme: Int = 0): ViewAnimator =
|
||||
themedViewAnimator(theme) {}
|
||||
|
||||
inline fun ViewManager.themedViewAnimator(
|
||||
theme: Int = 0,
|
||||
init: (@AnkoViewDslMarker _ViewAnimator).() -> Unit,
|
||||
): ViewAnimator {
|
||||
return ankoView(`$$Anko$Factories$Sdk28ViewGroup`.VIEW_ANIMATOR, theme) { init() }
|
||||
}
|
||||
|
||||
fun Context.viewAnimator(): ViewAnimator = viewAnimator {}
|
||||
inline fun Context.viewAnimator(init: (@AnkoViewDslMarker _ViewAnimator).() -> Unit): ViewAnimator {
|
||||
return ankoView(`$$Anko$Factories$Sdk28ViewGroup`.VIEW_ANIMATOR, theme = 0) { init() }
|
||||
}
|
||||
|
||||
fun Context.themedViewAnimator(theme: Int = 0): ViewAnimator =
|
||||
themedViewAnimator(theme) {}
|
||||
|
||||
inline fun Context.themedViewAnimator(
|
||||
theme: Int = 0,
|
||||
init: (@AnkoViewDslMarker _ViewAnimator).() -> Unit,
|
||||
): ViewAnimator {
|
||||
return ankoView(`$$Anko$Factories$Sdk28ViewGroup`.VIEW_ANIMATOR, theme) { init() }
|
||||
}
|
||||
|
||||
fun Activity.viewAnimator(): ViewAnimator = viewAnimator {}
|
||||
inline fun Activity.viewAnimator(init: (@AnkoViewDslMarker _ViewAnimator).() -> Unit): ViewAnimator {
|
||||
return ankoView(`$$Anko$Factories$Sdk28ViewGroup`.VIEW_ANIMATOR, theme = 0) { init() }
|
||||
}
|
||||
|
||||
fun Activity.themedViewAnimator(theme: Int = 0): ViewAnimator =
|
||||
themedViewAnimator(theme) {}
|
||||
|
||||
inline fun Activity.themedViewAnimator(
|
||||
theme: Int = 0,
|
||||
init: (@AnkoViewDslMarker _ViewAnimator).() -> Unit,
|
||||
): ViewAnimator {
|
||||
return ankoView(`$$Anko$Factories$Sdk28ViewGroup`.VIEW_ANIMATOR, theme) { init() }
|
||||
}
|
||||
|
||||
fun ViewManager.viewSwitcher(): ViewSwitcher = viewSwitcher {}
|
||||
inline fun ViewManager.viewSwitcher(init: (@AnkoViewDslMarker _ViewSwitcher).() -> Unit): ViewSwitcher {
|
||||
return ankoView(`$$Anko$Factories$Sdk28ViewGroup`.VIEW_SWITCHER, theme = 0) { init() }
|
||||
}
|
||||
|
||||
fun ViewManager.themedViewSwitcher(theme: Int = 0): ViewSwitcher =
|
||||
themedViewSwitcher(theme) {}
|
||||
|
||||
inline fun ViewManager.themedViewSwitcher(
|
||||
theme: Int = 0,
|
||||
init: (@AnkoViewDslMarker _ViewSwitcher).() -> Unit,
|
||||
): ViewSwitcher {
|
||||
return ankoView(`$$Anko$Factories$Sdk28ViewGroup`.VIEW_SWITCHER, theme) { init() }
|
||||
}
|
||||
|
||||
fun Context.viewSwitcher(): ViewSwitcher = viewSwitcher {}
|
||||
inline fun Context.viewSwitcher(init: (@AnkoViewDslMarker _ViewSwitcher).() -> Unit): ViewSwitcher {
|
||||
return ankoView(`$$Anko$Factories$Sdk28ViewGroup`.VIEW_SWITCHER, theme = 0) { init() }
|
||||
}
|
||||
|
||||
fun Context.themedViewSwitcher(theme: Int = 0): ViewSwitcher =
|
||||
themedViewSwitcher(theme) {}
|
||||
|
||||
inline fun Context.themedViewSwitcher(
|
||||
theme: Int = 0,
|
||||
init: (@AnkoViewDslMarker _ViewSwitcher).() -> Unit,
|
||||
): ViewSwitcher {
|
||||
return ankoView(`$$Anko$Factories$Sdk28ViewGroup`.VIEW_SWITCHER, theme) { init() }
|
||||
}
|
||||
|
||||
fun Activity.viewSwitcher(): ViewSwitcher = viewSwitcher {}
|
||||
inline fun Activity.viewSwitcher(init: (@AnkoViewDslMarker _ViewSwitcher).() -> Unit): ViewSwitcher {
|
||||
return ankoView(`$$Anko$Factories$Sdk28ViewGroup`.VIEW_SWITCHER, theme = 0) { init() }
|
||||
}
|
||||
|
||||
fun Activity.themedViewSwitcher(theme: Int = 0): ViewSwitcher =
|
||||
themedViewSwitcher(theme) {}
|
||||
|
||||
inline fun Activity.themedViewSwitcher(
|
||||
theme: Int = 0,
|
||||
init: (@AnkoViewDslMarker _ViewSwitcher).() -> Unit,
|
||||
): ViewSwitcher {
|
||||
return ankoView(`$$Anko$Factories$Sdk28ViewGroup`.VIEW_SWITCHER, theme) { init() }
|
||||
}
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -1,152 +1,152 @@
|
|||
/*
|
||||
* Copyright 2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.anko.appcompat.v7
|
||||
|
||||
import android.content.Context
|
||||
import android.content.DialogInterface
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.view.KeyEvent
|
||||
import android.view.View
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import org.jetbrains.anko.AlertBuilder
|
||||
import org.jetbrains.anko.AlertBuilderFactory
|
||||
import org.jetbrains.anko.internals.AnkoInternals
|
||||
import org.jetbrains.anko.internals.AnkoInternals.NO_GETTER
|
||||
import kotlin.DeprecationLevel.ERROR
|
||||
|
||||
val Appcompat: AlertBuilderFactory<AlertDialog> = ::AppcompatAlertBuilder
|
||||
|
||||
internal class AppcompatAlertBuilder(override val ctx: Context) : AlertBuilder<AlertDialog> {
|
||||
private val builder = AlertDialog.Builder(ctx)
|
||||
|
||||
override var title: CharSequence
|
||||
@Deprecated(NO_GETTER, level = ERROR) get() = AnkoInternals.noGetter()
|
||||
set(value) {
|
||||
builder.setTitle(value)
|
||||
}
|
||||
|
||||
override var titleResource: Int
|
||||
@Deprecated(NO_GETTER, level = ERROR) get() = AnkoInternals.noGetter()
|
||||
set(value) {
|
||||
builder.setTitle(value)
|
||||
}
|
||||
|
||||
override var message: CharSequence
|
||||
@Deprecated(NO_GETTER, level = ERROR) get() = AnkoInternals.noGetter()
|
||||
set(value) {
|
||||
builder.setMessage(value)
|
||||
}
|
||||
|
||||
override var messageResource: Int
|
||||
@Deprecated(NO_GETTER, level = ERROR) get() = AnkoInternals.noGetter()
|
||||
set(value) {
|
||||
builder.setMessage(value)
|
||||
}
|
||||
|
||||
override var icon: Drawable
|
||||
@Deprecated(NO_GETTER, level = ERROR) get() = AnkoInternals.noGetter()
|
||||
set(value) {
|
||||
builder.setIcon(value)
|
||||
}
|
||||
|
||||
override var iconResource: Int
|
||||
@Deprecated(NO_GETTER, level = ERROR) get() = AnkoInternals.noGetter()
|
||||
set(value) {
|
||||
builder.setIcon(value)
|
||||
}
|
||||
|
||||
override var customTitle: View
|
||||
@Deprecated(NO_GETTER, level = ERROR) get() = AnkoInternals.noGetter()
|
||||
set(value) {
|
||||
builder.setCustomTitle(value)
|
||||
}
|
||||
|
||||
override var customView: View
|
||||
@Deprecated(NO_GETTER, level = ERROR) get() = AnkoInternals.noGetter()
|
||||
set(value) {
|
||||
builder.setView(value)
|
||||
}
|
||||
|
||||
override var isCancelable: Boolean
|
||||
@Deprecated(NO_GETTER, level = ERROR) get() = AnkoInternals.noGetter()
|
||||
set(value) {
|
||||
builder.setCancelable(value)
|
||||
}
|
||||
|
||||
override fun onCancelled(handler: (DialogInterface) -> Unit) {
|
||||
builder.setOnCancelListener(handler)
|
||||
}
|
||||
|
||||
override fun onKeyPressed(handler: (dialog: DialogInterface, keyCode: Int, e: KeyEvent) -> Boolean) {
|
||||
builder.setOnKeyListener(handler)
|
||||
}
|
||||
|
||||
override fun positiveButton(buttonText: String, onClicked: (dialog: DialogInterface) -> Unit) {
|
||||
builder.setPositiveButton(buttonText) { dialog, _ -> onClicked(dialog) }
|
||||
}
|
||||
|
||||
override fun positiveButton(
|
||||
buttonTextResource: Int,
|
||||
onClicked: (dialog: DialogInterface) -> Unit,
|
||||
) {
|
||||
builder.setPositiveButton(buttonTextResource) { dialog, _ -> onClicked(dialog) }
|
||||
}
|
||||
|
||||
override fun negativeButton(buttonText: String, onClicked: (dialog: DialogInterface) -> Unit) {
|
||||
builder.setNegativeButton(buttonText) { dialog, _ -> onClicked(dialog) }
|
||||
}
|
||||
|
||||
override fun negativeButton(
|
||||
buttonTextResource: Int,
|
||||
onClicked: (dialog: DialogInterface) -> Unit,
|
||||
) {
|
||||
builder.setNegativeButton(buttonTextResource) { dialog, _ -> onClicked(dialog) }
|
||||
}
|
||||
|
||||
override fun neutralPressed(buttonText: String, onClicked: (dialog: DialogInterface) -> Unit) {
|
||||
builder.setNeutralButton(buttonText) { dialog, _ -> onClicked(dialog) }
|
||||
}
|
||||
|
||||
override fun neutralPressed(
|
||||
buttonTextResource: Int,
|
||||
onClicked: (dialog: DialogInterface) -> Unit,
|
||||
) {
|
||||
builder.setNeutralButton(buttonTextResource) { dialog, _ -> onClicked(dialog) }
|
||||
}
|
||||
|
||||
override fun items(
|
||||
items: List<CharSequence>,
|
||||
onItemSelected: (dialog: DialogInterface, index: Int) -> Unit,
|
||||
) {
|
||||
builder.setItems(Array(items.size) { i -> items[i].toString() }) { dialog, which ->
|
||||
onItemSelected(dialog, which)
|
||||
}
|
||||
}
|
||||
|
||||
override fun <T> items(
|
||||
items: List<T>,
|
||||
onItemSelected: (dialog: DialogInterface, item: T, index: Int) -> Unit,
|
||||
) {
|
||||
builder.setItems(Array(items.size) { i -> items[i].toString() }) { dialog, which ->
|
||||
onItemSelected(dialog, items[which], which)
|
||||
}
|
||||
}
|
||||
|
||||
override fun build(): AlertDialog = builder.create()
|
||||
|
||||
override fun show(): AlertDialog = builder.show()
|
||||
}
|
||||
///*
|
||||
// * Copyright 2016 JetBrains s.r.o.
|
||||
// *
|
||||
// * Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// * you may not use this file except in compliance with the License.
|
||||
// * You may obtain a copy of the License at
|
||||
// *
|
||||
// * http://www.apache.org/licenses/LICENSE-2.0
|
||||
// *
|
||||
// * Unless required by applicable law or agreed to in writing, software
|
||||
// * distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// * See the License for the specific language governing permissions and
|
||||
// * limitations under the License.
|
||||
// */
|
||||
//
|
||||
//package org.jetbrains.anko.appcompat.v7
|
||||
//
|
||||
//import android.content.Context
|
||||
//import android.content.DialogInterface
|
||||
//import android.graphics.drawable.Drawable
|
||||
//import android.view.KeyEvent
|
||||
//import android.view.View
|
||||
//import androidx.appcompat.app.AlertDialog
|
||||
//import org.jetbrains.anko.AlertBuilder
|
||||
//import org.jetbrains.anko.AlertBuilderFactory
|
||||
//import org.jetbrains.anko.internals.AnkoInternals
|
||||
//import org.jetbrains.anko.internals.AnkoInternals.NO_GETTER
|
||||
//import kotlin.DeprecationLevel.ERROR
|
||||
//
|
||||
//val Appcompat: AlertBuilderFactory<AlertDialog> = ::AppcompatAlertBuilder
|
||||
//
|
||||
//internal class AppcompatAlertBuilder(override val ctx: Context) : AlertBuilder<AlertDialog> {
|
||||
// private val builder = AlertDialog.Builder(ctx)
|
||||
//
|
||||
// override var title: CharSequence
|
||||
// @Deprecated(NO_GETTER, level = ERROR) get() = AnkoInternals.noGetter()
|
||||
// set(value) {
|
||||
// builder.setTitle(value)
|
||||
// }
|
||||
//
|
||||
// override var titleResource: Int
|
||||
// @Deprecated(NO_GETTER, level = ERROR) get() = AnkoInternals.noGetter()
|
||||
// set(value) {
|
||||
// builder.setTitle(value)
|
||||
// }
|
||||
//
|
||||
// override var message: CharSequence
|
||||
// @Deprecated(NO_GETTER, level = ERROR) get() = AnkoInternals.noGetter()
|
||||
// set(value) {
|
||||
// builder.setMessage(value)
|
||||
// }
|
||||
//
|
||||
// override var messageResource: Int
|
||||
// @Deprecated(NO_GETTER, level = ERROR) get() = AnkoInternals.noGetter()
|
||||
// set(value) {
|
||||
// builder.setMessage(value)
|
||||
// }
|
||||
//
|
||||
// override var icon: Drawable
|
||||
// @Deprecated(NO_GETTER, level = ERROR) get() = AnkoInternals.noGetter()
|
||||
// set(value) {
|
||||
// builder.setIcon(value)
|
||||
// }
|
||||
//
|
||||
// override var iconResource: Int
|
||||
// @Deprecated(NO_GETTER, level = ERROR) get() = AnkoInternals.noGetter()
|
||||
// set(value) {
|
||||
// builder.setIcon(value)
|
||||
// }
|
||||
//
|
||||
// override var customTitle: View
|
||||
// @Deprecated(NO_GETTER, level = ERROR) get() = AnkoInternals.noGetter()
|
||||
// set(value) {
|
||||
// builder.setCustomTitle(value)
|
||||
// }
|
||||
//
|
||||
// override var customView: View
|
||||
// @Deprecated(NO_GETTER, level = ERROR) get() = AnkoInternals.noGetter()
|
||||
// set(value) {
|
||||
// builder.setView(value)
|
||||
// }
|
||||
//
|
||||
// override var isCancelable: Boolean
|
||||
// @Deprecated(NO_GETTER, level = ERROR) get() = AnkoInternals.noGetter()
|
||||
// set(value) {
|
||||
// builder.setCancelable(value)
|
||||
// }
|
||||
//
|
||||
// override fun onCancelled(handler: (DialogInterface) -> Unit) {
|
||||
// builder.setOnCancelListener(handler)
|
||||
// }
|
||||
//
|
||||
// override fun onKeyPressed(handler: (dialog: DialogInterface, keyCode: Int, e: KeyEvent) -> Boolean) {
|
||||
// builder.setOnKeyListener(handler)
|
||||
// }
|
||||
//
|
||||
// override fun positiveButton(buttonText: String, onClicked: (dialog: DialogInterface) -> Unit) {
|
||||
// builder.setPositiveButton(buttonText) { dialog, _ -> onClicked(dialog) }
|
||||
// }
|
||||
//
|
||||
// override fun positiveButton(
|
||||
// buttonTextResource: Int,
|
||||
// onClicked: (dialog: DialogInterface) -> Unit,
|
||||
// ) {
|
||||
// builder.setPositiveButton(buttonTextResource) { dialog, _ -> onClicked(dialog) }
|
||||
// }
|
||||
//
|
||||
// override fun negativeButton(buttonText: String, onClicked: (dialog: DialogInterface) -> Unit) {
|
||||
// builder.setNegativeButton(buttonText) { dialog, _ -> onClicked(dialog) }
|
||||
// }
|
||||
//
|
||||
// override fun negativeButton(
|
||||
// buttonTextResource: Int,
|
||||
// onClicked: (dialog: DialogInterface) -> Unit,
|
||||
// ) {
|
||||
// builder.setNegativeButton(buttonTextResource) { dialog, _ -> onClicked(dialog) }
|
||||
// }
|
||||
//
|
||||
// override fun neutralPressed(buttonText: String, onClicked: (dialog: DialogInterface) -> Unit) {
|
||||
// builder.setNeutralButton(buttonText) { dialog, _ -> onClicked(dialog) }
|
||||
// }
|
||||
//
|
||||
// override fun neutralPressed(
|
||||
// buttonTextResource: Int,
|
||||
// onClicked: (dialog: DialogInterface) -> Unit,
|
||||
// ) {
|
||||
// builder.setNeutralButton(buttonTextResource) { dialog, _ -> onClicked(dialog) }
|
||||
// }
|
||||
//
|
||||
// override fun items(
|
||||
// items: List<CharSequence>,
|
||||
// onItemSelected: (dialog: DialogInterface, index: Int) -> Unit,
|
||||
// ) {
|
||||
// builder.setItems(Array(items.size) { i -> items[i].toString() }) { dialog, which ->
|
||||
// onItemSelected(dialog, which)
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// override fun <T> items(
|
||||
// items: List<T>,
|
||||
// onItemSelected: (dialog: DialogInterface, item: T, index: Int) -> Unit,
|
||||
// ) {
|
||||
// builder.setItems(Array(items.size) { i -> items[i].toString() }) { dialog, which ->
|
||||
// onItemSelected(dialog, items[which], which)
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// override fun build(): AlertDialog = builder.create()
|
||||
//
|
||||
// override fun show(): AlertDialog = builder.show()
|
||||
//}
|
||||
|
|
|
@ -1,93 +1,93 @@
|
|||
/*
|
||||
* Copyright 2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
@file:Suppress("unused", "NOTHING_TO_INLINE")
|
||||
package org.jetbrains.anko
|
||||
|
||||
import android.graphics.Typeface
|
||||
import android.text.SpannableStringBuilder
|
||||
import android.text.Spanned
|
||||
import android.text.style.BackgroundColorSpan
|
||||
import android.text.style.ClickableSpan
|
||||
import android.text.style.ForegroundColorSpan
|
||||
import android.text.style.StrikethroughSpan
|
||||
import android.text.style.StyleSpan
|
||||
import android.text.style.URLSpan
|
||||
import android.text.style.UnderlineSpan
|
||||
import android.view.View
|
||||
|
||||
inline fun buildSpanned(f: SpannableStringBuilder.() -> Unit): Spanned =
|
||||
SpannableStringBuilder().apply(f)
|
||||
|
||||
inline val SpannableStringBuilder.Bold: StyleSpan
|
||||
get() = StyleSpan(Typeface.BOLD)
|
||||
|
||||
inline val SpannableStringBuilder.Italic: StyleSpan
|
||||
get() = StyleSpan(Typeface.ITALIC)
|
||||
|
||||
inline val SpannableStringBuilder.Underline: UnderlineSpan
|
||||
get() = UnderlineSpan()
|
||||
|
||||
inline val SpannableStringBuilder.Strikethrough: StrikethroughSpan
|
||||
get() = StrikethroughSpan()
|
||||
|
||||
inline fun SpannableStringBuilder.foregroundColor(color: Int): ForegroundColorSpan =
|
||||
ForegroundColorSpan(color)
|
||||
|
||||
inline fun SpannableStringBuilder.backgroundColor(color: Int): BackgroundColorSpan =
|
||||
BackgroundColorSpan(color)
|
||||
|
||||
inline fun SpannableStringBuilder.clickable(crossinline onClick: (View) -> Unit): ClickableSpan {
|
||||
return object : ClickableSpan() {
|
||||
override fun onClick(widget: View) {
|
||||
onClick(widget)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
inline fun SpannableStringBuilder.link(url: String): URLSpan {
|
||||
return URLSpan(url)
|
||||
}
|
||||
|
||||
fun SpannableStringBuilder.append(text: CharSequence, vararg spans: Any) {
|
||||
val textLength = text.length
|
||||
append(text)
|
||||
spans.forEach { span ->
|
||||
setSpan(span, this.length - textLength, length, Spanned.SPAN_INCLUSIVE_EXCLUSIVE)
|
||||
}
|
||||
}
|
||||
|
||||
fun SpannableStringBuilder.append(text: CharSequence, span: Any) {
|
||||
val textLength = text.length
|
||||
append(text)
|
||||
setSpan(span, this.length - textLength, length, Spanned.SPAN_INCLUSIVE_EXCLUSIVE)
|
||||
}
|
||||
|
||||
inline fun SpannableStringBuilder.append(span: Any, f: SpannableStringBuilder.() -> Unit) = apply {
|
||||
val start = length
|
||||
f()
|
||||
setSpan(span, start, length, Spanned.SPAN_INCLUSIVE_EXCLUSIVE)
|
||||
}
|
||||
|
||||
inline fun SpannableStringBuilder.appendln(text: CharSequence, vararg spans: Any) {
|
||||
append(text, *spans)
|
||||
appendln()
|
||||
}
|
||||
|
||||
inline fun SpannableStringBuilder.appendln(text: CharSequence, span: Any) {
|
||||
append(text, span)
|
||||
appendln()
|
||||
}
|
||||
///*
|
||||
// * Copyright 2016 JetBrains s.r.o.
|
||||
// *
|
||||
// * Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// * you may not use this file except in compliance with the License.
|
||||
// * You may obtain a copy of the License at
|
||||
// *
|
||||
// * http://www.apache.org/licenses/LICENSE-2.0
|
||||
// *
|
||||
// * Unless required by applicable law or agreed to in writing, software
|
||||
// * distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// * See the License for the specific language governing permissions and
|
||||
// * limitations under the License.
|
||||
// */
|
||||
//
|
||||
//@file:Suppress("unused", "NOTHING_TO_INLINE")
|
||||
//package org.jetbrains.anko
|
||||
//
|
||||
//import android.graphics.Typeface
|
||||
//import android.text.SpannableStringBuilder
|
||||
//import android.text.Spanned
|
||||
//import android.text.style.BackgroundColorSpan
|
||||
//import android.text.style.ClickableSpan
|
||||
//import android.text.style.ForegroundColorSpan
|
||||
//import android.text.style.StrikethroughSpan
|
||||
//import android.text.style.StyleSpan
|
||||
//import android.text.style.URLSpan
|
||||
//import android.text.style.UnderlineSpan
|
||||
//import android.view.View
|
||||
//
|
||||
//inline fun buildSpanned(f: SpannableStringBuilder.() -> Unit): Spanned =
|
||||
// SpannableStringBuilder().apply(f)
|
||||
//
|
||||
//inline val SpannableStringBuilder.Bold: StyleSpan
|
||||
// get() = StyleSpan(Typeface.BOLD)
|
||||
//
|
||||
//inline val SpannableStringBuilder.Italic: StyleSpan
|
||||
// get() = StyleSpan(Typeface.ITALIC)
|
||||
//
|
||||
//inline val SpannableStringBuilder.Underline: UnderlineSpan
|
||||
// get() = UnderlineSpan()
|
||||
//
|
||||
//inline val SpannableStringBuilder.Strikethrough: StrikethroughSpan
|
||||
// get() = StrikethroughSpan()
|
||||
//
|
||||
//inline fun SpannableStringBuilder.foregroundColor(color: Int): ForegroundColorSpan =
|
||||
// ForegroundColorSpan(color)
|
||||
//
|
||||
//inline fun SpannableStringBuilder.backgroundColor(color: Int): BackgroundColorSpan =
|
||||
// BackgroundColorSpan(color)
|
||||
//
|
||||
//inline fun SpannableStringBuilder.clickable(crossinline onClick: (View) -> Unit): ClickableSpan {
|
||||
// return object : ClickableSpan() {
|
||||
// override fun onClick(widget: View) {
|
||||
// onClick(widget)
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//inline fun SpannableStringBuilder.link(url: String): URLSpan {
|
||||
// return URLSpan(url)
|
||||
//}
|
||||
//
|
||||
//fun SpannableStringBuilder.append(text: CharSequence, vararg spans: Any) {
|
||||
// val textLength = text.length
|
||||
// append(text)
|
||||
// spans.forEach { span ->
|
||||
// setSpan(span, this.length - textLength, length, Spanned.SPAN_INCLUSIVE_EXCLUSIVE)
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//fun SpannableStringBuilder.append(text: CharSequence, span: Any) {
|
||||
// val textLength = text.length
|
||||
// append(text)
|
||||
// setSpan(span, this.length - textLength, length, Spanned.SPAN_INCLUSIVE_EXCLUSIVE)
|
||||
//}
|
||||
//
|
||||
//inline fun SpannableStringBuilder.append(span: Any, f: SpannableStringBuilder.() -> Unit) = apply {
|
||||
// val start = length
|
||||
// f()
|
||||
// setSpan(span, start, length, Spanned.SPAN_INCLUSIVE_EXCLUSIVE)
|
||||
//}
|
||||
//
|
||||
//inline fun SpannableStringBuilder.appendln(text: CharSequence, vararg spans: Any) {
|
||||
// append(text, *spans)
|
||||
// appendln()
|
||||
//}
|
||||
//
|
||||
//inline fun SpannableStringBuilder.appendln(text: CharSequence, span: Any) {
|
||||
// append(text, span)
|
||||
// appendln()
|
||||
//}
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
@file:Suppress("unused", "NOTHING_TO_INLINE")
|
||||
package org.jetbrains.anko.collections
|
||||
|
||||
/**
|
||||
|
@ -66,19 +65,3 @@ inline fun <T> List<T>.forEachReversedWithIndex(f: (Int, T) -> Unit) {
|
|||
i--
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the Android pair to a Kotlin one.
|
||||
*
|
||||
* @see [toAndroidPair].
|
||||
*/
|
||||
@Deprecated(message = "Use the Android KTX version", replaceWith = ReplaceWith("toKotlinPair()", "androidx.core.util.toKotlinPair"))
|
||||
inline fun <F, S> android.util.Pair<F, S>.toKotlinPair(): Pair<F, S> = first to second
|
||||
|
||||
/**
|
||||
* Convert the Kotlin pair to an Android one.
|
||||
*
|
||||
* @see [toKotlinPair].
|
||||
*/
|
||||
@Deprecated(message = "Use the Android KTX version", replaceWith = ReplaceWith("toAndroidPair()", "androidx.core.util.toAndroidPair"))
|
||||
inline fun <F, S> Pair<F, S>.toAndroidPair(): android.util.Pair<F, S> = android.util.Pair(first, second)
|
||||
|
|
|
@ -1,64 +0,0 @@
|
|||
/*
|
||||
* Copyright 2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.anko.collections
|
||||
|
||||
import android.util.SparseArray
|
||||
import android.util.SparseBooleanArray
|
||||
import android.util.SparseIntArray
|
||||
import java.util.ConcurrentModificationException
|
||||
|
||||
/**
|
||||
* Iterate the receiver [SparseArray]
|
||||
* @action an action to invoke on each key value pair
|
||||
* @throws [ConcurrentModificationException] if modified while iterating
|
||||
*/
|
||||
@Deprecated(message = "Use the Android KTX version", replaceWith = ReplaceWith("forEach(action)", "androidx.core.util.forEach"))
|
||||
inline fun <E> SparseArray<E>.forEach(action: (Int, E) -> Unit) {
|
||||
val size = this.size()
|
||||
for (i in 0..size - 1) {
|
||||
if (size != this.size()) throw ConcurrentModificationException()
|
||||
action(this.keyAt(i), this.valueAt(i))
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Iterate the receiver [SparseBooleanArray]
|
||||
* @action an action to invoke on each key value pair
|
||||
* @throws [ConcurrentModificationException] if modified while iterating
|
||||
*/
|
||||
@Deprecated(message = "Use the Android KTX version", replaceWith = ReplaceWith("forEach(action)", "androidx.core.util.forEach"))
|
||||
inline fun SparseBooleanArray.forEach(action: (Int, Boolean) -> Unit) {
|
||||
val size = this.size()
|
||||
for (i in 0..size - 1) {
|
||||
if (size != this.size()) throw ConcurrentModificationException()
|
||||
action(this.keyAt(i), this.valueAt(i))
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Iterate the receiver [SparseIntArray]
|
||||
* @action an action to invoke on each key value pair
|
||||
* @throws [ConcurrentModificationException] if modified while iterating
|
||||
*/
|
||||
@Deprecated(message = "Use the Android KTX version", replaceWith = ReplaceWith("forEach(action)", "androidx.core.util.forEach"))
|
||||
inline fun SparseIntArray.forEach(action: (Int, Int) -> Unit) {
|
||||
val size = this.size()
|
||||
for (i in 0..size - 1) {
|
||||
if (size != this.size()) throw ConcurrentModificationException()
|
||||
action(this.keyAt(i), this.valueAt(i))
|
||||
}
|
||||
}
|
|
@ -14,7 +14,6 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
@file:Suppress("unused")
|
||||
|
||||
package org.jetbrains.anko.custom
|
||||
|
||||
|
@ -67,4 +66,4 @@ inline fun <reified T : View> Context.customView(theme: Int = 0, init: T.() -> U
|
|||
ankoView({ ctx -> AnkoInternals.initiateView(ctx, T::class.java) }, theme) { init() }
|
||||
|
||||
inline fun <reified T : View> Activity.customView(theme: Int = 0, init: T.() -> Unit): T =
|
||||
ankoView({ ctx -> AnkoInternals.initiateView(ctx, T::class.java) }, theme) { init() }
|
||||
ankoView({ ctx -> AnkoInternals.initiateView(ctx, T::class.java) }, theme) { init() }
|
||||
|
|
|
@ -1,94 +0,0 @@
|
|||
/*
|
||||
* Copyright 2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
@file:Suppress("unused")
|
||||
|
||||
package org.jetbrains.anko.custom
|
||||
|
||||
import android.content.Context
|
||||
import android.view.View
|
||||
import androidx.fragment.app.Fragment
|
||||
import org.jetbrains.anko.AnkoAsyncContext
|
||||
import org.jetbrains.anko.BackgroundExecutor
|
||||
import org.jetbrains.anko.applyRecursively
|
||||
import org.jetbrains.anko.collections.forEachReversedByIndex
|
||||
import org.jetbrains.anko.runOnUiThread
|
||||
import java.lang.ref.WeakReference
|
||||
import java.util.concurrent.ExecutorService
|
||||
import java.util.concurrent.Future
|
||||
|
||||
@Deprecated(
|
||||
"Use forEachReversedByIndex(f) instead.",
|
||||
ReplaceWith(
|
||||
"forEachReversedByIndex(f)",
|
||||
"org.jetbrains.anko.collections.forEachReversedByIndex"
|
||||
)
|
||||
)
|
||||
inline fun <T> Array<T>.forEachReversed(f: (T) -> Unit) = forEachReversedByIndex(f)
|
||||
|
||||
@Deprecated(
|
||||
"Use forEachReversedByIndex(f) instead.",
|
||||
ReplaceWith(
|
||||
"forEachReversedByIndex(f)",
|
||||
"org.jetbrains.anko.collections.forEachReversedByIndex"
|
||||
)
|
||||
)
|
||||
inline fun <T> List<T>.forEachReversed(f: (T) -> Unit) = forEachReversedByIndex(f)
|
||||
|
||||
@Deprecated("Use runOnUiThread(f) instead.", ReplaceWith("runOnUiThread(f)"))
|
||||
inline fun Fragment.onUiThread(crossinline f: () -> Unit) = runOnUiThread(f)
|
||||
|
||||
@Deprecated("Use runOnUiThread(f) instead.", ReplaceWith("runOnUiThread(f)"))
|
||||
fun Context.onUiThread(f: Context.() -> Unit) = runOnUiThread(f)
|
||||
|
||||
@Deprecated("Use doAsync(task) instead.", ReplaceWith("doAsync(task)"))
|
||||
fun <T> T.async(task: AnkoAsyncContext<T>.() -> Unit): Future<Unit> {
|
||||
val context = AnkoAsyncContext(WeakReference(this))
|
||||
return BackgroundExecutor.submit { context.task() }
|
||||
}
|
||||
|
||||
@Deprecated(
|
||||
"Use doAsync(executorService, task) instead.",
|
||||
ReplaceWith("doAsync(executorService, task)")
|
||||
)
|
||||
fun <T> T.async(
|
||||
executorService: ExecutorService,
|
||||
task: AnkoAsyncContext<T>.() -> Unit,
|
||||
): Future<Unit> {
|
||||
val context = AnkoAsyncContext(WeakReference(this))
|
||||
return executorService.submit<Unit> { context.task() }
|
||||
}
|
||||
|
||||
@Deprecated("Use doAsyncResult(task) instead.", ReplaceWith("doAsyncResult(task)"))
|
||||
fun <T, R> T.asyncResult(task: AnkoAsyncContext<T>.() -> R): Future<R> {
|
||||
val context = AnkoAsyncContext(WeakReference(this))
|
||||
return BackgroundExecutor.submit { context.task() }
|
||||
}
|
||||
|
||||
@Deprecated(
|
||||
"Use doAsyncResult(executorService, task) instead.",
|
||||
ReplaceWith("doAsyncResult(executorService, task)")
|
||||
)
|
||||
fun <T, R> T.asyncResult(
|
||||
executorService: ExecutorService,
|
||||
task: AnkoAsyncContext<T>.() -> R,
|
||||
): Future<R> {
|
||||
val context = AnkoAsyncContext(WeakReference(this))
|
||||
return executorService.submit<R> { context.task() }
|
||||
}
|
||||
|
||||
@Deprecated("Use applyRecursively(block) instead.", ReplaceWith("applyRecursively(style)"))
|
||||
fun <T : View> T.style(style: (View) -> Unit): T = applyRecursively(style)
|
|
@ -1,51 +0,0 @@
|
|||
/*
|
||||
* Copyright 2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
@file:Suppress("unused")
|
||||
package org.jetbrains.anko
|
||||
|
||||
import android.view.Menu
|
||||
import android.view.MenuItem
|
||||
import java.util.ConcurrentModificationException
|
||||
import java.util.NoSuchElementException
|
||||
|
||||
@Deprecated(message = "Use the Android KTX version", replaceWith = ReplaceWith("children", "androidx.core.view.children"))
|
||||
fun Menu.itemsSequence(): Sequence<MenuItem> = MenuItemsSequence(this)
|
||||
|
||||
private class MenuItemsSequence(private val menu: Menu) : Sequence<MenuItem> {
|
||||
override fun iterator(): Iterator<MenuItem> = MenuItemIterator(menu)
|
||||
|
||||
private class MenuItemIterator(private val menu: Menu) : Iterator<MenuItem> {
|
||||
private var index = 0
|
||||
private val count = menu.size()
|
||||
|
||||
override fun next(): MenuItem {
|
||||
if (!hasNext()) {
|
||||
throw NoSuchElementException()
|
||||
}
|
||||
|
||||
return menu.getItem(index++)
|
||||
}
|
||||
|
||||
override fun hasNext(): Boolean {
|
||||
if (count != menu.size()) {
|
||||
throw ConcurrentModificationException()
|
||||
}
|
||||
|
||||
return index < count
|
||||
}
|
||||
}
|
||||
}
|
|
@ -13,43 +13,11 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
@file:Suppress("unused")
|
||||
|
||||
package org.jetbrains.anko
|
||||
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
|
||||
/**
|
||||
* Execute [action] for each child of the received [ViewGroup].
|
||||
*
|
||||
* @param action the action to execute.
|
||||
*/
|
||||
@Deprecated(
|
||||
message = "Use the Android KTX version",
|
||||
replaceWith = ReplaceWith("forEach(action)", "androidx.core.view.forEach")
|
||||
)
|
||||
inline fun ViewGroup.forEachChild(action: (View) -> Unit) {
|
||||
for (i in 0..childCount - 1) {
|
||||
action(getChildAt(i))
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute [action] for each child of the received [ViewGroup].
|
||||
*
|
||||
* @param action the action to execute. The first index is 0.
|
||||
*/
|
||||
@Deprecated(
|
||||
message = "Use the Android KTX version",
|
||||
replaceWith = ReplaceWith("forEachIndexed(action)", "androidx.core.view.forEachIndexed")
|
||||
)
|
||||
inline fun ViewGroup.forEachChildWithIndex(action: (Int, View) -> Unit) {
|
||||
for (i in 0..childCount - 1) {
|
||||
action(i, getChildAt(i))
|
||||
}
|
||||
}
|
||||
import androidx.core.view.children
|
||||
|
||||
/**
|
||||
* Return the first child [View] matching the given [predicate].
|
||||
|
@ -70,7 +38,7 @@ inline fun ViewGroup.firstChild(predicate: (View) -> Boolean): View {
|
|||
* @return the child [View] that matches [predicate], or null if no such child was found.
|
||||
*/
|
||||
inline fun ViewGroup.firstChildOrNull(predicate: (View) -> Boolean): View? {
|
||||
for (i in 0..childCount - 1) {
|
||||
for (i in 0 until childCount) {
|
||||
val child = getChildAt(i)
|
||||
if (predicate(child)) {
|
||||
return child
|
||||
|
@ -79,18 +47,6 @@ inline fun ViewGroup.firstChildOrNull(predicate: (View) -> Boolean): View? {
|
|||
return null
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the sequence of children of the received [View].
|
||||
* Note that the sequence is not thread-safe.
|
||||
*
|
||||
* @return the [Sequence] of children.
|
||||
*/
|
||||
@Deprecated(
|
||||
message = "Use the Android KTX version",
|
||||
replaceWith = ReplaceWith("children", "androidx.core.view.children")
|
||||
)
|
||||
fun View.childrenSequence(): Sequence<View> = ViewChildrenSequence(this)
|
||||
|
||||
/**
|
||||
* Return the [Sequence] of all children of the received [View], recursively.
|
||||
* Note that the sequence is not thread-safe.
|
||||
|
@ -132,14 +88,15 @@ private class ViewChildrenRecursiveSequence(private val view: View) : Sequence<V
|
|||
}
|
||||
|
||||
private class RecursiveViewIterator(view: View) : Iterator<View> {
|
||||
private val sequences = arrayListOf(view.childrenSequence())
|
||||
|
||||
private val sequences = arrayListOf((view as? ViewGroup)?.children ?: sequenceOf(view))
|
||||
private var current = sequences.removeLast().iterator()
|
||||
|
||||
override fun next(): View {
|
||||
if (!hasNext()) throw NoSuchElementException()
|
||||
val view = current.next()
|
||||
if (view is ViewGroup && view.childCount > 0) {
|
||||
sequences.add(view.childrenSequence())
|
||||
sequences.add(view.children)
|
||||
}
|
||||
return view
|
||||
}
|
||||
|
|
|
@ -58,14 +58,17 @@ android {
|
|||
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled false
|
||||
shrinkResources false
|
||||
minifyEnabled true
|
||||
shrinkResources true
|
||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||
|
||||
lintOptions {
|
||||
disable 'MissingTranslation'
|
||||
}
|
||||
}
|
||||
debug{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// Specifies comma-separated list of flavor dimensions.
|
||||
|
@ -137,7 +140,8 @@ dependencies {
|
|||
implementation project(':anko')
|
||||
implementation fileTree(include: ['*.aar'], dir: 'src/main/libs')
|
||||
|
||||
implementation "org.conscrypt:conscrypt-openjdk-uber:$conscryptVersion"
|
||||
// implementation "org.conscrypt:conscrypt-android:$conscryptVersion"
|
||||
api "org.conscrypt:conscrypt-android:$conscryptVersion"
|
||||
|
||||
kapt "androidx.annotation:annotation:$androidxAnnotationVersion"
|
||||
kapt "androidx.room:room-compiler:$roomVersion"
|
||||
|
|
|
@ -41,7 +41,7 @@
|
|||
-dontobfuscate
|
||||
|
||||
-keepattributes *Annotation*, InnerClasses
|
||||
-dontnote kotlinx.serialization.AnnotationsKt # core serialization annotations
|
||||
#-dontnote kotlinx.serialization.AnnotationsKt # core serialization annotations
|
||||
|
||||
# kotlinx-serialization-json specific. Add this if you have java.lang.NoClassDefFoundError kotlinx.serialization.json.JsonObjectSerializer
|
||||
-keepclassmembers class kotlinx.serialization.json.** {
|
||||
|
@ -59,3 +59,7 @@
|
|||
-keepclasseswithmembers class jp.juggler.subwaytooter.** {
|
||||
kotlinx.serialization.KSerializer serializer(...);
|
||||
}
|
||||
|
||||
# keep everything
|
||||
-keep class ** { *; }
|
||||
-keepclassmembers class ** { *** Companion; }
|
||||
|
|
|
@ -94,7 +94,7 @@ dependencies {
|
|||
api "commons-codec:commons-codec:1.15"
|
||||
api "io.github.inflationx:calligraphy3:3.1.1"
|
||||
api "io.github.inflationx:viewpump:2.0.3"
|
||||
api "org.bouncycastle:bcpkix-jdk15on:1.70"
|
||||
api "org.bouncycastle:bcprov-jdk15on:1.70"
|
||||
api "org.jetbrains.kotlin:kotlin-reflect:$kotlinVersion"
|
||||
api "org.jetbrains.kotlinx:kotlinx-coroutines-android:$kotlinxCoroutinesVersion"
|
||||
api "org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlinxCoroutinesVersion"
|
||||
|
@ -151,6 +151,5 @@ dependencies {
|
|||
// conscrypt をUnitテストするための指定
|
||||
// https://github.com/google/conscrypt/issues/649
|
||||
|
||||
compileOnly "org.conscrypt:conscrypt-openjdk-uber:$conscryptVersion"
|
||||
testImplementation "org.conscrypt:conscrypt-openjdk-uber:$conscryptVersion"
|
||||
api "org.conscrypt:conscrypt-android:$conscryptVersion"
|
||||
}
|
||||
|
|
|
@ -1,14 +1,17 @@
|
|||
package jp.juggler
|
||||
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import jp.juggler.crypt.*
|
||||
import jp.juggler.util.data.decodeBase64
|
||||
import jp.juggler.util.data.decodeJsonObject
|
||||
import jp.juggler.util.log.AdbLog
|
||||
import org.junit.Assert.*
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import java.security.interfaces.ECPrivateKey
|
||||
|
||||
@Suppress("SpellCheckingInspection")
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
class WebPushCryptTest {
|
||||
|
||||
// https://developers.google.com/web/updates/2016/03/web-push-encryption
|
|
@ -12,6 +12,7 @@ import java.security.spec.ECGenParameterSpec
|
|||
import java.security.spec.ECPrivateKeySpec
|
||||
import java.security.spec.ECPublicKeySpec
|
||||
import java.security.spec.PKCS8EncodedKeySpec
|
||||
import java.util.*
|
||||
import javax.crypto.KeyAgreement
|
||||
import javax.crypto.Mac
|
||||
import javax.crypto.spec.SecretKeySpec
|
||||
|
|
Loading…
Reference in New Issue