Search in sources :

Example 21 with ImageLoadingListener

use of com.nostra13.universalimageloader.core.listener.ImageLoadingListener in project LibreraReader by foobnix.

the class BrowserAdapter method getView.

@Override
public View getView(int i, View convertView, ViewGroup viewGroup) {
    View browserItem = convertView = null;
    if (convertView != null && ((Boolean) convertView.getTag()) != AppState.get().isBrowseGrid) {
        convertView = null;
    }
    if (convertView == null) {
        if (AppState.get().isBrowseGrid) {
            browserItem = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.browse_item_grid, viewGroup, false);
        } else {
            browserItem = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.browse_item_list, viewGroup, false);
        }
        browserItem.setTag(AppState.get().isBrowseGrid);
    }
    final ImageView imageView = (ImageView) browserItem.findViewById(R.id.browserItemIcon);
    final ImageView starIcon = (ImageView) browserItem.findViewById(R.id.starIcon);
    final FileMeta file = files.get(i);
    final TextView title1 = (TextView) browserItem.findViewById(R.id.title1);
    final TextView title2 = (TextView) browserItem.findViewById(R.id.title2);
    title1.setText(file.getPathTxt());
    View progresLayout = browserItem.findViewById(R.id.progresLayout);
    if (progresLayout != null) {
        progresLayout.setVisibility(View.GONE);
    }
    View delete = browserItem.findViewById(R.id.delete);
    if (delete != null) {
        delete.setVisibility(View.GONE);
    }
    final TextView extFile = (TextView) browserItem.findViewById(R.id.browserExt);
    final ImageView itemMenu = (ImageView) browserItem.findViewById(R.id.itemMenu);
    TintUtil.setTintImageWithAlpha(itemMenu);
    final View infoLayout = browserItem.findViewById(R.id.infoLayout);
    final TextView textPath = (TextView) browserItem.findViewById(R.id.browserPath);
    imageView.setColorFilter(null);
    if (file.getPath().equals(currentDirectory.getParent())) {
        imageView.setImageResource(R.drawable.glyphicons_217_circle_arrow_left);
        TintUtil.setTintImageWithAlpha(imageView);
        imageView.setBackgroundColor(Color.TRANSPARENT);
        title1.setText(file.getPath());
        title1.setSingleLine();
        infoLayout.setVisibility(View.GONE);
        itemMenu.setVisibility(View.GONE);
        extFile.setVisibility(View.GONE);
        title2.setVisibility(View.GONE);
        textPath.setVisibility(View.GONE);
        imageView.setScaleType(ScaleType.CENTER_INSIDE);
        starIcon.setVisibility(View.GONE);
        imageView.getLayoutParams().width = AppState.get().isBrowseGrid ? Dips.dpToPx(AppState.get().coverBigSize) : Dips.dpToPx(35);
        imageView.getLayoutParams().height = AppState.get().isBrowseGrid ? Dips.dpToPx((int) (AppState.get().coverBigSize * 1.5)) : Dips.dpToPx(35);
        imageView.setLayoutParams(imageView.getLayoutParams());
    } else if (new File(file.getPath()).isDirectory()) {
        imageView.getLayoutParams().width = AppState.get().isBrowseGrid ? Dips.dpToPx(AppState.get().coverBigSize) : Dips.dpToPx(35);
        imageView.getLayoutParams().height = AppState.get().isBrowseGrid ? Dips.dpToPx((int) (AppState.get().coverBigSize * 1.5)) : Dips.dpToPx(35);
        imageView.setLayoutParams(imageView.getLayoutParams());
        title1.setSingleLine();
        imageView.setImageResource(R.drawable.glyphicons_441_folder_closed);
        TintUtil.setTintImageWithAlpha(imageView);
        imageView.setBackgroundColor(Color.TRANSPARENT);
        infoLayout.setVisibility(View.GONE);
        itemMenu.setVisibility(View.GONE);
        extFile.setVisibility(View.GONE);
        title2.setVisibility(View.GONE);
        textPath.setVisibility(View.GONE);
        imageView.setScaleType(ScaleType.CENTER_INSIDE);
        starIcon.setVisibility(View.GONE);
    } else {
        imageView.setBackgroundColor(Color.TRANSPARENT);
        if (AppState.get().isBrowseGrid) {
            IMG.updateImageSizeBig(imageView);
            IMG.updateImageSizeBig((View) imageView.getParent());
        } else {
            IMG.updateImageSizeSmall(imageView);
            IMG.updateImageSizeSmall((View) imageView.getParent());
        }
        if (AppState.get().isCropBookCovers) {
            imageView.setScaleType(ScaleType.CENTER_CROP);
        } else {
            imageView.setScaleType(ScaleType.FIT_CENTER);
        }
        starIcon.setVisibility(View.VISIBLE);
        if (AppState.get().isBrowseGrid) {
            title2.setVisibility(View.GONE);
            textPath.setVisibility(View.GONE);
        } else {
            title2.setVisibility(View.VISIBLE);
            textPath.setVisibility(View.VISIBLE);
        }
        FileMeta info = null;
        if (info != null) {
            title1.setText("" + info.getTitle());
            title2.setText("" + info.getAuthor());
        }
        if (!AppState.get().isBrowseGrid && AppState.get().coverSmallSize >= IMG.TWO_LINE_COVER_SIZE) {
            title1.setSingleLine(false);
            title1.setLines(2);
        } else {
            title1.setSingleLine(true);
            title1.setLines(1);
        }
        IMG.getCoverPageWithEffect(imageView, file.getPath(), IMG.getImageSize(), new ImageLoadingListener() {

            @Override
            public void onLoadingStarted(String arg0, View arg1) {
            // TODO Auto-generated method stub
            }

            @Override
            public void onLoadingFailed(String arg0, View arg1, FailReason arg2) {
            // TODO Auto-generated method stub
            }

            @Override
            public void onLoadingComplete(String arg0, View arg1, Bitmap arg2) {
                // MetaCache.get().getByPath(file.getPath());
                FileMeta info = null;
                if (info != null) {
                    title1.setText("" + info.getTitle());
                    title2.setText("" + info.getAuthor());
                    textPath.setText(info.getPathTxt());
                    extFile.setText(info.getExt());
                    StarsWrapper.addStars(starIcon, info);
                }
            }

            @Override
            public void onLoadingCancelled(String arg0, View arg1) {
            // TODO Auto-generated method stub
            }
        });
        textPath.setText(file.getPathTxt());
        infoLayout.setVisibility(View.VISIBLE);
        itemMenu.setVisibility(View.VISIBLE);
        extFile.setVisibility(View.VISIBLE);
        final TextView textSize = (TextView) browserItem.findViewById(R.id.browserSize);
        final TextView textDate = (TextView) browserItem.findViewById(R.id.browseDate);
        View menuIcon = browserItem.findViewById(R.id.itemMenu);
        menuIcon.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                if (onMenuPressed != null) {
                // onMenuPressed.onResult(file.getFile());
                }
            }
        });
        extFile.setText(file.getExt());
        textSize.setText(file.getSizeTxt());
        textDate.setText(file.getDateTxt());
    }
    return browserItem;
}
Also used : Bitmap(android.graphics.Bitmap) ImageLoadingListener(com.nostra13.universalimageloader.core.listener.ImageLoadingListener) OnClickListener(android.view.View.OnClickListener) TextView(android.widget.TextView) ImageView(android.widget.ImageView) FailReason(com.nostra13.universalimageloader.core.assist.FailReason) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) File(java.io.File) FileMeta(com.foobnix.dao2.FileMeta)

Example 22 with ImageLoadingListener

use of com.nostra13.universalimageloader.core.listener.ImageLoadingListener in project SmartMesh_Android by SmartMeshFoundation.

the class ScanPicAdapter method instantiateItem.

@Override
public View instantiateItem(ViewGroup container, final int position) {
    FrameLayout imageLayout = (FrameLayout) View.inflate(context, R.layout.item_photo_image, null);
    final PhotoView photoView = new PhotoView(context, btPhoto);
    ViewGroup.LayoutParams lp = new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
    imageLayout.addView(photoView, lp);
    final ProgressBar spinner = (ProgressBar) imageLayout.findViewById(R.id.loading);
    btPhoto.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            if (isOurSelf && stcb != null) {
                isShowTitle = !isShowTitle;
                stcb.showTitleCallBack(String.valueOf(getCount()), isShowTitle);
            } else {
                // close
                if (fcb != null) {
                    fcb.finishCallBack();
                }
            }
        }
    });
    photoView.setOnLongClickListener(new OnLongClickListener() {

        @Override
        public boolean onLongClick(View arg0) {
            final String oldPath = NextApplication.mImageLoader.getDiscCache().get(imageList.get(position)).getPath();
            File oldfile = new File(oldPath);
            if (!oldfile.exists()) {
                // Picture has not been downloaded
                return true;
            }
            if (longClickCallback != null) {
                longClickCallback.onLongClickCallback(oldPath);
            }
            return true;
        }
    });
    NextApplication.displayNothing(photoView, imageList.get(position), new ImageLoadingListener() {

        @Override
        public void onLoadingStarted(String imageUri, View view) {
            spinner.setVisibility(View.VISIBLE);
        }

        @Override
        public void onLoadingFailed(String imageUri, View view, FailReason failReason) {
            spinner.setVisibility(View.GONE);
        }

        @Override
        public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
            spinner.setVisibility(View.GONE);
        }

        @Override
        public void onLoadingCancelled(String imageUri, View view) {
            spinner.setVisibility(View.GONE);
        }
    });
    container.addView(imageLayout, 0);
    return imageLayout;
}
Also used : LayoutParams(android.view.ViewGroup.LayoutParams) ImageLoadingListener(com.nostra13.universalimageloader.core.listener.ImageLoadingListener) ViewGroup(android.view.ViewGroup) FailReason(com.nostra13.universalimageloader.core.assist.FailReason) PhotoView(com.lingtuan.firefly.imagescan.PhotoView) View(android.view.View) PhotoView(com.lingtuan.firefly.imagescan.PhotoView) Bitmap(android.graphics.Bitmap) FrameLayout(android.widget.FrameLayout) OnLongClickListener(android.view.View.OnLongClickListener) OnClickListener(android.view.View.OnClickListener) LayoutParams(android.view.ViewGroup.LayoutParams) ProgressBar(android.widget.ProgressBar) File(java.io.File)

Example 23 with ImageLoadingListener

use of com.nostra13.universalimageloader.core.listener.ImageLoadingListener in project fdroidclient by f-droid.

the class NotificationHelper method getLargeIconForEntry.

private Bitmap getLargeIconForEntry(AppUpdateStatusManager.AppUpdateStatus entry) {
    final Point largeIconSize = getLargeIconSize();
    Bitmap iconLarge = null;
    if (TextUtils.isEmpty(entry.app.iconUrl)) {
        return null;
    } else if (entry.status == AppUpdateStatusManager.Status.Downloading || entry.status == AppUpdateStatusManager.Status.Installing) {
        Bitmap bitmap = Bitmap.createBitmap(largeIconSize.x, largeIconSize.y, Bitmap.Config.ARGB_8888);
        Canvas canvas = new Canvas(bitmap);
        Drawable downloadIcon = ContextCompat.getDrawable(context, R.drawable.ic_notification_download);
        if (downloadIcon != null) {
            downloadIcon.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
            downloadIcon.draw(canvas);
        }
        return bitmap;
    } else if (DiskCacheUtils.findInCache(entry.app.iconUrl, ImageLoader.getInstance().getDiskCache()) != null) {
        iconLarge = ImageLoader.getInstance().loadImageSync(entry.app.iconUrl, new ImageSize(largeIconSize.x, largeIconSize.y));
    } else {
        // Load it for later!
        ImageLoader.getInstance().loadImage(entry.app.iconUrl, new ImageSize(largeIconSize.x, largeIconSize.y), new ImageLoadingListener() {

            AppUpdateStatusManager.AppUpdateStatus entry;

            ImageLoadingListener init(AppUpdateStatusManager.AppUpdateStatus entry) {
                this.entry = entry;
                return this;
            }

            @Override
            public void onLoadingStarted(String imageUri, View view) {
            }

            @Override
            public void onLoadingFailed(String imageUri, View view, FailReason failReason) {
            }

            @Override
            public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
                // Need to check that the notification is still valid, and also that the image
                // is indeed cached now, so we won't get stuck in an endless loop.
                AppUpdateStatusManager.AppUpdateStatus oldEntry = appUpdateStatusManager.get(entry.getUniqueKey());
                if (oldEntry != null && oldEntry.app != null && oldEntry.app.iconUrl != null && DiskCacheUtils.findInCache(oldEntry.app.iconUrl, ImageLoader.getInstance().getDiskCache()) != null) {
                    // Update with new image!
                    createNotification(oldEntry);
                }
            }

            @Override
            public void onLoadingCancelled(String imageUri, View view) {
            }
        }.init(entry));
    }
    return iconLarge;
}
Also used : Bitmap(android.graphics.Bitmap) ImageLoadingListener(com.nostra13.universalimageloader.core.listener.ImageLoadingListener) ImageSize(com.nostra13.universalimageloader.core.assist.ImageSize) Canvas(android.graphics.Canvas) Drawable(android.graphics.drawable.Drawable) Point(android.graphics.Point) FailReason(com.nostra13.universalimageloader.core.assist.FailReason) View(android.view.View)

Example 24 with ImageLoadingListener

use of com.nostra13.universalimageloader.core.listener.ImageLoadingListener in project QuickAndroid by ImKarl.

the class DefaultImage method load.

/**
 * 加载图片
 * @param view 将图片显示到该控件
 * @param url
 */
@Override
public void load(final View view, String url) {
    url = checkImageUri(url);
    if (view instanceof ImageView) {
        load((ImageView) view, url);
        return;
    }
    getImageLoader().loadImage(url, new ImageLoadingListener() {

        @Override
        public void onLoadingStarted(String imageUri, View viewNull) {
            showLoading(view);
        }

        @Override
        public void onLoadingFailed(String imageUri, View viewNull, FailReason failReason) {
            showLoadfail(view);
        }

        @SuppressWarnings("deprecation")
        @Override
        public void onLoadingComplete(String imageUri, View viewNull, Bitmap loadedImage) {
            if (loadedImage == null) {
                onLoadingFailed(imageUri, viewNull, new FailReason(FailType.UNKNOWN, new NullPointerException("'bitmap' is NULL.")));
                return;
            }
            view.setBackgroundDrawable(new BitmapDrawable(view.getResources(), loadedImage));
        }

        @Override
        public void onLoadingCancelled(String imageUri, View view) {
            showLoadfail(view);
        }
    });
}
Also used : Bitmap(android.graphics.Bitmap) ImageLoadingListener(com.nostra13.universalimageloader.core.listener.ImageLoadingListener) ImageView(android.widget.ImageView) FailReason(com.nostra13.universalimageloader.core.assist.FailReason) BitmapDrawable(android.graphics.drawable.BitmapDrawable) ImageView(android.widget.ImageView) View(android.view.View)

Example 25 with ImageLoadingListener

use of com.nostra13.universalimageloader.core.listener.ImageLoadingListener in project Timber by naman14.

the class AlbumDetailFragment method setAlbumart.

private void setAlbumart() {
    ImageUtils.loadAlbumArtIntoView(album.id, albumArt, new ImageLoadingListener() {

        @Override
        public void onLoadingStarted(String imageUri, View view) {
        }

        @Override
        public void onLoadingFailed(String imageUri, View view, FailReason failReason) {
            loadFailed = true;
            MaterialDrawableBuilder builder = MaterialDrawableBuilder.with(context).setIcon(MaterialDrawableBuilder.IconValue.SHUFFLE).setColor(TimberUtils.getBlackWhiteColor(Config.accentColor(context, Helpers.getATEKey(context))));
            ATEUtils.setFabBackgroundTint(fab, Config.accentColor(context, Helpers.getATEKey(context)));
            fab.setImageDrawable(builder.build());
        }

        @Override
        public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
            try {
                new Palette.Builder(loadedImage).generate(new Palette.PaletteAsyncListener() {

                    @Override
                    public void onGenerated(Palette palette) {
                        Palette.Swatch swatch = palette.getVibrantSwatch();
                        if (swatch != null) {
                            primaryColor = swatch.getRgb();
                            collapsingToolbarLayout.setContentScrimColor(primaryColor);
                            if (getActivity() != null)
                                ATEUtils.setStatusBarColor(getActivity(), Helpers.getATEKey(getActivity()), primaryColor);
                        } else {
                            Palette.Swatch swatchMuted = palette.getMutedSwatch();
                            if (swatchMuted != null) {
                                primaryColor = swatchMuted.getRgb();
                                collapsingToolbarLayout.setContentScrimColor(primaryColor);
                                if (getActivity() != null)
                                    ATEUtils.setStatusBarColor(getActivity(), Helpers.getATEKey(getActivity()), primaryColor);
                            }
                        }
                        if (getActivity() != null) {
                            MaterialDrawableBuilder builder = MaterialDrawableBuilder.with(getActivity()).setIcon(MaterialDrawableBuilder.IconValue.SHUFFLE).setSizeDp(30);
                            if (primaryColor != -1) {
                                builder.setColor(TimberUtils.getBlackWhiteColor(primaryColor));
                                ATEUtils.setFabBackgroundTint(fab, primaryColor);
                                fab.setImageDrawable(builder.build());
                            } else {
                                if (context != null) {
                                    ATEUtils.setFabBackgroundTint(fab, Config.accentColor(context, Helpers.getATEKey(context)));
                                    builder.setColor(TimberUtils.getBlackWhiteColor(Config.accentColor(context, Helpers.getATEKey(context))));
                                    fab.setImageDrawable(builder.build());
                                }
                            }
                        }
                    }
                });
            } catch (Exception ignored) {
            }
        }

        @Override
        public void onLoadingCancelled(String imageUri, View view) {
        }
    });
}
Also used : Palette(androidx.palette.graphics.Palette) Bitmap(android.graphics.Bitmap) ImageLoadingListener(com.nostra13.universalimageloader.core.listener.ImageLoadingListener) MaterialDrawableBuilder(net.steamcrafted.materialiconlib.MaterialDrawableBuilder) FailReason(com.nostra13.universalimageloader.core.assist.FailReason) ImageView(android.widget.ImageView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) TextView(android.widget.TextView) MaterialDrawableBuilder(net.steamcrafted.materialiconlib.MaterialDrawableBuilder)

Aggregations

FailReason (com.nostra13.universalimageloader.core.assist.FailReason)30 Bitmap (android.graphics.Bitmap)29 View (android.view.View)29 ImageView (android.widget.ImageView)23 ImageLoadingListener (com.nostra13.universalimageloader.core.listener.ImageLoadingListener)22 TextView (android.widget.TextView)14 ProgressBar (android.widget.ProgressBar)8 File (java.io.File)8 Reddit (me.ccrama.redditslide.Reddit)8 LinearLayout (android.widget.LinearLayout)7 ImageLoadingListener (com.nostra13.universalimageloader.core.assist.ImageLoadingListener)7 ImageViewAware (com.nostra13.universalimageloader.core.imageaware.ImageViewAware)7 ImageLoadingProgressListener (com.nostra13.universalimageloader.core.listener.ImageLoadingProgressListener)7 Handler (android.os.Handler)5 OnClickListener (android.view.View.OnClickListener)5 IOException (java.io.IOException)5 SubmissionsView (me.ccrama.redditslide.Fragments.SubmissionsView)5 ExoVideoView (me.ccrama.redditslide.Views.ExoVideoView)5 SubsamplingScaleImageView (me.ccrama.redditslide.Views.SubsamplingScaleImageView)5 LayoutInflater (android.view.LayoutInflater)4