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

Add option to show/hide the icon #32

Merged
merged 2 commits into from
Mar 6, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
Add option to show/hide the icon
  • Loading branch information
riclage committed Mar 3, 2017
commit 36dca5c601df91c6bff3071994dca5ab7c6284b1
14 changes: 13 additions & 1 deletion alerter/src/main/java/com/tapadoo/alerter/Alert.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ public class Alert extends FrameLayout implements View.OnClickListener, Animatio
private boolean enableIconPulse = true;
private boolean enableInfiniteDuration;

private boolean showIcon = true;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Remove.


/**
* Flag to ensure we only set the margins once
*/
Expand Down Expand Up @@ -176,7 +178,7 @@ public void onAnimationStart(final Animation animation) {
@Override
public void onAnimationEnd(final Animation animation) {
//Start the Icon Animation once the Alert is settled
if (enableIconPulse) {
if (enableIconPulse && showIcon) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Update here to check the visibility of the icon, instead of using a boolean flag.

if (enableIconPulse && ivIcon.getVisibility() == VISIBLE) {}

try {
ivIcon.startAnimation(AnimationUtils.loadAnimation(getContext(), R.anim.alerter_pulse));
} catch (Exception ex) {
Expand Down Expand Up @@ -341,6 +343,16 @@ public void setIcon(@DrawableRes final int iconId) {
ivIcon.setImageDrawable(iconDrawable);
}

/**
* Set whether to show the icon in the alert or not
*
* @param showIcon True to show the icon, false otherwise
*/
public void showIcon(final boolean showIcon) {
this.showIcon = showIcon;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Remove.

ivIcon.setVisibility(showIcon ? View.VISIBLE : View.GONE);
}

/**
* Get the Alert's on screen duration
*
Expand Down
13 changes: 13 additions & 0 deletions alerter/src/main/java/com/tapadoo/alerter/Alerter.java
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,19 @@ public Alerter enableIconPulse(final boolean pulse) {
return this;
}

/**
* Set whether to show the icon in the alert or not
*
* @param showIcon True to show the icon, false otherwise
* @return This Alerter
*/
public Alerter showIcon(final boolean showIcon) {
if (getAlert() != null) {
getAlert().showIcon(showIcon);
}
return this;
}

/**
* Enable or disable infinite duration of the alert
*
Expand Down