Commit d5acac79 authored by Divyanshu Bhargava's avatar Divyanshu Bhargava

Fix Alert Dialog Button

parent b14a2117
package chat.rocket.android.chatroom.ui
import android.app.Activity
import android.app.AlertDialog
import androidx.appcompat.app.AlertDialog
import android.content.ClipData
import android.content.ClipboardManager
import android.content.Context
......@@ -200,7 +200,7 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
private var verticalScrollOffset = AtomicInteger(0)
private val dialogView by lazy { View.inflate(context, R.layout.file_attachments_dialog, null) }
internal val alertDialog by lazy { AlertDialog.Builder(activity).setView(dialogView).create() }
internal val alertDialog by lazy { activity?.let { AlertDialog.Builder(it).setView(dialogView).create() } }
internal val imagePreview by lazy { dialogView.findViewById<ImageView>(R.id.image_preview) }
internal val sendButton by lazy { dialogView.findViewById<android.widget.Button>(R.id.button_send) }
internal val cancelButton by lazy { dialogView.findViewById<android.widget.Button>(R.id.button_cancel) }
......
......@@ -75,10 +75,10 @@ fun ChatRoomFragment.showFileAttachmentDialog(uri: Uri) {
(citation ?: "") + description.text.toString()
)
}
alertDialog.dismiss()
alertDialog?.dismiss()
}
cancelButton.setOnClickListener { alertDialog.dismiss() }
alertDialog.show()
cancelButton.setOnClickListener { alertDialog?.dismiss() }
alertDialog?.show()
}
fun ChatRoomFragment.showDrawAttachmentDialog(byteArray: ByteArray) {
......@@ -92,9 +92,9 @@ fun ChatRoomFragment.showDrawAttachmentDialog(byteArray: ByteArray) {
byteArray,
(citation ?: "") + description.text.toString()
)
alertDialog.dismiss()
alertDialog?.dismiss()
}
cancelButton.setOnClickListener { alertDialog.dismiss() }
alertDialog.show()
cancelButton.setOnClickListener { alertDialog?.dismiss() }
alertDialog?.show()
}
\ No newline at end of file
package chat.rocket.android.chatrooms.ui
import android.app.AlertDialog
import androidx.appcompat.app.AlertDialog
import android.app.ProgressDialog
import android.os.Bundle
import android.os.Handler
......@@ -236,14 +236,16 @@ class ChatRoomsFragment : Fragment(), ChatRoomsView {
)
}
AlertDialog.Builder(context)
.setTitle(R.string.dialog_sort_title)
.setView(dialogLayout)
.setPositiveButton(R.string.msg_sort) { dialog, _ ->
invalidateQueryOnSearch()
updateSort()
dialog.dismiss()
}.show()
context?.let {
AlertDialog.Builder(it)
.setTitle(R.string.dialog_sort_title)
.setView(dialogLayout)
.setPositiveButton(R.string.msg_sort) { dialog, _ ->
invalidateQueryOnSearch()
updateSort()
dialog.dismiss()
}.show()
}
}
}
return super.onOptionsItemSelected(item)
......
......@@ -2,7 +2,7 @@ package chat.rocket.android.main.ui
import DrawableHelper
import android.app.Activity
import android.app.AlertDialog
import androidx.appcompat.app.AlertDialog
import android.app.ProgressDialog
import android.os.Bundle
import androidx.annotation.IdRes
......
......@@ -2,7 +2,7 @@ package chat.rocket.android.profile.ui
import DrawableHelper
import android.app.Activity
import android.app.AlertDialog
import androidx.appcompat.app.AlertDialog
import android.content.Intent
import android.graphics.Bitmap
import android.os.Build
......@@ -296,14 +296,16 @@ class ProfileFragment : Fragment(), ProfileView, ActionMode.Callback {
val passwordEditText = EditText(context)
passwordEditText.hint = getString(R.string.msg_password)
val builder = AlertDialog.Builder(context)
builder.setTitle(R.string.title_are_you_sure)
.setView(passwordEditText)
.setPositiveButton(R.string.action_delete_account) { _, _ ->
presenter.deleteAccount(passwordEditText.text.toString())
}
.setNegativeButton(android.R.string.no) { dialog, _ -> dialog.cancel() }
.create()
.show()
context?.let {
val builder = AlertDialog.Builder(it)
builder.setTitle(R.string.title_are_you_sure)
.setView(passwordEditText)
.setPositiveButton(R.string.action_delete_account) { _, _ ->
presenter.deleteAccount(passwordEditText.text.toString())
}
.setNegativeButton(android.R.string.no) { dialog, _ -> dialog.cancel() }
.create()
.show()
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment