Skip to content

Commit

Permalink
actions: refactor DocumentResponse model to kotlin (fixes #2740) (#…
Browse files Browse the repository at this point in the history
…2744)

Co-authored-by: dogi <[email protected]>
  • Loading branch information
Okuro3499 and dogi authored Dec 1, 2023
1 parent 158f21c commit 7532a02
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 47 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ android {
applicationId "org.ole.planet.myplanet"
minSdkVersion 21
targetSdkVersion 34
versionCode 1173
versionName "0.11.73"
versionCode 1174
versionName "0.11.74"
ndkVersion '21.3.6528147'
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package org.ole.planet.myplanet.model

class DocumentResponse {
var total_rows: String? = null
var offset: String? = null
@JvmField
var rows: List<Rows>? = null
override fun toString(): String {
return "ClassPojo [total_rows = $total_rows, offset = $offset, rows = $rows]"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

import com.google.gson.Gson;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonNull;
import com.google.gson.JsonObject;

Expand Down Expand Up @@ -191,8 +190,8 @@ private void myLibraryTransactionSync() {
mRealm.executeTransaction(realm -> {
try {
DocumentResponse res = apiInterface.getDocuments(Utilities.getHeader(), Utilities.getUrl() + "/shelf/_all_docs").execute().body();
for (int i = 0; i < res.getRows().size(); i++) {
shelfDoc = res.getRows().get(i);
for (int i = 0; i < res.rows.size(); i++) {
shelfDoc = res.rows.get(i);
populateShelfItems(apiInterface, realm);
}
} catch (IOException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ private static void syncHealthData(RealmUserModel userModel, String header) {
try {
response = apiInterface.getDocuments(header, Utilities.getUrl() + "/" + table + "/_all_docs").execute();
DocumentResponse ob = (DocumentResponse) response.body();
if (ob != null && ob.getRows().size() > 0) {
Rows r = ob.getRows().get(0);
if (ob != null && ob.rows.size() > 0) {
Rows r = ob.rows.get(0);
JsonObject jsonDoc = apiInterface.getJsonObject(header, Utilities.getUrl() + "/" + table + "/" + r.getId()).execute().body();
userModel.setKey(JsonUtils.getString("key", jsonDoc));
userModel.setIv(JsonUtils.getString("iv", jsonDoc));
Expand Down

0 comments on commit 7532a02

Please sign in to comment.