use of com.owncloud.android.utils.svg.MenuSimpleTarget in project android by nextcloud.
the class DrawerActivity method updateExternalLinksInDrawer.
private void updateExternalLinksInDrawer() {
if (mNavigationView != null && getBaseContext().getResources().getBoolean(R.bool.show_external_links)) {
mNavigationView.getMenu().removeGroup(R.id.drawer_menu_external_links);
float density = getResources().getDisplayMetrics().density;
final int size = Math.round(24 * density);
int greyColor = ContextCompat.getColor(this, R.color.drawer_menu_icon);
for (final ExternalLink link : externalLinksProvider.getExternalLink(ExternalLinkType.LINK)) {
int id = mNavigationView.getMenu().add(R.id.drawer_menu_external_links, MENU_ITEM_EXTERNAL_LINK + link.getId(), MENU_ORDER_EXTERNAL_LINKS, link.getName()).setCheckable(true).getItemId();
MenuSimpleTarget target = new MenuSimpleTarget<Drawable>(id) {
@Override
public void onResourceReady(Drawable resource, GlideAnimation glideAnimation) {
setExternalLinkIcon(getIdMenuItem(), resource, greyColor);
}
@Override
public void onLoadFailed(Exception e, Drawable errorDrawable) {
super.onLoadFailed(e, errorDrawable);
setExternalLinkIcon(getIdMenuItem(), errorDrawable, greyColor);
}
};
DisplayUtils.downloadIcon(getUserAccountManager(), clientFactory, this, link.getIconUrl(), target, R.drawable.ic_link, size, size);
}
setDrawerMenuItemChecked(mCheckedMenuItem);
}
}
Aggregations