remove some explicit callback invoke calls

This commit is contained in:
tibbi 2017-10-19 20:44:10 +02:00
parent 2030221df1
commit eb2eca8996
8 changed files with 12 additions and 12 deletions

View file

@ -117,7 +117,7 @@ class ColorPickerDialog(val context: Context, color: Int, val callback: (color:
val textColor = context.baseConfig.textColor
AlertDialog.Builder(context)
.setPositiveButton(R.string.ok, { dialog, which -> callback.invoke(getColor()) })
.setPositiveButton(R.string.ok, { dialog, which -> callback(getColor()) })
.setNegativeButton(R.string.cancel, null)
.create().apply {
context.setupDialogStuff(view, this)

View file

@ -38,6 +38,6 @@ class ConfirmationDialog(val context: Context, message: String = "", messageId:
private fun dialogConfirmed() {
dialog.dismiss()
callback.invoke()
callback()
}
}

View file

@ -56,7 +56,7 @@ class CreateNewFolderDialog(val activity: BaseSimpleActivity, val path: String,
}
private fun sendSuccess(alertDialog: AlertDialog, file: File) {
callback.invoke(file.absolutePath.trimEnd('/'))
callback(file.absolutePath.trimEnd('/'))
alertDialog.dismiss()
}
}

View file

@ -21,7 +21,6 @@ import com.simplemobiletools.commons.views.Breadcrumbs
import kotlinx.android.synthetic.main.dialog_filepicker.view.*
import java.io.File
import java.util.*
import kotlin.comparisons.compareBy
/**
* The only filepicker constructor with a couple optional parameters
@ -110,7 +109,7 @@ class FilePickerDialog(val activity: BaseSimpleActivity,
private fun createNewFolder() {
CreateNewFolderDialog(activity, currPath) {
callback.invoke(it.trimEnd('/'))
callback(it.trimEnd('/'))
mDialog.dismiss()
}
}
@ -163,7 +162,7 @@ class FilePickerDialog(val activity: BaseSimpleActivity,
}
private fun sendSuccess() {
callback.invoke(if (currPath.length == 1) currPath else currPath.trimEnd('/'))
callback(if (currPath.length == 1) currPath else currPath.trimEnd('/'))
mDialog.dismiss()
}

View file

@ -56,7 +56,7 @@ class RadioGroupDialog(val activity: Activity, val items: ArrayList<RadioItem>,
override fun onCheckedChanged(group: RadioGroup?, checkedId: Int) {
if (wasInit) {
callback.invoke(items[checkedId].value)
callback(items[checkedId].value)
dialog.dismiss()
}
}

View file

@ -63,16 +63,16 @@ class StoragePickerDialog(val context: Context, currPath: String, val callback:
private fun internalPicked() {
mDialog.dismiss()
callback.invoke(context.internalStoragePath)
callback(context.internalStoragePath)
}
private fun sdPicked() {
mDialog.dismiss()
callback.invoke(context.sdCardPath)
callback(context.sdCardPath)
}
private fun rootPicked() {
mDialog.dismiss()
callback.invoke("/")
callback("/")
}
}

View file

@ -30,6 +30,6 @@ class WritePermissionDialog(context: Context, val callback: () -> Unit) {
private fun dialogConfirmed() {
dialog.dismiss()
callback.invoke()
callback()
}
}

View file

@ -152,8 +152,9 @@ fun Context.rescanPaths(paths: ArrayList<String>, action: () -> Unit) {
var cnt = paths.size
val realAction = WeakReference<() -> Unit>(action)
MediaScannerConnection.scanFile(applicationContext, paths.toTypedArray(), null, { s, uri ->
if (--cnt == 0)
if (--cnt == 0) {
realAction.get()?.invoke()
}
})
}