Resource Sync Notification Fix

This commit is contained in:
Caesar2011
2019-02-03 16:18:14 +01:00
parent d108d430df
commit 3380e79232
3 changed files with 32 additions and 9 deletions

View File

@@ -167,7 +167,8 @@ public class ModulesResources extends PartModules<ArrayList<Resource>> {
String content = resource.getJSONObject("contentHandler").getString("id"); String content = resource.getJSONObject("contentHandler").getString("id");
long createdDate = UtilsDate.stringToMillis(created, "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"); long createdDate = UtilsDate.stringToMillis(created, "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
if (content.equals("resource/x-bb-folder")) { 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); 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 -> { 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) { for (Resource resource1 : response1) {
@@ -178,7 +179,8 @@ public class ModulesResources extends PartModules<ArrayList<Resource>> {
} else { } else {
String bodyText = resource.optString("body", ""); String bodyText = resource.optString("body", "");
bodyText = String.valueOf(PartModules.fromHtml(bodyText)); 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); 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 -> { get(String.format("https://lms.fu-berlin.de/learn/api/public/v1/courses/%s/contents/%s/attachments", ID, resid), mLogin.getLoginTokenBB().getCookies(), response1 -> {

View File

@@ -123,6 +123,19 @@ public class KVVSyncAdapter extends AbstractThreadedSyncAdapter {
if (oldList == null || newList == null) { if (oldList == null || newList == null) {
return; 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<>(); ArrayList<T> obsoletes = new ArrayList<>();
for (T old: oldList) { for (T old: oldList) {
obsoletes.add(old); obsoletes.add(old);

View File

@@ -10,6 +10,7 @@ import java.util.ArrayList;
import androidx.annotation.LayoutRes; import androidx.annotation.LayoutRes;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import de.sebse.fuplanner.R; 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.LayoutItemType;
import de.sebse.fuplanner.tools.ui.treeview.TreeNode; import de.sebse.fuplanner.tools.ui.treeview.TreeNode;
@@ -46,6 +47,7 @@ public abstract class Resource implements Serializable {
} }
public String getUrl() { public String getUrl() {
Logger log = new Logger(this);
return url; return url;
} }
@@ -69,8 +71,9 @@ public abstract class Resource implements Serializable {
private final ArrayList<DownloadFile> urls; private final ArrayList<DownloadFile> urls;
private final String body; private final String body;
public Document(String author, String title, long modifiedDate, boolean visible, String container, String body) { public Document(String author, String title, long modifiedDate, String url, boolean visible, String container, String body) {
super(author, title, modifiedDate, "", visible, container); super(author, title, modifiedDate, url, visible, container);
Logger log = new Logger(this);
this.body = body; this.body = body;
this.urls = new ArrayList<>(); this.urls = new ArrayList<>();
} }
@@ -82,9 +85,9 @@ public abstract class Resource implements Serializable {
"author='" + author + '\'' + "author='" + author + '\'' +
", modifiedDate=" + modifiedDate + ", modifiedDate=" + modifiedDate +
", title='" + title + '\'' + ", title='" + title + '\'' +
", urls='" + urls.size() + '\'' + ", url='" + url + '\'' +
", body='" + body + '\'' + ", body='" + body + '\'' +
", urls='" + body + '\'' + ", urls='" + urls + '\'' +
'}'; '}';
} }
@@ -116,7 +119,7 @@ public abstract class Resource implements Serializable {
@Override @Override
public int hashCode() { 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 { public class DownloadFile implements Serializable {
@@ -127,6 +130,11 @@ public abstract class Resource implements Serializable {
this.url = url; this.url = url;
this.name = name; this.name = name;
} }
@Override
public int hashCode() {
return Objects.hashCode(url, name);
}
} }
} }
@@ -162,7 +170,7 @@ public abstract class Resource implements Serializable {
@Override @Override
public int hashCode() { 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 @Override
public int hashCode() { public int hashCode() {
return Objects.hashCode(super.hashCode(), this.getClass().getSimpleName()); return Objects.hashCode(super.hashCode(), children, this.getClass().getSimpleName());
} }
} }
} }