Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

selectTab() only callback onTabSelected. #120

Open
treycc opened this issue Apr 29, 2017 · 3 comments
Open

selectTab() only callback onTabSelected. #120

treycc opened this issue Apr 29, 2017 · 3 comments
Assignees

Comments

@treycc
Copy link

treycc commented Apr 29, 2017

you may check these method:
1.public void selectTab(int newPosition, boolean callListener){ selectTabInternal(newPosition, false, callListener, callListener); }
2. private void selectTabInternal(int newPosition, boolean firstTab, boolean callListener, boolean forcedSelection) { ... if (callListener) { sendListenerCall(oldPosition, newPosition, forcedSelection); } }
3.private void sendListenerCall(int oldPosition, int newPosition, boolean forcedSelection) { if (mTabSelectedListener != null) { if (forcedSelection) { mTabSelectedListener.onTabSelected(newPosition); } else { if (oldPosition == newPosition) { mTabSelectedListener.onTabReselected(newPosition); } else { mTabSelectedListener.onTabSelected(newPosition); if (oldPosition != -1) { mTabSelectedListener.onTabUnselected(oldPosition); } } } } }

selectTab(xxx,true) call sendListenerCall(xxx,xxx,true), that only callback
onTabSelected
selectTab(xxx,false) cannot access sendListenerCall().only if call sendListenerCall(xx,xx,false) that callback onTabSelected, onTabUnselected, onTabReselected.

you seems to not figure out my last issues,

@treycc
Copy link
Author

treycc commented May 1, 2017

and i reccommend override onSaveInstanceState and onRestoreInstanceState to save some state like currentposition for restore from killed background

@lichtz
Copy link

lichtz commented May 12, 2017

me too

@xiaotengteng
Copy link

you may add this method in BottomNavigationBar.java
public void selectTab(int newPosition, boolean callListener, boolean forcedSelection) {
selectTabInternal(newPosition, false, callListener, forcedSelection);
}

and call this method selectTab(position,true,false);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants