mirror of
https://github.com/ArcaneChat/android.git
synced 2026-07-03 14:05:24 +02:00
add scroll to first/last entry on empty search
This commit is contained in:
@@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user