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

Feature/allow subclass styles #335

Open
wants to merge 3 commits 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 @@ -112,11 +112,15 @@ public FloatingActionButton(Context context, AttributeSet attrs, int defStyleAtt
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public FloatingActionButton(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
init(context, attrs, defStyleAttr);
init(context, attrs, defStyleAttr, defStyleRes);
}

protected void init(Context context, AttributeSet attrs, int defStyleAttr) {
init(context, attrs, defStyleAttr, 0);
}

private void init(Context context, AttributeSet attrs, int defStyleAttr) {
TypedArray attr = context.obtainStyledAttributes(attrs, R.styleable.FloatingActionButton, defStyleAttr, 0);
protected void init(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
TypedArray attr = context.obtainStyledAttributes(attrs, R.styleable.FloatingActionButton, defStyleAttr, defStyleRes);
mColorNormal = attr.getColor(R.styleable.FloatingActionButton_fab_colorNormal, 0xFFDA4336);
mColorPressed = attr.getColor(R.styleable.FloatingActionButton_fab_colorPressed, 0xFFE75043);
mColorDisabled = attr.getColor(R.styleable.FloatingActionButton_fab_colorDisabled, 0xFFAAAAAA);
Expand Down
16 changes: 13 additions & 3 deletions library/src/main/java/com/github/clans/fab/FloatingActionMenu.java
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,21 @@ public FloatingActionMenu(Context context, AttributeSet attrs) {

public FloatingActionMenu(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
init(context, attrs);
init(context, attrs, defStyleAttr);
}

private void init(Context context, AttributeSet attrs) {
TypedArray attr = context.obtainStyledAttributes(attrs, R.styleable.FloatingActionMenu, 0, 0);
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public FloatingActionMenu(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
init(context, attrs, defStyleAttr, defStyleRes);
}

protected void init(Context context, AttributeSet attrs, int defStyleAttr) {
init(context, attrs, defStyleAttr, 0);
}

protected void init(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
TypedArray attr = context.obtainStyledAttributes(attrs, R.styleable.FloatingActionMenu, defStyleAttr, defStyleRes);
mButtonSpacing = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_buttonSpacing, mButtonSpacing);
mLabelsMargin = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_labels_margin, mLabelsMargin);
mLabelsPosition = attr.getInt(R.styleable.FloatingActionMenu_menu_labels_position, LABELS_POSITION_LEFT);
Expand Down