From 883ed4d9b42a83fd2b74477fa30a1a31ca1cf8e4 Mon Sep 17 00:00:00 2001 From: ccw Date: Mon, 21 Jan 2019 17:51:12 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0README?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index cb5d220..f90f1e5 100644 --- a/README.md +++ b/README.md @@ -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) { @@ -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);//停止旋转动画 } -- GitLab