Skip to content
This repository has been archived by the owner on Oct 23, 2020. It is now read-only.

Commit

Permalink
Fixed #82 and fixed #85.
Browse files Browse the repository at this point in the history
  • Loading branch information
Clans committed Jul 8, 2015
1 parent 687e4d2 commit d6b6433
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -507,8 +507,8 @@ OnClickListener getOnClickListener() {
return mClickListener;
}

TextView getLabelView() {
return (TextView) getTag(R.id.fab_label);
Label getLabelView() {
return (Label) getTag(R.id.fab_label);
}

void setColors(int colorNormal, int colorPressed, int colorRipple) {
Expand All @@ -521,7 +521,7 @@ void setColors(int colorNormal, int colorPressed, int colorRipple) {
void onActionDown() {
if (mBackgroundDrawable instanceof StateListDrawable) {
StateListDrawable drawable = (StateListDrawable) mBackgroundDrawable;
drawable.setState(new int[]{android.R.attr.state_pressed});
drawable.setState(new int[]{android.R.attr.state_enabled, android.R.attr.state_pressed});
} else if (Util.hasLollipop()) {
RippleDrawable ripple = (RippleDrawable) mBackgroundDrawable;
ripple.setState(new int[]{android.R.attr.state_enabled, android.R.attr.state_pressed});
Expand All @@ -534,7 +534,7 @@ void onActionDown() {
void onActionUp() {
if (mBackgroundDrawable instanceof StateListDrawable) {
StateListDrawable drawable = (StateListDrawable) mBackgroundDrawable;
drawable.setState(new int[]{});
drawable.setState(new int[]{android.R.attr.state_enabled});
} else if (Util.hasLollipop()) {
RippleDrawable ripple = (RippleDrawable) mBackgroundDrawable;
ripple.setState(new int[]{android.R.attr.state_enabled});
Expand Down Expand Up @@ -1025,7 +1025,7 @@ public void show(boolean animate) {
if (animate) {
playShowAnimation();
}
setVisibility(VISIBLE);
super.setVisibility(VISIBLE);
}
}

Expand All @@ -1039,7 +1039,7 @@ public void hide(boolean animate) {
if (animate) {
playHideAnimation();
}
setVisibility(INVISIBLE);
super.setVisibility(INVISIBLE);
}
}

Expand Down Expand Up @@ -1072,9 +1072,10 @@ public void setHideAnimation(Animation hideAnimation) {
}

public void setLabelVisibility(int visibility) {
TextView labelView = getLabelView();
Label labelView = getLabelView();
if (labelView != null) {
labelView.setVisibility(visibility);
labelView.setHandleVisibilityChanges(visibility == VISIBLE);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,7 @@ public void run() {

fab.show(animate);
Label label = (Label) fab.getTag(R.id.fab_label);
if (label != null) {
if (label != null && label.isHandleVisibilityChanges()) {
label.show(animate);
}

Expand Down Expand Up @@ -661,7 +661,7 @@ public void run() {

fab.hide(animate);
Label label = (Label) fab.getTag(R.id.fab_label);
if (label != null) {
if (label != null && label.isHandleVisibilityChanges()) {
label.hide(animate);
}

Expand Down
9 changes: 9 additions & 0 deletions library/src/main/java/com/github/clans/fab/Label.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public class Label extends TextView {
private Animation mShowAnimation;
private Animation mHideAnimation;
private boolean mUsingStyle;
private boolean mHandleVisibilityChanges = true;

public Label(Context context) {
super(context);
Expand Down Expand Up @@ -270,6 +271,14 @@ void setUsingStyle(boolean usingStyle) {
mUsingStyle = usingStyle;
}

void setHandleVisibilityChanges(boolean handle) {
mHandleVisibilityChanges = handle;
}

boolean isHandleVisibilityChanges() {
return mHandleVisibilityChanges;
}

@Override
public boolean onTouchEvent(MotionEvent event) {
if (mFab == null || mFab.getOnClickListener() == null || !mFab.isEnabled()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ protected void onCreate(Bundle savedInstanceState) {
@Override
public void onClick(View v) {
Toast.makeText(FloatingMenusActivity.this, programFab1.getLabelText(), Toast.LENGTH_SHORT).show();
fab3.setLabelVisibility(fab3.getLabelVisibility() == View.VISIBLE ? View.GONE : View.VISIBLE);
}
});

Expand Down

0 comments on commit d6b6433

Please sign in to comment.