use of org.wordpress.android.ui.main.SitePickerAdapter.SiteList in project WordPress-Android by wordpress-mobile.
the class SitePickerActivity method saveHiddenSites.
private void saveHiddenSites(Set<SiteRecord> changeSet) {
boolean skippedCurrentSite = false;
String currentSiteName = null;
SiteList hiddenSites = getAdapter().getHiddenSites();
List<SiteModel> siteList = new ArrayList<>();
for (SiteRecord siteRecord : changeSet) {
SiteModel siteModel = mSiteStore.getSiteByLocalId(siteRecord.localId);
if (hiddenSites.contains(siteRecord)) {
if (siteRecord.localId == mCurrentLocalId) {
skippedCurrentSite = true;
currentSiteName = siteRecord.getBlogNameOrHomeURL();
continue;
}
siteModel.setIsVisible(false);
// Remove stats data for hidden sites
StatsTable.deleteStatsForBlog(this, siteRecord.localId);
} else {
siteModel.setIsVisible(true);
}
// Save the site
mDispatcher.dispatch(SiteActionBuilder.newUpdateSiteAction(siteModel));
siteList.add(siteModel);
}
updateVisibilityOfSitesOnRemote(siteList);
// let user know the current site wasn't hidden
if (skippedCurrentSite) {
String cantHideCurrentSite = getString(R.string.site_picker_cant_hide_current_site);
ToastUtils.showToast(this, String.format(cantHideCurrentSite, currentSiteName), ToastUtils.Duration.LONG);
}
}
Aggregations