mirror of
https://github.com/SimpleMobileTools/Simple-App-Launcher.git
synced 2025-03-03 10:57:55 +01:00
create a helper extension for toasts
This commit is contained in:
parent
a8d186aa57
commit
26de994032
app/src/main/kotlin/com/simplemobiletools/applauncher
@ -6,7 +6,6 @@ import android.support.v7.app.AppCompatActivity
|
||||
import android.support.v7.view.ActionMode
|
||||
import android.support.v7.widget.RecyclerView
|
||||
import android.view.*
|
||||
import android.widget.Toast
|
||||
import com.bignerdranch.android.multiselector.ModalMultiSelectorCallback
|
||||
import com.bignerdranch.android.multiselector.MultiSelector
|
||||
import com.bignerdranch.android.multiselector.SwappingHolder
|
||||
@ -14,6 +13,7 @@ import com.simplemobiletools.applauncher.R
|
||||
import com.simplemobiletools.applauncher.databases.DbHelper
|
||||
import com.simplemobiletools.applauncher.extensions.hide
|
||||
import com.simplemobiletools.applauncher.extensions.show
|
||||
import com.simplemobiletools.applauncher.extensions.toast
|
||||
import com.simplemobiletools.applauncher.models.AppLauncher
|
||||
import kotlinx.android.synthetic.main.app_launcher_dialog_item.view.*
|
||||
import kotlinx.android.synthetic.main.edit_launcher.view.*
|
||||
@ -93,10 +93,10 @@ class RecyclerAdapter(val act: Activity, val launchers: List<AppLauncher>, val i
|
||||
finishActionMode()
|
||||
alertDialog.dismiss()
|
||||
} else {
|
||||
Toast.makeText(act, act.resources.getString(R.string.unknown_error), Toast.LENGTH_SHORT).show()
|
||||
act.toast(R.string.unknown_error)
|
||||
}
|
||||
} else {
|
||||
Toast.makeText(act, act.resources.getString(R.string.enter_launcher_name), Toast.LENGTH_SHORT).show()
|
||||
act.toast(R.string.enter_launcher_name)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,10 @@
|
||||
package com.simplemobiletools.applauncher.extensions
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.net.Uri
|
||||
import android.widget.Toast
|
||||
|
||||
fun viewIntent(url: String): Intent = Intent(Intent.ACTION_VIEW, Uri.parse(url))
|
||||
fun Context.viewIntent(url: String): Intent = Intent(Intent.ACTION_VIEW, Uri.parse(url))
|
||||
|
||||
fun Context.toast(msgId: Int, duration: Int = Toast.LENGTH_SHORT) = Toast.makeText(this, resources.getString(msgId), duration).show()
|
||||
|
@ -2,8 +2,6 @@ package com.simplemobiletools.applauncher.extensions
|
||||
|
||||
import android.view.View
|
||||
|
||||
val View.isVisible: Boolean get() = visibility == View.VISIBLE
|
||||
|
||||
fun View.hide() {
|
||||
visibility = View.INVISIBLE
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user