Skip to content

Commit

Permalink
Fix Bug the conlict of scroll and click animate when setUseScroll(false)
Browse files Browse the repository at this point in the history
  • Loading branch information
peng8350 committed Dec 4, 2016
1 parent 850f2fb commit 70bcb13
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 14 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,13 @@ Or, you can init in the oncreate

/**
* set the icon and title filter when scroll page and click the tab
* default value is false
*/
public JPTabBar setUseFilter(boolean filter);

/**
* Set the boolean If Need the PageAnimate
* default value is false
*/
public JPTabBar setUseScrollAnimate(boolean scrollAnimate);

Expand Down Expand Up @@ -148,7 +150,7 @@ Or, you can init in the oncreate
| TabIconFilter | Set the icon change by the font color|boolean | true |
| TabMargin |Set the icon distance above and below the distance from the text |dimension | 8dp |
| TabSelectBg |Set the TabItem Selected bg |color | transparent |
| TabAnimate |The animate type of the Tab Switch |enum | Scale |
| TabAnimate |The animate type of the Tab Switch(None,Scale,Jump....) |enum | Scale |
| TabMiddleIcon |The middle Icon of the tab |drawable ||
| BadgeColor |The background of the badgeView |color | #f00(RED) |
| BadgePadding |The background expansion distance of the badge |dimension | 4dp |
Expand Down Expand Up @@ -223,7 +225,7 @@ Or, you can init in the oncreate

# About Me
A college student, is still in the study of various techniques...<br>
E-mail:83508440@qq.com
E-mail:peng8350@gmail.com

# License
```
Expand Down
6 changes: 4 additions & 2 deletions README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,13 @@

/**
* 设置图标和标题的滑动渐变以及点击渐变是否使用
* 默认为false
*/
public JPTabBar setUseFilter(boolean filter);

/**
* 设置是否需要页面滚动动画
* 默认为false
*/
public JPTabBar setUseScrollAnimate(boolean scrollAnimate);

Expand Down Expand Up @@ -149,7 +151,7 @@
| TabIconFilter | 设置图标是否随着字体颜色而改变|boolean | true |
| TabMargin |设置图标距离上面和文字距离下面的距离 |dimension | 8dp |
| TabSelectBg |设置TabBarItem选中的背景颜色 |color | 透明 |
| TabAnimate |Tab切换的动画类型 |enum | Scale |
| TabAnimate |Tab切换的动画类型(None,Scale,Jump....) |enum | Scale |
| TabMiddleIcon |Tab中间的图标 |drawable ||
| BadgeColor |徽章的背景颜色 |color | #f00(红色) |
| BadgePadding |徽章的背景扩展距离 |dimension | 4dp |
Expand Down Expand Up @@ -222,7 +224,7 @@

# 关于我
一名在校大学生,目前还在专研学习各种技术中...<br>
邮箱:83508440@qq.com
邮箱:peng8350@gmail.com

# License
```
Expand Down
11 changes: 6 additions & 5 deletions app/src/main/java/com/jpeng/demo/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
import static com.jpeng.demo.R.id.tabbar;


public class MainActivity extends AppCompatActivity implements BadgeDismissListener, OnTabSelectListener{
public class MainActivity extends AppCompatActivity implements BadgeDismissListener, OnTabSelectListener {

private List<Fragment> list = new ArrayList<>();
// @Titles
// @Titles
// private int[] titles = {R.string.Tab1Pager,R.string.Tab2Pager,R.string.Tab3Pager,R.string.Tab4Pager};
// @NorIcons
// private int[] mNormalIcons = {R.mipmap.tab1_normal,R.mipmap.tab2_normal,R.mipmap.tab3_normal,R.mipmap.tab4_normal};
Expand All @@ -42,7 +42,7 @@ protected void onCreate(Bundle savedInstanceState) {
setContentView(R.layout.activity_main);
mPager = (NoScrollViewPager) findViewById(R.id.view_pager);
mTabbar = (JPTabBar) findViewById(tabbar);
mTabbar.setTitles(R.string.tab1,R.string.tab2,R.string.tab3,R.string.tab4)
mTabbar.setTitles(R.string.tab1, R.string.tab2, R.string.tab3, R.string.tab4)
.setNormalIcons(R.mipmap.tab1_normal, R.mipmap.tab2_normal, R.mipmap.tab3_normal, R.mipmap.tab4_normal)
.setSelectedIcons(R.mipmap.tab1_selected, R.mipmap.tab2_selected, R.mipmap.tab3_selected, R.mipmap.tab4_selected)
.generate();
Expand All @@ -67,7 +67,7 @@ protected void onCreate(Bundle savedInstanceState) {

@Override
public void onDismiss(int position) {
if (position==0){
if (position == 0) {
mTab1.clearCount();
}
}
Expand All @@ -80,11 +80,12 @@ public void onTabSelect(int index) {

@Override
public void onClickMiddle(View middleBtn) {
Intent intent= new Intent(this,SayActivity.class);
Intent intent = new Intent(this, SayActivity.class);
startActivity(intent);
}

public JPTabBar getTabbar() {
return mTabbar;
}

}
4 changes: 3 additions & 1 deletion app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@
<com.jpeng.jptabbar.JPTabBar
android:id="@+id/tabbar"
android:layout_width="match_parent"
android:layout_height="56dp"
android:layout_height="60dp"
android:layout_alignParentBottom="true"
android:background="@drawable/tab_bg"
jp:TabTextSize="12sp"
jp:TabAnimate="Scale"
jp:TabMiddleIcon="@mipmap/circle"
/>


Expand Down
6 changes: 4 additions & 2 deletions app/src/main/res/layout/tab3.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,13 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="打开"
android:checked="true"

android:id="@+id/radioButton1"/>

<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:text="关闭"
android:id="@+id/radioButton2"/>
</RadioGroup>
Expand All @@ -53,13 +54,14 @@
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"

android:text="打开"
android:id="@+id/radioButton3"/>

<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:text="关闭"
android:id="@+id/radioButton4"/>
</RadioGroup>
Expand Down
6 changes: 4 additions & 2 deletions library/src/main/java/com/jpeng/jptabbar/JPTabBar.java
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,12 @@ public class JPTabBar extends LinearLayout implements ViewPager.OnPageChangeList
/**
* 渐变判断
*/
private boolean mFilter = true;
private boolean mFilter;

/**
* 是否滚动页面的动画
*/
private boolean mNeedScrollAnimate = true;
private boolean mNeedScrollAnimate;


public JPTabBar(Context context) {
Expand Down Expand Up @@ -632,11 +632,13 @@ public void onPageScrolled(int position, float positionOffset, int positionOffse
mNeedAnimate = true;
}
}
else mNeedAnimate=true;
}
}

@Override
public void onPageSelected(int position) {
System.out.println(mNeedAnimate);
setSelectTab(position, mNeedAnimate);
}

Expand Down
2 changes: 2 additions & 0 deletions library/src/main/java/com/jpeng/jptabbar/JPTabItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ public class JPTabItem extends BadgeRelativeLayout {
*/
private int mSelectColor;


/**
* 没有选中的颜色(包括底部文字和图标)
*/
Expand Down Expand Up @@ -133,6 +134,7 @@ public class JPTabItem extends BadgeRelativeLayout {
*/
private int mBadgePadding;


/**
* 徽章被用户拖出去的回调事件
*/
Expand Down

0 comments on commit 70bcb13

Please sign in to comment.