mirror of
https://github.com/nextcloud/talk-android
synced 2025-06-20 03:59:35 +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,22 +367,16 @@ class ChatController(args: Bundle) :
|
||||
setTitle()
|
||||
participantPermissions = ParticipantPermissions(conversationUser, currentConversation!!)
|
||||
|
||||
try {
|
||||
setupSwipeToReply()
|
||||
setupMentionAutocomplete()
|
||||
checkShowCallButtons()
|
||||
checkShowMessageInputView()
|
||||
checkLobbyState()
|
||||
setupSwipeToReply()
|
||||
setupMentionAutocomplete()
|
||||
checkShowCallButtons()
|
||||
checkShowMessageInputView()
|
||||
checkLobbyState()
|
||||
|
||||
if (!inConversation) {
|
||||
joinRoomWithPassword()
|
||||
} else {
|
||||
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")
|
||||
if (!inConversation) {
|
||||
joinRoomWithPassword()
|
||||
} else {
|
||||
Log.d(TAG, "already inConversation. joinRoomWithPassword is skipped")
|
||||
}
|
||||
}
|
||||
|
||||
@ -714,43 +708,37 @@ class ChatController(args: Bundle) :
|
||||
|
||||
@Suppress("Detekt.TooGenericExceptionCaught")
|
||||
override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) {
|
||||
try {
|
||||
if (s.length >= lengthFilter) {
|
||||
binding?.messageInputView?.inputEditText?.error = String.format(
|
||||
Objects.requireNonNull<Resources>(resources).getString(R.string.nc_limit_hit),
|
||||
lengthFilter.toString()
|
||||
)
|
||||
} else {
|
||||
binding?.messageInputView?.inputEditText?.error = null
|
||||
}
|
||||
if (s.length >= lengthFilter) {
|
||||
binding?.messageInputView?.inputEditText?.error = String.format(
|
||||
Objects.requireNonNull<Resources>(resources).getString(R.string.nc_limit_hit),
|
||||
lengthFilter.toString()
|
||||
)
|
||||
} else {
|
||||
binding?.messageInputView?.inputEditText?.error = null
|
||||
}
|
||||
|
||||
val editable = binding?.messageInputView?.inputEditText?.editableText
|
||||
if (editable != null && binding?.messageInputView?.inputEditText != null) {
|
||||
val mentionSpans = editable.getSpans(
|
||||
0,
|
||||
binding?.messageInputView?.inputEditText!!.length(),
|
||||
Spans.MentionChipSpan::class.java
|
||||
)
|
||||
var mentionSpan: Spans.MentionChipSpan
|
||||
for (i in mentionSpans.indices) {
|
||||
mentionSpan = mentionSpans[i]
|
||||
if (start >= editable.getSpanStart(mentionSpan) &&
|
||||
start < editable.getSpanEnd(mentionSpan)
|
||||
val editable = binding?.messageInputView?.inputEditText?.editableText
|
||||
if (editable != null && binding?.messageInputView?.inputEditText != null) {
|
||||
val mentionSpans = editable.getSpans(
|
||||
0,
|
||||
binding?.messageInputView?.inputEditText!!.length(),
|
||||
Spans.MentionChipSpan::class.java
|
||||
)
|
||||
var mentionSpan: Spans.MentionChipSpan
|
||||
for (i in mentionSpans.indices) {
|
||||
mentionSpan = mentionSpans[i]
|
||||
if (start >= editable.getSpanStart(mentionSpan) &&
|
||||
start < editable.getSpanEnd(mentionSpan)
|
||||
) {
|
||||
if (editable.subSequence(
|
||||
editable.getSpanStart(mentionSpan),
|
||||
editable.getSpanEnd(mentionSpan)
|
||||
).toString().trim { it <= ' ' } != mentionSpan.label
|
||||
) {
|
||||
if (editable.subSequence(
|
||||
editable.getSpanStart(mentionSpan),
|
||||
editable.getSpanEnd(mentionSpan)
|
||||
).toString().trim { it <= ' ' } != mentionSpan.label
|
||||
) {
|
||||
editable.removeSpan(mentionSpan)
|
||||
}
|
||||
editable.removeSpan(mentionSpan)
|
||||
}
|
||||
}
|
||||
}
|
||||
} 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")
|
||||
}
|
||||
}
|
||||
|
||||
@ -768,16 +756,10 @@ class ChatController(args: Bundle) :
|
||||
showMicrophoneButton(true)
|
||||
|
||||
binding?.messageInputView?.messageInput?.doAfterTextChanged {
|
||||
try {
|
||||
if (binding?.messageInputView?.messageInput?.text?.isEmpty() == true) {
|
||||
showMicrophoneButton(true)
|
||||
} else {
|
||||
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")
|
||||
if (binding?.messageInputView?.messageInput?.text?.isEmpty() == true) {
|
||||
showMicrophoneButton(true)
|
||||
} else {
|
||||
showMicrophoneButton(false)
|
||||
}
|
||||
}
|
||||
|
||||
@ -1771,13 +1753,7 @@ class ChatController(args: Bundle) :
|
||||
)
|
||||
},
|
||||
onEmojiClickListener = {
|
||||
try {
|
||||
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")
|
||||
}
|
||||
binding?.messageInputView?.inputEditText?.editableText?.append(" ")
|
||||
}
|
||||
)
|
||||
}
|
||||
@ -1937,13 +1913,7 @@ class ChatController(args: Bundle) :
|
||||
|
||||
setupWebsocket()
|
||||
|
||||
try {
|
||||
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")
|
||||
}
|
||||
checkLobbyState()
|
||||
|
||||
if (isFirstMessagesProcessing) {
|
||||
pullChatMessages(0)
|
||||
@ -2123,17 +2093,10 @@ class ChatController(args: Bundle) :
|
||||
override fun onNext(genericOverall: GenericOverall) {
|
||||
myFirstMessage = message
|
||||
|
||||
try {
|
||||
if (binding?.popupBubbleView?.isShown == true) {
|
||||
binding?.popupBubbleView?.hide()
|
||||
}
|
||||
|
||||
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")
|
||||
if (binding?.popupBubbleView?.isShown == true) {
|
||||
binding?.popupBubbleView?.hide()
|
||||
}
|
||||
binding?.messagesListView?.smoothScrollToPosition(0)
|
||||
}
|
||||
|
||||
override fun onError(e: Throwable) {
|
||||
@ -2246,19 +2209,13 @@ class ChatController(args: Bundle) :
|
||||
override fun onNext(response: Response<*>) {
|
||||
Log.d(TAG, "pullChatMessages - pullChatMessages[lookIntoFuture > 0] - got response")
|
||||
pullChatMessagesPending = false
|
||||
try {
|
||||
if (response.code() == HTTP_CODE_NOT_MODIFIED) {
|
||||
Log.d(TAG, "pullChatMessages - quasi recursive call to pullChatMessages")
|
||||
pullChatMessages(1, setReadMarker, xChatLastCommonRead)
|
||||
} else if (response.code() == HTTP_CODE_PRECONDITION_FAILED) {
|
||||
futurePreconditionFailed = true
|
||||
} else {
|
||||
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")
|
||||
if (response.code() == HTTP_CODE_NOT_MODIFIED) {
|
||||
Log.d(TAG, "pullChatMessages - quasi recursive call to pullChatMessages")
|
||||
pullChatMessages(1, setReadMarker, xChatLastCommonRead)
|
||||
} else if (response.code() == HTTP_CODE_PRECONDITION_FAILED) {
|
||||
futurePreconditionFailed = true
|
||||
} else {
|
||||
processMessagesResponse(response, true)
|
||||
}
|
||||
|
||||
processExpiredMessages()
|
||||
@ -2291,16 +2248,10 @@ class ChatController(args: Bundle) :
|
||||
override fun onNext(response: Response<*>) {
|
||||
Log.d(TAG, "pullChatMessages - pullChatMessages[lookIntoFuture <= 0] - got response")
|
||||
pullChatMessagesPending = false
|
||||
try {
|
||||
if (response.code() == HTTP_CODE_PRECONDITION_FAILED) {
|
||||
pastPreconditionFailed = true
|
||||
} else {
|
||||
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)
|
||||
if (response.code() == HTTP_CODE_PRECONDITION_FAILED) {
|
||||
pastPreconditionFailed = true
|
||||
} else {
|
||||
processMessagesResponse(response, false)
|
||||
}
|
||||
|
||||
processExpiredMessages()
|
||||
|
@ -493,13 +493,7 @@ class ConversationInfoController(args: Bundle) :
|
||||
|
||||
@Suppress("Detekt.TooGenericExceptionCaught")
|
||||
override fun onNext(participantsOverall: ParticipantsOverall) {
|
||||
try {
|
||||
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")
|
||||
}
|
||||
handleParticipants(participantsOverall.ocs!!.data!!)
|
||||
}
|
||||
|
||||
override fun onError(e: Throwable) {
|
||||
@ -646,83 +640,77 @@ class ConversationInfoController(args: Bundle) :
|
||||
|
||||
@Suppress("Detekt.TooGenericExceptionCaught")
|
||||
override fun onNext(roomOverall: RoomOverall) {
|
||||
try {
|
||||
conversation = roomOverall.ocs!!.data
|
||||
conversation = roomOverall.ocs!!.data
|
||||
|
||||
val conversationCopy = conversation
|
||||
val conversationCopy = conversation
|
||||
|
||||
if (conversationCopy!!.canModerate(conversationUser)) {
|
||||
binding?.addParticipantsAction?.visibility = VISIBLE
|
||||
if (CapabilitiesUtilNew.hasSpreedFeatureCapability(conversationUser, "clear-history")) {
|
||||
binding?.clearConversationHistory?.visibility = VISIBLE
|
||||
} else {
|
||||
binding?.clearConversationHistory?.visibility = GONE
|
||||
}
|
||||
if (conversationCopy!!.canModerate(conversationUser)) {
|
||||
binding?.addParticipantsAction?.visibility = VISIBLE
|
||||
if (CapabilitiesUtilNew.hasSpreedFeatureCapability(conversationUser, "clear-history")) {
|
||||
binding?.clearConversationHistory?.visibility = VISIBLE
|
||||
} else {
|
||||
binding?.addParticipantsAction?.visibility = GONE
|
||||
binding?.clearConversationHistory?.visibility = GONE
|
||||
}
|
||||
} else {
|
||||
binding?.addParticipantsAction?.visibility = GONE
|
||||
binding?.clearConversationHistory?.visibility = GONE
|
||||
}
|
||||
|
||||
if (isAttached && (!isBeingDestroyed || !isDestroyed)) {
|
||||
binding?.ownOptions?.visibility = VISIBLE
|
||||
if (isAttached && (!isBeingDestroyed || !isDestroyed)) {
|
||||
binding?.ownOptions?.visibility = VISIBLE
|
||||
|
||||
setupWebinaryView()
|
||||
setupWebinaryView()
|
||||
|
||||
if (!conversation!!.canLeave()) {
|
||||
binding?.leaveConversationAction?.visibility = GONE
|
||||
} else {
|
||||
binding?.leaveConversationAction?.visibility = VISIBLE
|
||||
}
|
||||
|
||||
if (!conversation!!.canDelete(conversationUser)) {
|
||||
binding?.deleteConversationAction?.visibility = GONE
|
||||
} else {
|
||||
binding?.deleteConversationAction?.visibility = VISIBLE
|
||||
}
|
||||
|
||||
if (Conversation.ConversationType.ROOM_SYSTEM == conversation!!.type) {
|
||||
binding?.notificationSettingsView?.callNotifications?.visibility = GONE
|
||||
}
|
||||
|
||||
if (conversation!!.notificationCalls === null) {
|
||||
binding?.notificationSettingsView?.callNotifications?.visibility = GONE
|
||||
} else {
|
||||
binding?.notificationSettingsView?.callNotifications?.value =
|
||||
conversationCopy.notificationCalls == 1
|
||||
}
|
||||
|
||||
getListOfParticipants()
|
||||
|
||||
binding?.progressBar?.visibility = GONE
|
||||
|
||||
binding?.conversationInfoName?.visibility = VISIBLE
|
||||
|
||||
binding?.displayNameText?.text = conversation!!.displayName
|
||||
|
||||
if (conversation!!.description != null && !conversation!!.description!!.isEmpty()) {
|
||||
binding?.descriptionText?.text = conversation!!.description
|
||||
binding?.conversationDescription?.visibility = VISIBLE
|
||||
}
|
||||
|
||||
loadConversationAvatar()
|
||||
adjustNotificationLevelUI()
|
||||
initExpiringMessageOption()
|
||||
|
||||
binding?.let {
|
||||
GuestAccessHelper(
|
||||
this@ConversationInfoController,
|
||||
it,
|
||||
conversation!!,
|
||||
conversationUser
|
||||
).setupGuestAccess()
|
||||
}
|
||||
|
||||
binding?.notificationSettingsView?.notificationSettings?.visibility = VISIBLE
|
||||
if (!conversation!!.canLeave()) {
|
||||
binding?.leaveConversationAction?.visibility = GONE
|
||||
} else {
|
||||
binding?.leaveConversationAction?.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")
|
||||
|
||||
if (!conversation!!.canDelete(conversationUser)) {
|
||||
binding?.deleteConversationAction?.visibility = GONE
|
||||
} else {
|
||||
binding?.deleteConversationAction?.visibility = VISIBLE
|
||||
}
|
||||
|
||||
if (Conversation.ConversationType.ROOM_SYSTEM == conversation!!.type) {
|
||||
binding?.notificationSettingsView?.callNotifications?.visibility = GONE
|
||||
}
|
||||
|
||||
if (conversation!!.notificationCalls === null) {
|
||||
binding?.notificationSettingsView?.callNotifications?.visibility = GONE
|
||||
} else {
|
||||
binding?.notificationSettingsView?.callNotifications?.value =
|
||||
conversationCopy.notificationCalls == 1
|
||||
}
|
||||
|
||||
getListOfParticipants()
|
||||
|
||||
binding?.progressBar?.visibility = GONE
|
||||
|
||||
binding?.conversationInfoName?.visibility = VISIBLE
|
||||
|
||||
binding?.displayNameText?.text = conversation!!.displayName
|
||||
|
||||
if (conversation!!.description != null && !conversation!!.description!!.isEmpty()) {
|
||||
binding?.descriptionText?.text = conversation!!.description
|
||||
binding?.conversationDescription?.visibility = VISIBLE
|
||||
}
|
||||
|
||||
loadConversationAvatar()
|
||||
adjustNotificationLevelUI()
|
||||
initExpiringMessageOption()
|
||||
|
||||
binding?.let {
|
||||
GuestAccessHelper(
|
||||
this@ConversationInfoController,
|
||||
it,
|
||||
conversation!!,
|
||||
conversationUser
|
||||
).setupGuestAccess()
|
||||
}
|
||||
|
||||
binding?.notificationSettingsView?.notificationSettings?.visibility = VISIBLE
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -355,19 +355,13 @@ class ProfileController : BaseController(R.layout.controller_profile) {
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
binding?.emptyList?.emptyListViewHeadline?.text = headline
|
||||
binding?.emptyList?.emptyListViewText?.text = message
|
||||
binding?.emptyList?.emptyListIcon?.setImageResource(errorResource)
|
||||
binding?.emptyList?.emptyListIcon?.visibility = View.VISIBLE
|
||||
binding?.emptyList?.emptyListViewText?.visibility = View.VISIBLE
|
||||
binding?.userinfoList?.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")
|
||||
}
|
||||
binding?.emptyList?.emptyListViewHeadline?.text = headline
|
||||
binding?.emptyList?.emptyListViewText?.text = message
|
||||
binding?.emptyList?.emptyListIcon?.setImageResource(errorResource)
|
||||
binding?.emptyList?.emptyListIcon?.visibility = View.VISIBLE
|
||||
binding?.emptyList?.emptyListViewText?.visibility = View.VISIBLE
|
||||
binding?.userinfoList?.visibility = View.GONE
|
||||
binding?.loadingContent?.visibility = View.GONE
|
||||
}
|
||||
|
||||
@Suppress("Detekt.LongMethod")
|
||||
|
@ -29,7 +29,6 @@ import android.net.Uri
|
||||
import android.os.Bundle
|
||||
import android.security.KeyChain
|
||||
import android.text.TextUtils
|
||||
import android.util.Log
|
||||
import android.view.KeyEvent
|
||||
import android.view.View
|
||||
import android.view.inputmethod.EditorInfo
|
||||
@ -199,27 +198,21 @@ class ServerSelectionController :
|
||||
@Suppress("Detekt.TooGenericExceptionCaught")
|
||||
private fun checkServerAndProceed() {
|
||||
dispose()
|
||||
try {
|
||||
var url: String = binding?.serverEntryTextInputEditText?.text.toString().trim { it <= ' ' }
|
||||
binding?.serverEntryTextInputEditText?.isEnabled = false
|
||||
showserverEntryProgressBar()
|
||||
if (binding?.importOrChooseProviderText?.visibility != View.INVISIBLE) {
|
||||
binding?.importOrChooseProviderText?.visibility = View.INVISIBLE
|
||||
binding?.certTextView?.visibility = View.INVISIBLE
|
||||
}
|
||||
if (url.endsWith("/")) {
|
||||
url = url.substring(0, url.length - 1)
|
||||
}
|
||||
val queryUrl = url + ApiUtils.getUrlPostfixForStatus()
|
||||
if (UriUtils.hasHttpProtocollPrefixed(url)) {
|
||||
checkServer(queryUrl, false)
|
||||
} else {
|
||||
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")
|
||||
var url: String = binding?.serverEntryTextInputEditText?.text.toString().trim { it <= ' ' }
|
||||
binding?.serverEntryTextInputEditText?.isEnabled = false
|
||||
showserverEntryProgressBar()
|
||||
if (binding?.importOrChooseProviderText?.visibility != View.INVISIBLE) {
|
||||
binding?.importOrChooseProviderText?.visibility = View.INVISIBLE
|
||||
binding?.certTextView?.visibility = View.INVISIBLE
|
||||
}
|
||||
if (url.endsWith("/")) {
|
||||
url = url.substring(0, url.length - 1)
|
||||
}
|
||||
val queryUrl = url + ApiUtils.getUrlPostfixForStatus()
|
||||
if (UriUtils.hasHttpProtocollPrefixed(url)) {
|
||||
checkServer(queryUrl, false)
|
||||
} else {
|
||||
checkServer("https://$queryUrl", true)
|
||||
}
|
||||
}
|
||||
|
||||
@ -357,18 +350,12 @@ class ServerSelectionController :
|
||||
private fun setCertTextView() {
|
||||
if (activity != null) {
|
||||
activity!!.runOnUiThread {
|
||||
try {
|
||||
if (!TextUtils.isEmpty(appPreferences!!.temporaryClientCertAlias)) {
|
||||
binding?.certTextView?.setText(R.string.nc_change_cert_auth)
|
||||
} else {
|
||||
binding?.certTextView?.setText(R.string.nc_configure_cert_auth)
|
||||
}
|
||||
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")
|
||||
if (!TextUtils.isEmpty(appPreferences!!.temporaryClientCertAlias)) {
|
||||
binding?.certTextView?.setText(R.string.nc_change_cert_auth)
|
||||
} else {
|
||||
binding?.certTextView?.setText(R.string.nc_configure_cert_auth)
|
||||
}
|
||||
hideserverEntryProgressBar()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -848,26 +848,20 @@ class SettingsController : BaseController(R.layout.controller_settings) {
|
||||
private inner class ProxyTypeChangeListener : OnPreferenceValueChangedListener<String> {
|
||||
@Suppress("Detekt.TooGenericExceptionCaught")
|
||||
override fun onChanged(newValue: String) {
|
||||
try {
|
||||
if (("No proxy" == newValue)) {
|
||||
hideProxySettings()
|
||||
} else {
|
||||
when (newValue) {
|
||||
"HTTP" ->
|
||||
binding?.settingsProxyPortEdit?.value = "3128"
|
||||
"DIRECT" ->
|
||||
binding?.settingsProxyPortEdit?.value = "8080"
|
||||
"SOCKS" ->
|
||||
binding?.settingsProxyPortEdit?.value = "1080"
|
||||
else -> {
|
||||
}
|
||||
if (("No proxy" == newValue)) {
|
||||
hideProxySettings()
|
||||
} else {
|
||||
when (newValue) {
|
||||
"HTTP" ->
|
||||
binding?.settingsProxyPortEdit?.value = "3128"
|
||||
"DIRECT" ->
|
||||
binding?.settingsProxyPortEdit?.value = "8080"
|
||||
"SOCKS" ->
|
||||
binding?.settingsProxyPortEdit?.value = "1080"
|
||||
else -> {
|
||||
}
|
||||
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")
|
||||
showProxySettings()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -178,39 +178,33 @@ class WebViewLoginController(args: Bundle? = null) : BaseController(
|
||||
|
||||
@Suppress("Detekt.TooGenericExceptionCaught")
|
||||
override fun onPageFinished(view: WebView, url: String) {
|
||||
try {
|
||||
loginStep++
|
||||
if (!basePageLoaded) {
|
||||
binding?.progressBar?.visibility = View.GONE
|
||||
binding?.webview?.visibility = View.VISIBLE
|
||||
loginStep++
|
||||
if (!basePageLoaded) {
|
||||
binding?.progressBar?.visibility = View.GONE
|
||||
binding?.webview?.visibility = View.VISIBLE
|
||||
|
||||
basePageLoaded = true
|
||||
}
|
||||
if (!TextUtils.isEmpty(username)) {
|
||||
if (loginStep == 1) {
|
||||
basePageLoaded = true
|
||||
}
|
||||
if (!TextUtils.isEmpty(username)) {
|
||||
if (loginStep == 1) {
|
||||
binding?.webview?.loadUrl(
|
||||
"javascript: {document.getElementsByClassName('login')[0].click(); };"
|
||||
)
|
||||
} else if (!automatedLoginAttempted) {
|
||||
automatedLoginAttempted = true
|
||||
if (TextUtils.isEmpty(password)) {
|
||||
binding?.webview?.loadUrl(
|
||||
"javascript: {document.getElementsByClassName('login')[0].click(); };"
|
||||
"javascript:var justStore = document.getElementById('user').value = '$username';"
|
||||
)
|
||||
} else {
|
||||
binding?.webview?.loadUrl(
|
||||
"javascript: {" +
|
||||
"document.getElementById('user').value = '" + username + "';" +
|
||||
"document.getElementById('password').value = '" + password + "';" +
|
||||
"document.getElementById('submit').click(); };"
|
||||
)
|
||||
} else if (!automatedLoginAttempted) {
|
||||
automatedLoginAttempted = true
|
||||
if (TextUtils.isEmpty(password)) {
|
||||
binding?.webview?.loadUrl(
|
||||
"javascript:var justStore = document.getElementById('user').value = '$username';"
|
||||
)
|
||||
} else {
|
||||
binding?.webview?.loadUrl(
|
||||
"javascript: {" +
|
||||
"document.getElementById('user').value = '" + username + "';" +
|
||||
"document.getElementById('password').value = '" + password + "';" +
|
||||
"document.getElementById('submit').click(); };"
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
} 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)
|
||||
|
Loading…
Reference in New Issue
Block a user