Skip to content

Commit

Permalink
Minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Clans committed Mar 22, 2015
1 parent d394f3d commit 51865e2
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import android.content.Context;
import android.content.res.ColorStateList;
import android.content.res.TypedArray;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.ColorFilter;
Expand All @@ -14,7 +13,6 @@
import android.graphics.drawable.Drawable;
import android.graphics.drawable.LayerDrawable;
import android.graphics.drawable.RippleDrawable;
import android.graphics.drawable.RotateDrawable;
import android.graphics.drawable.ShapeDrawable;
import android.graphics.drawable.StateListDrawable;
import android.graphics.drawable.shapes.OvalShape;
Expand All @@ -25,16 +23,13 @@
import android.support.annotation.NonNull;
import android.util.AttributeSet;
import android.view.GestureDetector;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewOutlineProvider;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.ImageButton;
import android.widget.TextView;
import android.widget.Toast;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
Expand Down Expand Up @@ -62,7 +57,7 @@ public class FloatingActionButton extends ImageButton {
private int mIconSize = Util.dpToPx(getContext(), 24f);
private Animation mShowAnimation;
private Animation mHideAnimation;
private String mLabel;
private String mLabelText;
private OnClickListener mClickListener;
private Drawable mBackgroundDrawable;

Expand Down Expand Up @@ -96,7 +91,7 @@ private void init(Context context, AttributeSet attrs) {
mShadowXOffset = attr.getDimensionPixelSize(R.styleable.FloatingActionButton_fab_shadowXOffset, mShadowXOffset);
mShadowYOffset = attr.getDimensionPixelSize(R.styleable.FloatingActionButton_fab_shadowYOffset, mShadowYOffset);
mFabSize = attr.getInt(R.styleable.FloatingActionButton_fab_size, SIZE_NORMAL);
mLabel = attr.getString(R.styleable.FloatingActionButton_fab_label);
mLabelText = attr.getString(R.styleable.FloatingActionButton_fab_label);
initShowAnimation(attr);
initHideAnimation(attr);
attr.recycle();
Expand Down Expand Up @@ -656,16 +651,16 @@ public void toggle(boolean animate) {
}
}

public void setLabel(String label) {
mLabel = label;
public void setLabelText(String text) {
mLabelText = text;
TextView labelView = getLabelView();
if (labelView != null) {
labelView.setText(label);
labelView.setText(text);
}
}

public String getLabel() {
return mLabel;
public String getLabelText() {
return mLabelText;
}

public void setShowAnimation(Animation showAnimation) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ private void createLabels() {

for (int i = 0; i < mButtonsCount; i++) {
final FloatingActionButton fab = (FloatingActionButton) getChildAt(i);
String text = fab.getLabel();
String text = fab.getLabelText();

if (fab == mMenuButton || TextUtils.isEmpty(text) || fab.getTag(R.id.fab_label) != null) {
continue;
Expand Down Expand Up @@ -522,6 +522,10 @@ public void setAnimationDelayPerItem(int animationDelayPerItem) {
mAnimationDelayPerItem = animationDelayPerItem;
}

public int getAnimationDelayPerItem() {
return mAnimationDelayPerItem;
}

public void setOnMenuToggleListener(OnMenuToggleListener listener) {
mToggleListener = listener;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,18 @@ protected void onCreate(Bundle savedInstanceState) {

FloatingActionMenu menu2 = (FloatingActionMenu) findViewById(R.id.menu2);
menu2.setIconAnimationInterpolator(new OvershootInterpolator());
menu2.setOnMenuToggleListener(new FloatingActionMenu.OnMenuToggleListener() {
@Override
public void onMenuToggle(boolean opened) {
String text = "";
if (opened) {
text = "Menu opened";
} else {
text = "Menu closed";
}
Toast.makeText(FloatingMenusActivity.this, text, Toast.LENGTH_SHORT).show();
}
});

fab1 = (FloatingActionButton) findViewById(R.id.fab1);
fab2 = (FloatingActionButton) findViewById(R.id.fab2);
Expand Down Expand Up @@ -65,22 +77,22 @@ public void onClick(View v) {

switch (v.getId()) {
case R.id.fab1:
text = fab1.getLabel();
text = fab1.getLabelText();
break;
case R.id.fab2:
text = fab2.getLabel();
text = fab2.getLabelText();
break;
case R.id.fab3:
text = fab3.getLabel();
text = fab3.getLabelText();
break;
case R.id.fab12:
text = fab12.getLabel();
text = fab12.getLabelText();
break;
case R.id.fab22:
text = fab22.getLabel();
text = fab22.getLabelText();
break;
case R.id.fab32:
text = fab32.getLabel();
text = fab32.getLabelText();
break;
}

Expand Down

0 comments on commit 51865e2

Please sign in to comment.