Skip to content
This repository was archived by the owner on Jul 25, 2024. It is now read-only.

Commit 4559fb8

Browse files
jainkuniyakunall17
authored andcommitted
Fix:Message not added in home list.
Problem: Messages were not added in home list when user is narrowed and then again come back to home. Fixed: onCreateView is called even when fragment is popped from fragment manager stack, so no need to recreate adapter, use previously initialized adapter. Fix: #377
1 parent f4ed2c6 commit 4559fb8

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

app/src/main/java/com/zulip/android/activities/MessageListFragment.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ public void onCreate(Bundle savedInstanceState) {
105105
}
106106
messageIndex = new SparseArray<>();
107107
messageList = new ArrayList<>();
108+
adapter = new RecyclerMessageAdapter(messageList, getActivity(), (filter != null));
108109
}
109110

110111
public void onPause() {
@@ -139,8 +140,16 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
139140
recyclerView = (RecyclerView) view.findViewById(R.id.recyclerView);
140141
linearLayoutManager = new LinearLayoutManager(getContext());
141142
recyclerView.setLayoutManager(linearLayoutManager);
142-
adapter = new RecyclerMessageAdapter(messageList, getActivity(), (filter != null));
143143
recyclerView.addItemDecoration(new HeaderSpaceItemDecoration(getContext()));
144+
//as onCreateView is even called when fragment is popped from stack
145+
//if adapter is null then create new instance else use the previous one
146+
if (adapter == null) {
147+
adapter = new RecyclerMessageAdapter(messageList, getActivity(), (filter != null));
148+
} else {
149+
//footer is shown when it is resumed, and then it is hidden in setupLists method
150+
//but now setupLists is not called so hide footer here
151+
adapter.setFooterShowing(false);
152+
}
144153
recyclerView.setAdapter(adapter);
145154
registerForContextMenu(recyclerView);
146155
recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {

0 commit comments

Comments
 (0)