Skip to content

Commit

Permalink
Merge pull request Clans#2 from Clans/dev
Browse files Browse the repository at this point in the history
Added option to disable FAM icon animation
  • Loading branch information
Clans committed Mar 26, 2015
2 parents c9904ec + dc1fd30 commit 7ebda55
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 8 deletions.
4 changes: 2 additions & 2 deletions library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ android {
defaultConfig {
minSdkVersion 15
targetSdkVersion 22
versionCode 1
versionName "1.0"
versionCode Integer.parseInt(project.VERSION_CODE)
versionName project.VERSION_NAME
}
buildTypes {
release {
Expand Down
21 changes: 17 additions & 4 deletions library/src/main/java/com/github/clans/fab/FloatingActionMenu.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ public class FloatingActionMenu extends ViewGroup {
private int mLabelsMaxLines;
private int mMenuFabSize;
private int mLabelsStyle;
private boolean mIconAnimated = true;

private OnMenuToggleListener mToggleListener;

Expand Down Expand Up @@ -423,8 +424,10 @@ public void toggle(boolean animate) {

public void open(final boolean animate) {
if (!isOpened()) {
mCloseAnimatorSet.cancel();
mOpenAnimatorSet.start();
if (mIconAnimated) {
mCloseAnimatorSet.cancel();
mOpenAnimatorSet.start();
}
mMenuOpened = true;
int delay = 0;
for (int i = getChildCount() - 1; i >= 0; i--) {
Expand Down Expand Up @@ -455,8 +458,10 @@ public void run() {

public void close(final boolean animate) {
if (isOpened()) {
mCloseAnimatorSet.start();
mOpenAnimatorSet.cancel();
if (mIconAnimated) {
mCloseAnimatorSet.start();
mOpenAnimatorSet.cancel();
}
mMenuOpened = false;
int delay = 0;
for (int i = 0; i < getChildCount(); i++) {
Expand Down Expand Up @@ -529,4 +534,12 @@ public int getAnimationDelayPerItem() {
public void setOnMenuToggleListener(OnMenuToggleListener listener) {
mToggleListener = listener;
}

public void setIconAnimated(boolean animated) {
mIconAnimated = animated;
}

public boolean isIconAnimated() {
return mIconAnimated;
}
}
9 changes: 7 additions & 2 deletions sample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,16 @@ android {
applicationId "com.github.fab.sample"
minSdkVersion 15
targetSdkVersion 22
versionCode 1
versionName "1.0"
versionCode Integer.parseInt(project.VERSION_CODE)
versionName project.VERSION_NAME
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}

debug {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
Expand Down
6 changes: 6 additions & 0 deletions sample/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,9 @@
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# keep getters/setters in RotatingDrawable so that animations can still work.
-keepclassmembers class com.github.clans.fab.FloatingActionMenu$RotatingDrawable {
void set*(***);
*** get*();
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ protected void onCreate(Bundle savedInstanceState) {
getSupportActionBar().setDisplayHomeAsUpEnabled(true);

FloatingActionMenu menu2 = (FloatingActionMenu) findViewById(R.id.menu2);
FloatingActionMenu menu3 = (FloatingActionMenu) findViewById(R.id.menu3);
menu3.setIconAnimated(false);

menu2.setIconAnimationInterpolator(new OvershootInterpolator());
menu2.setOnMenuToggleListener(new FloatingActionMenu.OnMenuToggleListener() {
@Override
Expand Down

0 comments on commit 7ebda55

Please sign in to comment.