Skip to content

Commit

Permalink
Ashok-Varma#48 bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Ashok-Varma committed Jul 14, 2016
1 parent 9e8ba60 commit 45973aa
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,9 @@ private BottomNavigationBar setScrollable(boolean scrollable) {
* This method will take all changes in to consideration and redraws tabs.
*/
public void initialise() {
mSelectedPosition = DEFAULT_SELECTED_POSITION;
mBottomNavigationTabs.clear();

if (!mBottomNavigationItems.isEmpty()) {
mTabContainer.removeAllViews();
if (mMode == MODE_DEFAULT) {
Expand Down Expand Up @@ -567,6 +570,26 @@ private void sendListenerCall(int oldPosition, int newPosition) {
// Animating methods
///////////////////////////////////////////////////////////////////////////

/**
* show BottomNavigationBar if it is hidden and hide if it is shown
*/
public void toggle() {
toggle(true);
}

/**
* show BottomNavigationBar if it is hidden and hide if it is shown
*
* @param animate is animation enabled for toggle
*/
public void toggle(boolean animate) {
if (mIsHidden) {
show(animate);
} else {
hide(animate);
}
}

/**
* hide with animation
*/
Expand Down Expand Up @@ -614,7 +637,7 @@ private void setTranslationY(int offset, boolean animate) {

/**
* Internal Method
* <p/>
* <p>
* used to set animation and
* takes care of cancelling current animation
* and sets duration and interpolator for animation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ public class HomeActivity extends AppCompatActivity implements View.OnClickListe

int lastSelectedPosition = 0;

boolean hidden = false;

BadgeItem numberBadgeItem;

@Override
Expand Down Expand Up @@ -115,18 +113,13 @@ public boolean onOptionsItemSelected(MenuItem item) {
public void onClick(View v) {
if (v.getId() == R.id.toggle_hide) {
if (bottomNavigationBar != null) {
if (hidden) {
bottomNavigationBar.show();
} else {
bottomNavigationBar.hide();
}
hidden = !hidden;
bottomNavigationBar.toggle();
}
} else if (v.getId() == R.id.toggle_badge) {
if (numberBadgeItem != null) {
numberBadgeItem.toggle();
}
} else if (v.getId() == R.id.fab_home){
} else if (v.getId() == R.id.fab_home) {
final Snackbar snackbar = Snackbar.make(message, "Fab Clicked", Snackbar.LENGTH_LONG);
snackbar.setAction("dismiss", new View.OnClickListener() {
@Override
Expand Down Expand Up @@ -255,7 +248,7 @@ public void onTabReselected(int position) {
setMessageText(position + " Tab Reselected");
}

private void setMessageText(String messageText){
private void setMessageText(String messageText) {
message.setText(messageText);
}

Expand Down

0 comments on commit 45973aa

Please sign in to comment.