Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix obstructing snackbar padding #1600

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading