From f540aa9305655a684c62a3df39775ab3df368dd7 Mon Sep 17 00:00:00 2001 From: Andy Scherzinger Date: Mon, 17 May 2021 14:56:46 +0200 Subject: [PATCH] improve logging, empty method documentation and new codacy issues Signed-off-by: Andy Scherzinger --- .../MagicPreviewMessageViewHolder.java | 3 +- .../filebrowser/models/properties/OCSize.kt | 2 +- .../talk/controllers/ProfileController.java | 29 ++++++++++++------- .../com/nextcloud/talk/utils/PushUtils.java | 28 ++++++++---------- 4 files changed, 33 insertions(+), 29 deletions(-) diff --git a/app/src/main/java/com/nextcloud/talk/adapters/messages/MagicPreviewMessageViewHolder.java b/app/src/main/java/com/nextcloud/talk/adapters/messages/MagicPreviewMessageViewHolder.java index 75436ef02..a77c2e6c9 100644 --- a/app/src/main/java/com/nextcloud/talk/adapters/messages/MagicPreviewMessageViewHolder.java +++ b/app/src/main/java/com/nextcloud/talk/adapters/messages/MagicPreviewMessageViewHolder.java @@ -459,7 +459,7 @@ public class MagicPreviewMessageViewHolder extends MessageHolders.IncomingImageM .subscribe(new SingleObserver() { @Override public void onSubscribe(@NonNull Disposable d) { - + // unused atm } @Override @@ -479,6 +479,7 @@ public class MagicPreviewMessageViewHolder extends MessageHolders.IncomingImageM @Override public void onError(@NonNull Throwable e) { + Log.e(TAG, "Error reading file information", e); } }); diff --git a/app/src/main/java/com/nextcloud/talk/components/filebrowser/models/properties/OCSize.kt b/app/src/main/java/com/nextcloud/talk/components/filebrowser/models/properties/OCSize.kt index 32b0179ea..951feec9d 100644 --- a/app/src/main/java/com/nextcloud/talk/components/filebrowser/models/properties/OCSize.kt +++ b/app/src/main/java/com/nextcloud/talk/components/filebrowser/models/properties/OCSize.kt @@ -56,6 +56,6 @@ class OCSize private constructor(var ocSize: Long) : Property { companion object { @JvmField - val NAME:Property. Name = Property.Name(DavUtils.OC_NAMESPACE, DavUtils.EXTENDED_PROPERTY_NAME_SIZE) + val NAME: Property.Name = Property.Name(DavUtils.OC_NAMESPACE, DavUtils.EXTENDED_PROPERTY_NAME_SIZE) } } diff --git a/app/src/main/java/com/nextcloud/talk/controllers/ProfileController.java b/app/src/main/java/com/nextcloud/talk/controllers/ProfileController.java index fe6f87852..ec8f290ea 100644 --- a/app/src/main/java/com/nextcloud/talk/controllers/ProfileController.java +++ b/app/src/main/java/com/nextcloud/talk/controllers/ProfileController.java @@ -183,6 +183,7 @@ public class ProfileController extends BaseController { .subscribe(new Observer() { @Override public void onSubscribe(@io.reactivex.annotations.NonNull Disposable d) { + // unused atm } @Override @@ -198,7 +199,7 @@ public class ProfileController extends BaseController { @Override public void onComplete() { - + // unused atm } }); } else { @@ -243,6 +244,7 @@ public class ProfileController extends BaseController { .subscribe(new Observer() { @Override public void onSubscribe(@NonNull Disposable d) { + // unused atm } @Override @@ -260,7 +262,7 @@ public class ProfileController extends BaseController { @Override public void onComplete() { - + // unused atm } })); @@ -273,6 +275,7 @@ public class ProfileController extends BaseController { .subscribe(new Observer() { @Override public void onSubscribe(@io.reactivex.annotations.NonNull Disposable d) { + // unused atm } @Override @@ -291,7 +294,7 @@ public class ProfileController extends BaseController { @Override public void onComplete() { - + // unused atm } }); } @@ -349,6 +352,7 @@ public class ProfileController extends BaseController { .subscribe(new Observer() { @Override public void onSubscribe(@io.reactivex.annotations.NonNull Disposable d) { + // unused atm } @Override @@ -366,7 +370,7 @@ public class ProfileController extends BaseController { @Override public void onComplete() { - + // unused atm } }); } @@ -452,6 +456,7 @@ public class ProfileController extends BaseController { .subscribe(new Observer() { @Override public void onSubscribe(@io.reactivex.annotations.NonNull Disposable d) { + // unused atm } @Override @@ -477,7 +482,7 @@ public class ProfileController extends BaseController { @Override public void onComplete() { - + // unused atm } }); } @@ -533,7 +538,7 @@ public class ProfileController extends BaseController { @Override public void onFailure(@NonNull Call call, @NonNull Throwable t) { - + // unused atm } }); } @@ -545,7 +550,6 @@ public class ProfileController extends BaseController { file = File.createTempFile("avatar", "png", Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM)); - try (FileOutputStream out = new FileOutputStream(file)) { bitmap.compress(Bitmap.CompressFormat.PNG, 100, out); } catch (IOException e) { @@ -602,6 +606,7 @@ public class ProfileController extends BaseController { .subscribe(new Observer() { @Override public void onSubscribe(@io.reactivex.annotations.NonNull Disposable d) { + // unused atm } @Override @@ -612,11 +617,12 @@ public class ProfileController extends BaseController { @Override public void onError(@io.reactivex.annotations.NonNull Throwable e) { Toast.makeText(getApplicationContext(), "Error", Toast.LENGTH_LONG).show(); + Log.e(TAG, "Error uploading avatar", e); } @Override public void onComplete() { - + // unused atm } }); } @@ -634,6 +640,7 @@ public class ProfileController extends BaseController { .subscribe(new Observer() { @Override public void onSubscribe(@io.reactivex.annotations.NonNull Disposable d) { + // unused atm } @Override @@ -649,7 +656,7 @@ public class ProfileController extends BaseController { @Override public void onComplete() { - + // unused atm } }); } @@ -771,7 +778,7 @@ public class ProfileController extends BaseController { holder.text.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { - + // unused atm } @Override @@ -785,7 +792,7 @@ public class ProfileController extends BaseController { @Override public void afterTextChanged(Editable s) { - + // unused atm } }); diff --git a/app/src/main/java/com/nextcloud/talk/utils/PushUtils.java b/app/src/main/java/com/nextcloud/talk/utils/PushUtils.java index 205b906ac..0708d25de 100644 --- a/app/src/main/java/com/nextcloud/talk/utils/PushUtils.java +++ b/app/src/main/java/com/nextcloud/talk/utils/PushUtils.java @@ -256,7 +256,6 @@ public class PushUtils { if (((TextUtils.isEmpty(providerValue) || accountPushData == null) && !userEntity.getScheduledForDeletion()) || (accountPushData != null && !accountPushData.getPushToken().equals(token) && !userEntity.getScheduledForDeletion())) { - Map queryMap = new HashMap<>(); queryMap.put("format", "json"); queryMap.put("pushTokenHash", pushTokenHash); @@ -271,7 +270,7 @@ public class PushUtils { .subscribe(new Observer() { @Override public void onSubscribe(@NonNull Disposable d) { - + // unused atm } @Override @@ -285,14 +284,13 @@ public class PushUtils { proxyMap.put("userPublicKey", pushRegistrationOverall.getOcs() .getData().getPublicKey()); - ncApi.registerDeviceForNotificationsWithProxy( ApiUtils.getUrlPushProxy(), proxyMap) .subscribeOn(Schedulers.io()) .subscribe(new Observer() { @Override public void onSubscribe(@NonNull Disposable d) { - + // unused atm } @Override @@ -319,17 +317,17 @@ public class PushUtils { null, userEntity.getId(), null, null, null) .subscribe(new Observer() { @Override - public void onSubscribe(Disposable d) { - + public void onSubscribe(@NonNull Disposable d) { + // unused atm } @Override - public void onNext(UserEntity userEntity) { + public void onNext(@NonNull UserEntity userEntity) { eventBus.post(new EventStatus(userEntity.getId(), EventStatus.EventType.PUSH_REGISTRATION, true)); } @Override - public void onError(Throwable e) { + public void onError(@NonNull Throwable e) { eventBus.post(new EventStatus (userEntity.getId(), EventStatus.EventType @@ -338,14 +336,12 @@ public class PushUtils { @Override public void onComplete() { - + // unused atm } }); } catch (IOException e) { - Log.e(TAG, "IOException while updating user"); + Log.e(TAG, "IOException while updating user", e); } - - } @Override @@ -356,7 +352,7 @@ public class PushUtils { @Override public void onComplete() { - + // unused atm } }); } @@ -365,11 +361,11 @@ public class PushUtils { public void onError(@NonNull Throwable e) { eventBus.post(new EventStatus(userEntity.getId(), EventStatus.EventType.PUSH_REGISTRATION, false)); - } @Override public void onComplete() { + // unused atm } }); } @@ -400,9 +396,9 @@ public class PushUtils { } } catch (NoSuchAlgorithmException e) { - Log.d("TAG", "No such algorithm while reading key from string"); + Log.d(TAG, "No such algorithm while reading key from string"); } catch (InvalidKeySpecException e) { - Log.d("TAG", "Invalid key spec while reading key from string"); + Log.d(TAG, "Invalid key spec while reading key from string"); } return null;