mirror of
https://github.com/beemdevelopment/Aegis.git
synced 2025-05-14 14:02:49 +00:00
Fix behavior of the new entry highlight in case no scroll is needed
This commit is contained in:
parent
f4bdf4645b
commit
ad138e4a4c
1 changed files with 34 additions and 22 deletions
|
@ -287,7 +287,6 @@ public class EntryListView extends Fragment implements EntryAdapter.Listener {
|
|||
|
||||
public void addEntry(VaultEntry entry) {
|
||||
addEntry(entry, false);
|
||||
|
||||
}
|
||||
|
||||
@SuppressLint("ClickableViewAccessibility")
|
||||
|
@ -295,33 +294,46 @@ public class EntryListView extends Fragment implements EntryAdapter.Listener {
|
|||
int position = _adapter.addEntry(entry);
|
||||
updateEmptyState();
|
||||
|
||||
LinearLayoutManager layoutManager = (LinearLayoutManager) _recyclerView.getLayoutManager();
|
||||
if (focusEntry && position >= 0) {
|
||||
RecyclerView.OnScrollListener scrollListener = new RecyclerView.OnScrollListener() {
|
||||
@Override
|
||||
public void onScrollStateChanged(@NonNull RecyclerView recyclerView, int newState) {
|
||||
if (newState == RecyclerView.SCROLL_STATE_IDLE) {
|
||||
_recyclerView.removeOnScrollListener(this);
|
||||
_adapter.setTempHighlightEntry(true);
|
||||
|
||||
final int secondsToFocus = 3;
|
||||
_adapter.focusEntry(entry, secondsToFocus);
|
||||
int last = layoutManager.findLastVisibleItemPosition();
|
||||
int first = layoutManager.findFirstVisibleItemPosition();
|
||||
if ((_recyclerView.canScrollVertically(1) && position > layoutManager.findLastCompletelyVisibleItemPosition())
|
||||
|| (_recyclerView.canScrollVertically(-1) && position < layoutManager.findFirstCompletelyVisibleItemPosition())) {
|
||||
RecyclerView.OnScrollListener scrollListener = new RecyclerView.OnScrollListener() {
|
||||
@Override
|
||||
public void onScrollStateChanged(@NonNull RecyclerView recyclerView, int newState) {
|
||||
if (newState == RecyclerView.SCROLL_STATE_IDLE) {
|
||||
_recyclerView.removeOnScrollListener(this);
|
||||
_recyclerView.setOnTouchListener(null);
|
||||
tempHighlightEntry(entry);
|
||||
}
|
||||
}
|
||||
};
|
||||
_recyclerView.addOnScrollListener(scrollListener);
|
||||
_recyclerView.setOnTouchListener((v, event) -> {
|
||||
if (event.getAction() == MotionEvent.ACTION_DOWN) {
|
||||
_recyclerView.removeOnScrollListener(scrollListener);
|
||||
_recyclerView.stopScroll();
|
||||
_recyclerView.setOnTouchListener(null);
|
||||
}
|
||||
}
|
||||
};
|
||||
_recyclerView.addOnScrollListener(scrollListener);
|
||||
_recyclerView.setOnTouchListener((v, event) -> {
|
||||
if (event.getAction() == MotionEvent.ACTION_DOWN) {
|
||||
_recyclerView.removeOnScrollListener(scrollListener);
|
||||
_recyclerView.stopScroll();
|
||||
_recyclerView.setOnTouchListener(null);
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
_recyclerView.smoothScrollToPosition(position);
|
||||
return false;
|
||||
});
|
||||
_recyclerView.smoothScrollToPosition(position);
|
||||
} else {
|
||||
tempHighlightEntry(entry);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void tempHighlightEntry(VaultEntry entry) {
|
||||
_adapter.setTempHighlightEntry(true);
|
||||
|
||||
final int secondsToFocus = 3;
|
||||
_adapter.focusEntry(entry, secondsToFocus);
|
||||
}
|
||||
|
||||
public void addEntries(Collection<VaultEntry> entries) {
|
||||
_adapter.addEntries(entries);
|
||||
updateEmptyState();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue