Search in sources :

Example 16 with BottomNavigationView

use of android.support.design.widget.BottomNavigationView in project mytarget-android by myTargetSDK.

the class NativeAdActivity method onCreate.

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_native_ads);
    toolbar = findViewById(R.id.toolbar);
    topContainer = findViewById(R.id.top_container);
    setSupportActionBar(toolbar);
    if (getSupportActionBar() != null) {
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        getSupportActionBar().setDisplayShowHomeEnabled(true);
    }
    bottomNavigationView = findViewById(R.id.bottom_navigation);
    if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
        hideBottomView();
    }
    bottomNavigationView.setOnNavigationItemSelectedListener(this);
    ArrayList<View> touchables = bottomNavigationView.getTouchables();
    for (int i = 0; i < touchables.size(); i++) {
        View view = touchables.get(i);
        view.setContentDescription("Bottom_" + i);
    }
    fragmentManager = getSupportFragmentManager();
    FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
    NativeAdFragment nativeAdFragment = NativeAdFragment.newInstance(slotId, R.id.action_native_static);
    fragmentTransaction.add(R.id.fragment_container, nativeAdFragment);
    fragmentTransaction.commit();
}
Also used : FragmentTransaction(android.support.v4.app.FragmentTransaction) NativeAdFragment(com.my.targetDemoApp.fragments.NativeAdFragment) BottomNavigationView(android.support.design.widget.BottomNavigationView) View(android.view.View)

Example 17 with BottomNavigationView

use of android.support.design.widget.BottomNavigationView in project openScale by oliexdev.

the class MainActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    prefs = PreferenceManager.getDefaultSharedPreferences(this);
    prefs.registerOnSharedPreferenceChangeListener(this);
    CaocConfig.Builder.create().trackActivities(true).apply();
    setContentView(R.layout.activity_main);
    // Set a Toolbar to replace the ActionBar.
    toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayShowHomeEnabled(true);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    // Find our drawer view
    drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    // Find our drawer view
    navDrawer = (NavigationView) findViewById(R.id.navigation_view);
    navBottomDrawer = (BottomNavigationView) findViewById(R.id.navigation_bottom_view);
    navBottomDrawer.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() {

        @Override
        public boolean onNavigationItemSelected(@NonNull MenuItem item) {
            selectDrawerItem(item.getItemId());
            return true;
        }
    });
    disableShiftMode(navBottomDrawer);
    // Create Drawer Toggle
    drawerToggle = new ActionBarDrawerToggle(this, drawerLayout, R.string.open_drawer, R.string.close_drawer) {

        @Override
        public void onDrawerOpened(View drawerView) {
            super.onDrawerOpened(drawerView);
        }

        @Override
        public void onDrawerClosed(View drawerView) {
            super.onDrawerClosed(drawerView);
        }
    };
    drawerLayout.addDrawerListener(drawerToggle);
    // Setup drawer view
    setupDrawerContent(navDrawer);
    selectDrawerItem(prefs.getInt("lastFragmentId", R.id.nav_overview));
    navBottomDrawer.setSelectedItemId(prefs.getInt("lastFragmentId", R.id.nav_overview));
    if (prefs.getBoolean("firstStart", true)) {
        Intent intent = new Intent(this, UserSettingsActivity.class);
        intent.putExtra(UserSettingsActivity.EXTRA_MODE, UserSettingsActivity.ADD_USER_REQUEST);
        startActivity(intent);
        prefs.edit().putBoolean("firstStart", false).commit();
    }
    if (!valueOfCountModified) {
        int launchCount = prefs.getInt("launchCount", 0);
        if (prefs.edit().putInt("launchCount", ++launchCount).commit()) {
            valueOfCountModified = true;
            // ask the user once for feedback on the 30th app launch
            if (launchCount == 30) {
                AlertDialog.Builder builder = new AlertDialog.Builder(this);
                builder.setMessage(R.string.label_feedback_message_enjoying).setPositiveButton(R.string.label_feedback_message_yes, new DialogInterface.OnClickListener() {

                    public void onClick(DialogInterface dialog, int id) {
                        dialog.dismiss();
                        positiveFeedbackDialog();
                    }
                }).setNegativeButton(R.string.label_feedback_message_no, new DialogInterface.OnClickListener() {

                    public void onClick(DialogInterface dialog, int id) {
                        dialog.dismiss();
                        negativeFeedbackDialog();
                    }
                });
                AlertDialog dialog = builder.create();
                dialog.show();
            }
        }
    }
}
Also used : AlertDialog(android.app.AlertDialog) DialogInterface(android.content.DialogInterface) ActionBarDrawerToggle(android.support.v7.app.ActionBarDrawerToggle) MenuItem(android.view.MenuItem) Intent(android.content.Intent) NavigationView(android.support.design.widget.NavigationView) View(android.view.View) BottomNavigationMenuView(android.support.design.internal.BottomNavigationMenuView) BottomNavigationItemView(android.support.design.internal.BottomNavigationItemView) BottomNavigationView(android.support.design.widget.BottomNavigationView) SuppressLint(android.annotation.SuppressLint) BottomNavigationView(android.support.design.widget.BottomNavigationView)

Example 18 with BottomNavigationView

use of android.support.design.widget.BottomNavigationView in project talk-android by nextcloud.

the class ContactsController method initSearchView.

private void initSearchView() {
    if (getActivity() != null) {
        SearchManager searchManager = (SearchManager) getActivity().getSystemService(Context.SEARCH_SERVICE);
        if (searchItem != null) {
            searchView = (SearchView) MenuItemCompat.getActionView(searchItem);
            searchView.setMaxWidth(Integer.MAX_VALUE);
            searchView.setInputType(InputType.TYPE_TEXT_VARIATION_FILTER);
            searchView.setImeOptions(EditorInfo.IME_ACTION_DONE | EditorInfo.IME_FLAG_NO_FULLSCREEN);
            searchView.setQueryHint(getResources().getString(R.string.nc_search));
            if (searchManager != null) {
                searchView.setSearchableInfo(searchManager.getSearchableInfo(getActivity().getComponentName()));
            }
            searchView.setOnQueryTextListener(this);
        }
    }
    final View mSearchEditFrame = searchView.findViewById(android.support.v7.appcompat.R.id.search_edit_frame);
    BottomNavigationView bottomNavigationView = null;
    if (getParentController() != null && getParentController().getView() != null) {
        bottomNavigationView = getParentController().getView().findViewById(R.id.navigation);
    }
    Handler handler = new Handler();
    ViewTreeObserver vto = mSearchEditFrame.getViewTreeObserver();
    BottomNavigationView finalBottomNavigationView = bottomNavigationView;
    vto.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {

        int oldVisibility = -1;

        @Override
        public void onGlobalLayout() {
            int currentVisibility = mSearchEditFrame.getVisibility();
            if (currentVisibility != oldVisibility) {
                if (currentVisibility == View.VISIBLE) {
                    if (finalBottomNavigationView != null) {
                        handler.postDelayed(() -> finalBottomNavigationView.setVisibility(View.GONE), 100);
                    }
                } else {
                    handler.postDelayed(() -> {
                        if (finalBottomNavigationView != null) {
                            finalBottomNavigationView.setVisibility(View.VISIBLE);
                        }
                        searchItem.setVisible(contactItems.size() > 0);
                    }, 500);
                }
                oldVisibility = currentVisibility;
            }
        }
    });
}
Also used : SearchManager(android.app.SearchManager) BottomNavigationView(android.support.design.widget.BottomNavigationView) Handler(android.os.Handler) VerticalChangeHandler(com.bluelinelabs.conductor.changehandler.VerticalChangeHandler) HorizontalChangeHandler(com.bluelinelabs.conductor.changehandler.HorizontalChangeHandler) SearchView(android.support.v7.widget.SearchView) BindView(butterknife.BindView) View(android.view.View) BottomNavigationView(android.support.design.widget.BottomNavigationView) FlipView(eu.davidea.flipview.FlipView) RecyclerView(android.support.v7.widget.RecyclerView) ViewTreeObserver(android.view.ViewTreeObserver)

Example 19 with BottomNavigationView

use of android.support.design.widget.BottomNavigationView in project Bro by 2BAB.

the class HomeActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_home);
    BottomNavigationView bottomNavigationView = (BottomNavigationView) findViewById(R.id.home_bottom_navigation);
    bottomNavigationView.inflateMenu(R.menu.navi_menu);
    bottomNavigationView.setItemBackgroundResource(R.color.bottom_bar_bg);
    bottomNavigationView.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() {

        @Override
        public boolean onNavigationItemSelected(@NonNull MenuItem item) {
            int id = item.getItemId();
            if (id == R.id.action_home) {
                getFragmentManager().beginTransaction().replace(R.id.home_fragment_container, homeFragment).commitAllowingStateLoss();
            } else if (id == R.id.action_mine) {
                getFragmentManager().beginTransaction().replace(R.id.home_fragment_container, (Fragment) mineFragment).commitAllowingStateLoss();
                mineFragment.updateCount();
            }
            return true;
        }
    });
    homeFragment = HomeFragment.newInstance(null);
    mineFragment = Bro.getApi(ISettingsApi.class).getMineFragment();
    getFragmentManager().beginTransaction().replace(R.id.home_fragment_container, homeFragment).commitAllowingStateLoss();
}
Also used : BottomNavigationView(android.support.design.widget.BottomNavigationView) MenuItem(android.view.MenuItem) Fragment(android.app.Fragment)

Example 20 with BottomNavigationView

use of android.support.design.widget.BottomNavigationView in project Eye by tommyolsson.

the class MainActivity method setupNavigationView.

/* Bottom Navigation bar and fragments  */
private void setupNavigationView() {
    BottomNavigationView bottomNavigationView = findViewById(R.id.bottom_navigation);
    if (bottomNavigationView != null) {
        // Select first menu item by default and show Fragment accordingly.
        Menu menu = bottomNavigationView.getMenu();
        selectFragment(menu.getItem(0));
        // Set action to perform when any menu-item is selected.
        bottomNavigationView.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() {

            @Override
            public boolean onNavigationItemSelected(@NonNull MenuItem item) {
                selectFragment(item);
                return false;
            }
        });
    }
}
Also used : BottomNavigationView(android.support.design.widget.BottomNavigationView) MenuItem(android.view.MenuItem) Menu(android.view.Menu)

Aggregations

BottomNavigationView (android.support.design.widget.BottomNavigationView)24 View (android.view.View)8 MenuItem (android.view.MenuItem)6 FragmentTransaction (android.support.v4.app.FragmentTransaction)5 Bundle (android.os.Bundle)4 NavigationView (android.support.design.widget.NavigationView)3 UiController (android.support.test.espresso.UiController)3 ViewAction (android.support.test.espresso.ViewAction)3 BindView (butterknife.BindView)3 SearchManager (android.app.SearchManager)2 Intent (android.content.Intent)2 Handler (android.os.Handler)2 Fragment (android.support.v4.app.Fragment)2 ActionBarDrawerToggle (android.support.v7.app.ActionBarDrawerToggle)2 RecyclerView (android.support.v7.widget.RecyclerView)2 SearchView (android.support.v7.widget.SearchView)2 Toolbar (android.support.v7.widget.Toolbar)2 Menu (android.view.Menu)2 ViewTreeObserver (android.view.ViewTreeObserver)2 TextView (android.widget.TextView)2