Search in sources :

Example 1 with MenuSimpleTarget

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);
    }
}
Also used : MenuSimpleTarget(com.owncloud.android.utils.svg.MenuSimpleTarget) ColorDrawable(android.graphics.drawable.ColorDrawable) Drawable(android.graphics.drawable.Drawable) LayerDrawable(android.graphics.drawable.LayerDrawable) BitmapDrawable(android.graphics.drawable.BitmapDrawable) GlideAnimation(com.bumptech.glide.request.animation.GlideAnimation) ExternalLink(com.owncloud.android.lib.common.ExternalLink) AuthenticatorException(android.accounts.AuthenticatorException) OperationCanceledException(android.accounts.OperationCanceledException) IOException(java.io.IOException)

Aggregations

AuthenticatorException (android.accounts.AuthenticatorException)1 OperationCanceledException (android.accounts.OperationCanceledException)1 BitmapDrawable (android.graphics.drawable.BitmapDrawable)1 ColorDrawable (android.graphics.drawable.ColorDrawable)1 Drawable (android.graphics.drawable.Drawable)1 LayerDrawable (android.graphics.drawable.LayerDrawable)1 GlideAnimation (com.bumptech.glide.request.animation.GlideAnimation)1 ExternalLink (com.owncloud.android.lib.common.ExternalLink)1 MenuSimpleTarget (com.owncloud.android.utils.svg.MenuSimpleTarget)1 IOException (java.io.IOException)1