package { switch (item.getItemId()) { case R.id.navigation_camera: startActivityForResult(new

package org.fossasia.phimpme.base;import android.animation.Animator;import android.animation.AnimatorListenerAdapter;import android.content.Intent;import android.content.pm.PackageManager;import android.content.res.ColorStateList;import android.graphics.Color;import android.os.Bundle;import android.support.annotation.NonNull;import android.support.design.internal.BottomNavigationItemView;import android.support.design.widget.BottomNavigationView;import android.support.v4.content.ContextCompat;import android.support.v7.app.AppCompatActivity;import android.view.Menu;import android.view.MenuItem;import android.view.View;import org.fossasia.phimpme.R;import org.fossasia.phimpme.gallery.activities.LFMainActivity;import org.fossasia.phimpme.opencamera.Camera.CameraActivity;import uk.co.deanwild.materialshowcaseview.MaterialShowcaseSequence;import uk.co.deanwild.materialshowcaseview.MaterialShowcaseView;import uk.co.deanwild.materialshowcaseview.ShowcaseConfig;public abstract class BaseActivity extends AppCompatActivity implements BottomNavigationView.OnNavigationItemSelectedListener { protected BottomNavigationView navigationView; private static final String SHOWCASE_ID = “1”; BottomNavigationItemView nav_home; BottomNavigationItemView nav_cam; private int states = new int { new int {android.R.attr.state_checked}, // checked new int {-android.R.attr.state_checked}, // unchecked }; private int colors = new int { Color.WHITE, // checked 0 // unchecked set default in onCreate }; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(getContentViewId()); colors1 = ContextCompat.getColor(this, R.color.bottom_navigation_tabs); ColorStateList myList = new ColorStateList(states, colors); navigationView = (BottomNavigationView) findViewById(R.id.bottombar); navigationView.setItemIconTintList(myList); navigationView.setItemTextColor(myList); navigationView.setOnNavigationItemSelectedListener(this); nav_home = (BottomNavigationItemView) findViewById(R.id.navigation_home); nav_cam = (BottomNavigationItemView) findViewById(R.id.navigation_camera); //presentShowcaseSequence(); // one second delay } @Override protected void onStart() { super.onStart(); updateNavigationBarState(); } // Remove inter-activity transition to avoid screen tossing on tapping bottom navigation items @Override public void onPause() { super.onPause(); overridePendingTransition(0, 0); } @Override public boolean onNavigationItemSelected(@NonNull final MenuItem item) { if (item.getItemId() != getNavigationMenuItemId()) { switch (item.getItemId()) { case R.id.navigation_camera: startActivityForResult(new Intent(this, CameraActivity.class).addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP),101); break; case R.id.navigation_home: startActivityForResult(new Intent(this, LFMainActivity.class),101); break; } } return true; } private void updateNavigationBarState() { int actionId = getNavigationMenuItemId(); selectBottomNavigationBarItem(actionId); } void selectBottomNavigationBarItem(int itemId) { Menu menu = navigationView.getMenu(); for (int i = 0, size = menu.size(); i < size; i++) { MenuItem item = menu.getItem(i); boolean shouldBeChecked = item.getItemId() == itemId; if (shouldBeChecked) { item.setChecked(true); break; } } } void setIconColor(int color){ if(Color.red(color) + Color.green(color)+ Color.blue(color) < 300) colors0 = Color.WHITE; else colors0 = Color.BLACK; } public abstract int getContentViewId(); public abstract int getNavigationMenuItemId(); public void setNavigationBarColor(int color) { navigationView.setBackgroundColor(color); setIconColor(color); } /** * Animate bottom navigation bar from GONE to VISIBLE */ public void showNavigationBar() { navigationView.animate() .translationY(0) .alpha(1.0f) .setDuration(400) .setListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animation) { super.onAnimationStart(animation); navigationView.setVisibility(View.VISIBLE); } }); } protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if(requestCode==101&&requestCode==RESULT_OK){ Intent returnIntent = new Intent(); returnIntent.putExtra("result",(data.getStringExtra("result"))); setResult(RESULT_OK,returnIntent); finish(); }} /** * Animate bottom navigation bar from VISIBLE to GONE */ public void hideNavigationBar() { navigationView.animate() .alpha(0.0f) .translationYBy(navigationView.getHeight()) .setDuration(400) .setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); navigationView.setVisibility(View.GONE); } }); }}