mirror of
https://github.com/deltachat/deltachat-android.git
synced 2025-10-06 03:49:58 +02:00
add scroll to first/last entry on empty search
This commit is contained in:
parent
158d272419
commit
ab6fa55867
2 changed files with 17 additions and 1 deletions
|
@ -1572,6 +1572,13 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
|||
if(searchResultPosition<0) searchResultPosition = searchResult.length-1;
|
||||
if(searchResultPosition>=searchResult.length) searchResultPosition = 0;
|
||||
fragment.scrollToMsgId(searchResult[searchResultPosition]);
|
||||
} else {
|
||||
// no search, scroll to first/last message
|
||||
if(searchNext) {
|
||||
fragment.scrollToBottom();
|
||||
} else {
|
||||
fragment.scrollToTop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -310,6 +310,16 @@ public class ConversationFragment extends Fragment
|
|||
}
|
||||
}
|
||||
|
||||
public void scrollToTop() {
|
||||
ConversationAdapter adapter = (ConversationAdapter)list.getAdapter();
|
||||
if (adapter.getItemCount()>0) {
|
||||
final int pos = adapter.getItemCount()-1;
|
||||
list.post(() -> {
|
||||
list.getLayoutManager().scrollToPosition(pos);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public void scrollToBottom() {
|
||||
if (((LinearLayoutManager) list.getLayoutManager()).findFirstVisibleItemPosition() < SCROLL_ANIMATION_THRESHOLD) {
|
||||
list.smoothScrollToPosition(0);
|
||||
|
@ -517,7 +527,6 @@ public class ConversationFragment extends Fragment
|
|||
int position = adapter.msgIdToPosition(msgId);
|
||||
if (position!=-1) {
|
||||
scrollToStartingPosition(position);
|
||||
Log.i("Delta Chat", String.format(">>>>>>>>>>>>>>>>>>> %d", position));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue