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

Added option to stop icon pulsing. Added null check for activity in c… #3

Merged
merged 2 commits into from
Feb 16, 2017
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ A work in progress...

```groovy
dependecies {
compile 'com.tapadoo.android:alerter:1.0.0'
compile 'com.tapadoo.android:alerter:1.0.1'
}
```

Expand Down
2 changes: 1 addition & 1 deletion alerter/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ apply plugin: "maven-publish"
apply from: rootProject.file('quality.gradle')

def final String PACKAGE_NAME = "com.tapadoo.android"
def final String VERSION = "1.0.0"
def final String VERSION = "1.0.1"
def final String DESCRIPTION = "An Android Alerting Library"
def final String GITHUB_URL = "https://github.com/Tapadoo/Alerter"

Expand Down
22 changes: 17 additions & 5 deletions alerter/src/main/java/com/tapadoo/alerter/Alert.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
*
* @author Kevin Murphy, Tapadoo, Dublin, Ireland, Europe, Earth.
* @since 26/01/2016
*
**/
public class Alert extends FrameLayout implements View.OnClickListener, Animation.AnimationListener {

Expand All @@ -53,6 +52,8 @@ public class Alert extends FrameLayout implements View.OnClickListener, Animatio

private long duration = DISPLAY_TIME_IN_SECONDS;

private boolean enableIconPulse = true;

/**
* Flag to ensure we only set the margins once
*/
Expand Down Expand Up @@ -187,10 +188,12 @@ public void onAnimationStart(final Animation animation) {
@Override
public void onAnimationEnd(final Animation animation) {
//Start the Icon Animation once the Alert is settled
try {
ivIcon.startAnimation(AnimationUtils.loadAnimation(getContext(), R.anim.alerter_pulse));
} catch (Exception ex) {
Log.e(getClass().getSimpleName(), Log.getStackTraceString(ex));
if (enableIconPulse) {
try {
ivIcon.startAnimation(AnimationUtils.loadAnimation(getContext(), R.anim.alerter_pulse));
} catch (Exception ex) {
Log.e(getClass().getSimpleName(), Log.getStackTraceString(ex));
}
}

//Start the Handler to clean up the Alert
Expand Down Expand Up @@ -359,6 +362,15 @@ public void setDuration(final long duration) {
this.duration = duration;
}

/**
* Set if the Icon should pulse or not
*
* @param shouldPulse True if the icon should be animated
*/
public void pulseIcon(final boolean shouldPulse) {
this.enableIconPulse = shouldPulse;
}

/**
* Get the screen height in pixels
*
Expand Down
17 changes: 17 additions & 0 deletions alerter/src/main/java/com/tapadoo/alerter/Alerter.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ private Alerter() {
* @return This Alerter
*/
public static Alerter create(@NonNull final Activity activity) {
if (activity == null) {
throw new IllegalArgumentException("Activity cannot be null!");
}

final Alerter alerter = new Alerter();

//Clear Current Alert, if one is Active
Expand Down Expand Up @@ -215,6 +219,19 @@ public Alerter setDuration(@NonNull final long milliseconds) {
return this;
}

/**
* Enable or Disable Icon Pulse Animations
*
* @param pulse True if the icon should pulse
* @return This Alerter
*/
public Alerter enableIconPulse(final boolean pulse) {
if (getAlert() != null) {
getAlert().pulseIcon(pulse);
}
return this;
}

/**
* Gets the Alert associated with the Alerter
*
Expand Down

This file was deleted.