mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-16 04:39:54 +01:00
Merge branch '565-forums-sometimes-appear-empty' into 'master'
Fix regression where forum entries were not shown Closes #565 See merge request !271
This commit is contained in:
@@ -111,8 +111,7 @@ public class ForumActivity extends BriarActivity implements
|
|||||||
recyclerView.setAdapter(forumAdapter);
|
recyclerView.setAdapter(forumAdapter);
|
||||||
linearLayoutManager = new LinearLayoutManager(this);
|
linearLayoutManager = new LinearLayoutManager(this);
|
||||||
recyclerView.setLayoutManager(linearLayoutManager);
|
recyclerView.setLayoutManager(linearLayoutManager);
|
||||||
recyclerView.setEmptyText(getString(R.string.no_forum_posts));
|
recyclerView.setEmptyText(R.string.no_forum_posts);
|
||||||
recyclerView.showProgressBar();
|
|
||||||
|
|
||||||
forumController.loadForum(groupId, new UiResultHandler<Boolean>(this) {
|
forumController.loadForum(groupId, new UiResultHandler<Boolean>(this) {
|
||||||
@Override
|
@Override
|
||||||
@@ -120,13 +119,18 @@ public class ForumActivity extends BriarActivity implements
|
|||||||
if (result) {
|
if (result) {
|
||||||
Forum forum = forumController.getForum();
|
Forum forum = forumController.getForum();
|
||||||
if (forum != null) setTitle(forum.getName());
|
if (forum != null) setTitle(forum.getName());
|
||||||
forumAdapter.setEntries(forumController.getForumEntries());
|
List<ForumEntry> entries =
|
||||||
if (state != null) {
|
forumController.getForumEntries();
|
||||||
byte[] replyId = state.getByteArray(KEY_REPLY_ID);
|
if (entries.isEmpty()) {
|
||||||
if (replyId != null)
|
recyclerView.showData();
|
||||||
forumAdapter.setReplyEntryById(replyId);
|
} else {
|
||||||
|
forumAdapter.setEntries(entries);
|
||||||
|
if (state != null) {
|
||||||
|
byte[] replyId = state.getByteArray(KEY_REPLY_ID);
|
||||||
|
if (replyId != null)
|
||||||
|
forumAdapter.setReplyEntryById(replyId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
recyclerView.showData();
|
|
||||||
} else {
|
} else {
|
||||||
// TODO Maybe an error dialog ?
|
// TODO Maybe an error dialog ?
|
||||||
finish();
|
finish();
|
||||||
@@ -383,6 +387,7 @@ public class ForumActivity extends BriarActivity implements
|
|||||||
void setEntries(List<ForumEntry> entries) {
|
void setEntries(List<ForumEntry> entries) {
|
||||||
forumEntries.clear();
|
forumEntries.clear();
|
||||||
forumEntries.addAll(entries);
|
forumEntries.addAll(entries);
|
||||||
|
notifyItemRangeInserted(0, entries.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
void addEntry(int index, ForumEntry entry, boolean isScrolling) {
|
void addEntry(int index, ForumEntry entry, boolean isScrolling) {
|
||||||
@@ -494,7 +499,7 @@ public class ForumActivity extends BriarActivity implements
|
|||||||
return indexList;
|
return indexList;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void showDescendants(ForumEntry forumEntry) {
|
void showDescendants(ForumEntry forumEntry) {
|
||||||
forumEntry.setShowingDescendants(true);
|
forumEntry.setShowingDescendants(true);
|
||||||
int visiblePos = getVisiblePos(forumEntry);
|
int visiblePos = getVisiblePos(forumEntry);
|
||||||
List<Integer> indexList =
|
List<Integer> indexList =
|
||||||
@@ -509,7 +514,7 @@ public class ForumActivity extends BriarActivity implements
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void hideDescendants(ForumEntry forumEntry) {
|
void hideDescendants(ForumEntry forumEntry) {
|
||||||
int visiblePos = getVisiblePos(forumEntry);
|
int visiblePos = getVisiblePos(forumEntry);
|
||||||
List<Integer> indexList =
|
List<Integer> indexList =
|
||||||
getSubTreeIndexes(visiblePos, forumEntry.getLevel());
|
getSubTreeIndexes(visiblePos, forumEntry.getLevel());
|
||||||
@@ -536,7 +541,7 @@ public class ForumActivity extends BriarActivity implements
|
|||||||
|
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public ForumEntry getVisibleEntry(int position) {
|
ForumEntry getVisibleEntry(int position) {
|
||||||
int levelLimit = UNDEFINED;
|
int levelLimit = UNDEFINED;
|
||||||
for (ForumEntry forumEntry : forumEntries) {
|
for (ForumEntry forumEntry : forumEntries) {
|
||||||
if (levelLimit >= 0) {
|
if (levelLimit >= 0) {
|
||||||
|
|||||||
Reference in New Issue
Block a user