Skip to content

Commit

Permalink
remove the dependence of FlycoRoundView
Browse files Browse the repository at this point in the history
  • Loading branch information
H07000223 committed Mar 1, 2016
1 parent 196d450 commit 5dae137
Show file tree
Hide file tree
Showing 17 changed files with 259 additions and 84 deletions.
8 changes: 7 additions & 1 deletion CHNAGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,10 @@ Version 1.4.6 *(2015-12-11)*

Version 1.5.0 *(2015-12-11)*
----------------------------
* change code style
* change code style

Version 2.0.0 *(2016.3.1)*
----------------------------
* remove the dependence of FlycoRoundView
* new added method getIconView and getTitleView

1 change: 0 additions & 1 deletion FlycoTabLayout_Lib/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:support-v4:23.1.1'
compile 'com.nineoldandroids:library:2.4.0'
compile 'com.flyco.roundview:FlycoRoundView_Lib:1.1.2@aar'
}

//def siteUrl = 'https://github.com/H07000223' // 项目的主页
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@
import android.widget.LinearLayout;
import android.widget.TextView;

import com.flyco.roundview.RoundTextView;
import com.flyco.tablayout.listener.CustomTabEntity;
import com.flyco.tablayout.listener.OnTabSelectListener;
import com.flyco.tablayout.utils.FragmentChangeManager;
import com.flyco.tablayout.utils.UnreadMsgUtils;
import com.flyco.tablayout.widget.MsgView;
import com.nineoldandroids.animation.TypeEvaluator;
import com.nineoldandroids.animation.ValueAnimator;

Expand Down Expand Up @@ -795,7 +795,7 @@ public void showMsg(int position, int num) {
}

View tabView = mTabsContainer.getChildAt(position);
RoundTextView tipView = (RoundTextView) tabView.findViewById(R.id.rtv_msg_tip);
MsgView tipView = (MsgView) tabView.findViewById(R.id.rtv_msg_tip);
if (tipView != null) {
UnreadMsgUtils.show(tipView, num);

Expand Down Expand Up @@ -832,7 +832,7 @@ public void hideMsg(int position) {
}

View tabView = mTabsContainer.getChildAt(position);
RoundTextView tipView = (RoundTextView) tabView.findViewById(R.id.rtv_msg_tip);
MsgView tipView = (MsgView) tabView.findViewById(R.id.rtv_msg_tip);
if (tipView != null) {
tipView.setVisibility(View.GONE);
}
Expand All @@ -848,7 +848,7 @@ public void setMsgMargin(int position, float leftPadding, float bottomPadding) {
position = mTabCount - 1;
}
View tabView = mTabsContainer.getChildAt(position);
RoundTextView tipView = (RoundTextView) tabView.findViewById(R.id.rtv_msg_tip);
MsgView tipView = (MsgView) tabView.findViewById(R.id.rtv_msg_tip);
if (tipView != null) {
TextView tv_tab_title = (TextView) tabView.findViewById(R.id.tv_tab_title);
mTextPaint.setTextSize(mTextsize);
Expand Down Expand Up @@ -878,12 +878,12 @@ public void setMsgMargin(int position, float leftPadding, float bottomPadding) {
}

/** 当前类只提供了少许设置未读消息属性的方法,可以通过该方法获取RoundTextView对象从而各种设置 */
public RoundTextView getMsgView(int position) {
public MsgView getMsgView(int position) {
if (position >= mTabCount) {
position = mTabCount - 1;
}
View tabView = mTabsContainer.getChildAt(position);
RoundTextView tipView = (RoundTextView) tabView.findViewById(R.id.rtv_msg_tip);
MsgView tipView = (MsgView) tabView.findViewById(R.id.rtv_msg_tip);
return tipView;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
import android.widget.LinearLayout;
import android.widget.TextView;

import com.flyco.roundview.RoundTextView;
import com.flyco.tablayout.listener.OnTabSelectListener;
import com.flyco.tablayout.utils.FragmentChangeManager;
import com.flyco.tablayout.utils.UnreadMsgUtils;
import com.flyco.tablayout.widget.MsgView;
import com.nineoldandroids.animation.TypeEvaluator;
import com.nineoldandroids.animation.ValueAnimator;

Expand Down Expand Up @@ -613,7 +613,7 @@ public void showMsg(int position, int num) {
}

View tabView = mTabsContainer.getChildAt(position);
RoundTextView tipView = (RoundTextView) tabView.findViewById(R.id.rtv_msg_tip);
MsgView tipView = (MsgView) tabView.findViewById(R.id.rtv_msg_tip);
if (tipView != null) {
UnreadMsgUtils.show(tipView, num);

Expand Down Expand Up @@ -645,7 +645,7 @@ public void hideMsg(int position) {
}

View tabView = mTabsContainer.getChildAt(position);
RoundTextView tipView = (RoundTextView) tabView.findViewById(R.id.rtv_msg_tip);
MsgView tipView = (MsgView) tabView.findViewById(R.id.rtv_msg_tip);
if (tipView != null) {
tipView.setVisibility(View.GONE);
}
Expand All @@ -661,7 +661,7 @@ public void setMsgMargin(int position, float leftPadding, float bottomPadding) {
position = mTabCount - 1;
}
View tabView = mTabsContainer.getChildAt(position);
RoundTextView tipView = (RoundTextView) tabView.findViewById(R.id.rtv_msg_tip);
MsgView tipView = (MsgView) tabView.findViewById(R.id.rtv_msg_tip);
if (tipView != null) {
TextView tv_tab_title = (TextView) tabView.findViewById(R.id.tv_tab_title);
mTextPaint.setTextSize(mTextsize);
Expand All @@ -677,12 +677,12 @@ public void setMsgMargin(int position, float leftPadding, float bottomPadding) {
}

/** 当前类只提供了少许设置未读消息属性的方法,可以通过该方法获取RoundTextView对象从而各种设置 */
public RoundTextView getMsgView(int position) {
public MsgView getMsgView(int position) {
if (position >= mTabCount) {
position = mTabCount - 1;
}
View tabView = mTabsContainer.getChildAt(position);
RoundTextView tipView = (RoundTextView) tabView.findViewById(R.id.rtv_msg_tip);
MsgView tipView = (MsgView) tabView.findViewById(R.id.rtv_msg_tip);
return tipView;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
import android.widget.LinearLayout;
import android.widget.TextView;

import com.flyco.roundview.RoundTextView;
import com.flyco.tablayout.listener.OnTabSelectListener;
import com.flyco.tablayout.utils.UnreadMsgUtils;
import com.flyco.tablayout.widget.MsgView;

import java.util.ArrayList;

Expand Down Expand Up @@ -746,7 +746,7 @@ public void showMsg(int position, int num) {
}

View tabView = mTabsContainer.getChildAt(position);
RoundTextView tipView = (RoundTextView) tabView.findViewById(R.id.rtv_msg_tip);
MsgView tipView = (MsgView) tabView.findViewById(R.id.rtv_msg_tip);
if (tipView != null) {
UnreadMsgUtils.show(tipView, num);

Expand Down Expand Up @@ -778,7 +778,7 @@ public void hideMsg(int position) {
}

View tabView = mTabsContainer.getChildAt(position);
RoundTextView tipView = (RoundTextView) tabView.findViewById(R.id.rtv_msg_tip);
MsgView tipView = (MsgView) tabView.findViewById(R.id.rtv_msg_tip);
if (tipView != null) {
tipView.setVisibility(View.GONE);
}
Expand All @@ -790,7 +790,7 @@ public void setMsgMargin(int position, float leftPadding, float bottomPadding) {
position = mTabCount - 1;
}
View tabView = mTabsContainer.getChildAt(position);
RoundTextView tipView = (RoundTextView) tabView.findViewById(R.id.rtv_msg_tip);
MsgView tipView = (MsgView) tabView.findViewById(R.id.rtv_msg_tip);
if (tipView != null) {
TextView tv_tab_title = (TextView) tabView.findViewById(R.id.tv_tab_title);
mTextPaint.setTextSize(mTextsize);
Expand All @@ -804,12 +804,12 @@ public void setMsgMargin(int position, float leftPadding, float bottomPadding) {
}

/** 当前类只提供了少许设置未读消息属性的方法,可以通过该方法获取RoundTextView对象从而各种设置 */
public RoundTextView getMsgView(int position) {
public MsgView getMsgView(int position) {
if (position >= mTabCount) {
position = mTabCount - 1;
}
View tabView = mTabsContainer.getChildAt(position);
RoundTextView tipView = (RoundTextView) tabView.findViewById(R.id.rtv_msg_tip);
MsgView tipView = (MsgView) tabView.findViewById(R.id.rtv_msg_tip);
return tipView;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
import android.view.View;
import android.widget.RelativeLayout;

import com.flyco.roundview.RoundTextView;
import com.flyco.roundview.RoundViewDelegate;
import com.flyco.tablayout.widget.MsgView;

/**
* 未读消息提示View,显示小红点或者带有数字的红点:
Expand All @@ -15,40 +14,39 @@
* 数字超过两位,显示99+
*/
public class UnreadMsgUtils {
public static void show(RoundTextView rtv, int num) {
if (rtv == null) {
public static void show(MsgView msgView, int num) {
if (msgView == null) {
return;
}
RelativeLayout.LayoutParams lp = (RelativeLayout.LayoutParams) rtv.getLayoutParams();
DisplayMetrics dm = rtv.getResources().getDisplayMetrics();
RoundViewDelegate delegate = rtv.getDelegate();
rtv.setVisibility(View.VISIBLE);
RelativeLayout.LayoutParams lp = (RelativeLayout.LayoutParams) msgView.getLayoutParams();
DisplayMetrics dm = msgView.getResources().getDisplayMetrics();
msgView.setVisibility(View.VISIBLE);
if (num <= 0) {//圆点,设置默认宽高
delegate.setStrokeWidth(0);
rtv.setText("");
msgView.setStrokeWidth(0);
msgView.setText("");

lp.width = (int) (5 * dm.density);
lp.height = (int) (5 * dm.density);
rtv.setLayoutParams(lp);
msgView.setLayoutParams(lp);
} else {
lp.height = (int) (18 * dm.density);
if (num > 0 && num < 10) {//圆
lp.width = (int) (18 * dm.density);
rtv.setText(num + "");
msgView.setText(num + "");
} else if (num > 9 && num < 100) {//圆角矩形,圆角是高度的一半,设置默认padding
lp.width = RelativeLayout.LayoutParams.WRAP_CONTENT;
rtv.setPadding((int) (6 * dm.density), 0, (int) (6 * dm.density), 0);
rtv.setText(num + "");
msgView.setPadding((int) (6 * dm.density), 0, (int) (6 * dm.density), 0);
msgView.setText(num + "");
} else {//数字超过两位,显示99+
lp.width = RelativeLayout.LayoutParams.WRAP_CONTENT;
rtv.setPadding((int) (6 * dm.density), 0, (int) (6 * dm.density), 0);
rtv.setText("99+");
msgView.setPadding((int) (6 * dm.density), 0, (int) (6 * dm.density), 0);
msgView.setText("99+");
}
rtv.setLayoutParams(lp);
msgView.setLayoutParams(lp);
}
}

public static void setSize(RoundTextView rtv, int size) {
public static void setSize(MsgView rtv, int size) {
if (rtv == null) {
return;
}
Expand Down
Loading

0 comments on commit 5dae137

Please sign in to comment.