From 5030676dcdaf0dda85d6732f6b0058a5fef2a721 Mon Sep 17 00:00:00 2001 From: Gideon Okuro Date: Tue, 5 Dec 2023 18:49:26 +0300 Subject: [PATCH] convert realmMyLibrary to kotlin --- .../myplanet/base/BaseContainerFragment.kt | 8 +- .../myplanet/base/BaseRecyclerFragment.java | 16 +- .../myplanet/base/BaseResourceFragment.java | 6 +- .../datamanager/FileUploadService.java | 4 +- .../datamanager/MyDownloadService.java | 4 +- .../planet/myplanet/model/RealmMyLibrary.java | 757 ------------------ .../planet/myplanet/model/RealmMyLibrary.kt | 485 +++++++++++ .../service/UserProfileDbHandler.java | 4 +- .../planet/myplanet/ui/SettingActivity.java | 2 +- .../ui/dashboard/DashboardActivity.java | 2 +- .../myplanet/ui/library/AdapterLibrary.java | 28 +- .../ui/library/AddResourceActivity.java | 36 +- .../ui/library/LibraryDetailFragment.java | 24 +- .../myplanet/ui/library/LibraryFragment.java | 7 +- .../planet/myplanet/ui/news/AdapterNews.java | 2 +- .../ui/team/MyTeamsDetailFragment.java | 2 +- .../teamResource/AdapterTeamResource.java | 4 +- .../teamResource/TeamResourceFragment.java | 4 +- .../ui/userprofile/AchievementFragment.java | 4 +- .../userprofile/EditAchievementFragment.java | 4 +- .../myplanet/ui/viewer/PDFReaderActivity.java | 6 +- .../planet/myplanet/utilities/Utilities.java | 2 +- 22 files changed, 568 insertions(+), 843 deletions(-) delete mode 100644 app/src/main/java/org/ole/planet/myplanet/model/RealmMyLibrary.java create mode 100644 app/src/main/java/org/ole/planet/myplanet/model/RealmMyLibrary.kt diff --git a/app/src/main/java/org/ole/planet/myplanet/base/BaseContainerFragment.kt b/app/src/main/java/org/ole/planet/myplanet/base/BaseContainerFragment.kt index f7f6b077bf..ff198f7994 100644 --- a/app/src/main/java/org/ole/planet/myplanet/base/BaseContainerFragment.kt +++ b/app/src/main/java/org/ole/planet/myplanet/base/BaseContainerFragment.kt @@ -99,7 +99,7 @@ abstract class BaseContainerFragment : BaseResourceFragment() { fun openIntent(items: RealmMyLibrary, typeClass: Class<*>?) { val fileOpenIntent = Intent(activity, typeClass) - if (items.resourceLocalAddress.contains("ole/audio") || items.resourceLocalAddress.contains( + if (items.resourceLocalAddress!!.contains("ole/audio") || items.resourceLocalAddress!!.contains( "ole/video" ) ) { @@ -118,7 +118,7 @@ abstract class BaseContainerFragment : BaseResourceFragment() { } fun openResource(items: RealmMyLibrary) { - if (items.resourceOffline != null && items.isResourceOffline) { + if (items.resourceOffline != null && items.isResourceOffline()) { openFileType(items, "offline") } else if (FileUtils.getFileExtension(items.resourceLocalAddress) == "mp4") { openFileType(items, "online") @@ -131,7 +131,7 @@ abstract class BaseContainerFragment : BaseResourceFragment() { } fun checkFileExtension(items: RealmMyLibrary) { - val filenameArray = items.resourceLocalAddress.split("\\.".toRegex()).toTypedArray() + val filenameArray = items.resourceLocalAddress!!.split("\\.".toRegex()).toTypedArray() val extension = filenameArray[filenameArray.size - 1] val mimetype = Utilities.getMimeType(items.resourceLocalAddress) if (mimetype.contains("image")) { @@ -256,7 +256,7 @@ abstract class BaseContainerFragment : BaseResourceFragment() { tv.setCompoundDrawablesWithIntrinsicBounds( 0, 0, - if (library!!.isResourceOffline) R.drawable.ic_eye else R.drawable.ic_download, + if (library!!.isResourceOffline()) R.drawable.ic_eye else R.drawable.ic_download, 0 ) tv.text = library.title diff --git a/app/src/main/java/org/ole/planet/myplanet/base/BaseRecyclerFragment.java b/app/src/main/java/org/ole/planet/myplanet/base/BaseRecyclerFragment.java index 1148617d29..026106b376 100644 --- a/app/src/main/java/org/ole/planet/myplanet/base/BaseRecyclerFragment.java +++ b/app/src/main/java/org/ole/planet/myplanet/base/BaseRecyclerFragment.java @@ -112,9 +112,9 @@ public void addToMyList() { for (int i = 0; i < selectedItems.size(); i++) { RealmObject object = (RealmObject) selectedItems.get(i); if (object instanceof RealmMyLibrary) { - RealmMyLibrary myObject = mRealm.where(RealmMyLibrary.class).equalTo("resourceId", ((RealmMyLibrary) object).getResource_id()).findFirst(); + RealmMyLibrary myObject = mRealm.where(RealmMyLibrary.class).equalTo("resourceId", ((RealmMyLibrary) object).resourceId).findFirst(); RealmMyLibrary.createFromResource(myObject, mRealm, model.getId()); - RealmRemovedLog.onAdd(mRealm, "resources", profileDbHandler.getUserModel().getId(), myObject.getResourceId()); + RealmRemovedLog.onAdd(mRealm, "resources", profileDbHandler.getUserModel().getId(), myObject.resourceId); Utilities.toast(getActivity(), getString(R.string.added_to_my_library)); } else { RealmMyCourse myObject = RealmMyCourse.getMyCourse(mRealm, ((RealmMyCourse) object).getCourseId()); @@ -176,7 +176,7 @@ private List
  • getData(String s, Class c) { } private void searchAndAddToList(LI l, Class c, String[] query, List
  • li) { - String title = c == RealmMyLibrary.class ? ((RealmMyLibrary) l).getTitle() : ((RealmMyCourse) l).getCourseTitle(); + String title = c == RealmMyLibrary.class ? ((RealmMyLibrary) l).title : ((RealmMyCourse) l).getCourseTitle(); boolean isExists = false; for (String q : query) { isExists = title.toLowerCase().contains(q.toLowerCase()); @@ -219,7 +219,7 @@ public List filterCourseByTag(String s, List tags) { private void filter(List tags, RealmMyLibrary library, RealmList libraries) { for (RealmTag tg : tags) { - long count = mRealm.where(RealmTag.class).equalTo("db", "resources").equalTo("tagId", tg.getId()).equalTo("linkId", library.getId()).count(); + long count = mRealm.where(RealmTag.class).equalTo("db", "resources").equalTo("tagId", tg.getId()).equalTo("linkId", library.id).count(); if (count > 0 && !libraries.contains(library)) libraries.add(library); } } @@ -247,10 +247,10 @@ public List applyCourseFilter(List courses) { } private boolean isValidFilter(RealmMyLibrary l) { - boolean sub = subjects.isEmpty() || l.getSubject().containsAll(subjects); - boolean lev = levels.isEmpty() || l.getLevel().containsAll(levels); - boolean lan = languages.isEmpty() || languages.contains(l.getLanguage()); - boolean med = mediums.isEmpty() || mediums.contains(l.getMediaType()); + boolean sub = subjects.isEmpty() || l.subject.containsAll(subjects); + boolean lev = levels.isEmpty() || l.level.containsAll(levels); + boolean lan = languages.isEmpty() || languages.contains(l.language); + boolean med = mediums.isEmpty() || mediums.contains(l.mediaType); return (sub && lev && lan && med); } } \ No newline at end of file diff --git a/app/src/main/java/org/ole/planet/myplanet/base/BaseResourceFragment.java b/app/src/main/java/org/ole/planet/myplanet/base/BaseResourceFragment.java index ea3f7169ff..2b537fffe7 100644 --- a/app/src/main/java/org/ole/planet/myplanet/base/BaseResourceFragment.java +++ b/app/src/main/java/org/ole/planet/myplanet/base/BaseResourceFragment.java @@ -188,7 +188,7 @@ public void createListView(List db_myLibrary, AlertDialog alertD lv = convertView.findViewById(R.id.alertDialog_listView); ArrayList names = new ArrayList<>(); for (int i = 0; i < db_myLibrary.size(); i++) { - names.add(db_myLibrary.get(i).getTitle()); + names.add(db_myLibrary.get(i).title); } ArrayAdapter adapter = new ArrayAdapter(getActivity().getBaseContext(), R.layout.rowlayout, R.id.checkBoxRowLayout, names); lv.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE); @@ -257,9 +257,9 @@ public void onPause() { public void removeFromShelf(RealmObject object) { if (object instanceof RealmMyLibrary) { - RealmMyLibrary myObject = mRealm.where(RealmMyLibrary.class).equalTo("resourceId", ((RealmMyLibrary) object).getResource_id()).findFirst(); + RealmMyLibrary myObject = mRealm.where(RealmMyLibrary.class).equalTo("resourceId", ((RealmMyLibrary) object).resourceId).findFirst(); myObject.removeUserId(model.getId()); - RealmRemovedLog.onRemove(mRealm, "resources", model.getId(), ((RealmMyLibrary) object).getResource_id()); + RealmRemovedLog.onRemove(mRealm, "resources", model.getId(), ((RealmMyLibrary) object).resourceId); Utilities.toast(getActivity(), getString(R.string.removed_from_mylibrary)); } else { RealmMyCourse myObject = RealmMyCourse.getMyCourse(mRealm, ((RealmMyCourse) object).getCourseId()); diff --git a/app/src/main/java/org/ole/planet/myplanet/datamanager/FileUploadService.java b/app/src/main/java/org/ole/planet/myplanet/datamanager/FileUploadService.java index 861ea41c81..64f50c7b2d 100644 --- a/app/src/main/java/org/ole/planet/myplanet/datamanager/FileUploadService.java +++ b/app/src/main/java/org/ole/planet/myplanet/datamanager/FileUploadService.java @@ -32,8 +32,8 @@ public void uploadAttachment(String id, String rev, RealmMyPersonal personal, Su } public void uploadAttachment(String id, String rev, RealmMyLibrary personal, SuccessListener listener) { - File f = new File(personal.getResourceLocalAddress()); - String name = FileUtils.getFileNameFromUrl(personal.getResourceLocalAddress()); + File f = new File(personal.resourceLocalAddress); + String name = FileUtils.getFileNameFromUrl(personal.resourceLocalAddress); upload_doc(id, rev, "%s/resources/%s/%s", f, name, listener); } diff --git a/app/src/main/java/org/ole/planet/myplanet/datamanager/MyDownloadService.java b/app/src/main/java/org/ole/planet/myplanet/datamanager/MyDownloadService.java index 18e76f2162..155c68fe67 100644 --- a/app/src/main/java/org/ole/planet/myplanet/datamanager/MyDownloadService.java +++ b/app/src/main/java/org/ole/planet/myplanet/datamanager/MyDownloadService.java @@ -202,8 +202,8 @@ private void changeOfflineStatus() { mRealm.executeTransaction(realm -> { RealmMyLibrary obj = realm.where(RealmMyLibrary.class).equalTo("resourceLocalAddress", currentFileName).findFirst(); if (obj != null) { - obj.setResourceOffline(true); - obj.setDownloadedRev(obj.get_rev()); + obj.resourceOffline = true; + obj.downloadedRev = obj.get_rev(); } else { Utilities.log("object Is null"); } diff --git a/app/src/main/java/org/ole/planet/myplanet/model/RealmMyLibrary.java b/app/src/main/java/org/ole/planet/myplanet/model/RealmMyLibrary.java deleted file mode 100644 index 5c421a387c..0000000000 --- a/app/src/main/java/org/ole/planet/myplanet/model/RealmMyLibrary.java +++ /dev/null @@ -1,757 +0,0 @@ -package org.ole.planet.myplanet.model; - -import android.content.Context; -import android.content.SharedPreferences; -import android.text.TextUtils; - -import com.google.gson.JsonArray; -import com.google.gson.JsonElement; -import com.google.gson.JsonNull; -import com.google.gson.JsonObject; -import com.google.gson.JsonParser; - -import org.ole.planet.myplanet.MainApplication; -import org.ole.planet.myplanet.ui.sync.SyncActivity; -import org.ole.planet.myplanet.utilities.FileUtils; -import org.ole.planet.myplanet.utilities.JsonUtils; -import org.ole.planet.myplanet.utilities.NetworkUtils; - -import java.util.ArrayList; -import java.util.Calendar; -import java.util.Date; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import io.realm.Realm; -import io.realm.RealmList; -import io.realm.RealmObject; -import io.realm.RealmResults; -import io.realm.annotations.PrimaryKey; - -public class RealmMyLibrary extends RealmObject { - @PrimaryKey - private String id; - private String _id; - private RealmList userId; - private String resourceRemoteAddress; - private String resourceLocalAddress; - private Boolean resourceOffline = false; - private String resourceId; - private String _rev; - private String downloadedRev; - private boolean need_optimization; - private String publisher; - private String linkToLicense; - private String addedBy; - private String uploadDate; - private String createdDate; - private String openWith; - private String articleDate; - private String kind; - private String language; - private String author; - private String year; - private String medium; - private String title; - private String averageRating; - private String filename; - private String mediaType; - private String resourceType; - private String description; - private String sendOnAccept; - private String translationAudioPath; - private int sum; - private int timesRated; - private RealmList resourceFor; - private RealmList subject; - private RealmList level; - private RealmList tag; - private RealmList languages; - private String courseId; - private String stepId; - private String downloaded; - private boolean isPrivate; - - public static List getMyLibraryByUserId(Realm mRealm, SharedPreferences settings) { - RealmResults libs = mRealm.where(RealmMyLibrary.class).findAll(); - return getMyLibraryByUserId(settings.getString("userId", "--"), libs, mRealm); - } - - public static List getMyLibraryByUserId(String userId, List libs, Realm mRealm) { - List libraries = new ArrayList<>(); - List ids = RealmMyTeam.getResourceIdsByUser(userId, mRealm); - - for (RealmMyLibrary item : libs) { - if (item.getUserId().contains(userId) || ids.contains(item.getResourceId())) { - libraries.add(item); - } - } - return libraries; - } - - public static List getMyLibraryByUserId(String userId, List libs) { - List libraries = new ArrayList<>(); - - for (RealmMyLibrary item : libs) { - if (item.getUserId().contains(userId)) { - libraries.add(item); - } - } - return libraries; - } - - public static List getOurLibrary(String userId, List libs) { - List libraries = new ArrayList<>(); - for (RealmMyLibrary item : libs) { - if (!item.getUserId().contains(userId)) { - libraries.add(item); - } - } - return libraries; - } - public static String[] getIds(Realm mRealm) { - List list = mRealm.where(RealmMyLibrary.class).findAll(); - String[] ids = new String[list.size()]; - int i = 0; - for (RealmMyLibrary library : list) { - ids[i] = (library.getResource_id()); - i++; - } - return ids; - } - - public static void removeDeletedResource(List newIds, Realm mRealm) { - String[] ids = getIds(mRealm); - for (String id : ids) { - if (!newIds.contains(id)) { - mRealm.where(RealmMyLibrary.class).equalTo("resourceId", id).findAll().deleteAllFromRealm(); - } - } - } - - public static JsonObject serialize(RealmMyLibrary personal, RealmUserModel user) { - JsonObject object = new JsonObject(); - object.addProperty("title", personal.getTitle()); - object.addProperty("uploadDate", new Date().getTime()); - object.addProperty("createdDate", personal.getCreatedDate()); - object.addProperty("filename", FileUtils.getFileNameFromUrl(personal.getResourceLocalAddress())); - object.addProperty("author", user.getName()); - object.addProperty("addedBy", user.getId()); - object.addProperty("medium", personal.getMedium()); - object.addProperty("description", personal.getDescription()); - object.addProperty("year", personal.getYear()); - object.addProperty("language", personal.getLanguage()); - object.add("subject", JsonUtils.getAsJsonArray(personal.getSubject())); - object.add("level", JsonUtils.getAsJsonArray(personal.getLevel())); - object.addProperty("resourceType", personal.getResourceType()); - object.addProperty("openWith", personal.getOpenWith()); - object.add("resourceFor", JsonUtils.getAsJsonArray(personal.getResourceFor())); - object.addProperty("private", false); - object.addProperty("isDownloadable", ""); - object.addProperty("sourcePlanet", user.getPlanetCode()); - object.addProperty("resideOn", user.getPlanetCode()); - object.addProperty("updatedDate", Calendar.getInstance().getTimeInMillis()); - object.addProperty("createdDate", personal.getCreatedDate()); - object.addProperty("androidId", NetworkUtils.getUniqueIdentifier()); - object.addProperty("deviceName", NetworkUtils.getDeviceName()); - object.addProperty("customDeviceName", NetworkUtils.getCustomDeviceName(MainApplication.context)); - return object; - } - - public String getDownloaded() { - return downloaded; - } - - public void setDownloaded(String downloaded) { - this.downloaded = downloaded; - } - - public static void insertResources(JsonObject doc, Realm mRealm) { - insertMyLibrary("", doc, mRealm); - } - - public static void createStepResource(Realm mRealm, JsonObject res, String myCoursesID, String stepId) { - insertMyLibrary("", stepId, myCoursesID, res, mRealm); - } - - public static void insertMyLibrary(String userId, JsonObject doc, Realm mRealm) { - insertMyLibrary(userId, "", "", doc, mRealm); - } - - public String getMedium() { - return medium; - } - - public boolean isPrivate() { - return isPrivate; - } - - public void setPrivate(boolean aPrivate) { - isPrivate = aPrivate; - } - - public void setMedium(String medium) { - this.medium = medium; - } - - public static void createFromResource(RealmMyLibrary resource, Realm mRealm, String userId) { - if (!mRealm.isInTransaction()) mRealm.beginTransaction(); - resource.setUserId(userId); - mRealm.commitTransaction(); - } - - public String get_id() { - return _id; - } - - public void set_id(String _id) { - this._id = _id; - } - - public static void insertMyLibrary(String userId, String stepId, String courseId, JsonObject doc, Realm mRealm) { - - String resourceId = JsonUtils.getString("_id", doc); - SharedPreferences settings = MainApplication.context.getSharedPreferences(SyncActivity.PREFS_NAME, Context.MODE_PRIVATE); - RealmMyLibrary resource = mRealm.where(RealmMyLibrary.class).equalTo("id", resourceId).findFirst(); - if (resource == null) { - resource = mRealm.createObject(RealmMyLibrary.class, resourceId); - } - resource.setUserId(userId); - resource.set_id(resourceId); - if (!TextUtils.isEmpty(stepId)) { - resource.setStepId(stepId); - } - if (!TextUtils.isEmpty(courseId)) { - resource.setCourseId(courseId); - } - resource.set_rev(JsonUtils.getString("_rev", doc)); - - resource.setResource_id(resourceId); - resource.setTitle(JsonUtils.getString("title", doc)); - resource.setDescription(JsonUtils.getString("description", doc)); - if (doc.has("_attachments")) { - JsonObject attachments = doc.get("_attachments").getAsJsonObject(); - JsonParser parser = new JsonParser(); - JsonElement element = parser.parse(String.valueOf(attachments)); - JsonObject obj = element.getAsJsonObject(); - Set> entries = obj.entrySet(); - for (Map.Entry entry : entries) { - if (entry.getKey().indexOf("/") < 0) { - resource.setResourceRemoteAddress(settings.getString("couchdbURL", "http://") + "/resources/" + resourceId + "/" + entry.getKey()); - resource.setResourceLocalAddress(entry.getKey()); - resource.setResourceOffline(FileUtils.checkFileExist(resource.getResourceRemoteAddress())); - } - } - } - resource.setFilename(JsonUtils.getString("filename", doc)); - resource.setAverageRating(JsonUtils.getString("averageRating", doc)); - resource.setUploadDate(JsonUtils.getString("uploadDate", doc)); - resource.setYear(JsonUtils.getString("year", doc)); - resource.setAddedBy(JsonUtils.getString("addedBy", doc)); - resource.setPublisher(JsonUtils.getString("publisher", doc)); - resource.setLinkToLicense(JsonUtils.getString("linkToLicense", doc)); - resource.setOpenWith(JsonUtils.getString("openWith", doc)); - resource.setArticleDate(JsonUtils.getString("articleDate", doc)); - resource.setKind(JsonUtils.getString("kind", doc)); - resource.setCreatedDate(JsonUtils.getString("createdDate", doc)); - resource.setLanguage(JsonUtils.getString("language", doc)); - resource.setAuthor(JsonUtils.getString("author", doc)); - resource.setMediaType(JsonUtils.getString("mediaType", doc)); - resource.setResourceType(JsonUtils.getString("resourceType", doc)); - resource.setTimesRated(JsonUtils.getInt("timesRated", doc)); - resource.setMedium(JsonUtils.getString("medium", doc)); - resource.setResourceFor(JsonUtils.getJsonArray("resourceFor", doc), resource); - resource.setSubject(JsonUtils.getJsonArray("subject", doc), resource); - resource.setLevel(JsonUtils.getJsonArray("level", doc), resource); - resource.setTag(JsonUtils.getJsonArray("tags", doc), resource); - resource.setPrivate(JsonUtils.getBoolean("private", doc)); - resource.setLanguages(JsonUtils.getJsonArray("languages", doc), resource); - } - - public String getResourceType() { - return resourceType; - } - - public void setResourceType(String resourceType) { - this.resourceType = resourceType; - } - - public String getCreatedDate() { - return createdDate; - } - - public void setCreatedDate(String createdDate) { - this.createdDate = createdDate; - } - - public JsonObject serializeResource() { - JsonObject object = new JsonObject(); - object.addProperty("_id", _id); - object.addProperty("_rev", _rev); - object.addProperty("_rev", _rev); - object.addProperty("need_optimization", need_optimization); - - object.add("resourceFor", getArray(resourceFor)); - object.addProperty("publisher", publisher); - object.addProperty("linkToLicense", linkToLicense); - object.addProperty("addedBy", addedBy); - object.addProperty("uploadDate", uploadDate); - object.addProperty("openWith", openWith); - object.add("subject", getArray(subject)); - object.addProperty("kind", kind); - object.addProperty("medium", medium); - object.addProperty("language", language); - object.addProperty("author", author); - object.addProperty("sum", sum); - object.addProperty("createdDate", uploadDate); - object.add("level", getArray(level)); - object.add("languages", getArray(languages)); - object.add("tag", getArray(tag)); - object.addProperty("timesRated", timesRated); - object.addProperty("year", year); - object.addProperty("title", title); - object.addProperty("averageRating", averageRating); - object.addProperty("filename", filename); - object.addProperty("mediaType", mediaType); - object.addProperty("description", description); - JsonObject ob = new JsonObject(); - ob.add(resourceLocalAddress, new JsonObject()); - object.add("_attachments", ob); - return object; - } - - public JsonArray getArray(RealmList ar) { - JsonArray sub = new JsonArray(); - if (ar != null) { - for (String s : ar) { - sub.add(s); - } - } - return sub; - } - - public RealmList getUserId() { - return userId; - } - - public void setUserId(String userId) { - if (this.userId == null) { - this.userId = new RealmList<>(); - } - - if (!this.userId.contains(userId) && !TextUtils.isEmpty(userId)) this.userId.add(userId); - } - - public String getResourceId() { - return resourceId; - } - - public void setResourceId(String resourceId) { - this.resourceId = resourceId; - } - - public String getResourceRemoteAddress() { - return resourceRemoteAddress; - } - - public void setResourceRemoteAddress(String resourceRemoteAddress) { - this.resourceRemoteAddress = resourceRemoteAddress; - } - - public String getResourceLocalAddress() { - return resourceLocalAddress; - } - - public void setResourceLocalAddress(String resourceLocalAddress) { - this.resourceLocalAddress = resourceLocalAddress; - } - - public Boolean getResourceOffline() { - return resourceOffline; - } - - public Boolean isResourceOffline() { - return resourceOffline && TextUtils.equals(_rev, downloadedRev); - } - - public void setResourceOffline(Boolean resourceOffline) { - this.resourceOffline = resourceOffline; - } - - public String getResource_id() { - return resourceId; - } - - public void setResource_id(String resource_id) { - this.resourceId = resource_id; - } - - public RealmList getResourceFor() { - return resourceFor; - } - - public void setResourceFor(JsonArray array, RealmMyLibrary resource) { - for (JsonElement s : array) { - if (!(s instanceof JsonNull) && !resource.getResourceFor().contains(s.getAsString())) - resource.getResourceFor().add(s.getAsString()); - } - } - - public void setSubject(JsonArray array, RealmMyLibrary resource) { - for (JsonElement s : array) { - if (!(s instanceof JsonNull) && !resource.getSubject().contains(s.getAsString())) - resource.getSubject().add(s.getAsString()); - } - } - - public void setLevel(JsonArray array, RealmMyLibrary resource) { - for (JsonElement s : array) { - if (!(s instanceof JsonNull) && !resource.getLevel().contains(s.getAsString())) - resource.getLevel().add(s.getAsString()); - } - } - - public String getTranslationAudioPath() { - return translationAudioPath; - } - - public void setTranslationAudioPath(String translationAudioPath) { - this.translationAudioPath = translationAudioPath; - } - - public void setTag(JsonArray array, RealmMyLibrary resource) { - for (JsonElement s : array) { - if (!(s instanceof JsonNull) && !resource.getTag().contains(s.getAsString())) - resource.getTag().add(s.getAsString()); - } - } - - public void setLanguages(JsonArray array, RealmMyLibrary resource) { - for (JsonElement s : array) { - if (!(s instanceof JsonNull) && !resource.getLanguages().contains(s.getAsString())) - resource.getLanguages().add(s.getAsString()); - } - } - - public static CharSequence[] getListAsArray(RealmResults db_myLibrary) { - CharSequence[] array = new CharSequence[db_myLibrary.size()]; - for (int i = 0; i < db_myLibrary.size(); i++) { - array[i] = db_myLibrary.get(i).getTitle(); - } - return array; - } - - public void setResourceFor(RealmList resourceFor) { - this.resourceFor = resourceFor; - } - - public RealmList getSubject() { - return subject; - } - - public void setUserId(RealmList userId) { - this.userId = userId; - } - - public String getDownloadedRev() { - return downloadedRev; - } - - public void setDownloadedRev(String downloadedRev) { - this.downloadedRev = downloadedRev; - } - - public String getSubjectsAsString() { - if ((subject).isEmpty()) { - return ""; - } - String str = ""; - for (String s : subject) { - str += s + ", "; - } - return str.substring(0, str.length() - 1); - } - - public void setSubject(RealmList subject) { - this.subject = subject; - } - - public RealmList getLevel() { - return level; - } - - public void setLevel(RealmList level) { - this.level = level; - } - - public RealmList getTag() { - return tag; - } - - public static String listToString(RealmList list) { - StringBuilder s = new StringBuilder(); - for (String tag : list) { - s.append(tag).append(", "); - } - return s.toString(); - } - - public String getCourseId() { - return courseId; - } - - public void setCourseId(String courseId) { - this.courseId = courseId; - } - - public String getStepId() { - return stepId; - } - - public void setStepId(String stepId) { - this.stepId = stepId; - } - - public void setTag(RealmList tag) { - this.tag = tag; - } - - public RealmList getLanguages() { - return languages; - } - - public void setLanguages(RealmList languages) { - this.languages = languages; - } - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String get_rev() { - return _rev; - } - - public void set_rev(String _rev) { - this._rev = _rev; - } - - public boolean isNeed_optimization() { - return need_optimization; - } - - public void setNeed_optimization(boolean need_optimization) { - this.need_optimization = need_optimization; - } - - public String getPublisher() { - return publisher; - } - - public void setPublisher(String publisher) { - publisher = publisher; - } - - public String getLinkToLicense() { - return linkToLicense; - } - - public void setLinkToLicense(String linkToLicense) { - this.linkToLicense = linkToLicense; - } - - public String getAddedBy() { - return addedBy; - } - - public void setAddedBy(String addedBy) { - this.addedBy = addedBy; - } - - public String getUploadDate() { - return uploadDate; - } - - public void setUploadDate(String uploadDate) { - this.uploadDate = uploadDate; - } - - public String getOpenWith() { - return openWith; - } - - public void setOpenWith(String openWith) { - this.openWith = openWith; - } - - public String getArticleDate() { - return articleDate; - } - - public void setArticleDate(String articleDate) { - this.articleDate = articleDate; - } - - public String getKind() { - return kind; - } - - public void setKind(String kind) { - this.kind = kind; - } - - public String getLanguage() { - return language; - } - - public void setLanguage(String language) { - this.language = language; - } - - public String getAuthor() { - return author; - } - - public void setAuthor(String author) { - this.author = author; - } - - public String getYear() { - return year; - } - - public void setYear(String year) { - this.year = year; - } - - public String getTitle() { - return title; - } - - public void setTitle(String title) { - this.title = title; - } - - public String getAverageRating() { - return averageRating; - } - - public void setAverageRating(String averageRating) { - this.averageRating = averageRating; - } - - public String getFilename() { - return filename; - } - - public void setFilename(String filename) { - this.filename = filename; - } - - public String getMediaType() { - return mediaType; - } - - public void setMediaType(String mediaType) { - this.mediaType = mediaType; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public String getSendOnAccept() { - return sendOnAccept; - } - - public void setSendOnAccept(String sendOnAccept) { - this.sendOnAccept = sendOnAccept; - } - - public int getSum() { - return sum; - } - - public void setSum(int sum) { - this.sum = sum; - } - - public int getTimesRated() { - return timesRated; - } - - public void setTimesRated(int timesRated) { - this.timesRated = timesRated; - } - - public static List save(JsonArray allDocs, Realm mRealm) { - List list = new ArrayList<>(); - for (int i = 0; i < allDocs.size(); i++) { - JsonObject doc = allDocs.get(i).getAsJsonObject(); - doc = JsonUtils.getJsonObject("doc", doc); - String id = JsonUtils.getString("_id", doc); - if (!id.startsWith("_design")) { - list.add(id); - RealmMyLibrary.insertResources(doc, mRealm); - } - } - return list; - } - - public static JsonArray getMyLibIds(Realm realm, String userId) { - List myLibraries = realm.where(RealmMyLibrary.class).contains("userId", userId).findAll(); - JsonArray ids = new JsonArray(); - for (RealmMyLibrary lib : myLibraries) { - ids.add(lib.getId()); - } - return ids; - } - - @Override - public String toString() { - return title; - } - - public void removeUserId(String id) { - this.userId.remove(id); - } - - public boolean needToUpdate() { - return (getResourceLocalAddress() != null) && !getResourceOffline() || !(TextUtils.equals(get_rev(), getDownloadedRev())); - } - - public static Set getLevels(List libraries) { - Set list = new HashSet<>(); - for (RealmMyLibrary li : libraries) { - list.addAll(li.getLevel()); - } - return list; - } - - public static Set getArrayList(List libraries, String type) { - Set list = new HashSet<>(); - for (RealmMyLibrary li : libraries) { - String s = type.equals("mediums") ? li.getMediaType() : li.getLanguage(); - if (!TextUtils.isEmpty(s)) list.add(s); - } - return list; - } - - public static Set getSubjects(List libraries) { - Set list = new HashSet<>(); - for (RealmMyLibrary li : libraries) { - list.addAll(li.getSubject()); - } - return list; - } -} \ No newline at end of file diff --git a/app/src/main/java/org/ole/planet/myplanet/model/RealmMyLibrary.kt b/app/src/main/java/org/ole/planet/myplanet/model/RealmMyLibrary.kt new file mode 100644 index 0000000000..2fa8a9b890 --- /dev/null +++ b/app/src/main/java/org/ole/planet/myplanet/model/RealmMyLibrary.kt @@ -0,0 +1,485 @@ +package org.ole.planet.myplanet.model + +import android.content.Context +import android.content.SharedPreferences +import android.text.TextUtils +import com.google.gson.JsonArray +import com.google.gson.JsonNull +import com.google.gson.JsonObject +import com.google.gson.JsonParser +import io.realm.Realm +import io.realm.RealmList +import io.realm.RealmObject +import io.realm.RealmResults +import io.realm.annotations.PrimaryKey +import org.ole.planet.myplanet.MainApplication +import org.ole.planet.myplanet.ui.sync.SyncActivity +import org.ole.planet.myplanet.utilities.FileUtils +import org.ole.planet.myplanet.utilities.JsonUtils +import org.ole.planet.myplanet.utilities.NetworkUtils +import java.util.Calendar +import java.util.Date + +open class RealmMyLibrary : RealmObject() { + @JvmField + @PrimaryKey + var id: String? = null + private var _id: String? = null + var userId: RealmList? = null + private set + @JvmField + var resourceRemoteAddress: String? = null + @JvmField + var resourceLocalAddress: String? = null + @JvmField + var resourceOffline = false + @JvmField + var resourceId: String? = null + private var _rev: String? = null + @JvmField + var downloadedRev: String? = null + @JvmField + var isNeed_optimization = false + @JvmField + var publisher: String? = null + @JvmField + var linkToLicense: String? = null + @JvmField + var addedBy: String? = null + @JvmField + var uploadDate: String? = null + @JvmField + var createdDate: String? = null + @JvmField + var openWith: String? = null + @JvmField + var articleDate: String? = null + @JvmField + var kind: String? = null + @JvmField + var language: String? = null + @JvmField + var author: String? = null + @JvmField + var year: String? = null + @JvmField + var medium: String? = null + @JvmField + var title: String? = null + @JvmField + var averageRating: String? = null + @JvmField + var filename: String? = null + @JvmField + var mediaType: String? = null + @JvmField + var resourceType: String? = null + @JvmField + var description: String? = null + @JvmField + var sendOnAccept: String? = null + @JvmField + var translationAudioPath: String? = null + @JvmField + var sum = 0 + @JvmField + var timesRated = 0 + @JvmField + var resourceFor: RealmList? = null + @JvmField + var subject: RealmList? = null + @JvmField + var level: RealmList? = null + @JvmField + var tag: RealmList? = null + @JvmField + var languages: RealmList? = null + @JvmField + var courseId: String? = null + @JvmField + var stepId: String? = null + @JvmField + var downloaded: String? = null + @JvmField + var isPrivate = false + fun get_id(): String? { + return _id + } + + fun set_id(_id: String?) { + this._id = _id + } + + fun serializeResource(): JsonObject { + val `object` = JsonObject() + `object`.addProperty("_id", _id) + `object`.addProperty("_rev", _rev) + `object`.addProperty("_rev", _rev) + `object`.addProperty("need_optimization", isNeed_optimization) + `object`.add("resourceFor", getArray(resourceFor)) + `object`.addProperty("publisher", publisher) + `object`.addProperty("linkToLicense", linkToLicense) + `object`.addProperty("addedBy", addedBy) + `object`.addProperty("uploadDate", uploadDate) + `object`.addProperty("openWith", openWith) + `object`.add("subject", getArray(subject)) + `object`.addProperty("kind", kind) + `object`.addProperty("medium", medium) + `object`.addProperty("language", language) + `object`.addProperty("author", author) + `object`.addProperty("sum", sum) + `object`.addProperty("createdDate", uploadDate) + `object`.add("level", getArray(level)) + `object`.add("languages", getArray(languages)) + `object`.add("tag", getArray(tag)) + `object`.addProperty("timesRated", timesRated) + `object`.addProperty("year", year) + `object`.addProperty("title", title) + `object`.addProperty("averageRating", averageRating) + `object`.addProperty("filename", filename) + `object`.addProperty("mediaType", mediaType) + `object`.addProperty("description", description) + val ob = JsonObject() + ob.add(resourceLocalAddress, JsonObject()) + `object`.add("_attachments", ob) + return `object` + } + + fun getArray(ar: RealmList?): JsonArray { + val sub = JsonArray() + if (ar != null) { + for (s in ar) { + sub.add(s) + } + } + return sub + } + + fun setUserId(userId: String?) { + if (this.userId == null) { + this.userId = RealmList() + } + if (!this.userId!!.contains(userId) && !TextUtils.isEmpty(userId)) this.userId!!.add(userId) + } + + fun isResourceOffline(): Boolean { + return resourceOffline && TextUtils.equals(_rev, downloadedRev) + } + + fun setResourceFor(array: JsonArray, resource: RealmMyLibrary?) { + for (s in array) { + if (s !is JsonNull && !resource!!.resourceFor!!.contains(s.asString)) resource.resourceFor!!.add(s.asString) + } + } + + fun setSubject(array: JsonArray, resource: RealmMyLibrary?) { + for (s in array) { + if (s !is JsonNull && !resource!!.subject!!.contains(s.asString)) resource.subject!!.add(s.asString) + } + } + + fun setLevel(array: JsonArray, resource: RealmMyLibrary?) { + for (s in array) { + if (s !is JsonNull && !resource!!.level!!.contains(s.asString)) resource.level!!.add(s.asString) + } + } + + fun setTag(array: JsonArray, resource: RealmMyLibrary?) { + for (s in array) { + if (s !is JsonNull && !resource!!.tag!!.contains(s.asString)) resource.tag!!.add(s.asString) + } + } + + fun setLanguages(array: JsonArray, resource: RealmMyLibrary?) { + for (s in array) { + if (s !is JsonNull && !resource!!.languages!!.contains(s.asString)) resource.languages!!.add(s.asString) + } + } + + fun setUserId(userId: RealmList?) { + this.userId = userId + } + + val subjectsAsString: String + get() { + if (subject!!.isEmpty()) { + return "" + } + var str = "" + for (s in subject!!) { + str += "$s, " + } + return str.substring(0, str.length - 1) + } + + fun get_rev(): String? { + return _rev + } + + fun set_rev(_rev: String?) { + this._rev = _rev + } + + fun getPublisher(): String? { + return publisher + } + + fun setPublisher(publisher: String?) { + var publisher = publisher + publisher = publisher + } + + override fun toString(): String { + return title!! + } + + fun removeUserId(id: String?) { + userId!!.remove(id) + } + + fun needToUpdate(): Boolean { + return resourceLocalAddress != null && !resourceOffline || !TextUtils.equals( + get_rev(), + downloadedRev + ) + } + + companion object { + fun getMyLibraryByUserId(mRealm: Realm, settings: SharedPreferences): List { + val libs = mRealm.where(RealmMyLibrary::class.java).findAll() + return getMyLibraryByUserId(settings.getString("userId", "--"), libs, mRealm) + } + + fun getMyLibraryByUserId(userId: String?, libs: List, mRealm: Realm?): List { + val libraries: MutableList = ArrayList() + val ids = RealmMyTeam.getResourceIdsByUser(userId, mRealm) + for (item in libs) { + if (item.userId!!.contains(userId) || ids.contains(item.resourceId)) { + libraries.add(item) + } + } + return libraries + } + + @JvmStatic + fun getMyLibraryByUserId(userId: String?, libs: List): List { + val libraries: MutableList = ArrayList() + for (item in libs) { + if (item.userId!!.contains(userId)) { + libraries.add(item) + } + } + return libraries + } + + @JvmStatic + fun getOurLibrary(userId: String?, libs: List): List { + val libraries: MutableList = ArrayList() + for (item in libs) { + if (!item.userId!!.contains(userId)) { + libraries.add(item) + } + } + return libraries + } + + fun getIds(mRealm: Realm): Array { + val list: List = mRealm.where(RealmMyLibrary::class.java).findAll() + val ids = arrayOfNulls(list.size) + var i = 0 + for (library in list) { + ids[i] = library.resourceId + i++ + } + return ids + } + + @JvmStatic + fun removeDeletedResource(newIds: List, mRealm: Realm) { + val ids = getIds(mRealm) + for (id in ids) { + if (!newIds.contains(id)) { + mRealm.where(RealmMyLibrary::class.java).equalTo("resourceId", id).findAll().deleteAllFromRealm() + } + } + } + + @JvmStatic + fun serialize(personal: RealmMyLibrary, user: RealmUserModel): JsonObject { + val `object` = JsonObject() + `object`.addProperty("title", personal.title) + `object`.addProperty("uploadDate", Date().time) + `object`.addProperty("createdDate", personal.createdDate) + `object`.addProperty("filename", FileUtils.getFileNameFromUrl(personal.resourceLocalAddress)) + `object`.addProperty("author", user.name) + `object`.addProperty("addedBy", user.id) + `object`.addProperty("medium", personal.medium) + `object`.addProperty("description", personal.description) + `object`.addProperty("year", personal.year) + `object`.addProperty("language", personal.language) + `object`.add("subject", JsonUtils.getAsJsonArray(personal.subject)) + `object`.add("level", JsonUtils.getAsJsonArray(personal.level)) + `object`.addProperty("resourceType", personal.resourceType) + `object`.addProperty("openWith", personal.openWith) + `object`.add("resourceFor", JsonUtils.getAsJsonArray(personal.resourceFor)) + `object`.addProperty("private", false) + `object`.addProperty("isDownloadable", "") + `object`.addProperty("sourcePlanet", user.planetCode) + `object`.addProperty("resideOn", user.planetCode) + `object`.addProperty("updatedDate", Calendar.getInstance().timeInMillis) + `object`.addProperty("createdDate", personal.createdDate) + `object`.addProperty("androidId", NetworkUtils.getUniqueIdentifier()) + `object`.addProperty("deviceName", NetworkUtils.getDeviceName()) + `object`.addProperty("customDeviceName", NetworkUtils.getCustomDeviceName(MainApplication.context)) + return `object` + } + + fun insertResources(doc: JsonObject, mRealm: Realm) { + insertMyLibrary("", doc, mRealm) + } + + @JvmStatic + fun createStepResource(mRealm: Realm, res: JsonObject, myCoursesID: String?, stepId: String?) { + insertMyLibrary("", stepId, myCoursesID, res, mRealm) + } + + @JvmStatic + fun insertMyLibrary(userId: String?, doc: JsonObject, mRealm: Realm) { + insertMyLibrary(userId, "", "", doc, mRealm) + } + + @JvmStatic + fun createFromResource(resource: RealmMyLibrary, mRealm: Realm, userId: String?) { + if (!mRealm.isInTransaction) mRealm.beginTransaction() + resource.setUserId(userId) + mRealm.commitTransaction() + } + + fun insertMyLibrary(userId: String?, stepId: String?, courseId: String?, doc: JsonObject, mRealm: Realm) { + val resourceId = JsonUtils.getString("_id", doc) + val settings = MainApplication.context.getSharedPreferences(SyncActivity.PREFS_NAME, Context.MODE_PRIVATE) + var resource = mRealm.where(RealmMyLibrary::class.java).equalTo("id", resourceId).findFirst() + if (resource == null) { + resource = mRealm.createObject(RealmMyLibrary::class.java, resourceId) + } + resource!!.setUserId(userId) + resource.set_id(resourceId) + if (!TextUtils.isEmpty(stepId)) { + resource.stepId = stepId + } + if (!TextUtils.isEmpty(courseId)) { + resource.courseId = courseId + } + resource.set_rev(JsonUtils.getString("_rev", doc)) + resource.resourceId = resourceId + resource.title = JsonUtils.getString("title", doc) + resource.description = JsonUtils.getString("description", doc) + if (doc.has("_attachments")) { + val attachments = doc["_attachments"].asJsonObject + val parser = JsonParser() + val element = parser.parse(attachments.toString()) + val obj = element.asJsonObject + val entries = obj.entrySet() + for ((key) in entries) { + if (key.indexOf("/") < 0) { + resource.resourceRemoteAddress = settings.getString("couchdbURL", "http://") + "/resources/" + resourceId + "/" + key + resource.resourceLocalAddress = key + resource.resourceOffline = FileUtils.checkFileExist(resource.resourceRemoteAddress) + } + } + } + resource.filename = JsonUtils.getString("filename", doc) + resource.averageRating = JsonUtils.getString("averageRating", doc) + resource.uploadDate = JsonUtils.getString("uploadDate", doc) + resource.year = JsonUtils.getString("year", doc) + resource.addedBy = JsonUtils.getString("addedBy", doc) + resource.setPublisher(JsonUtils.getString("publisher", doc)) + resource.linkToLicense = JsonUtils.getString("linkToLicense", doc) + resource.openWith = JsonUtils.getString("openWith", doc) + resource.articleDate = JsonUtils.getString("articleDate", doc) + resource.kind = JsonUtils.getString("kind", doc) + resource.createdDate = JsonUtils.getString("createdDate", doc) + resource.language = JsonUtils.getString("language", doc) + resource.author = JsonUtils.getString("author", doc) + resource.mediaType = JsonUtils.getString("mediaType", doc) + resource.resourceType = JsonUtils.getString("resourceType", doc) + resource.timesRated = JsonUtils.getInt("timesRated", doc) + resource.medium = JsonUtils.getString("medium", doc) + resource.setResourceFor(JsonUtils.getJsonArray("resourceFor", doc), resource) + resource.setSubject(JsonUtils.getJsonArray("subject", doc), resource) + resource.setLevel(JsonUtils.getJsonArray("level", doc), resource) + resource.setTag(JsonUtils.getJsonArray("tags", doc), resource) + resource.isPrivate = JsonUtils.getBoolean("private", doc) + resource.setLanguages(JsonUtils.getJsonArray("languages", doc), resource) + } + + fun getListAsArray(db_myLibrary: RealmResults): Array { + val array = arrayOfNulls(db_myLibrary.size) + for (i in db_myLibrary.indices) { + array[i] = db_myLibrary[i]!!.title + } + return array + } + + @JvmStatic + fun listToString(list: RealmList): String { + val s = StringBuilder() + for (tag in list) { + s.append(tag).append(", ") + } + return s.toString() + } + + @JvmStatic + fun save(allDocs: JsonArray, mRealm: Realm): List { + val list: MutableList = ArrayList() + for (i in 0 until allDocs.size()) { + var doc = allDocs[i].asJsonObject + doc = JsonUtils.getJsonObject("doc", doc) + val id = JsonUtils.getString("_id", doc) + if (!id.startsWith("_design")) { + list.add(id) + insertResources(doc, mRealm) + } + } + return list + } + + @JvmStatic + fun getMyLibIds(realm: Realm, userId: String?): JsonArray { + val myLibraries: List = realm.where(RealmMyLibrary::class.java).contains("userId", userId).findAll() + val ids = JsonArray() + for (lib in myLibraries) { + ids.add(lib.id) + } + return ids + } + @JvmStatic + fun getLevels(libraries: List): Set { + val list: MutableSet = HashSet() + for (li in libraries) { + list.addAll(li.level!!) + } + return list + } + + @JvmStatic + fun getArrayList(libraries: List, type: String): Set { + val list: MutableSet = HashSet() + for (li in libraries) { + val s = if (type == "mediums") li.mediaType else li.language + if (!TextUtils.isEmpty(s)) list.add(s) + } + return list + } + + @JvmStatic + fun getSubjects(libraries: List): Set { + val list: MutableSet = HashSet() + for (li in libraries) { + list.addAll(li.subject!!) + } + return list + } + } +} \ No newline at end of file diff --git a/app/src/main/java/org/ole/planet/myplanet/service/UserProfileDbHandler.java b/app/src/main/java/org/ole/planet/myplanet/service/UserProfileDbHandler.java index fc2edfb5ba..746d663a62 100644 --- a/app/src/main/java/org/ole/planet/myplanet/service/UserProfileDbHandler.java +++ b/app/src/main/java/org/ole/planet/myplanet/service/UserProfileDbHandler.java @@ -104,8 +104,8 @@ public void setResourceOpenCount(RealmMyLibrary item, String type) { if (!mRealm.isInTransaction()) mRealm.beginTransaction(); RealmResourceActivity offlineActivities = mRealm.copyToRealm(createResourceUser(model)); offlineActivities.setType(type); - offlineActivities.setTitle(item.getTitle()); - offlineActivities.setResourceId(item.getResource_id()); + offlineActivities.setTitle(item.title); + offlineActivities.setResourceId(item.resourceId); offlineActivities.setTime(new Date().getTime()); mRealm.commitTransaction(); Utilities.log("Set resource open"); diff --git a/app/src/main/java/org/ole/planet/myplanet/ui/SettingActivity.java b/app/src/main/java/org/ole/planet/myplanet/ui/SettingActivity.java index 22c3003613..00ce8f9d07 100644 --- a/app/src/main/java/org/ole/planet/myplanet/ui/SettingActivity.java +++ b/app/src/main/java/org/ole/planet/myplanet/ui/SettingActivity.java @@ -119,7 +119,7 @@ private void clearDataButtonInit() { mRealm.executeTransactionAsync(realm -> { RealmResults libraries = realm.where(RealmMyLibrary.class).findAll(); for (RealmMyLibrary library : libraries) - library.setResourceOffline(false); + library.resourceOffline = false; }, () -> { File f = new File(Utilities.SD_PATH); deleteRecursive(f); diff --git a/app/src/main/java/org/ole/planet/myplanet/ui/dashboard/DashboardActivity.java b/app/src/main/java/org/ole/planet/myplanet/ui/dashboard/DashboardActivity.java index 5c550230ae..0007691189 100644 --- a/app/src/main/java/org/ole/planet/myplanet/ui/dashboard/DashboardActivity.java +++ b/app/src/main/java/org/ole/planet/myplanet/ui/dashboard/DashboardActivity.java @@ -367,7 +367,7 @@ public void openCallFragment(Fragment f) { public void openLibraryDetailFragment(RealmMyLibrary library) { Fragment f = new LibraryDetailFragment(); Bundle b = new Bundle(); - b.putString("libraryId", library.getResource_id()); + b.putString("libraryId", library.resourceId); b.putString("openFrom", "Dashboard"); f.setArguments(b); openCallFragment(f); diff --git a/app/src/main/java/org/ole/planet/myplanet/ui/library/AdapterLibrary.java b/app/src/main/java/org/ole/planet/myplanet/ui/library/AdapterLibrary.java index c2d0753026..d532230d3f 100644 --- a/app/src/main/java/org/ole/planet/myplanet/ui/library/AdapterLibrary.java +++ b/app/src/main/java/org/ole/planet/myplanet/ui/library/AdapterLibrary.java @@ -97,19 +97,19 @@ public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, final int if (holder instanceof ViewHolderLibrary) { ViewHolderLibrary viewHolder = (ViewHolderLibrary) holder; viewHolder.bind(); - viewHolder.rowLibraryBinding.title.setText(libraryList.get(position).getTitle()); - Utilities.log(libraryList.get(position).getDescription()); - markwon.setMarkdown(viewHolder.rowLibraryBinding.description, libraryList.get(position).getDescription()); - viewHolder.rowLibraryBinding.timesRated.setText(libraryList.get(position).getTimesRated() + context.getString(R.string.total)); + viewHolder.rowLibraryBinding.title.setText(libraryList.get(position).title); + Utilities.log(libraryList.get(position).description); + markwon.setMarkdown(viewHolder.rowLibraryBinding.description, libraryList.get(position).description); + viewHolder.rowLibraryBinding.timesRated.setText(libraryList.get(position).timesRated + context.getString(R.string.total)); viewHolder.rowLibraryBinding.checkbox.setChecked(selectedItems.contains(libraryList.get(position))); - viewHolder.rowLibraryBinding.rating.setText(TextUtils.isEmpty(libraryList.get(position).getAverageRating()) ? "0.0" : String.format("%.1f", Double.parseDouble(libraryList.get(position).getAverageRating()))); - viewHolder.rowLibraryBinding.tvDate.setText(TimeUtils.formatDate(Long.parseLong(libraryList.get(position).getCreatedDate().trim()), "MMM dd, yyyy")); + viewHolder.rowLibraryBinding.rating.setText(TextUtils.isEmpty(libraryList.get(position).averageRating) ? "0.0" : String.format("%.1f", Double.parseDouble(libraryList.get(position).averageRating))); + viewHolder.rowLibraryBinding.tvDate.setText(TimeUtils.formatDate(Long.parseLong(libraryList.get(position).createdDate.trim()), "MMM dd, yyyy")); displayTagCloud(viewHolder.rowLibraryBinding.flexboxDrawable, position); holder.itemView.setOnClickListener(view -> openLibrary(libraryList.get(position))); viewHolder.rowLibraryBinding.ivDownloaded.setImageResource(libraryList.get(position).isResourceOffline() ? R.drawable.ic_eye : R.drawable.ic_download); - if (ratingMap.containsKey(libraryList.get(position).getResource_id())) { - JsonObject object = ratingMap.get(libraryList.get(position).getResource_id()); + if (ratingMap.containsKey(libraryList.get(position).resourceId)) { + JsonObject object = ratingMap.get(libraryList.get(position).resourceId); AdapterCourses.showRating(object, viewHolder.rowLibraryBinding.rating, viewHolder.rowLibraryBinding.timesRated, viewHolder.rowLibraryBinding.ratingBar); } else { viewHolder.rowLibraryBinding.ratingBar.setRating(0); @@ -154,7 +154,7 @@ private void openLibrary(RealmMyLibrary library) { private void displayTagCloud(FlexboxLayout flexboxDrawable, int position) { flexboxDrawable.removeAllViews(); final ChipCloud chipCloud = new ChipCloud(context, flexboxDrawable, config); - List tags = realm.where(RealmTag.class).equalTo("db", "resources").equalTo("linkId", libraryList.get(position).getId()).findAll(); + List tags = realm.where(RealmTag.class).equalTo("db", "resources").equalTo("linkId", libraryList.get(position).id).findAll(); for (RealmTag tag : tags) { RealmTag parent = realm.where(RealmTag.class).equalTo("id", tag.getTagId()).findFirst(); try { @@ -185,9 +185,9 @@ public void toggleSortOrder() { private void sortLibraryListByTitle() { Collections.sort(libraryList, (library1, library2) -> { if (isTitleAscending) { - return library1.getTitle().compareToIgnoreCase(library2.getTitle()); + return library1.title.compareToIgnoreCase(library2.title); } else { - return library2.getTitle().compareToIgnoreCase(library1.getTitle()); + return library2.title.compareToIgnoreCase(library1.title); } }); } @@ -195,9 +195,9 @@ private void sortLibraryListByTitle() { private void sortLibraryList() { Collections.sort(libraryList, (library1, library2) -> { if (isAscending) { - return library1.getCreatedDate().compareTo(library2.getCreatedDate()); + return library1.createdDate.compareTo(library2.createdDate); } else { - return library2.getCreatedDate().compareTo(library1.getCreatedDate()); + return library2.createdDate.compareTo(library1.createdDate); } }); } @@ -215,7 +215,7 @@ public ViewHolderLibrary(RowLibraryBinding rowLibraryBinding) { this.rowLibraryBinding = rowLibraryBinding; rowLibraryBinding.ratingBar.setOnTouchListener((v1, event) -> { if (event.getAction() == MotionEvent.ACTION_UP) - homeItemClickListener.showRatingDialog("resource", libraryList.get(getAdapterPosition()).getResource_id(), libraryList.get(getAdapterPosition()).getTitle(), ratingChangeListener); + homeItemClickListener.showRatingDialog("resource", libraryList.get(getAdapterPosition()).resourceId, libraryList.get(getAdapterPosition()).title, ratingChangeListener); return true; }); } diff --git a/app/src/main/java/org/ole/planet/myplanet/ui/library/AddResourceActivity.java b/app/src/main/java/org/ole/planet/myplanet/ui/library/AddResourceActivity.java index 2b8f881180..72851f5d8b 100644 --- a/app/src/main/java/org/ole/planet/myplanet/ui/library/AddResourceActivity.java +++ b/app/src/main/java/org/ole/planet/myplanet/ui/library/AddResourceActivity.java @@ -74,7 +74,7 @@ private void saveResource() { mRealm.executeTransactionAsync(realm -> { String id = UUID.randomUUID().toString(); RealmMyLibrary resource = realm.createObject(RealmMyLibrary.class, id); - resource.setTitle(title); + resource.title = title; createResource(resource, id); }, () -> { Utilities.toast(AddResourceActivity.this, getString(R.string.resource_saved_successfully)); @@ -83,25 +83,25 @@ private void saveResource() { } private void createResource(RealmMyLibrary resource, String id) { - resource.setAddedBy(activityAddResourceBinding.tvAddedBy.getText().toString().trim()); - resource.setAuthor(activityAddResourceBinding.etAuthor.getText().toString().trim()); - resource.setResource_id(id); - resource.setYear(activityAddResourceBinding.etYear.getText().toString().trim()); - resource.setDescription(activityAddResourceBinding.etDescription.getText().toString().trim()); + resource.addedBy = activityAddResourceBinding.tvAddedBy.getText().toString().trim(); + resource.author = activityAddResourceBinding.etAuthor.getText().toString().trim(); + resource.resourceId = id; + resource.year = activityAddResourceBinding.etYear.getText().toString().trim(); + resource.description = activityAddResourceBinding.etDescription.getText().toString().trim(); resource.setPublisher(activityAddResourceBinding.etPublisher.getText().toString().trim()); - resource.setLinkToLicense(activityAddResourceBinding.etLinkToLicense.getText().toString().trim()); - resource.setOpenWith(activityAddResourceBinding.spnOpenWith.getSelectedItem().toString()); - resource.setLanguage(activityAddResourceBinding.spnLang.getSelectedItem().toString()); - resource.setMediaType(activityAddResourceBinding.spnMedia.getSelectedItem().toString()); - resource.setResourceType(activityAddResourceBinding.spnResourceType.getSelectedItem().toString()); - resource.setSubject(subjects); + resource.linkToLicense = activityAddResourceBinding.etLinkToLicense.getText().toString().trim(); + resource.openWith = activityAddResourceBinding.spnOpenWith.getSelectedItem().toString(); + resource.language = activityAddResourceBinding.spnLang.getSelectedItem().toString(); + resource.mediaType = activityAddResourceBinding.spnMedia.getSelectedItem().toString(); + resource.resourceType = activityAddResourceBinding.spnResourceType.getSelectedItem().toString(); + resource.subject = subjects; resource.setUserId(new RealmList<>()); - resource.setLevel(levels); - resource.setCreatedDate(String.valueOf(Calendar.getInstance().getTimeInMillis())); - resource.setResourceFor(resourceFor); - resource.setResourceLocalAddress(resourceUrl); - resource.setResourceOffline(true); - resource.setFilename(resourceUrl.substring(resourceUrl.lastIndexOf("/"))); + resource.level = levels; + resource.createdDate = String.valueOf(Calendar.getInstance().getTimeInMillis()); + resource.resourceFor = resourceFor; + resource.resourceLocalAddress = resourceUrl; + resource.resourceOffline = true; + resource.filename = resourceUrl.substring(resourceUrl.lastIndexOf("/")); } private boolean validate(String title) { diff --git a/app/src/main/java/org/ole/planet/myplanet/ui/library/LibraryDetailFragment.java b/app/src/main/java/org/ole/planet/myplanet/ui/library/LibraryDetailFragment.java index d373eec519..43b9ad0db0 100644 --- a/app/src/main/java/org/ole/planet/myplanet/ui/library/LibraryDetailFragment.java +++ b/app/src/main/java/org/ole/planet/myplanet/ui/library/LibraryDetailFragment.java @@ -68,19 +68,19 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa @Override public void onActivityCreated(@Nullable Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); - initRatingView("resource", library.getResource_id(), library.getTitle(), LibraryDetailFragment.this); + initRatingView("resource", library.resourceId, library.title, LibraryDetailFragment.this); setLibraryData(); } private void setLibraryData() { - fragmentLibraryDetailBinding.tvTitle.setText(String.format("%s%s", openFrom.isEmpty() ? "" : openFrom + "-", library.getTitle())); - fragmentLibraryDetailBinding.tvAuthor.setText(library.getAuthor()); + fragmentLibraryDetailBinding.tvTitle.setText(String.format("%s%s", openFrom.isEmpty() ? "" : openFrom + "-", library.title)); + fragmentLibraryDetailBinding.tvAuthor.setText(library.author); fragmentLibraryDetailBinding.tvPublished.setText(library.getPublisher()); - fragmentLibraryDetailBinding.tvMedia.setText(library.getMediaType()); + fragmentLibraryDetailBinding.tvMedia.setText(library.mediaType); fragmentLibraryDetailBinding.tvSubject.setText(library.getSubjectsAsString()); - fragmentLibraryDetailBinding.tvLanguage.setText(library.getLanguage()); - fragmentLibraryDetailBinding.tvLicense.setText(library.getLinkToLicense()); - fragmentLibraryDetailBinding.tvResource.setText(RealmMyLibrary.listToString(library.getResourceFor())); + fragmentLibraryDetailBinding.tvLanguage.setText(library.language); + fragmentLibraryDetailBinding.tvLicense.setText(library.linkToLicense); + fragmentLibraryDetailBinding.tvResource.setText(RealmMyLibrary.listToString(library.resourceFor)); profileDbHandler.setResourceOpenCount(library); try { onRatingChanged(); @@ -88,9 +88,9 @@ private void setLibraryData() { ex.printStackTrace(); } - fragmentLibraryDetailBinding.btnDownload.setVisibility(TextUtils.isEmpty(library.getResourceLocalAddress()) ? View.GONE : View.VISIBLE); - fragmentLibraryDetailBinding.btnDownload.setImageResource(library.getResourceOffline() == null || library.isResourceOffline() ? R.drawable.ic_eye : R.drawable.ic_download); - if (FileUtils.getFileExtension(library.getResourceLocalAddress()).equals("mp4")) { + fragmentLibraryDetailBinding.btnDownload.setVisibility(TextUtils.isEmpty(library.resourceLocalAddress) ? View.GONE : View.VISIBLE); + fragmentLibraryDetailBinding.btnDownload.setImageResource(!library.resourceOffline || library.isResourceOffline() ? R.drawable.ic_eye : R.drawable.ic_download); + if (FileUtils.getFileExtension(library.resourceLocalAddress).equals("mp4")) { fragmentLibraryDetailBinding.btnDownload.setImageResource(R.drawable.ic_play); } setClickListeners(); @@ -98,7 +98,7 @@ private void setLibraryData() { public void setClickListeners() { fragmentLibraryDetailBinding.btnDownload.setOnClickListener(view -> { - if (TextUtils.isEmpty(library.getResourceLocalAddress())) { + if (TextUtils.isEmpty(library.resourceLocalAddress)) { Toast.makeText(getActivity(), getString(R.string.link_not_available), Toast.LENGTH_LONG).show(); return; } @@ -126,7 +126,7 @@ public void setClickListeners() { @Override public void onRatingChanged() { - JsonObject object = RealmRating.getRatingsById(mRealm, "resource", library.getResource_id(), userModel.getId()); + JsonObject object = RealmRating.getRatingsById(mRealm, "resource", library.resourceId, userModel.getId()); setRatings(object); } } diff --git a/app/src/main/java/org/ole/planet/myplanet/ui/library/LibraryFragment.java b/app/src/main/java/org/ole/planet/myplanet/ui/library/LibraryFragment.java index 6b96a40e3e..36fa043a4d 100644 --- a/app/src/main/java/org/ole/planet/myplanet/ui/library/LibraryFragment.java +++ b/app/src/main/java/org/ole/planet/myplanet/ui/library/LibraryFragment.java @@ -9,12 +9,10 @@ import android.text.Editable; import android.text.TextWatcher; import android.view.View; -import android.widget.AdapterView; import android.widget.Button; import android.widget.CheckBox; import android.widget.EditText; import android.widget.ImageButton; -import android.widget.Spinner; import android.widget.TextView; import androidx.annotation.Nullable; @@ -50,7 +48,6 @@ import fisk.chipcloud.ChipCloud; import fisk.chipcloud.ChipCloudConfig; import fisk.chipcloud.ChipDeletedListener; -import io.realm.Sort; public class LibraryFragment extends BaseRecyclerFragment implements OnLibraryItemSelected, ChipDeletedListener, TagClickListener, OnFilterListener { TextView tvAddToLib, tvSelected; @@ -185,11 +182,11 @@ private AlertDialog createAlertDialog() { String msg = getString(R.string.success_you_have_added_these_resources_to_your_mylibrary); if (selectedItems.size() <= 5) { for (int i = 0; i < selectedItems.size(); i++) { - msg += " - " + selectedItems.get(i).getTitle() + "\n"; + msg += " - " + selectedItems.get(i).title + "\n"; } } else { for (int i = 0; i < 5; i++) { - msg += " - " + selectedItems.get(i).getTitle() + "\n"; + msg += " - " + selectedItems.get(i).title + "\n"; } msg += getString(R.string.and) + (selectedItems.size() - 5) + getString(R.string.more_resource_s); } diff --git a/app/src/main/java/org/ole/planet/myplanet/ui/news/AdapterNews.java b/app/src/main/java/org/ole/planet/myplanet/ui/news/AdapterNews.java index 7511b887ca..2ae1d6f948 100644 --- a/app/src/main/java/org/ole/planet/myplanet/ui/news/AdapterNews.java +++ b/app/src/main/java/org/ole/planet/myplanet/ui/news/AdapterNews.java @@ -200,7 +200,7 @@ private void loadRemoteImage(RecyclerView.ViewHolder holder, RealmNews news) { RealmMyLibrary library = mRealm.where(RealmMyLibrary.class).equalTo("_id", resourceId).findFirst(); if (library != null) { File basePath = context.getExternalFilesDir(null); - File imageFile = new File(basePath, "ole/" + library.getId() + "/" + library.getResourceLocalAddress()); + File imageFile = new File(basePath, "ole/" + library.id + "/" + library.resourceLocalAddress); if (imageFile.exists()) { Glide.with(context).load(imageFile).into(viewHolder.rowNewsBinding.imgNews); diff --git a/app/src/main/java/org/ole/planet/myplanet/ui/team/MyTeamsDetailFragment.java b/app/src/main/java/org/ole/planet/myplanet/ui/team/MyTeamsDetailFragment.java index c07a23858c..72e2c3a6a9 100644 --- a/app/src/main/java/org/ole/planet/myplanet/ui/team/MyTeamsDetailFragment.java +++ b/app/src/main/java/org/ole/planet/myplanet/ui/team/MyTeamsDetailFragment.java @@ -218,7 +218,7 @@ private void setLibraryList(TabLayout.Tab tab) { if (homeItemClickListener != null) { LibraryDetailFragment f = new LibraryDetailFragment(); Bundle b = new Bundle(); - b.putString("libraryId", libraries.get(i).getId()); + b.putString("libraryId", libraries.get(i).id); b.putString("openFrom", team.getTeamType() + "-" + team.getTitle()); f.setArguments(b); homeItemClickListener.openCallFragment(f); diff --git a/app/src/main/java/org/ole/planet/myplanet/ui/team/teamResource/AdapterTeamResource.java b/app/src/main/java/org/ole/planet/myplanet/ui/team/teamResource/AdapterTeamResource.java index d7212acb08..538f7a5610 100644 --- a/app/src/main/java/org/ole/planet/myplanet/ui/team/teamResource/AdapterTeamResource.java +++ b/app/src/main/java/org/ole/planet/myplanet/ui/team/teamResource/AdapterTeamResource.java @@ -47,8 +47,8 @@ public ViewHolderTeamResource onCreateViewHolder(@NonNull ViewGroup parent, int @Override public void onBindViewHolder(@NonNull ViewHolderTeamResource holder, int position) { - rowTeamResourceBinding.tvTitle.setText(list.get(position).getTitle()); - rowTeamResourceBinding.tvDescription.setText(list.get(position).getDescription()); + rowTeamResourceBinding.tvTitle.setText(list.get(position).title); + rowTeamResourceBinding.tvDescription.setText(list.get(position).description); holder.itemView.setOnClickListener(v -> { if (listener != null) { listener.openLibraryDetailFragment(list.get(position)); diff --git a/app/src/main/java/org/ole/planet/myplanet/ui/team/teamResource/TeamResourceFragment.java b/app/src/main/java/org/ole/planet/myplanet/ui/team/teamResource/TeamResourceFragment.java index 2e49aabfdd..fa1fb052ee 100644 --- a/app/src/main/java/org/ole/planet/myplanet/ui/team/teamResource/TeamResourceFragment.java +++ b/app/src/main/java/org/ole/planet/myplanet/ui/team/teamResource/TeamResourceFragment.java @@ -66,7 +66,7 @@ private void showResourceListDialog() { for (Integer se : selected) { RealmMyTeam team = mRealm.createObject(RealmMyTeam.class, UUID.randomUUID().toString()); team.setTeamId(teamId); - team.setTitle(libraries.get(se).getTitle()); + team.setTitle(libraries.get(se).title); team.setSourcePlanet(user.getParentCode()); team.setResourceId(libraries.get(se).get_id()); team.setDocType("resourceLink"); @@ -86,7 +86,7 @@ private void showResourceListDialog() { private void listSetting(AlertDialog alertDialog, List libraries, CheckboxListView lv) { ArrayList names = new ArrayList<>(); for (int i = 0; i < libraries.size(); i++) { - names.add(libraries.get(i).getTitle()); + names.add(libraries.get(i).title); } ArrayAdapter adapter = new ArrayAdapter<>(getActivity(), R.layout.rowlayout, R.id.checkBoxRowLayout, names); lv.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE); diff --git a/app/src/main/java/org/ole/planet/myplanet/ui/userprofile/AchievementFragment.java b/app/src/main/java/org/ole/planet/myplanet/ui/userprofile/AchievementFragment.java index e9ef509b57..97e6122c3f 100644 --- a/app/src/main/java/org/ole/planet/myplanet/ui/userprofile/AchievementFragment.java +++ b/app/src/main/java/org/ole/planet/myplanet/ui/userprofile/AchievementFragment.java @@ -90,7 +90,7 @@ public void onActivityCreated(@Nullable Bundle savedInstanceState) { }); for (RealmMyLibrary lib : libraries) { layoutButtonPrimaryBinding = LayoutButtonPrimaryBinding.inflate(LayoutInflater.from(MainApplication.context)); - layoutButtonPrimaryBinding.getRoot().setText(lib.getTitle()); + layoutButtonPrimaryBinding.getRoot().setText(lib.title); layoutButtonPrimaryBinding.getRoot().setCompoundDrawablesWithIntrinsicBounds(0, 0, (lib.isResourceOffline() ? R.drawable.ic_eye : R.drawable.ic_download), 0); layoutButtonPrimaryBinding.getRoot().setOnClickListener(view -> { if (lib.isResourceOffline()) { @@ -138,7 +138,7 @@ private void createAchievementList() { }); for (RealmMyLibrary lib : libraries) { layoutButtonPrimaryBinding = LayoutButtonPrimaryBinding.inflate(LayoutInflater.from(MainApplication.context)); - layoutButtonPrimaryBinding.getRoot().setText(lib.getTitle()); + layoutButtonPrimaryBinding.getRoot().setText(lib.title); layoutButtonPrimaryBinding.getRoot().setCompoundDrawablesWithIntrinsicBounds(0, 0, (lib.isResourceOffline() ? R.drawable.ic_eye : R.drawable.ic_download), 0); layoutButtonPrimaryBinding.getRoot().setOnClickListener(view -> { if (lib.isResourceOffline()) { diff --git a/app/src/main/java/org/ole/planet/myplanet/ui/userprofile/EditAchievementFragment.java b/app/src/main/java/org/ole/planet/myplanet/ui/userprofile/EditAchievementFragment.java index b0d5166818..892e97c59b 100644 --- a/app/src/main/java/org/ole/planet/myplanet/ui/userprofile/EditAchievementFragment.java +++ b/app/src/main/java/org/ole/planet/myplanet/ui/userprofile/EditAchievementFragment.java @@ -274,8 +274,8 @@ public CheckboxListView createResourceList(MyLibraryAlertdialogBinding myLibrary ArrayList names = new ArrayList<>(); ArrayList selected = new ArrayList(); for (int i = 0; i < list.size(); i++) { - names.add(list.get(i).getTitle()); - if (prevList.contains(list.get(i).getTitle())) selected.add(i); + names.add(list.get(i).title); + if (prevList.contains(list.get(i).title)) selected.add(i); } ArrayAdapter adapter = new ArrayAdapter(getActivity(), R.layout.item_checkbox, R.id.checkBoxRowLayout, names) { diff --git a/app/src/main/java/org/ole/planet/myplanet/ui/viewer/PDFReaderActivity.java b/app/src/main/java/org/ole/planet/myplanet/ui/viewer/PDFReaderActivity.java index 651992b848..d079fd3357 100644 --- a/app/src/main/java/org/ole/planet/myplanet/ui/viewer/PDFReaderActivity.java +++ b/app/src/main/java/org/ole/planet/myplanet/ui/viewer/PDFReaderActivity.java @@ -58,8 +58,8 @@ protected void onCreate(Bundle savedInstanceState) { }); activityPdfreaderBinding.fabPlay.setOnClickListener(view -> { - if (library != null && !TextUtils.isEmpty(library.getTranslationAudioPath())) { - IntentUtils.openAudioFile(this, library.getTranslationAudioPath()); + if (library != null && !TextUtils.isEmpty(library.translationAudioPath)) { + IntentUtils.openAudioFile(this, library.translationAudioPath); } }); } @@ -118,7 +118,7 @@ public void onRecordStopped(String outputFile) { private void updateTranslation(String outputFile) { if (library != null) { if (!mRealm.isInTransaction()) mRealm.beginTransaction(); - library.setTranslationAudioPath(outputFile); + library.translationAudioPath = outputFile; mRealm.commitTransaction(); Utilities.toast(this, getString(R.string.audio_file_saved_in_database)); } diff --git a/app/src/main/java/org/ole/planet/myplanet/utilities/Utilities.java b/app/src/main/java/org/ole/planet/myplanet/utilities/Utilities.java index e94e948037..86f8e2c786 100644 --- a/app/src/main/java/org/ole/planet/myplanet/utilities/Utilities.java +++ b/app/src/main/java/org/ole/planet/myplanet/utilities/Utilities.java @@ -51,7 +51,7 @@ public static void log(String message) { } public static String getUrl(RealmMyLibrary library, SharedPreferences settings) { - return getUrl(library.getResource_id(), library.getResourceLocalAddress(), settings); + return getUrl(library.resourceId, library.resourceLocalAddress, settings); }