From ce31554687b37aeca7a2a796187633b372455c59 Mon Sep 17 00:00:00 2001 From: Ammar Githam Date: Tue, 25 May 2021 02:08:46 +0900 Subject: [PATCH] Fix Caption de-serialization --- .../awais/instagrabber/repositories/responses/Caption.kt | 7 +++++-- .../repositories/serializers/CaptionDeserializer.java | 2 +- .../awais/instagrabber/viewmodels/PostViewV2ViewModel.java | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/awais/instagrabber/repositories/responses/Caption.kt b/app/src/main/java/awais/instagrabber/repositories/responses/Caption.kt index eebc6655..48be369c 100644 --- a/app/src/main/java/awais/instagrabber/repositories/responses/Caption.kt +++ b/app/src/main/java/awais/instagrabber/repositories/responses/Caption.kt @@ -2,6 +2,9 @@ package awais.instagrabber.repositories.responses import java.io.Serializable -data class Caption(val userId: Long, var text: String?) : Serializable { - var pk: Long = 0 +data class Caption( + val userId: Long = 0, + var text: String? = null, +) : Serializable { + var pk: String? = null } \ No newline at end of file diff --git a/app/src/main/java/awais/instagrabber/repositories/serializers/CaptionDeserializer.java b/app/src/main/java/awais/instagrabber/repositories/serializers/CaptionDeserializer.java index 0bd796ab..9db0278d 100644 --- a/app/src/main/java/awais/instagrabber/repositories/serializers/CaptionDeserializer.java +++ b/app/src/main/java/awais/instagrabber/repositories/serializers/CaptionDeserializer.java @@ -30,7 +30,7 @@ public class CaptionDeserializer implements JsonDeserializer { pkString = pkString.substring(0, pkString.indexOf("_")); } try { - caption.setPk(Long.parseLong(pkString)); + caption.setPk(pkString); } catch (NumberFormatException e) { Log.e(TAG, "deserialize: ", e); } diff --git a/app/src/main/java/awais/instagrabber/viewmodels/PostViewV2ViewModel.java b/app/src/main/java/awais/instagrabber/viewmodels/PostViewV2ViewModel.java index 653428b9..6b9466bc 100644 --- a/app/src/main/java/awais/instagrabber/viewmodels/PostViewV2ViewModel.java +++ b/app/src/main/java/awais/instagrabber/viewmodels/PostViewV2ViewModel.java @@ -272,7 +272,7 @@ public class PostViewV2ViewModel extends ViewModel { data.postValue(Resource.loading(null)); final Caption value = caption.getValue(); if (value == null) return data; - mediaService.translate(String.valueOf(value.getPk()), "1", new ServiceCallback() { + mediaService.translate(value.getPk(), "1", new ServiceCallback() { @Override public void onSuccess(final String result) { if (TextUtils.isEmpty(result)) {