Skip to content

Commit

Permalink
Merge pull request #1600 from michaelschattgen/fix/import-entries-pad…
Browse files Browse the repository at this point in the history
…ding

Fix obstructing snackbar padding
  • Loading branch information
alexbakker authored Jan 24, 2025
2 parents 6bbb42f + a4812c5 commit ce29d12
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
public class ImportEntriesActivity extends AegisActivity {
private View _view;
private Menu _menu;
private RecyclerView _entriesView;
private ImportEntriesAdapter _adapter;
private FabScrollHelper _fabScrollHelper;

Expand All @@ -74,8 +75,8 @@ protected void onCreate(Bundle savedInstanceState) {
bar.setDisplayHomeAsUpEnabled(true);

_adapter = new ImportEntriesAdapter();
RecyclerView entriesView = findViewById(R.id.list_entries);
entriesView.addOnScrollListener(new RecyclerView.OnScrollListener() {
_entriesView = findViewById(R.id.list_entries);
_entriesView.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
super.onScrolled(recyclerView, dx, dy);
Expand All @@ -84,9 +85,9 @@ public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
});

LinearLayoutManager layoutManager = new LinearLayoutManager(this);
entriesView.setLayoutManager(layoutManager);
entriesView.setAdapter(_adapter);
entriesView.setNestedScrollingEnabled(false);
_entriesView.setLayoutManager(layoutManager);
_entriesView.setAdapter(_adapter);
_entriesView.setNestedScrollingEnabled(false);

FloatingActionButton fab = findViewById(R.id.fab);
fab.setOnClickListener(v -> {
Expand Down Expand Up @@ -358,6 +359,31 @@ private void findDuplicates(List<ImportEntry> importEntries) {

_adapter.setCheckboxStates(duplicateEntries, false);
Snackbar snackbar = Snackbar.make(_view, getResources().getQuantityString(R.plurals.import_duplicate_toast, duplicateEntries.size(), duplicateEntries.size()), Snackbar.LENGTH_INDEFINITE);
snackbar.addCallback(new Snackbar.Callback() {
@Override
public void onShown(Snackbar sb) {
int snackbarHeight = sb.getView().getHeight();

_entriesView.setPadding(
_entriesView.getPaddingLeft(),
_entriesView.getPaddingTop(),
_entriesView.getPaddingRight(),
_entriesView.getPaddingBottom() + snackbarHeight * 2
);
}

@Override
public void onDismissed(Snackbar sb, int event) {
int snackbarHeight = sb.getView().getHeight();

_entriesView.setPadding(
_entriesView.getPaddingLeft(),
_entriesView.getPaddingTop(),
_entriesView.getPaddingRight(),
_entriesView.getPaddingBottom() - snackbarHeight * 2
);
}
});
snackbar.setAction(R.string.undo, new View.OnClickListener() {
@Override
public void onClick(View v) {
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/layout/activity_import_entries.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
android:id="@+id/list_entries"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="60dp"
android:clipToPadding="false"
android:scrollbars="vertical"
app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
Expand Down

0 comments on commit ce29d12

Please sign in to comment.