Skip to content
This repository has been archived by the owner on Mar 27, 2022. It is now read-only.

Commit

Permalink
SegmentedButton's drawable positioning fix.
Browse files Browse the repository at this point in the history
  • Loading branch information
ceryle committed Nov 20, 2016
1 parent 9493090 commit 2350db3
Show file tree
Hide file tree
Showing 9 changed files with 169 additions and 268 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package co.ceryle.segmentedbutton.util;
package co.ceryle.segmentedbutton;

import android.animation.ValueAnimator;
import android.view.View;
Expand All @@ -22,9 +22,9 @@
/**
* Created by EGE on 16/08/2016.
*/
public class AnimationCollapse {
class AnimationCollapse {

public static void expand(final View v, Interpolator interpolator, int duration, int targetWidth) {
static void expand(final View v, Interpolator interpolator, int duration, int targetWidth) {

int prevWidth = v.getWidth();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
/**
* Created by EGE on 2.10.2016.
*/

public class ButtonAttributes {
class ButtonAttributes {
private int tintColor, textColor, rippleColor, width = 0;
private float weight = 0;

Expand All @@ -31,115 +31,107 @@ public class ButtonAttributes {
private View rippleView;
private View dividerView;

public View getRippleView() {
View getRippleView() {
return rippleView;
}

public LinearLayout.LayoutParams getRippleViewParams() {
LinearLayout.LayoutParams getRippleViewParams() {
return (LinearLayout.LayoutParams) rippleView.getLayoutParams();
}

public void setRippleView(View rippleView) {
void setRippleView(View rippleView) {
this.rippleView = rippleView;
}

public View getDividerView() {
View getDividerView() {
return dividerView;
}

public LinearLayout.LayoutParams getDividerViewParams() {
LinearLayout.LayoutParams getDividerViewParams() {
return (LinearLayout.LayoutParams) dividerView.getLayoutParams();
}

public void setDividerView(View dividerView) {
void setDividerView(View dividerView) {
this.dividerView = dividerView;
}

public float getWeight() {
float getWeight() {
return weight;
}

public void setWeight(float weight) {
void setWeight(float weight) {
this.weight = weight;
}


public int getWidth() {

int getWidth() {
return width;
}

public boolean hasWidth() {
boolean hasWidth() {
return hasWidth;
}

public void setHasWidth(boolean hasWidth) {
void setHasWidth(boolean hasWidth) {
this.hasWidth = hasWidth;
}

public boolean hasWeight() {
boolean hasWeight() {
return hasWeight;
}

public void setHasWeight(boolean hasWeight) {
void setHasWeight(boolean hasWeight) {
this.hasWeight = hasWeight;
}

public void setWidth(int width) {
this.width = width;
}

public ButtonAttributes() {
}

public ButtonAttributes(int width) {
void setWidth(int width) {
this.width = width;
}

public int getTintColor() {
int getTintColor() {
return tintColor;
}

public void setTintColor(int tintColor) {
void setTintColor(int tintColor) {
this.tintColor = tintColor;
}

public int getTextColor() {
int getTextColor() {
return textColor;
}

public void setTextColor(int textColor) {
void setTextColor(int textColor) {
this.textColor = textColor;
}

public boolean hasTintColor() {
boolean hasTintColor() {
return hasTintColor;
}

public void setTintColor(boolean hasTintColor) {
void setTintColor(boolean hasTintColor) {
this.hasTintColor = hasTintColor;
}

public boolean hasTextColor() {
boolean hasTextColor() {
return hasTextColor;
}

public void setTextColor(boolean hasTextColor) {
void setTextColor(boolean hasTextColor) {
this.hasTextColor = hasTextColor;
}

public boolean hasRippleColor() {
boolean hasRippleColor() {
return hasRippleColor;
}

public void setRippleColor(boolean hasRippleColor) {
void setRippleColor(boolean hasRippleColor) {
this.hasRippleColor = hasRippleColor;
}

public int getRippleColor() {
int getRippleColor() {
return rippleColor;
}

public void setRippleColor(int rippleColor) {
void setRippleColor(int rippleColor) {
this.rippleColor = rippleColor;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package co.ceryle.segmentedbutton.util;
package co.ceryle.segmentedbutton;

import android.annotation.TargetApi;
import android.content.Context;
Expand All @@ -30,9 +30,9 @@
/**
* Created by EGE on 18.8.2016.
*/
public class RippleHelper {
class RippleHelper {

public static void setSelectableItemBackground(Context context, View view) {
static void setSelectableItemBackground(Context context, View view) {
int[] attrs = new int[]{android.R.attr.selectableItemBackground};
TypedArray ta = context.obtainStyledAttributes(attrs);
Drawable drawableFromTheme = ta.getDrawable(0 /* index */);
Expand All @@ -44,15 +44,15 @@ public static void setSelectableItemBackground(Context context, View view) {
}
}

public static void setRipple(View view, int pressedColor) {
static void setRipple(View view, int pressedColor) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
view.setBackground(getPressedColorRippleDrawable(pressedColor));
} else {
view.setBackgroundDrawable(getStateListDrawable(pressedColor));
}
}

public static Drawable createRipple(int normalColor, int pressedColor) {
static Drawable createRipple(int normalColor, int pressedColor) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
return getPressedColorRippleDrawable(pressedColor);
} else {
Expand Down Expand Up @@ -90,5 +90,4 @@ private static ColorStateList getPressedColorSelector(int pressedColor) {
private static ColorDrawable getColorDrawableFromColor(int color) {
return new ColorDrawable(color);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package co.ceryle.segmentedbutton.util;
package co.ceryle.segmentedbutton;

import android.graphics.drawable.Drawable;
import android.graphics.drawable.GradientDrawable;
Expand All @@ -24,7 +24,7 @@
/**
* Created by EGE on 22/08/2016.
*/
public class RoundHelper {
class RoundHelper {

private static GradientDrawable getGradientDrawable(int dividerColor, int dividerRadius, int dividerSize) {
GradientDrawable gradient =
Expand All @@ -35,7 +35,7 @@ private static GradientDrawable getGradientDrawable(int dividerColor, int divide
return gradient;
}

public static void makeRound(View view, int dividerColor, int dividerRadius, int dividerSize) {
static void makeRound(View view, int dividerColor, int dividerRadius, int dividerSize) {
GradientDrawable gradient = getGradientDrawable(dividerColor, dividerRadius, dividerSize);

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
Expand All @@ -44,7 +44,7 @@ public static void makeRound(View view, int dividerColor, int dividerRadius, int
view.setBackgroundDrawable(gradient);
}

public static void makeDividerRound(LinearLayout layout, int dividerColor, int dividerRadius, int dividerSize, Drawable drawable) {
static void makeDividerRound(LinearLayout layout, int dividerColor, int dividerRadius, int dividerSize, Drawable drawable) {
GradientDrawable gradient = null;
if (null != drawable) {
if (drawable instanceof GradientDrawable) {
Expand Down
Loading

0 comments on commit 2350db3

Please sign in to comment.