Search in sources :

Example 1 with BottomNavigationView

use of android.support.design.widget.BottomNavigationView in project material-components-android by material-components.

the class BottomNavigationViewActions method setItemIconTintList.

/** Sets item icon tint list on the content of the bottom navigation view. */
public static ViewAction setItemIconTintList(@Nullable final ColorStateList tint) {
    return new ViewAction() {

        @Override
        public Matcher<View> getConstraints() {
            return isDisplayed();
        }

        @Override
        public String getDescription() {
            return "Set item icon tint list";
        }

        @Override
        public void perform(UiController uiController, View view) {
            uiController.loopMainThreadUntilIdle();
            BottomNavigationView navigationView = (BottomNavigationView) view;
            navigationView.setItemIconTintList(tint);
            uiController.loopMainThreadUntilIdle();
        }
    };
}
Also used : ViewAction(android.support.test.espresso.ViewAction) BottomNavigationView(android.support.design.widget.BottomNavigationView) UiController(android.support.test.espresso.UiController) BottomNavigationView(android.support.design.widget.BottomNavigationView) View(android.view.View)

Example 2 with BottomNavigationView

use of android.support.design.widget.BottomNavigationView in project NPSmiles by bmcglynn1.

the class MainActivity method onResume.

@Override
public void onResume() {
    super.onResume();
    BottomNavigationView navigation = (BottomNavigationView) findViewById(R.id.navigation);
    int id = navigation.getSelectedItemId();
    if (id == R.id.navigation_news) {
        FragmentTransaction transaction = fragmentManager.beginTransaction();
        transaction.replace(R.id.main_container, new NewsFragment(), "News").commit();
    }
    invalidateOptionsMenu();
}
Also used : FragmentTransaction(android.support.v4.app.FragmentTransaction) BottomNavigationView(android.support.design.widget.BottomNavigationView)

Example 3 with BottomNavigationView

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

the class CallsListController 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 = getParentController().getView().findViewById(R.id.navigation);
    Handler handler = new Handler();
    ViewTreeObserver vto = mSearchEditFrame.getViewTreeObserver();
    vto.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {

        int oldVisibility = -1;

        @Override
        public void onGlobalLayout() {
            int currentVisibility = mSearchEditFrame.getVisibility();
            if (currentVisibility != oldVisibility) {
                if (currentVisibility == View.VISIBLE) {
                    handler.postDelayed(() -> bottomNavigationView.setVisibility(View.GONE), 100);
                } else {
                    handler.postDelayed(() -> {
                        bottomNavigationView.setVisibility(View.VISIBLE);
                        searchItem.setVisible(callItems.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) NoOpControllerChangeHandler(com.bluelinelabs.conductor.internal.NoOpControllerChangeHandler) 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) RecyclerView(android.support.v7.widget.RecyclerView) ViewTreeObserver(android.view.ViewTreeObserver)

Example 4 with BottomNavigationView

use of android.support.design.widget.BottomNavigationView in project Carebase by robertsimoes.

the class MainActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    /**
     * Set Toolbar
     */
    Toolbar myToolbar = (Toolbar) findViewById(R.id.general_fragments_toolbar);
    setSupportActionBar(myToolbar);
    ILocalCache cache = new LocalCacheDb(this);
    String userId = cache.getUserId();
    boolean isFirstInstall = cache.isFirstInstall();
    if (isFirstInstall) {
        cache.setFirstInstall(false);
        startActivity(new Intent(this, IntroActivity.class));
    }
    /* Get Patient Info */
    src.getPatient(userId, new ValueEventListener() {

        @Override
        public void onDataChange(DataSnapshot dataSnapshot) {
            Toast.makeText(MainActivity.this, "Welcome Back!", Toast.LENGTH_SHORT).show();
            Log.d("TAG", "SUCCESS \n\n\n\n ------");
            Patient p = dataSnapshot.getValue(Patient.class);
            fragmentArgs = new Bundle();
            fragmentArgs.putSerializable(Const.BUNDLE_KEY_PATIENT, p);
            BottomNavigationView bottomNavigationView = (BottomNavigationView) findViewById(R.id.main_bottom_navigation);
            bottomNavigationView.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() {

                @Override
                public boolean onNavigationItemSelected(@NonNull MenuItem item) {
                    switch(item.getItemId()) {
                        case R.id.action_inbox:
                            invalidateOptionsMenu();
                            selectedFragment = InboxFragment.newInstance(fragmentArgs);
                            currentFragment = Frag.INBOX;
                            break;
                        case R.id.action_appointments:
                            invalidateOptionsMenu();
                            AppointmentsFragment f = AppointmentsFragment.newInstance(fragmentArgs);
                            f.setCallback(MainActivity.this);
                            selectedFragment = f;
                            currentFragment = Frag.APPOINTMENTS;
                            break;
                        case R.id.action_rx:
                            invalidateOptionsMenu();
                            selectedFragment = RxFragment.newInstance(fragmentArgs);
                            currentFragment = Frag.RX;
                            break;
                        case R.id.action_profile:
                            invalidateOptionsMenu();
                            selectedFragment = ProfileFragment.newInstance(fragmentArgs);
                            currentFragment = Frag.PROFILE_EDIT;
                            break;
                    }
                    refreshFragmentUI(selectedFragment);
                    return true;
                }
            });
        // Before the application or user has picked anything to display
        // Let's just display the inbox fragment by default so that when the app loads up
        // we pick that.
        }

        @Override
        public void onCancelled(DatabaseError databaseError) {
            Log.e("ERR", "Could not load patient snapshot" + databaseError.getDetails());
        }
    });
}
Also used : IntroActivity(com.hci.carebase.ui.activities.IntroActivity) Bundle(android.os.Bundle) Patient(com.hci.carebase.domain.Patient) ILocalCache(com.hci.carebase.data.interfaces.ILocalCache) Intent(android.content.Intent) MenuItem(android.view.MenuItem) DataSnapshot(com.google.firebase.database.DataSnapshot) LocalCacheDb(com.hci.carebase.data.datasource.LocalCacheDb) DatabaseError(com.google.firebase.database.DatabaseError) BottomNavigationView(android.support.design.widget.BottomNavigationView) NonNull(android.support.annotation.NonNull) AppointmentsFragment(com.hci.carebase.ui.fragments.AppointmentsFragment) ValueEventListener(com.google.firebase.database.ValueEventListener) Toolbar(android.support.v7.widget.Toolbar)

Example 5 with BottomNavigationView

use of android.support.design.widget.BottomNavigationView in project Devsfolio by Madonahs.

the class MainActivity method onCreate.

/**
 * Theme can only be changed before setContentView is called.
 * Therefore, I am changing the theme on here.
 * store data
 * @param savedInstanceState
 */
@Override
protected void onCreate(Bundle savedInstanceState) {
    sharedPref = new SharedPref(this);
    if (sharedPref.loadNightModeState()) {
        setTheme(R.style.DarkTheme);
    } else {
        setTheme(R.style.AppTheme);
    }
    prev_State = sharedPref.loadNightModeState();
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    ButterKnife.bind(this);
    // This method will save the theme and initiates the preferenceChange listener
    setCorrectTheme();
    // Get all user information views from the drawer header view
    View drawerHeaderView = navView.getHeaderView(0);
    profilePicView = drawerHeaderView.findViewById(R.id.drawer_header_user_image);
    userName = drawerHeaderView.findViewById(R.id.drawer_header_user_name);
    userProfession = drawerHeaderView.findViewById(R.id.drawer_header_user_profession);
    // Set action bar, navigation drawer, navigation drawer header
    setSupportActionBar(toolbar);
    setupNavDrawer();
    setDrawerHeader();
    fragment = getSupportFragmentManager().findFragmentByTag(TAG);
    if (fragment == null) {
        fragment = new FeedsFragment();
    }
    BottomNavigationView navigation = findViewById(R.id.navigation);
    BottomNavigationViewHelper.disableShiftMode(navigation);
    navigation.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener);
    FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
    transaction.replace(R.id.content, fragment, TAG);
    transaction.commit();
    /*TODO: Get user data from intent or load from DB if intent is null*/
    Bundle data = getIntent().getBundleExtra(Constant.USER);
    if (data != null)
        user = User.build(data);
    else
        // TODO: load from DB
        user = new User("this guy", "thisguy@devs.com", "000000");
}
Also used : FragmentTransaction(android.support.v4.app.FragmentTransaction) User(com.madonasyombua.growwithgoogleteamproject.models.User) BottomNavigationView(android.support.design.widget.BottomNavigationView) Bundle(android.os.Bundle) FeedsFragment(com.madonasyombua.growwithgoogleteamproject.ui.fragment.FeedsFragment) SharedPref(com.madonasyombua.growwithgoogleteamproject.ui.SharedPref) NavigationView(android.support.design.widget.NavigationView) CircleImageView(de.hdodenhof.circleimageview.CircleImageView) BindView(butterknife.BindView) View(android.view.View) AdapterView(android.widget.AdapterView) BottomNavigationView(android.support.design.widget.BottomNavigationView) TextView(android.widget.TextView)

Aggregations

BottomNavigationView (android.support.design.widget.BottomNavigationView)24 View (android.view.View)8 FragmentTransaction (android.support.v4.app.FragmentTransaction)5 MenuItem (android.view.MenuItem)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