Skip to content

Instantly share code, notes, and snippets.

@RajeshNaddy
Last active June 8, 2019 18:09
Show Gist options
  • Save RajeshNaddy/652b7a6914d2b8af094e3f405b517a7c to your computer and use it in GitHub Desktop.
Save RajeshNaddy/652b7a6914d2b8af094e3f405b517a7c to your computer and use it in GitHub Desktop.
BaseActivity Kotlin
abstract class BaseActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
//initialize() initialize if you want anything
}
internal fun showToast(message: String) {
Toast.makeText(this, message, Toast.LENGTH_SHORT).show()
}
internal fun showLongToast(message: String) {
Toast.makeText(this, message, Toast.LENGTH_LONG).show()
}
internal fun showParkrProgress() {
}
internal fun dismissParkrProgress() {
}
fun showAlertDialog(title: String,message: String?,clickButtonText: String?,onClickListener: DialogInterface.OnClickListener?,
isCancellable: Boolean
) {
val alertDialogBuilder = AlertDialog.Builder(this@BaseActivity)
if (!title.isEmpty()) {
alertDialogBuilder.setTitle(title)
}
if (message != null)
alertDialogBuilder.setMessage(message)
if (clickButtonText != null && onClickListener != null)
alertDialogBuilder.setPositiveButton(clickButtonText, onClickListener)
val alertDialog = alertDialogBuilder.create()
alertDialog.setCancelable(isCancellable)
alertDialog.show()
}
fun logOut(){
LoginPreferences.remove(PREF_USER_NAME)
LoginActivity.start(this)
finish()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment