mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-20 22:59:54 +01:00
Fixed race between loadHeaders() and loadAvailable().
This commit is contained in:
@@ -164,11 +164,13 @@ public class ForumListFragment extends BaseEventFragment implements
|
|||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
long now = System.currentTimeMillis();
|
long now = System.currentTimeMillis();
|
||||||
|
boolean displayedHeaders = false;
|
||||||
for (Forum f : forumManager.getForums()) {
|
for (Forum f : forumManager.getForums()) {
|
||||||
try {
|
try {
|
||||||
Collection<ForumPostHeader> headers =
|
Collection<ForumPostHeader> headers =
|
||||||
forumManager.getPostHeaders(f.getId());
|
forumManager.getPostHeaders(f.getId());
|
||||||
displayHeaders(f, headers);
|
displayHeaders(f, headers);
|
||||||
|
displayedHeaders = true;
|
||||||
} catch (NoSuchGroupException e) {
|
} catch (NoSuchGroupException e) {
|
||||||
// Continue
|
// Continue
|
||||||
}
|
}
|
||||||
@@ -178,6 +180,7 @@ public class ForumListFragment extends BaseEventFragment implements
|
|||||||
long duration = System.currentTimeMillis() - now;
|
long duration = System.currentTimeMillis() - now;
|
||||||
if (LOG.isLoggable(INFO))
|
if (LOG.isLoggable(INFO))
|
||||||
LOG.info("Full load took " + duration + " ms");
|
LOG.info("Full load took " + duration + " ms");
|
||||||
|
if (!displayedHeaders) displayEmpty();
|
||||||
displayAvailable(available);
|
displayAvailable(available);
|
||||||
} catch (DbException e) {
|
} catch (DbException e) {
|
||||||
if (LOG.isLoggable(WARNING))
|
if (LOG.isLoggable(WARNING))
|
||||||
@@ -216,11 +219,18 @@ public class ForumListFragment extends BaseEventFragment implements
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void displayEmpty() {
|
||||||
|
listener.runOnUiThread(new Runnable() {
|
||||||
|
public void run() {
|
||||||
|
empty.setVisibility(VISIBLE);
|
||||||
|
loading.setVisibility(GONE);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
private void displayAvailable(final int availableCount) {
|
private void displayAvailable(final int availableCount) {
|
||||||
listener.runOnUiThread(new Runnable() {
|
listener.runOnUiThread(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
if (adapter.isEmpty()) empty.setVisibility(VISIBLE);
|
|
||||||
loading.setVisibility(GONE);
|
|
||||||
if (availableCount == 0) {
|
if (availableCount == 0) {
|
||||||
available.setVisibility(GONE);
|
available.setVisibility(GONE);
|
||||||
} else {
|
} else {
|
||||||
@@ -277,7 +287,8 @@ public class ForumListFragment extends BaseEventFragment implements
|
|||||||
if (c.equals(forumManager.getClientId())) {
|
if (c.equals(forumManager.getClientId())) {
|
||||||
LOG.info("Forum post added, reloading");
|
LOG.info("Forum post added, reloading");
|
||||||
loadHeaders(m.getMessage().getGroupId());
|
loadHeaders(m.getMessage().getGroupId());
|
||||||
} else if (c.equals(forumSharingManager.getClientId())) {
|
} else if (!m.isLocal()
|
||||||
|
&& c.equals(forumSharingManager.getClientId())) {
|
||||||
LOG.info("Available forums updated, reloading");
|
LOG.info("Available forums updated, reloading");
|
||||||
loadAvailable();
|
loadAvailable();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user