/* * 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 Array.forEachReversed(f: (T) -> Unit) = forEachReversedByIndex(f) @Deprecated( "Use forEachReversedByIndex(f) instead.", ReplaceWith( "forEachReversedByIndex(f)", "org.jetbrains.anko.collections.forEachReversedByIndex" ) ) inline fun List.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.async(task: AnkoAsyncContext.() -> Unit): Future { val context = AnkoAsyncContext(WeakReference(this)) return BackgroundExecutor.submit { context.task() } } @Deprecated( "Use doAsync(executorService, task) instead.", ReplaceWith("doAsync(executorService, task)") ) fun T.async( executorService: ExecutorService, task: AnkoAsyncContext.() -> Unit, ): Future { val context = AnkoAsyncContext(WeakReference(this)) return executorService.submit { context.task() } } @Deprecated("Use doAsyncResult(task) instead.", ReplaceWith("doAsyncResult(task)")) fun T.asyncResult(task: AnkoAsyncContext.() -> R): Future { val context = AnkoAsyncContext(WeakReference(this)) return BackgroundExecutor.submit { context.task() } } @Deprecated( "Use doAsyncResult(executorService, task) instead.", ReplaceWith("doAsyncResult(executorService, task)") ) fun T.asyncResult( executorService: ExecutorService, task: AnkoAsyncContext.() -> R, ): Future { val context = AnkoAsyncContext(WeakReference(this)) return executorService.submit { context.task() } } @Deprecated("Use applyRecursively(block) instead.", ReplaceWith("applyRecursively(style)")) fun T.style(style: (View) -> Unit): T = applyRecursively(style)