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();
}
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();
}
}
}
}
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;
}
}
});
}
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();
}
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;
}
});
}
}
Aggregations