Resource Sync Notification Fix
This commit is contained in:
@@ -167,7 +167,8 @@ public class ModulesResources extends PartModules<ArrayList<Resource>> {
|
||||
String content = resource.getJSONObject("contentHandler").getString("id");
|
||||
long createdDate = UtilsDate.stringToMillis(created, "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
|
||||
if (content.equals("resource/x-bb-folder")) {
|
||||
Resource.Folder folder = new Resource.Folder("", title, createdDate, "", true, "");
|
||||
String url2 = String.format("https://lms.fu-berlin.de/learn/api/public/v1/courses/%s/contents/%s", ID, resid);
|
||||
Resource.Folder folder = new Resource.Folder("", title, createdDate, url2, true, "");
|
||||
resources.add(folder);
|
||||
getRescourceFolder(String.format("https://lms.fu-berlin.de/learn/api/public/v1/courses/%s/contents/%s/children", ID, resid), ID, true, response1 -> {
|
||||
for (Resource resource1 : response1) {
|
||||
@@ -178,7 +179,8 @@ public class ModulesResources extends PartModules<ArrayList<Resource>> {
|
||||
} else {
|
||||
String bodyText = resource.optString("body", "");
|
||||
bodyText = String.valueOf(PartModules.fromHtml(bodyText));
|
||||
Resource.Document document = new Resource.Document("", title, createdDate, true, "", bodyText);
|
||||
String url2 = String.format("https://lms.fu-berlin.de/learn/api/public/v1/courses/%s/contents/%s", ID, resid);
|
||||
Resource.Document document = new Resource.Document("", title, createdDate, url2, true, "", bodyText);
|
||||
resources.add(document);
|
||||
get(String.format("https://lms.fu-berlin.de/learn/api/public/v1/courses/%s/contents/%s/attachments", ID, resid), mLogin.getLoginTokenBB().getCookies(), response1 -> {
|
||||
|
||||
|
||||
@@ -123,6 +123,19 @@ public class KVVSyncAdapter extends AbstractThreadedSyncAdapter {
|
||||
if (oldList == null || newList == null) {
|
||||
return;
|
||||
}
|
||||
if (oldList instanceof ArrayList && ((ArrayList<T>) oldList).size() > 0 && ((ArrayList<T>) oldList).get(0) instanceof Resource) {
|
||||
log.d("-- all --");
|
||||
log.d(oldList.hashCode(), newList.hashCode());
|
||||
log.d("-- old --");
|
||||
for (T x: oldList) {
|
||||
log.d(titleInterface.get(x), idInterface.get(x), x.hashCode(), x);
|
||||
}
|
||||
log.d("-- new --");
|
||||
for (T x: newList) {
|
||||
log.d(titleInterface.get(x), idInterface.get(x), x.hashCode(), x);
|
||||
}
|
||||
log.d("-- --- --");
|
||||
}
|
||||
ArrayList<T> obsoletes = new ArrayList<>();
|
||||
for (T old: oldList) {
|
||||
obsoletes.add(old);
|
||||
|
||||
@@ -10,6 +10,7 @@ import java.util.ArrayList;
|
||||
import androidx.annotation.LayoutRes;
|
||||
import androidx.annotation.NonNull;
|
||||
import de.sebse.fuplanner.R;
|
||||
import de.sebse.fuplanner.tools.logging.Logger;
|
||||
import de.sebse.fuplanner.tools.ui.treeview.LayoutItemType;
|
||||
import de.sebse.fuplanner.tools.ui.treeview.TreeNode;
|
||||
|
||||
@@ -46,6 +47,7 @@ public abstract class Resource implements Serializable {
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
Logger log = new Logger(this);
|
||||
return url;
|
||||
}
|
||||
|
||||
@@ -69,8 +71,9 @@ public abstract class Resource implements Serializable {
|
||||
private final ArrayList<DownloadFile> urls;
|
||||
private final String body;
|
||||
|
||||
public Document(String author, String title, long modifiedDate, boolean visible, String container, String body) {
|
||||
super(author, title, modifiedDate, "", visible, container);
|
||||
public Document(String author, String title, long modifiedDate, String url, boolean visible, String container, String body) {
|
||||
super(author, title, modifiedDate, url, visible, container);
|
||||
Logger log = new Logger(this);
|
||||
this.body = body;
|
||||
this.urls = new ArrayList<>();
|
||||
}
|
||||
@@ -82,9 +85,9 @@ public abstract class Resource implements Serializable {
|
||||
"author='" + author + '\'' +
|
||||
", modifiedDate=" + modifiedDate +
|
||||
", title='" + title + '\'' +
|
||||
", urls='" + urls.size() + '\'' +
|
||||
", url='" + url + '\'' +
|
||||
", body='" + body + '\'' +
|
||||
", urls='" + body + '\'' +
|
||||
", urls='" + urls + '\'' +
|
||||
'}';
|
||||
}
|
||||
|
||||
@@ -116,7 +119,7 @@ public abstract class Resource implements Serializable {
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(super.hashCode(), this.getClass().getSimpleName());
|
||||
return Objects.hashCode(super.hashCode(), urls, body, this.getClass().getSimpleName());
|
||||
}
|
||||
|
||||
public class DownloadFile implements Serializable {
|
||||
@@ -127,6 +130,11 @@ public abstract class Resource implements Serializable {
|
||||
this.url = url;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(url, name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -162,7 +170,7 @@ public abstract class Resource implements Serializable {
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(super.hashCode(), this.getClass().getSimpleName());
|
||||
return Objects.hashCode(super.hashCode(), this.type, this.getClass().getSimpleName());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -214,7 +222,7 @@ public abstract class Resource implements Serializable {
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(super.hashCode(), this.getClass().getSimpleName());
|
||||
return Objects.hashCode(super.hashCode(), children, this.getClass().getSimpleName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user