Caching toots (#809)

* Initial timeline cache implementation

* Fix build/DI errors for caching

* Rename timeline entities tables. Add migration. Add DB scheme file.

* Fix uniqueness problem, change offline strategy, improve mapping

* Try to merge in new statuses, fix bottom loading, fix saving spans.

* Fix reblogs IDs, fix inserting elements from top

* Send one more request to get latest timeline statuses

* Give Timeline placeholders string id. Rewrite Either in Kotlin

* Initial placeholder implementation for caching

* Fix crash on removing overlap statuses

* Migrate counters to long

* Remove unused counters. Add minimal TimelineDAOTest

* Fix bug with placeholder ID

* Update cache in response to events. Refactor TimelineCases

* Fix crash, reduce number of placeholders

* Fix crash, fix filtering, improve placeholder handling

* Fix migration, add 8-9 migration test

* Fix initial timeline update, remove more placeholders

* Add cleanup for old statuses

* Fix cleanup

* Delete ExampleInstrumentedTest

* Improve timeline UX regarding caching

* Fix typos

* Fix initial timeline update

* Cleanup/fix initial timeline update

* Workaround for weird behavior of first post on initial tl update.

* Change counter types back to int

* Clear timeline cache on logout

* Fix loading when timeline is completely empty

* Fix androidx migration issues

* Fix tests

* Apply caching feedback

* Save account emojis to cache

* Fix warnings and bugs
This commit is contained in:
Ivan Kupalov 2019-01-14 22:05:08 +01:00 committed by Konrad Pozniak
commit 3ab78a19bc
29 changed files with 1950 additions and 497 deletions

View file

@ -16,7 +16,7 @@ data class AttachmentViewData(
fun list(status: Status): List<AttachmentViewData> {
val actionable = status.actionableStatus
return actionable.attachments.map {
AttachmentViewData(it, actionable.id, actionable.url)
AttachmentViewData(it, actionable.id, actionable.url!!)
}
}
}

View file

@ -331,9 +331,9 @@ public abstract class StatusViewData {
public static final class Placeholder extends StatusViewData {
private final boolean isLoading;
private final long id;
private final String id;
public Placeholder(long id, boolean isLoading) {
public Placeholder(String id, boolean isLoading) {
this.id = id;
this.isLoading = isLoading;
}
@ -342,18 +342,18 @@ public abstract class StatusViewData {
return isLoading;
}
public long getId() {
public String getId() {
return id;
}
@Override public long getViewDataId() {
return id;
return id.hashCode();
}
@Override public boolean deepEquals(StatusViewData other) {
if (!(other instanceof Placeholder)) return false;
Placeholder that = (Placeholder) other;
return isLoading == that.isLoading && id == that.id;
return isLoading == that.isLoading && id.equals(that.id);
}
@Override public boolean equals(Object o) {
@ -365,9 +365,10 @@ public abstract class StatusViewData {
return deepEquals(that);
}
@Override public int hashCode() {
@Override
public int hashCode() {
int result = (isLoading ? 1 : 0);
result = 31 * result + (int) (id ^ (id >>> 32));
result = 31 * result + id.hashCode();
return result;
}
}