Use kotlin extension to display toast

This commit is contained in:
Abdul Wadood 2019-12-03 23:13:43 +05:30
parent 4a2d3c4ab9
commit 70583a742f

View File

@ -34,6 +34,7 @@ import androidx.recyclerview.widget.RecyclerView
import org.kiwix.kiwixmobile.R import org.kiwix.kiwixmobile.R
import org.kiwix.kiwixmobile.core.BuildConfig import org.kiwix.kiwixmobile.core.BuildConfig
import org.kiwix.kiwixmobile.core.base.BaseActivity import org.kiwix.kiwixmobile.core.base.BaseActivity
import org.kiwix.kiwixmobile.core.extensions.toast
import org.kiwix.kiwixmobile.core.utils.AlertDialogShower import org.kiwix.kiwixmobile.core.utils.AlertDialogShower
import org.kiwix.kiwixmobile.core.utils.KiwixDialog import org.kiwix.kiwixmobile.core.utils.KiwixDialog
import org.kiwix.kiwixmobile.core.utils.ServerUtils import org.kiwix.kiwixmobile.core.utils.ServerUtils
@ -133,11 +134,7 @@ class ZimHostActivity : BaseActivity(), ZimHostCallbacks, ZimHostContract.View {
when { when {
ServerUtils.isServerStarted -> stopServer() ServerUtils.isServerStarted -> stopServer()
selectedBooksPath.size > 0 -> startHotspotManuallyDialog() selectedBooksPath.size > 0 -> startHotspotManuallyDialog()
else -> Toast.makeText( else -> toast(R.string.no_books_selected_toast_message, Toast.LENGTH_SHORT)
this,
R.string.no_books_selected_toast_message,
Toast.LENGTH_SHORT
).show()
} }
} }
@ -258,7 +255,7 @@ class ZimHostActivity : BaseActivity(), ZimHostCallbacks, ZimHostContract.View {
} }
override fun onServerFailedToStart() { override fun onServerFailedToStart() {
Toast.makeText(this, R.string.server_failed_toast_message, Toast.LENGTH_LONG).show() toast(R.string.server_failed_toast_message)
} }
private fun launchTetheringSettingsScreen() { private fun launchTetheringSettingsScreen() {
@ -292,11 +289,7 @@ class ZimHostActivity : BaseActivity(), ZimHostCallbacks, ZimHostContract.View {
override fun onIpAddressInvalid() { override fun onIpAddressInvalid() {
progressDialog!!.dismiss() progressDialog!!.dismiss()
Toast.makeText( toast(R.string.server_failed_message, Toast.LENGTH_SHORT)
this, R.string.server_failed_message,
Toast.LENGTH_SHORT
)
.show()
} }
companion object { companion object {