Browse Source

Fix Caption de-serialization

renovate/org.robolectric-robolectric-4.x
Ammar Githam 4 years ago
parent
commit
ce31554687
  1. 7
      app/src/main/java/awais/instagrabber/repositories/responses/Caption.kt
  2. 2
      app/src/main/java/awais/instagrabber/repositories/serializers/CaptionDeserializer.java
  3. 2
      app/src/main/java/awais/instagrabber/viewmodels/PostViewV2ViewModel.java

7
app/src/main/java/awais/instagrabber/repositories/responses/Caption.kt

@ -2,6 +2,9 @@ package awais.instagrabber.repositories.responses
import java.io.Serializable 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
} }

2
app/src/main/java/awais/instagrabber/repositories/serializers/CaptionDeserializer.java

@ -30,7 +30,7 @@ public class CaptionDeserializer implements JsonDeserializer<Caption> {
pkString = pkString.substring(0, pkString.indexOf("_")); pkString = pkString.substring(0, pkString.indexOf("_"));
} }
try { try {
caption.setPk(Long.parseLong(pkString));
caption.setPk(pkString);
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
Log.e(TAG, "deserialize: ", e); Log.e(TAG, "deserialize: ", e);
} }

2
app/src/main/java/awais/instagrabber/viewmodels/PostViewV2ViewModel.java

@ -272,7 +272,7 @@ public class PostViewV2ViewModel extends ViewModel {
data.postValue(Resource.loading(null)); data.postValue(Resource.loading(null));
final Caption value = caption.getValue(); final Caption value = caption.getValue();
if (value == null) return data; if (value == null) return data;
mediaService.translate(String.valueOf(value.getPk()), "1", new ServiceCallback<String>() {
mediaService.translate(value.getPk(), "1", new ServiceCallback<String>() {
@Override @Override
public void onSuccess(final String result) { public void onSuccess(final String result) {
if (TextUtils.isEmpty(result)) { if (TextUtils.isEmpty(result)) {

Loading…
Cancel
Save