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

setLabelText - setMenuButtonLabelText programmatically (issue #274) #287

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import android.os.Parcel;
import android.os.Parcelable;
import android.os.SystemClock;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.GestureDetector;
import android.view.MotionEvent;
Expand Down Expand Up @@ -511,6 +512,10 @@ Label getLabelView() {
return (Label) getTag(R.id.fab_label);
}

void setLabelView(Label label) {
setTag(R.id.fab_label, label);
}

void setColors(int colorNormal, int colorPressed, int colorRipple) {
mColorNormal = colorNormal;
mColorPressed = colorPressed;
Expand Down Expand Up @@ -1078,6 +1083,7 @@ public void setLabelText(String text) {
TextView labelView = getLabelView();
if (labelView != null) {
labelView.setText(text);
labelView.setVisibility(TextUtils.isEmpty(text) ? INVISIBLE : VISIBLE);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -476,9 +476,8 @@ public void onClick(View v) {
private void addLabel(FloatingActionButton fab) {
String text = fab.getLabelText();

if (TextUtils.isEmpty(text)) return;

final Label label = new Label(mLabelsContext);
label.setVisibility(TextUtils.isEmpty(text) ? INVISIBLE : VISIBLE);
label.setClickable(true);
label.setFab(fab);
label.setShowAnimation(AnimationUtils.loadAnimation(getContext(), mLabelsShowAnimation));
Expand Down Expand Up @@ -527,7 +526,7 @@ private void addLabel(FloatingActionButton fab) {
label.setOnClickListener(fab.getOnClickListener());

addView(label);
fab.setTag(R.id.fab_label, label);
fab.setLabelView(label);
}

private void setLabelEllipsize(Label label) {
Expand Down Expand Up @@ -655,8 +654,8 @@ public void run() {
fab.show(animate);
}

Label label = (Label) fab.getTag(R.id.fab_label);
if (label != null && label.isHandleVisibilityChanges()) {
Label label = fab.getLabelView();
if (label != null && label.isHandleVisibilityChanges() && !TextUtils.isEmpty(label.getText())) {
label.show(animate);
}
}
Expand Down Expand Up @@ -711,8 +710,8 @@ public void run() {
fab.hide(animate);
}

Label label = (Label) fab.getTag(R.id.fab_label);
if (label != null && label.isHandleVisibilityChanges()) {
Label label = fab.getLabelView();
if (label != null && label.isHandleVisibilityChanges() && !TextUtils.isEmpty(label.getText())) {
label.hide(animate);
}
}
Expand Down