mirror of
https://github.com/nextcloud/talk-android
synced 2025-06-20 12:09:45 +01:00
remove try-catch for NPEs for bindings
since null checks are done for the nullable bindings by PR #2694, the try-catch blocks arent necessary anymore. Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
parent
30879dfd49
commit
1d9868daa6
@ -367,7 +367,6 @@ class ChatController(args: Bundle) :
|
|||||||
setTitle()
|
setTitle()
|
||||||
participantPermissions = ParticipantPermissions(conversationUser, currentConversation!!)
|
participantPermissions = ParticipantPermissions(conversationUser, currentConversation!!)
|
||||||
|
|
||||||
try {
|
|
||||||
setupSwipeToReply()
|
setupSwipeToReply()
|
||||||
setupMentionAutocomplete()
|
setupMentionAutocomplete()
|
||||||
checkShowCallButtons()
|
checkShowCallButtons()
|
||||||
@ -379,11 +378,6 @@ class ChatController(args: Bundle) :
|
|||||||
} else {
|
} else {
|
||||||
Log.d(TAG, "already inConversation. joinRoomWithPassword is skipped")
|
Log.d(TAG, "already inConversation. joinRoomWithPassword is skipped")
|
||||||
}
|
}
|
||||||
} catch (npe: NullPointerException) {
|
|
||||||
// view binding can be null
|
|
||||||
// since this is called asynchronously and UI might have been destroyed in the meantime
|
|
||||||
Log.i(TAG, "UI destroyed - view binding already gone")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onError(e: Throwable) {
|
override fun onError(e: Throwable) {
|
||||||
@ -714,7 +708,6 @@ class ChatController(args: Bundle) :
|
|||||||
|
|
||||||
@Suppress("Detekt.TooGenericExceptionCaught")
|
@Suppress("Detekt.TooGenericExceptionCaught")
|
||||||
override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) {
|
override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) {
|
||||||
try {
|
|
||||||
if (s.length >= lengthFilter) {
|
if (s.length >= lengthFilter) {
|
||||||
binding?.messageInputView?.inputEditText?.error = String.format(
|
binding?.messageInputView?.inputEditText?.error = String.format(
|
||||||
Objects.requireNonNull<Resources>(resources).getString(R.string.nc_limit_hit),
|
Objects.requireNonNull<Resources>(resources).getString(R.string.nc_limit_hit),
|
||||||
@ -747,11 +740,6 @@ class ChatController(args: Bundle) :
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (npe: NullPointerException) {
|
|
||||||
// view binding can be null
|
|
||||||
// since this is called asynchronously and UI might have been destroyed in the meantime
|
|
||||||
Log.i(TAG, "UI destroyed - view binding already gone")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun afterTextChanged(s: Editable) {
|
override fun afterTextChanged(s: Editable) {
|
||||||
@ -768,17 +756,11 @@ class ChatController(args: Bundle) :
|
|||||||
showMicrophoneButton(true)
|
showMicrophoneButton(true)
|
||||||
|
|
||||||
binding?.messageInputView?.messageInput?.doAfterTextChanged {
|
binding?.messageInputView?.messageInput?.doAfterTextChanged {
|
||||||
try {
|
|
||||||
if (binding?.messageInputView?.messageInput?.text?.isEmpty() == true) {
|
if (binding?.messageInputView?.messageInput?.text?.isEmpty() == true) {
|
||||||
showMicrophoneButton(true)
|
showMicrophoneButton(true)
|
||||||
} else {
|
} else {
|
||||||
showMicrophoneButton(false)
|
showMicrophoneButton(false)
|
||||||
}
|
}
|
||||||
} catch (npe: NullPointerException) {
|
|
||||||
// view binding can be null
|
|
||||||
// since this is called asynchronously and UI might have been destroyed in the meantime
|
|
||||||
Log.i(TAG, "UI destroyed - view binding already gone")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var sliderInitX = 0F
|
var sliderInitX = 0F
|
||||||
@ -1771,13 +1753,7 @@ class ChatController(args: Bundle) :
|
|||||||
)
|
)
|
||||||
},
|
},
|
||||||
onEmojiClickListener = {
|
onEmojiClickListener = {
|
||||||
try {
|
|
||||||
binding?.messageInputView?.inputEditText?.editableText?.append(" ")
|
binding?.messageInputView?.inputEditText?.editableText?.append(" ")
|
||||||
} catch (npe: NullPointerException) {
|
|
||||||
// view binding can be null
|
|
||||||
// since this is called asynchronously and UI might have been destroyed in the meantime
|
|
||||||
Log.i(WebViewLoginController.TAG, "UI destroyed - view binding already gone")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -1937,13 +1913,7 @@ class ChatController(args: Bundle) :
|
|||||||
|
|
||||||
setupWebsocket()
|
setupWebsocket()
|
||||||
|
|
||||||
try {
|
|
||||||
checkLobbyState()
|
checkLobbyState()
|
||||||
} catch (npe: NullPointerException) {
|
|
||||||
// view binding can be null
|
|
||||||
// since this is called asynchronously and UI might have been destroyed in the meantime
|
|
||||||
Log.i(TAG, "UI destroyed - view binding already gone")
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isFirstMessagesProcessing) {
|
if (isFirstMessagesProcessing) {
|
||||||
pullChatMessages(0)
|
pullChatMessages(0)
|
||||||
@ -2123,17 +2093,10 @@ class ChatController(args: Bundle) :
|
|||||||
override fun onNext(genericOverall: GenericOverall) {
|
override fun onNext(genericOverall: GenericOverall) {
|
||||||
myFirstMessage = message
|
myFirstMessage = message
|
||||||
|
|
||||||
try {
|
|
||||||
if (binding?.popupBubbleView?.isShown == true) {
|
if (binding?.popupBubbleView?.isShown == true) {
|
||||||
binding?.popupBubbleView?.hide()
|
binding?.popupBubbleView?.hide()
|
||||||
}
|
}
|
||||||
|
|
||||||
binding?.messagesListView?.smoothScrollToPosition(0)
|
binding?.messagesListView?.smoothScrollToPosition(0)
|
||||||
} catch (npe: NullPointerException) {
|
|
||||||
// view binding can be null
|
|
||||||
// since this is called asynchronously and UI might have been destroyed in the meantime
|
|
||||||
Log.i(TAG, "UI destroyed - view binding already gone")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onError(e: Throwable) {
|
override fun onError(e: Throwable) {
|
||||||
@ -2246,7 +2209,6 @@ class ChatController(args: Bundle) :
|
|||||||
override fun onNext(response: Response<*>) {
|
override fun onNext(response: Response<*>) {
|
||||||
Log.d(TAG, "pullChatMessages - pullChatMessages[lookIntoFuture > 0] - got response")
|
Log.d(TAG, "pullChatMessages - pullChatMessages[lookIntoFuture > 0] - got response")
|
||||||
pullChatMessagesPending = false
|
pullChatMessagesPending = false
|
||||||
try {
|
|
||||||
if (response.code() == HTTP_CODE_NOT_MODIFIED) {
|
if (response.code() == HTTP_CODE_NOT_MODIFIED) {
|
||||||
Log.d(TAG, "pullChatMessages - quasi recursive call to pullChatMessages")
|
Log.d(TAG, "pullChatMessages - quasi recursive call to pullChatMessages")
|
||||||
pullChatMessages(1, setReadMarker, xChatLastCommonRead)
|
pullChatMessages(1, setReadMarker, xChatLastCommonRead)
|
||||||
@ -2255,11 +2217,6 @@ class ChatController(args: Bundle) :
|
|||||||
} else {
|
} else {
|
||||||
processMessagesResponse(response, true)
|
processMessagesResponse(response, true)
|
||||||
}
|
}
|
||||||
} catch (npe: NullPointerException) {
|
|
||||||
// view binding can be null
|
|
||||||
// since this is called asynchronously and UI might have been destroyed in the meantime
|
|
||||||
Log.i(TAG, "UI destroyed - view binding already gone")
|
|
||||||
}
|
|
||||||
|
|
||||||
processExpiredMessages()
|
processExpiredMessages()
|
||||||
}
|
}
|
||||||
@ -2291,17 +2248,11 @@ class ChatController(args: Bundle) :
|
|||||||
override fun onNext(response: Response<*>) {
|
override fun onNext(response: Response<*>) {
|
||||||
Log.d(TAG, "pullChatMessages - pullChatMessages[lookIntoFuture <= 0] - got response")
|
Log.d(TAG, "pullChatMessages - pullChatMessages[lookIntoFuture <= 0] - got response")
|
||||||
pullChatMessagesPending = false
|
pullChatMessagesPending = false
|
||||||
try {
|
|
||||||
if (response.code() == HTTP_CODE_PRECONDITION_FAILED) {
|
if (response.code() == HTTP_CODE_PRECONDITION_FAILED) {
|
||||||
pastPreconditionFailed = true
|
pastPreconditionFailed = true
|
||||||
} else {
|
} else {
|
||||||
processMessagesResponse(response, false)
|
processMessagesResponse(response, false)
|
||||||
}
|
}
|
||||||
} catch (e: NullPointerException) {
|
|
||||||
// view binding can be null
|
|
||||||
// since this is called asynchronously and UI might have been destroyed in the meantime
|
|
||||||
Log.i(TAG, "UI destroyed - view binding already gone", e)
|
|
||||||
}
|
|
||||||
|
|
||||||
processExpiredMessages()
|
processExpiredMessages()
|
||||||
}
|
}
|
||||||
|
@ -493,13 +493,7 @@ class ConversationInfoController(args: Bundle) :
|
|||||||
|
|
||||||
@Suppress("Detekt.TooGenericExceptionCaught")
|
@Suppress("Detekt.TooGenericExceptionCaught")
|
||||||
override fun onNext(participantsOverall: ParticipantsOverall) {
|
override fun onNext(participantsOverall: ParticipantsOverall) {
|
||||||
try {
|
|
||||||
handleParticipants(participantsOverall.ocs!!.data!!)
|
handleParticipants(participantsOverall.ocs!!.data!!)
|
||||||
} catch (npe: NullPointerException) {
|
|
||||||
// view binding can be null
|
|
||||||
// since this is called asynchronously and UI might have been destroyed in the meantime
|
|
||||||
Log.i(TAG, "UI destroyed - view binding already gone")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onError(e: Throwable) {
|
override fun onError(e: Throwable) {
|
||||||
@ -646,7 +640,6 @@ class ConversationInfoController(args: Bundle) :
|
|||||||
|
|
||||||
@Suppress("Detekt.TooGenericExceptionCaught")
|
@Suppress("Detekt.TooGenericExceptionCaught")
|
||||||
override fun onNext(roomOverall: RoomOverall) {
|
override fun onNext(roomOverall: RoomOverall) {
|
||||||
try {
|
|
||||||
conversation = roomOverall.ocs!!.data
|
conversation = roomOverall.ocs!!.data
|
||||||
|
|
||||||
val conversationCopy = conversation
|
val conversationCopy = conversation
|
||||||
@ -719,11 +712,6 @@ class ConversationInfoController(args: Bundle) :
|
|||||||
|
|
||||||
binding?.notificationSettingsView?.notificationSettings?.visibility = VISIBLE
|
binding?.notificationSettingsView?.notificationSettings?.visibility = VISIBLE
|
||||||
}
|
}
|
||||||
} catch (npe: NullPointerException) {
|
|
||||||
// view binding can be null
|
|
||||||
// since this is called asynchronously and UI might have been destroyed in the meantime
|
|
||||||
Log.i(TAG, "UI destroyed - view binding already gone")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onError(e: Throwable) {
|
override fun onError(e: Throwable) {
|
||||||
|
@ -355,7 +355,6 @@ class ProfileController : BaseController(R.layout.controller_profile) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
|
||||||
binding?.emptyList?.emptyListViewHeadline?.text = headline
|
binding?.emptyList?.emptyListViewHeadline?.text = headline
|
||||||
binding?.emptyList?.emptyListViewText?.text = message
|
binding?.emptyList?.emptyListViewText?.text = message
|
||||||
binding?.emptyList?.emptyListIcon?.setImageResource(errorResource)
|
binding?.emptyList?.emptyListIcon?.setImageResource(errorResource)
|
||||||
@ -363,11 +362,6 @@ class ProfileController : BaseController(R.layout.controller_profile) {
|
|||||||
binding?.emptyList?.emptyListViewText?.visibility = View.VISIBLE
|
binding?.emptyList?.emptyListViewText?.visibility = View.VISIBLE
|
||||||
binding?.userinfoList?.visibility = View.GONE
|
binding?.userinfoList?.visibility = View.GONE
|
||||||
binding?.loadingContent?.visibility = View.GONE
|
binding?.loadingContent?.visibility = View.GONE
|
||||||
} catch (npe: NullPointerException) {
|
|
||||||
// view binding can be null
|
|
||||||
// since this is called asynchronously and UI might have been destroyed in the meantime
|
|
||||||
Log.i(TAG, "UI destroyed - view binding already gone")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Suppress("Detekt.LongMethod")
|
@Suppress("Detekt.LongMethod")
|
||||||
|
@ -29,7 +29,6 @@ import android.net.Uri
|
|||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.security.KeyChain
|
import android.security.KeyChain
|
||||||
import android.text.TextUtils
|
import android.text.TextUtils
|
||||||
import android.util.Log
|
|
||||||
import android.view.KeyEvent
|
import android.view.KeyEvent
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.inputmethod.EditorInfo
|
import android.view.inputmethod.EditorInfo
|
||||||
@ -199,7 +198,6 @@ class ServerSelectionController :
|
|||||||
@Suppress("Detekt.TooGenericExceptionCaught")
|
@Suppress("Detekt.TooGenericExceptionCaught")
|
||||||
private fun checkServerAndProceed() {
|
private fun checkServerAndProceed() {
|
||||||
dispose()
|
dispose()
|
||||||
try {
|
|
||||||
var url: String = binding?.serverEntryTextInputEditText?.text.toString().trim { it <= ' ' }
|
var url: String = binding?.serverEntryTextInputEditText?.text.toString().trim { it <= ' ' }
|
||||||
binding?.serverEntryTextInputEditText?.isEnabled = false
|
binding?.serverEntryTextInputEditText?.isEnabled = false
|
||||||
showserverEntryProgressBar()
|
showserverEntryProgressBar()
|
||||||
@ -216,11 +214,6 @@ class ServerSelectionController :
|
|||||||
} else {
|
} else {
|
||||||
checkServer("https://$queryUrl", true)
|
checkServer("https://$queryUrl", true)
|
||||||
}
|
}
|
||||||
} catch (npe: NullPointerException) {
|
|
||||||
// view binding can be null
|
|
||||||
// since this is called asynchronously and UI might have been destroyed in the meantime
|
|
||||||
Log.i(TAG, "UI destroyed - view binding already gone")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun checkServer(queryUrl: String, checkForcedHttps: Boolean) {
|
private fun checkServer(queryUrl: String, checkForcedHttps: Boolean) {
|
||||||
@ -357,18 +350,12 @@ class ServerSelectionController :
|
|||||||
private fun setCertTextView() {
|
private fun setCertTextView() {
|
||||||
if (activity != null) {
|
if (activity != null) {
|
||||||
activity!!.runOnUiThread {
|
activity!!.runOnUiThread {
|
||||||
try {
|
|
||||||
if (!TextUtils.isEmpty(appPreferences!!.temporaryClientCertAlias)) {
|
if (!TextUtils.isEmpty(appPreferences!!.temporaryClientCertAlias)) {
|
||||||
binding?.certTextView?.setText(R.string.nc_change_cert_auth)
|
binding?.certTextView?.setText(R.string.nc_change_cert_auth)
|
||||||
} else {
|
} else {
|
||||||
binding?.certTextView?.setText(R.string.nc_configure_cert_auth)
|
binding?.certTextView?.setText(R.string.nc_configure_cert_auth)
|
||||||
}
|
}
|
||||||
hideserverEntryProgressBar()
|
hideserverEntryProgressBar()
|
||||||
} catch (npe: java.lang.NullPointerException) {
|
|
||||||
// view binding can be null
|
|
||||||
// since this is called asynchronously and UI might have been destroyed in the meantime
|
|
||||||
Log.i(TAG, "UI destroyed - view binding already gone")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -848,7 +848,6 @@ class SettingsController : BaseController(R.layout.controller_settings) {
|
|||||||
private inner class ProxyTypeChangeListener : OnPreferenceValueChangedListener<String> {
|
private inner class ProxyTypeChangeListener : OnPreferenceValueChangedListener<String> {
|
||||||
@Suppress("Detekt.TooGenericExceptionCaught")
|
@Suppress("Detekt.TooGenericExceptionCaught")
|
||||||
override fun onChanged(newValue: String) {
|
override fun onChanged(newValue: String) {
|
||||||
try {
|
|
||||||
if (("No proxy" == newValue)) {
|
if (("No proxy" == newValue)) {
|
||||||
hideProxySettings()
|
hideProxySettings()
|
||||||
} else {
|
} else {
|
||||||
@ -864,11 +863,6 @@ class SettingsController : BaseController(R.layout.controller_settings) {
|
|||||||
}
|
}
|
||||||
showProxySettings()
|
showProxySettings()
|
||||||
}
|
}
|
||||||
} catch (npe: NullPointerException) {
|
|
||||||
// view binding can be null
|
|
||||||
// since this is called asynchronously and UI might have been destroyed in the meantime
|
|
||||||
Log.i(TAG, "UI destroyed - view binding already gone")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -178,7 +178,6 @@ class WebViewLoginController(args: Bundle? = null) : BaseController(
|
|||||||
|
|
||||||
@Suppress("Detekt.TooGenericExceptionCaught")
|
@Suppress("Detekt.TooGenericExceptionCaught")
|
||||||
override fun onPageFinished(view: WebView, url: String) {
|
override fun onPageFinished(view: WebView, url: String) {
|
||||||
try {
|
|
||||||
loginStep++
|
loginStep++
|
||||||
if (!basePageLoaded) {
|
if (!basePageLoaded) {
|
||||||
binding?.progressBar?.visibility = View.GONE
|
binding?.progressBar?.visibility = View.GONE
|
||||||
@ -207,11 +206,6 @@ class WebViewLoginController(args: Bundle? = null) : BaseController(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (npe: NullPointerException) {
|
|
||||||
// view binding can be null
|
|
||||||
// since this is called asynchronously and UI might have been destroyed in the meantime
|
|
||||||
Log.i(TAG, "UI destroyed - view binding already gone")
|
|
||||||
}
|
|
||||||
|
|
||||||
super.onPageFinished(view, url)
|
super.onPageFinished(view, url)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user