Skip to content

Commit

Permalink
Merge pull request Tapadoo#3 from Tapadoo/archiving_prep
Browse files Browse the repository at this point in the history
Added option to stop icon pulsing. Added null check for activity in c…
  • Loading branch information
kpmmmurphy authored Feb 16, 2017
2 parents 1e17024 + 4b1fc3f commit c1ff61d
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 33 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ Alerter.create(this)

```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.

0 comments on commit c1ff61d

Please sign in to comment.