Skip to content

Commit

Permalink
avoid NPE in ProfileActivity because userInfo could be null
Browse files Browse the repository at this point in the history
reported via gplay:

Exception java.lang.NullPointerException:
  at com.nextcloud.talk.profile.ProfileActivity$save$1.onError (ProfileActivity.kt:457)
  at io.reactivex.internal.operators.observable.ObservableObserveOn$ObserveOnObserver.checkTerminated (ObservableObserveOn.java:281)
  at io.reactivex.internal.operators.observable.ObservableObserveOn$ObserveOnObserver.drainNormal (ObservableObserveOn.java:172)
  at io.reactivex.internal.operators.observable.ObservableObserveOn$ObserveOnObserver.run (ObservableObserveOn.java:255)
  at io.reactivex.android.schedulers.HandlerScheduler$ScheduledRunnable.run (HandlerScheduler.java:124)
  at android.os.Handler.handleCallback (Handler.java:938)
  at android.os.Handler.dispatchMessage (Handler.java:99)
  at android.os.Looper.loop (Looper.java:257)
  at android.app.ActivityThread.main (ActivityThread.java:8220)
  at java.lang.reflect.Method.invoke
  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:626)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1015)

Signed-off-by: Marcel Hibbe <[email protected]>
  • Loading branch information
mahibi committed Jul 7, 2023
1 parent 9c89d68 commit f491b81
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ class ProfileActivity : BaseActivity() {
private fun save() {
for (item in adapter!!.displayList!!) {
// Text
if (item.text != userInfo!!.getValueByField(item.field)) {
if (item.text != userInfo?.getValueByField(item.field)) {
val credentials = ApiUtils.getCredentials(currentUser!!.username, currentUser!!.token)
ncApi.setUserData(
credentials,
Expand All @@ -458,7 +458,7 @@ class ProfileActivity : BaseActivity() {
}

override fun onError(e: Throwable) {
item.text = userInfo!!.getValueByField(item.field)!!
item.text = userInfo?.getValueByField(item.field)
Toast.makeText(
applicationContext,
String.format(
Expand All @@ -479,7 +479,7 @@ class ProfileActivity : BaseActivity() {
}

// Scope
if (item.scope != userInfo!!.getScopeByField(item.field)) {
if (item.scope != userInfo?.getScopeByField(item.field)) {
saveScope(item, userInfo)
}
adapter!!.updateFilteredList()
Expand Down Expand Up @@ -586,7 +586,7 @@ class ProfileActivity : BaseActivity() {
}

override fun onError(e: Throwable) {
item.scope = userInfo!!.getScopeByField(item.field)
item.scope = userInfo?.getScopeByField(item.field)
Log.e(TAG, "Failed to saved: " + item.scope + " as " + item.field, e)
}

Expand Down

0 comments on commit f491b81

Please sign in to comment.