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

Commit ec940d4

Browse files
jainkuniyatimabbott
authored andcommitted
Dismiss TopSnackBar when reached at bottom.
1 parent 68ea66c commit ec940d4

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,8 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
146146
recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
147147
@Override
148148
public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
149-
mListener.recyclerViewScrolled();
149+
//check if scrolled at last
150+
mListener.recyclerViewScrolled(linearLayoutManager.findLastCompletelyVisibleItemPosition() == adapter.getItemCount() - 2);
150151
final int near = 6;
151152
if (newState == RecyclerView.SCROLL_STATE_IDLE) {
152153
if (!paused && !loadingMessages && firstMessageId > 0 && lastMessageId > 0) {
@@ -699,7 +700,7 @@ private Message getMessageById(int id) {
699700
public interface Listener {
700701
void onListResume(MessageListFragment f);
701702

702-
void recyclerViewScrolled();
703+
void recyclerViewScrolled(boolean isReachedAtBottom);
703704

704705
void clearChatBox();
705706

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ public HashMap<String, Bitmap> getGravatars() {
271271
}
272272

273273
@Override
274-
public void recyclerViewScrolled() {
274+
public void recyclerViewScrolled(boolean isReachedAtBottom) {
275275
/* in this method we check if the messageEt is empty or not
276276
if messageEt is not empty, it means that the user has typed something in the chatBox and that the chatBox should be open
277277
in spite of scrolling */
@@ -297,6 +297,11 @@ else if (chatBox.getVisibility() == View.VISIBLE && streamActv.getText().toStrin
297297
displayFAB(true);
298298
}
299299

300+
//on reaching at bottom dismiss snackBar
301+
if (isReachedAtBottom && topSnackBar.isShown()) {
302+
topSnackBar.dismiss();
303+
}
304+
300305
}
301306

302307
public RefreshableCursorAdapter getPeopleAdapter() {

0 commit comments

Comments
 (0)