From 5c36764169ff93dc7270c7d95c3ed960e56744aa Mon Sep 17 00:00:00 2001 From: JPeng Date: Sat, 7 Oct 2017 13:02:25 +0800 Subject: [PATCH] Remove useless code --- app/build.gradle | 3 +- gradlew | 0 library/build.gradle | 3 +- .../jpeng/jptabbar/BadgeDismissListener.java | 2 - .../java/com/jpeng/jptabbar/DensityUtils.java | 5 - .../java/com/jpeng/jptabbar/JPTabBar.java | 113 ++-------- .../java/com/jpeng/jptabbar/JPTabItem.java | 201 ++++-------------- .../jpeng/jptabbar/OnTabSelectListener.java | 3 - .../jpeng/jptabbar/animate/Animatable.java | 14 +- .../jpeng/jptabbar/animate/FlipAnimater.java | 1 - .../jpeng/jptabbar/animate/JumpAnimater.java | 1 - .../jptabbar/animate/RotateAnimater.java | 3 - .../jptabbar/animate/Scale2Animater.java | 1 - .../jpeng/jptabbar/animate/ScaleAnimater.java | 1 - .../jptabbar/badgeview/BadgeViewHelper.java | 8 +- 15 files changed, 64 insertions(+), 295 deletions(-) mode change 100644 => 100755 gradlew diff --git a/app/build.gradle b/app/build.gradle index 4607876..403bb5c 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -25,6 +25,5 @@ android { dependencies { compile project(':library') - compile 'com.android.support:appcompat-v7:23.4.0' - compile 'com.nineoldandroids:library:2.4.0' + compile 'com.android.support:appcompat-v7:23.0.1' } diff --git a/gradlew b/gradlew old mode 100644 new mode 100755 diff --git a/library/build.gradle b/library/build.gradle index dc6dffa..ce4992d 100644 --- a/library/build.gradle +++ b/library/build.gradle @@ -26,8 +26,7 @@ android { } dependencies { - - provided 'com.android.support:support-v4:24.2.1' + provided 'com.android.support:support-v4:23.0.1' compile 'com.nineoldandroids:library:2.4.0' } diff --git a/library/src/main/java/com/jpeng/jptabbar/BadgeDismissListener.java b/library/src/main/java/com/jpeng/jptabbar/BadgeDismissListener.java index 6bbf1ca..443f823 100644 --- a/library/src/main/java/com/jpeng/jptabbar/BadgeDismissListener.java +++ b/library/src/main/java/com/jpeng/jptabbar/BadgeDismissListener.java @@ -9,6 +9,4 @@ public interface BadgeDismissListener { * TabItem徽章消失的回调 */ void onDismiss(int position); - - } diff --git a/library/src/main/java/com/jpeng/jptabbar/DensityUtils.java b/library/src/main/java/com/jpeng/jptabbar/DensityUtils.java index 15f8c16..bfb3c3f 100644 --- a/library/src/main/java/com/jpeng/jptabbar/DensityUtils.java +++ b/library/src/main/java/com/jpeng/jptabbar/DensityUtils.java @@ -8,9 +8,6 @@ */ public class DensityUtils { - - - public static int dp2sp(Context context, float dipValue) { float pxValue = dp2px(context, dipValue); return px2sp(context, pxValue); @@ -41,6 +38,4 @@ public static int sp2px(@NonNull Context context, float spValue) { return (int) (spValue * fontScale); } - - } \ No newline at end of file diff --git a/library/src/main/java/com/jpeng/jptabbar/JPTabBar.java b/library/src/main/java/com/jpeng/jptabbar/JPTabBar.java index 07c70ce..c5c8193 100644 --- a/library/src/main/java/com/jpeng/jptabbar/JPTabBar.java +++ b/library/src/main/java/com/jpeng/jptabbar/JPTabBar.java @@ -24,7 +24,6 @@ * 主要的底部导航操作类,控制导航的行为(显示隐藏徽章等等) */ public class JPTabBar extends LinearLayout implements ViewPager.OnPageChangeListener { - //默认的图标大小 private static final int DEFAULT_ICONSIZE = 24; //字体默认大小 @@ -51,64 +50,29 @@ public class JPTabBar extends LinearLayout implements ViewPager.OnPageChangeList private static final int DEFAULT_MIDDLEICONBOTTOM = 20; //默认中间的左右间距 private static final int DEFAULT_MIDDLEMARGIN = 24; - private Context mContext; - private int mLimit = 99; - - private TypedArray mAttribute; - - /** - * 选中的当前Tab的位置 - */ + // 选中的当前Tab的位置 private int mSelectIndex; - - /** - * 标题的数组 - */ + // 标题的数组 private String[] mTitles; - - /** - * 没有选中的图标数组 - */ + // 没有选中的图标数组 private int[] mNormalIcons; - - /** - * 选中的图标数组 - */ + // 选中的图标数组 private int[] mSelectedIcons; - - /** - * 所有Tabitem - */ + //所有Tabitem private JPTabItem[] mJPTabItems; - - /** - * 中间按钮 - */ + // 中间按钮 private View mMiddleItem; - - /** - * 监听点击Tab回调的观察者 - */ + // 监听点击Tab回调的观察者 private OnTabSelectListener mTabSelectLis; - - /** - * 判断是否需要动画,解决Viewpager回调onpageChange冲突事件 - */ + //判断是否需要动画,解决Viewpager回调onpageChange冲突事件 private boolean mNeedAnimate = true; - - /** - * Tab对应的ViewPager - */ + // Tab对应的ViewPager private ViewPager mTabPager; - - /** - * 渐变判断(用于滑动的渐变) - */ + // 渐变判断(用于滑动的渐变) private boolean mFilter; - /** * 是否滚动页面的动画 * 注意:这个变量是全局控制滚动动画是否执行 @@ -118,7 +82,6 @@ public class JPTabBar extends LinearLayout implements ViewPager.OnPageChangeList */ private boolean mNeedScrollAnimate; - public JPTabBar(Context context) { super(context); init(context, null); @@ -129,7 +92,6 @@ public JPTabBar(Context context, @Nullable AttributeSet attrs) { init(context, attrs); } - /** * 初始化TabBar * @@ -137,21 +99,15 @@ public JPTabBar(Context context, @Nullable AttributeSet attrs) { * @param set XML结点集合 */ private void init(Context context, AttributeSet set) { - mContext = context; - mAttribute = context.obtainStyledAttributes(set, R.styleable.JPTabBar); - setMinimumHeight(DensityUtils.dp2px(mContext, 48)); boolean haveAnno = reflectAnnotation(); if (haveAnno) { initFromAttribute(); } - - } - /** * 从类获取注解,映射值到mTiles,mNormalIcons,mSelectedIcons * @@ -161,12 +117,10 @@ private boolean reflectAnnotation() { int total = 0;//表示获得注解的总数 //反射注解 Field[] fields = mContext.getClass().getDeclaredFields(); - //遍历所有字段,寻找标记 for (Field field : fields) { field.setAccessible(true); if (field.isAnnotationPresent(Titles.class)) { - //标题 try { if (field.get(mContext).getClass().equals(String[].class)) { mTitles = (String[]) field.get(mContext); @@ -184,7 +138,6 @@ private boolean reflectAnnotation() { } else if (field.isAnnotationPresent(NorIcons.class)) { try { mNormalIcons = (int[]) field.get(mContext); - } catch (IllegalAccessException e) { e.printStackTrace(); } @@ -192,13 +145,11 @@ private boolean reflectAnnotation() { } else if (field.isAnnotationPresent(SeleIcons.class)) { try { mSelectedIcons = (int[]) field.get(mContext); - } catch (IllegalAccessException e) { e.printStackTrace(); } if (mSelectedIcons != null) total++; } - } return total > 0; } @@ -211,7 +162,6 @@ private void initFromAttribute() { int normalColor = mAttribute.getColor(R.styleable.JPTabBar_TabNormalColor, DEFAULT_NORMAL_COLOR); int selectColor = mAttribute.getColor(R.styleable.JPTabBar_TabSelectColor, DEFAULT_SELECT_COLOR); int textSize = DensityUtils.px2sp(mContext, mAttribute.getDimensionPixelSize(R.styleable.JPTabBar_TabTextSize, DensityUtils.sp2px(mContext, DEFAULT_TEXTSIZE))); - //这里 int iconSize = mAttribute.getDimensionPixelSize(R.styleable.JPTabBar_TabIconSize, DensityUtils.dp2px(mContext, DEFAULT_ICONSIZE)); int margin = mAttribute.getDimensionPixelOffset(R.styleable.JPTabBar_TabMargin, DensityUtils.dp2px(mContext, DEFAULT_MARGIN)); AnimationType AnimateType = AnimationType.values()[mAttribute.getInt(R.styleable.JPTabBar_TabAnimate, AnimationType.NONE.ordinal())]; @@ -223,18 +173,16 @@ private void initFromAttribute() { int hMargin = mAttribute.getDimensionPixelOffset(R.styleable.JPTabBar_TabMiddleHMargin, DensityUtils.dp2px(mContext, DEFAULT_MIDDLEMARGIN)); boolean acceptFilter = mAttribute.getBoolean(R.styleable.JPTabBar_TabIconFilter, DEFAULT_ACEEPTFILTER); Drawable tabselectbg = mAttribute.getDrawable(R.styleable.JPTabBar_TabSelectBg); - //假如所有都为空默认已经开启了 if (!isInEditMode()) { CheckIfAssertError(mTitles, mNormalIcons, mSelectedIcons); //计算Tab的宽度 - mJPTabItems = new JPTabItem[mNormalIcons.length]; //实例化TabItem添加进去 for (int i = 0; i < mJPTabItems.length; i++) { final int temp = i; Animatable animater = AnimateType == AnimationType.SCALE ? new ScaleAnimater() : AnimateType == AnimationType.ROTATE ? new RotateAnimater() : - AnimateType == AnimationType.FLIP ? new FlipAnimater() : AnimateType == AnimationType.JUMP ? new JumpAnimater() :AnimateType==AnimationType.SCALE2?new Scale2Animater() : null; + AnimateType == AnimationType.FLIP ? new FlipAnimater() : AnimateType == AnimationType.JUMP ? new JumpAnimater() : AnimateType == AnimationType.SCALE2 ? new Scale2Animater() : null; mJPTabItems[i] = new JPTabItem.Builder(mContext).setTitle(mTitles == null ? null : mTitles[i]).setIndex(temp).setTextSize(textSize) .setNormalColor(normalColor).setSelectBg(tabselectbg).setBadgeColor(BadgeColor) .setBadgeTextSize(BadgetextSize).setNormalIcon(mNormalIcons[i]) @@ -250,15 +198,13 @@ public boolean onTouch(View v, MotionEvent event) { } switch (event.getAction()) { case MotionEvent.ACTION_DOWN: - if(mJPTabItems[mSelectIndex].getAnimater()!=null) { + if (mJPTabItems[mSelectIndex].getAnimater() != null) { mJPTabItems[mSelectIndex].getAnimater().onPressDown(mJPTabItems[mSelectIndex].getIconView(), true); ((JPTabItem) v).getAnimater().onPressDown(((JPTabItem) v).getIconView(), false); } break; - case MotionEvent.ACTION_UP: if (isInRect(v, event)) { - //在触摸的item内 if (mTabPager != null && mTabPager.getAdapter() != null && mTabPager.getAdapter().getCount() >= mJPTabItems.length) { mNeedAnimate = true; mTabPager.setCurrentItem(temp, false); @@ -270,7 +216,7 @@ public boolean onTouch(View v, MotionEvent event) { setSelectTab(temp, true); } } else { - if(mJPTabItems[mSelectIndex].getAnimater()!=null) { + if (mJPTabItems[mSelectIndex].getAnimater() != null) { mJPTabItems[mSelectIndex].getAnimater().onTouchOut(mJPTabItems[mSelectIndex].getIconView(), true); ((JPTabItem) v).getAnimater().onTouchOut(((JPTabItem) v).getIconView(), false); } @@ -281,25 +227,15 @@ public boolean onTouch(View v, MotionEvent event) { return true; } }); -// mJPTabItems[i].setOnClickListener(new OnClickListener() { -// @Override -// public void onClick(View v) { - -// } -// }); addView(mJPTabItems[i]); - //判断是不是准备到中间的tab,假如设置了中间图标就添加进去 if (i == (mJPTabItems.length / 2 - 1) && mAttribute.getResourceId(R.styleable.JPTabBar_TabMiddleView, 0) != 0) { - //添加中间的占位距离控件 View stement_view = new View(mContext); ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(hMargin, ViewGroup.LayoutParams.MATCH_PARENT); stement_view.setLayoutParams(params); addView(stement_view); - } - } mJPTabItems[0].setSelect(true, true, false); @@ -310,14 +246,12 @@ public boolean onTouch(View v, MotionEvent event) { } } - /** * 切换Tab页面,是否带动画 */ private void setSelectTab(int index, boolean animated) { if (mJPTabItems == null || index > mJPTabItems.length - 1) return; mSelectIndex = index; - //把全部tab selected设置为false for (int i = 0; i < mJPTabItems.length; i++) { if (i == index) { continue; @@ -327,11 +261,8 @@ private void setSelectTab(int index, boolean animated) { } else { mJPTabItems[i].setSelect(false, animated); } - } - mJPTabItems[index].setSelect(true, animated); - if (mTabSelectLis != null) { mTabSelectLis.onTabSelect(index); } @@ -358,17 +289,13 @@ private void CheckIfAssertError(String[] titles, int[] normalIcon, int[] selecte private void BuildMiddleView() { - int layout_res = mAttribute.getResourceId(R.styleable.JPTabBar_TabMiddleView, 0); if (layout_res == 0) { return; } - mMiddleItem = LayoutInflater.from(mContext).inflate(layout_res, (ViewGroup) getParent(), false); - //给中间自定义View填充额外参数,令布局在父View的中间和最下边的位置(父View指的是TabBar的父控件) fillMiddleParams(); - } //判断触摸位置是否在View的区域 @@ -388,7 +315,6 @@ protected void onAttachedToWindow() { BuildMiddleView(); } mAttribute.recycle(); - } private void fillMiddleParams() { @@ -406,12 +332,10 @@ private void fillMiddleParams() { mMiddleItem.setLayoutParams(params); } ((ViewGroup) getParent()).addView(mMiddleItem); - } /****-------提供给开发者调用的方法---------****/ - /** * 切换Tab页面 */ @@ -511,7 +435,6 @@ public void showBadge(int pos, int count, boolean draggable) { mJPTabItems[pos].getBadgeViewHelper().setDragable(draggable); if (count == 0) { mJPTabItems[pos].hiddenBadge(); - } else if (count > mLimit) { mJPTabItems[pos].showTextBadge(mLimit + "+"); } else { @@ -522,7 +445,6 @@ public void showBadge(int pos, int count, boolean draggable) { /** * 隐藏徽章 - * * @param position */ public void hideBadge(int position) { @@ -532,7 +454,6 @@ public void hideBadge(int position) { /** * 设置标题数组 - * * @param titles */ public JPTabBar setTitles(String... titles) { @@ -543,9 +464,7 @@ public JPTabBar setTitles(String... titles) { public JPTabBar setTitles(int... titles) { if (titles != null && titles.length > 0) { mTitles = new String[titles.length]; - for (int i = 0; i < titles.length; i++) { - mTitles[i] = mContext.getString(titles[i]); } } @@ -581,7 +500,6 @@ public void generate() { * 获得选中的位置 */ public int getSelectPosition() { - return mSelectIndex; } @@ -591,7 +509,7 @@ public int getSelectPosition() { public void setAnimation(AnimationType animationType) { for (int i = 0; i < mJPTabItems.length; i++) { mJPTabItems[i].setAnimater(animationType == AnimationType.SCALE ? new ScaleAnimater() : animationType == AnimationType.ROTATE ? new RotateAnimater() : - animationType == AnimationType.JUMP ? new JumpAnimater() : animationType == AnimationType.FLIP ? new FlipAnimater():animationType==AnimationType.SCALE2?new Scale2Animater(): null); + animationType == AnimationType.JUMP ? new JumpAnimater() : animationType == AnimationType.FLIP ? new FlipAnimater() : animationType == AnimationType.SCALE2 ? new Scale2Animater() : null); } } @@ -601,7 +519,6 @@ public void setAnimation(AnimationType animationType) { public boolean isBadgeShow(int index) { if (mJPTabItems != null) return mJPTabItems[index].isBadgeShow(); - return false; } @@ -615,7 +532,6 @@ public View getMiddleView() { if (mMiddleItem == null) { BuildMiddleView(); } - return mMiddleItem; } @@ -768,6 +684,5 @@ public void onPageScrollStateChanged(int state) { } } - } diff --git a/library/src/main/java/com/jpeng/jptabbar/JPTabItem.java b/library/src/main/java/com/jpeng/jptabbar/JPTabItem.java index b8494bb..c9c243d 100644 --- a/library/src/main/java/com/jpeng/jptabbar/JPTabItem.java +++ b/library/src/main/java/com/jpeng/jptabbar/JPTabItem.java @@ -22,127 +22,52 @@ * TabBarItem类 */ public class JPTabItem extends BadgeRelativeLayout { - - //颜色渐变时间 private static final int FILTER_DURATION = 10; - /** - * 上下文 - */ + private Context mContext; - /** - * 标题 - */ private String mTitle; - - /** - * 索引值 - */ private int mIndex; - - /** - * 对应图标的大小 - */ + // 对应图标的大小 private int mIconSize; - - /** - * Tab的上下编剧 - */ + // Tab的上下边距 private int mMargin; - - /** - * 选中颜色(包括底部文字和图标) - */ + //选中颜色(包括底部文字和图标) private int mSelectColor; - - /** - * 没有选中的颜色(包括底部文字和图标) - */ + //没有选中的颜色(包括底部文字和图标) private int mNormalColor; - - - /** - * Tab字体大小 - */ + // Tab字体大小 private int mTextSize; - - /** - * 允许图标颜色随着字体颜色变化而变化 - */ + //允许图标颜色随着字体颜色变化而变化 private boolean mAcceptFilter; - - /** - * Badge的字体大小 - */ + // Badge的字体大小 private int mBadgeTextSize; - - /** - * 徽章垂直Margin - */ + // 徽章垂直Margin private int mBadgeVerMargin; - - /** - * 徽章水平Margin - */ + // 徽章水平Margin private int mBadgeHorMargin; - - /** - * Badge的背景颜色 - */ + // Badge的背景颜色 private int mBadgeBackground; - private int mOffset; - - /** - * 是否被选中 - */ + // 是否被选中 private boolean mSelected; - - /** - * badge的间距 - */ + // badge的间距 private int mBadgePadding; - - /** - * Tab的没有选中图标 - */ + // Tab的没有选中图标 private Drawable mNormalIcon; - - /** - * Tab选中的图标 - */ + // Tab选中的图标 private Drawable mSelectIcon; - - /** - * 选中的颜色 - */ + // 选中的颜色 private Drawable mSelectBg; - - /** - * Tab字体的画笔 - */ + // Tab字体的画笔 private Paint mTextPaint; - - /** - * 图标的图层 - */ + // 图标的图层 private LayerDrawable mCompundIcon; - - - /** - * 图标ImageView - */ + //图标ImageView private ImageView mIconView; - - /** - * 动画对象 - */ + // 动画对象 private Animatable mAnimater; - - - /** - * 徽章被用户拖出去的回调事件 - */ + // 徽章被用户拖出去的回调事件 private BadgeDismissListener mDismissListener; public JPTabItem(Context context) { @@ -151,7 +76,6 @@ public JPTabItem(Context context) { /** * 初始化布局和数据 - * */ private void init(Context context) { mContext = context; @@ -182,24 +106,20 @@ public void onDismiss(Badgeable badgeable) { }); } - /** * 初始化所有画笔 */ private void initPaint() { - //底部画笔 mTextPaint = new Paint(); mTextPaint.setAntiAlias(true); mTextPaint.setTextAlign(Paint.Align.CENTER); mTextPaint.setTextSize(DensityUtils.sp2px(mContext, mTextSize)); - } /** * 初始化图标ImageView */ private void initImageView() { - //设置ImageView布局属性 mIconView = new ImageView(mContext); RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams( mIconSize, mIconSize); @@ -208,45 +128,37 @@ private void initImageView() { params.topMargin = mMargin; mIconView.setScaleType(ImageView.ScaleType.FIT_XY); mIconView.setLayoutParams(params); - //设置图标 if (mSelectIcon == null) { mIconView.setImageDrawable(mNormalIcon); - } else { mCompundIcon = new LayerDrawable(new Drawable[]{mNormalIcon, mSelectIcon}); mNormalIcon.setAlpha(255); mSelectIcon.setAlpha(0); mIconView.setImageDrawable(mCompundIcon); } - //添加进去主布局 addView(mIconView); //初始化BadgeView设置回调和属性 initBadge(); } - @Override protected void onDraw(Canvas canvas) { if (mTitle != null) DrawText(canvas); } - /** * 画底部文字 */ private void DrawText(Canvas canvas) { - Rect textBound = new Rect(); mTextPaint.getTextBounds(mTitle, 0, mTitle.length(), textBound); Paint.FontMetrics fontMetrics = mTextPaint.getFontMetrics(); - - float x = getMeasuredWidth() / 2f; float y = getTextY(textBound, fontMetrics); mTextPaint.setColor(mNormalColor); - mTextPaint.setAlpha(255-mOffset); + mTextPaint.setAlpha(255 - mOffset); canvas.drawText(mTitle, x, y, mTextPaint); mTextPaint.setColor(mSelectColor); mTextPaint.setAlpha(mOffset); @@ -268,13 +180,14 @@ public ImageView getIconView() { return mIconView; } - Animatable getAnimater(){ + Animatable getAnimater() { return mAnimater; } - void setAnimater(Animatable animater){ + void setAnimater(Animatable animater) { mAnimater = animater; } + /** * 给Item设置代理 */ @@ -282,15 +195,15 @@ void setDismissDelegate(BadgeDismissListener listener) { this.mDismissListener = listener; } - void setNormalColor(int color){ + void setNormalColor(int color) { this.mNormalColor = color; } - void setSelectedColor(int color){ + void setSelectedColor(int color) { this.mSelectColor = color; } - void setTextSize(int size){ + void setTextSize(int size) { this.mTextSize = size; mTextPaint.setTextSize(mTextSize); } @@ -298,11 +211,11 @@ void setTextSize(int size){ /** * 设置TabItem选中的状态 */ - void setSelect(boolean selected, boolean animated){ - setSelect(selected,animated,true); + void setSelect(boolean selected, boolean animated) { + setSelect(selected, animated, true); } - void setSelect(boolean selected,boolean animated,boolean filter){ + void setSelect(boolean selected, boolean animated, boolean filter) { if (selected && mSelectBg != null) { setBackgroundDrawable(mSelectBg); } else { @@ -312,16 +225,16 @@ void setSelect(boolean selected,boolean animated,boolean filter){ mSelected = selected; if (mCompundIcon != null) { if (selected) { - if (!animated||mAnimater==null||!filter) { + if (!animated || mAnimater == null || !filter) { changeAlpha(1f); - } else{ + } else { ObjectAnimator.ofInt(mSelectIcon, "alpha", 0, 255).setDuration(FILTER_DURATION).start(); ObjectAnimator.ofInt(mNormalIcon, "alpha", 255, 0).setDuration(FILTER_DURATION).start(); } } else { - if (!animated||mAnimater==null||!filter) { + if (!animated || mAnimater == null || !filter) { changeAlpha(0f); - } else{ + } else { ObjectAnimator.ofInt(mNormalIcon, "alpha", 0, 255).setDuration(FILTER_DURATION).start(); ObjectAnimator.ofInt(mSelectIcon, "alpha", 255, 0).setDuration(FILTER_DURATION).start(); } @@ -332,17 +245,15 @@ void setSelect(boolean selected,boolean animated,boolean filter){ //播放动画 if (animated) { if (mAnimater != null) { - mAnimater.onSelectChanged(mIconView,mSelected); + mAnimater.onSelectChanged(mIconView, mSelected); } } - - if(mSelected) - mOffset=255; + if (mSelected) + mOffset = 255; else - mOffset=0; + mOffset = 0; postInvalidate(); } - } boolean isSelect() { @@ -378,58 +289,33 @@ void changeAlpha(float offset) { this.mOffset = (int) (offset * 255); postInvalidate(); } - - } - - /** - * 构造者 - */ static class Builder { - private int iconSize; - private int margin; - private int selectColor; - private int normalColor; - private int textSize; - private int normalIcon; - private int selectIcon; - private int badgeBackground; - private int badgeVerMargin; - private int badgeHorMargin; - private int badgeTextSize; - private int badgepadding; - private Drawable selectbg; - private String title; - private Context context; - private int index; - private boolean iconfilter; - private Animatable animater; - Builder(Context context) { this.context = context; } - Builder setAnimater(Animatable animater){ + Builder setAnimater(Animatable animater) { this.animater = animater; return this; } @@ -449,13 +335,11 @@ Builder setNormalColor(int normalColor) { return this; } - Builder setSelectedColor(int selectColor) { this.selectColor = selectColor; return this; } - Builder setMargin(int margin) { this.margin = margin; return this; @@ -491,13 +375,11 @@ Builder setSelectBg(Drawable res) { return this; } - Builder setBadgePadding(int padding) { this.badgepadding = padding; return this; } - Builder setNormalIcon(@DrawableRes int icon) { this.normalIcon = icon; return this; @@ -518,7 +400,6 @@ Builder setTitle(String title) { return this; } - JPTabItem build() { JPTabItem item = new JPTabItem(context); item.mTextSize = textSize @@ -544,7 +425,5 @@ JPTabItem build() { return item; } - } - } diff --git a/library/src/main/java/com/jpeng/jptabbar/OnTabSelectListener.java b/library/src/main/java/com/jpeng/jptabbar/OnTabSelectListener.java index 880d2a7..42ebcb3 100644 --- a/library/src/main/java/com/jpeng/jptabbar/OnTabSelectListener.java +++ b/library/src/main/java/com/jpeng/jptabbar/OnTabSelectListener.java @@ -12,7 +12,4 @@ public interface OnTabSelectListener { */ void onTabSelect(int index); - - - } diff --git a/library/src/main/java/com/jpeng/jptabbar/animate/Animatable.java b/library/src/main/java/com/jpeng/jptabbar/animate/Animatable.java index 9287d7b..8a0cc5e 100644 --- a/library/src/main/java/com/jpeng/jptabbar/animate/Animatable.java +++ b/library/src/main/java/com/jpeng/jptabbar/animate/Animatable.java @@ -6,33 +6,29 @@ * Created by jpeng on 16-11-14. */ public interface Animatable { - /** * 按下View动画行为 */ - public void onPressDown(View v,boolean selected); + void onPressDown(View v,boolean selected); /** * 松开时,手指触摸在View外发生的动作行为 */ - public void onTouchOut(View v,boolean selected); + void onTouchOut(View v,boolean selected); /** * 当选中状态发生改变时 */ - public void onSelectChanged(View v, boolean selected); + void onSelectChanged(View v, boolean selected); /** * 页面切换动画 */ - public void onPageAnimate(View v,float offset); + void onPageAnimate(View v,float offset); /** * 是否需要页面切换动画 */ - public boolean isNeedPageAnimate(); - - - + boolean isNeedPageAnimate(); } diff --git a/library/src/main/java/com/jpeng/jptabbar/animate/FlipAnimater.java b/library/src/main/java/com/jpeng/jptabbar/animate/FlipAnimater.java index 66f0e7e..29add51 100644 --- a/library/src/main/java/com/jpeng/jptabbar/animate/FlipAnimater.java +++ b/library/src/main/java/com/jpeng/jptabbar/animate/FlipAnimater.java @@ -11,7 +11,6 @@ */ public class FlipAnimater implements Animatable{ - @Override public void onPressDown(View v, boolean selected) { ViewHelper.setRotationY(v,selected?54f:126f); diff --git a/library/src/main/java/com/jpeng/jptabbar/animate/JumpAnimater.java b/library/src/main/java/com/jpeng/jptabbar/animate/JumpAnimater.java index 8d24e7e..438327a 100644 --- a/library/src/main/java/com/jpeng/jptabbar/animate/JumpAnimater.java +++ b/library/src/main/java/com/jpeng/jptabbar/animate/JumpAnimater.java @@ -11,7 +11,6 @@ */ public class JumpAnimater implements Animatable { - @Override public void onPressDown(View v, boolean selected) { ViewHelper.setTranslationY(v,-3f); diff --git a/library/src/main/java/com/jpeng/jptabbar/animate/RotateAnimater.java b/library/src/main/java/com/jpeng/jptabbar/animate/RotateAnimater.java index 18e710c..a16b58c 100644 --- a/library/src/main/java/com/jpeng/jptabbar/animate/RotateAnimater.java +++ b/library/src/main/java/com/jpeng/jptabbar/animate/RotateAnimater.java @@ -11,7 +11,6 @@ */ public class RotateAnimater implements Animatable { - @Override public void onPressDown(View v, boolean selected) { @@ -34,7 +33,6 @@ public void onSelectChanged(View v, boolean selected) { @Override public void onPageAnimate(View v, float offset) { ViewHelper.setRotation(v, offset * 360); - } @Override @@ -42,5 +40,4 @@ public boolean isNeedPageAnimate() { return true; } - } diff --git a/library/src/main/java/com/jpeng/jptabbar/animate/Scale2Animater.java b/library/src/main/java/com/jpeng/jptabbar/animate/Scale2Animater.java index 3aa26e9..ce43359 100644 --- a/library/src/main/java/com/jpeng/jptabbar/animate/Scale2Animater.java +++ b/library/src/main/java/com/jpeng/jptabbar/animate/Scale2Animater.java @@ -10,7 +10,6 @@ */ public class Scale2Animater implements Animatable { - @Override public void onPressDown(View v, boolean selected) { if(!selected) { diff --git a/library/src/main/java/com/jpeng/jptabbar/animate/ScaleAnimater.java b/library/src/main/java/com/jpeng/jptabbar/animate/ScaleAnimater.java index fd468a2..6afb897 100644 --- a/library/src/main/java/com/jpeng/jptabbar/animate/ScaleAnimater.java +++ b/library/src/main/java/com/jpeng/jptabbar/animate/ScaleAnimater.java @@ -11,7 +11,6 @@ */ public class ScaleAnimater implements Animatable{ - @Override public void onPressDown(View v, boolean selected) { ViewHelper.setScaleX(v,1.1f); diff --git a/library/src/main/java/com/jpeng/jptabbar/badgeview/BadgeViewHelper.java b/library/src/main/java/com/jpeng/jptabbar/badgeview/BadgeViewHelper.java index a3f30a1..01605dd 100644 --- a/library/src/main/java/com/jpeng/jptabbar/badgeview/BadgeViewHelper.java +++ b/library/src/main/java/com/jpeng/jptabbar/badgeview/BadgeViewHelper.java @@ -139,8 +139,6 @@ private void initDefaultAttrs(Context context, BadgeGravity defaultBadgeGravity) mBadgeDragExtraRectF = new RectF(); } - - private void afterInitDefaultAndCustomAttrs() { mBadgePaint.setTextSize(mBadgeTextSize); } @@ -171,8 +169,8 @@ public void setBadgeVerticalMarginDp(int badgeVerticalMargin) { } public void setBadgeHorizontalMarginDp(int badgeHorizontalMargin) { - mBadgeHorizontalMargin = DensityUtils.dp2px(mBadgeable.getContext(), badgeHorizontalMargin); - mBadgeable.postInvalidate(); + mBadgeHorizontalMargin = DensityUtils.dp2px(mBadgeable.getContext(), badgeHorizontalMargin); + mBadgeable.postInvalidate(); } public void setBadgePaddingDp(int badgePadding) { @@ -326,7 +324,7 @@ private void drawTextBadge(Canvas canvas) { mBadgeRectF.bottom = mBadgeRectF.top + badgeHeight; // 计算徽章背景左右的值 - mBadgeRectF.right = mBadgeable.getWidth()/2 + mBadgeHorizontalMargin; + mBadgeRectF.right = mBadgeable.getWidth() / 2 + mBadgeHorizontalMargin; mBadgeRectF.left = mBadgeRectF.right - badgeWidth; if (mBadgeBorderWidth > 0) {