Skip to content

Commit

Permalink
更新README
Browse files Browse the repository at this point in the history
  • Loading branch information
ccw committed Jan 21, 2019
1 parent b771cd1 commit 883ed4d
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -339,15 +339,20 @@ drawable的编写如下:

只需为BottomBarLayout设置页签选中的监听,在回调中进行以下处理:

mBottomBarLayout.setOnItemSelectedListener(new BottomBarLayout.OnItemSelectedListener() {
mBottomBarLayout.setOnItemSelectedListener(new BottomBarLayout.OnItemSelectedListener() {
@Override
public void onItemSelected(final BottomBarItem bottomBarItem, int position) {
if (position == 0){
public void onItemSelected(final BottomBarItem bottomBarItem, int previousPosition, final int currentPosition) {
Log.i("MainActivity", "position: " + currentPosition);
if (currentPosition == 0) {
//如果是第一个,即首页
if (mBottomBarLayout.getCurrentItem() == position){
if (previousPosition == currentPosition) {
//如果是在原来位置上点击,更换首页图标并播放旋转动画
bottomBarItem.setIconSelectedResourceId(R.mipmap.tab_loading);//更换成加载图标
bottomBarItem.setStatus(true);
if (mRotateAnimation != null && !mRotateAnimation.hasEnded()){
//如果当前动画正在执行
return;
}

bottomBarItem.setSelectedIcon(R.mipmap.tab_loading);//更换成加载图标

//播放旋转动画
if (mRotateAnimation == null) {
Expand All @@ -365,18 +370,18 @@ drawable的编写如下:
mHandler.postDelayed(new Runnable() {
@Override
public void run() {
bottomBarItem.setIconSelectedResourceId(R.mipmap.tab_home_selected);//更换成首页原来图标
bottomBarItem.setStatus(true);//刷新图标
boolean tabNotChanged = mBottomBarLayout.getCurrentItem() == currentPosition; //是否还停留在当前页签
bottomBarItem.setSelectedIcon(R.mipmap.tab_home_selected);//更换成首页原来选中图标
cancelTabLoading(bottomBarItem);
}
},3000);
}, 3000);
return;
}
}

//如果点击了其他条目
BottomBarItem bottomItem = mBottomBarLayout.getBottomItem(0);
bottomItem.setIconSelectedResourceId(R.mipmap.tab_home_selected);//更换为原来的图标
bottomItem.setSelectedIcon(R.mipmap.tab_home_selected);//更换为原来的图标

cancelTabLoading(bottomItem);//停止旋转动画
}
Expand Down

0 comments on commit 883ed4d

Please sign in to comment.