Source:
<code>public boolean onOptionsItemSelected(MenuItem item) { int id = item.getItemId(); switch (id) { case R.id.actionSettings: Intent i = new Intent(this, SettingsActivity.class); startActivity(i); return true; case R.id.actionSearchLocal: return true; case R.id.actionLogout: this.showLogoutDialog(); return true; case R.id.syncbutton: boolean syncState = OpenMRS.getInstance().getSyncState(); if (syncState) { OpenMRS.getInstance().setSyncState(false); setSyncButtonState(false); showNoInternetConnectionSnackbar(); ToastUtil.showShortToast(getApplicationContext(), ToastUtil.ToastType.NOTICE, R.string.disconn_server); } else if (NetworkUtils.hasNetwork()) { OpenMRS.getInstance().setSyncState(true); setSyncButtonState(true); Intent intent = new Intent("org.openmrs.mobile.intent.action.SYNC_PATIENTS"); getApplicationContext().sendBroadcast(intent); ToastUtil.showShortToast(getApplicationContext(), ToastUtil.ToastType.NOTICE, R.string.reconn_server); if (PatientDetailsFragment.snackbar != null) { <START> PatientDetailsFragment.snackbar.dismiss(); <END> showInternetConnectionSnackbar(); } if (snackbar != null) { snackbar.dismiss(); showInternetConnectionSnackbar(); } } else { showNoInternetConnectionSnackbar(); } return true; case R.id.actionLocation: if (!locationList.isEmpty()) { locationList.clear(); } Observable<List<Location>> observableList = new LocationDAO().getLocations(); observableList.subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(getLocationList()); return true; default: return super.onOptionsItemSelected(item); } }</code><technical_language>@Abdelaty remove this - this is a functionality of internet connection snackbar. create another if statement it</technical_language>

Target:
public boolean onOptionsItemSelected(MenuItem item) { int id = item.getItemId(); switch (id) { case R.id.actionSettings: Intent i = new Intent(this, SettingsActivity.class); startActivity(i); return true; case R.id.actionSearchLocal: return true; case R.id.actionLogout: this.showLogoutDialog(); return true; case R.id.syncbutton: boolean syncState = OpenMRS.getInstance().getSyncState(); if (syncState) { OpenMRS.getInstance().setSyncState(false); setSyncButtonState(false); showNoInternetConnectionSnackbar(); ToastUtil.showShortToast(getApplicationContext(), ToastUtil.ToastType.NOTICE, R.string.disconn_server); } else if (NetworkUtils.hasNetwork()) { OpenMRS.getInstance().setSyncState(true); setSyncButtonState(true); Intent intent = new Intent("org.openmrs.mobile.intent.action.SYNC_PATIENTS"); getApplicationContext().sendBroadcast(intent); ToastUtil.showShortToast(getApplicationContext(), ToastUtil.ToastType.NOTICE, R.string.reconn_server); if (PatientDetailsFragment.snackbar != null) { PatientDetailsFragment.snackbar.dismiss(); } if (snackbar != null) { snackbar.dismiss(); showConnectedToInternetSnackbar(); } } else { showNoInternetConnectionSnackbar(); } return true; case R.id.actionLocation: if (!locationList.isEmpty()) { locationList.clear(); } Observable<List<Location>> observableList = new LocationDAO().getLocations(); observableList.subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(getLocationList()); return true; default: return super.onOptionsItemSelected(item); } }