Remove selected item bottombar (Lib Roughike)

1

I have an application that uses NavigationView and BottomBar, I'm having a hard time removing the bootloader item selection when I select a navigationView item, I'm using the Roughike Library link .

I tried to use:

// Remove item selected BottomBar *** Problem here ***
    public void rmSelectBottom() {
        bottomBar.getCurrentTab().clearFocus();
        bottomBar.getCurrentTab().setSelected(false);
    }

But I did not succeed

Complete code

@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        toolbar = (Toolbar) findViewById(R.id.toolbar);
        navigationView = (NavigationView) findViewById(R.id.nav_view);
        bottomBar = (BottomBar) findViewById(R.id.bottom_navigation_view);

        toolbar.setTitle("Title");
        setSupportActionBar(toolbar);
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);

        DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
        ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
                this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
        drawer.setDrawerListener(toggle);
        toggle.syncState();


        navigationView.setNavigationItemSelectedListener(this);

        AppBarLayout appBarLayout = (AppBarLayout) findViewById(R.id.app_bar);
        appBarLayout.setExpanded(false, true);


        appBarLayout.addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() {
            @Override
            public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {

            }
        });

//BottomBar
        bottomBar.setDefaultTabPosition(0);
        bottomBar.setOnTabSelectListener(new OnTabSelectListener() {
            @Override
            public void onTabSelected(@IdRes int tabId) {

                Fragment fragment = null;
                Class fragmentClass = null;

                rmSelectNavigation();

                switch (tabId) {
                    case R.id.tab_home:
                        fragmentClass = TabHomeFragment.class;
                        break;
                    case R.id.tab_notas:
                        fragmentClass = TabGradesFragment.class;
                        break;
                    case R.id.tab_aval:
                        fragmentClass = TabAvaliationsFragment.class;
                        break;
                    case R.id.tab_faltas:
                        fragmentClass = TabAbsencesFragment.class;
                        break;
                }

                try {
                    fragment = (Fragment) fragmentClass.newInstance();
                } catch (Exception e) {
                    e.printStackTrace();
                }
                FragmentManager fragmentManager = getSupportFragmentManager();
                fragmentManager.beginTransaction().replace(R.id.flContent, fragment).commit();

            }
        });

    }

// NavigationView
    @Override
    public boolean onNavigationItemSelected(MenuItem item) {
        // Handle navigation view item clicks here.
        int id = item.getItemId();
        Fragment fragment = null;
        Class fragmentClass = null;

        rmSelectBottom();

        if (id == R.id.nav_notification) {
            fragmentClass = NavIncidentsFragment.class;
        }
        if (id == R.id.nav_task) {
            fragmentClass = NavTasksFragment.class;
        }
        if (id == R.id.nav_content) {
            fragmentClass = NavContentFragment.class;
        }
        if (id == R.id.nav_financial) {
            fragmentClass = NavFinancialFragment.class;
        }
        if (id == R.id.nav_promotion) {
            fragmentClass = NavPromotionsFragment.class;
        }
        if (id == R.id.nav_config) {
            Intent intent = new Intent(MainActivity.this, SettingsActivity.class);
            startActivity(intent);
        }

        if (id != R.id.nav_config) {
            try {
                fragment = (Fragment) fragmentClass.newInstance();
            } catch (Exception e) {
                e.printStackTrace();
            }
            FragmentManager fragmentManager = getSupportFragmentManager();
            fragmentManager.beginTransaction().replace(R.id.flContent, fragment).commit();
        }

        DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
        drawer.closeDrawer(GravityCompat.START);
        return true;
    }

// Remove item selected NavigationView
    public void rmSelectNavigation() {
        int size = navigationView.getMenu().size();
        for (int i = 0; i < size; i++) {
            navigationView.getMenu().getItem(i).setChecked(false);
        }
    }
// Remove item selected BottomBar *** Problem here ***
    public void rmSelectBottom() {
        bottomBar.getCurrentTab().clearFocus();
        bottomBar.getCurrentTab().setSelected(false);
    }

Is there any other specific method to remove the selected item?

Here is an example image of the problem:

    
asked by anonymous 16.12.2016 / 11:18

1 answer

1

After much searching without finding a solution to the Roughike Library problem, I decided to follow the @Wakim suggestion and used the BottomNavigationView, which is in the Design Support Library 25. > When I click on a NavigationView item I call a method that traverses the BottomBarNavigationView items and a setChecked (false)

int size = bottomBar.getMenu().size();
for (int i = 0; i < size; i++) {
    bottomBar.getMenu().getItem(i).setChecked(false);
} 
    
20.12.2016 / 17:11