Skip to content

Conversation

@yashk2000
Copy link
Member

Fixed #2593

Changes: Replace snackbars with snackbarshandler

@yashk2000
Copy link
Member Author

@adityastic please review.

@iamareebjamal
Copy link
Member

Why?

@yashk2000
Copy link
Member Author

We have a separate class which we use for handling snackbars across the app, SnackbarHandler. Some of the snackbars being used currently were just made using snackbar.make, instead of the Handler class for snackbars. So I converted those to SnackbarHandler.

@iamareebjamal
Copy link
Member

What advantage does SnackbarHandler have?

@yashk2000
Copy link
Member Author

@iamareebjamal it was created to have a common class to create all kinds of snackbars except those with actions. We use it to create snackbars with different bottom margins. So all these functions we created in this common class, SnackbarHandler, and it is used in almost all places in the app, except the ones which I fixed in this pr.

.show();
getString(R.string.Cloudrail_License_key),
Snackbar.LENGTH_SHORT);
snackbar.show();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is ridiculous. Why calling show 2 times. It should only be called once

Copy link
Member Author

@yashk2000 yashk2000 Aug 14, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The earlier .show is SnackBarHandler.show(). This creates a snackbar and returns it. Then to show it, we use the second .show().

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then it should not be called show. It should be create or make

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. I'll do that and update the pr.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

public void showError() {
Snackbar snackbar = SnackBarHandler.show(coordinatorLayout, getString(no_account_signed_in));
Snackbar snackbar = SnackBarHandler.create(coordinatorLayout, getString(no_account_signed_in));
snackbar.show();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to save in a variable. Directly call show

@yashk2000
Copy link
Member Author

@iamareebjamal please merge.

@iamareebjamal iamareebjamal merged commit 8b2804e into fossasia:development Aug 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Replacing Snackbar.make() in the app with SnackbarHandler.

2 participants