Search in sources :

Example 11 with DrawableTransitionOptions

use of com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions in project 91Pop by DanteAndroid.

the class DownloadVideoAdapter method convert.

@Override
protected void convert(BaseViewHolder helper, UnLimit91PornItem item) {
    helper.setText(R.id.tv_91porn_item_title, item.getTitleWithDuration());
    ImageView simpleDraweeView = helper.getView(R.id.iv_91porn_item_img);
    Uri uri = Uri.parse(item.getImgUrl());
    GlideApp.with(helper.itemView).load(uri).placeholder(R.drawable.placeholder).transition(new DrawableTransitionOptions().crossFade(300)).into(simpleDraweeView);
    helper.setProgress(R.id.progressBar_download, item.getProgress());
    helper.setText(R.id.tv_download_progress, String.valueOf(item.getProgress()) + "%");
    helper.setText(R.id.tv_download_filesize, Formatter.formatFileSize(helper.itemView.getContext(), item.getSoFarBytes()).replace("MB", "") + "/ " + Formatter.formatFileSize(helper.itemView.getContext(), item.getTotalFarBytes()));
    if (item.getStatus() == FileDownloadStatus.completed) {
        helper.setText(R.id.tv_download_speed, "已完成");
        helper.setVisible(R.id.iv_download_control, false);
    } else {
        // 未下载完成,显示控制
        helper.setVisible(R.id.iv_download_control, true);
        if (FileDownloader.getImpl().isServiceConnected()) {
            helper.setImageResource(R.id.iv_download_control, R.drawable.pause_download);
            if (item.getStatus() == FileDownloadStatus.progress) {
                helper.setText(R.id.tv_download_speed, item.getSpeed() + " KB/s");
            } else if (item.getStatus() == FileDownloadStatus.paused) {
                helper.setText(R.id.tv_download_speed, "暂停中");
                helper.setImageResource(R.id.iv_download_control, R.drawable.start_download);
            } else if (item.getStatus() == FileDownloadStatus.pending) {
                helper.setText(R.id.tv_download_speed, "准备中");
            } else if (item.getStatus() == FileDownloadStatus.started) {
                helper.setText(R.id.tv_download_speed, "开始下载");
            } else if (item.getStatus() == FileDownloadStatus.connected) {
                helper.setText(R.id.tv_download_speed, "连接中");
            } else if (item.getStatus() == FileDownloadStatus.error) {
                helper.setText(R.id.tv_download_speed, "下载错误");
                helper.setImageResource(R.id.iv_download_control, R.drawable.start_download);
            } else if (item.getStatus() == FileDownloadStatus.retry) {
                helper.setText(R.id.tv_download_speed, "重试中");
            } else if (item.getStatus() == FileDownloadStatus.warn) {
                helper.setText(R.id.tv_download_speed, "警告");
                helper.setImageResource(R.id.iv_download_control, R.drawable.start_download);
            }
        } else {
            helper.setText(R.id.tv_download_speed, "暂停中");
            helper.setImageResource(R.id.iv_download_control, R.drawable.start_download);
        }
    }
    helper.addOnClickListener(R.id.iv_download_control);
    helper.addOnClickListener(R.id.right_menu_delete);
}
Also used : DrawableTransitionOptions(com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions) ImageView(android.widget.ImageView) Uri(android.net.Uri)

Example 12 with DrawableTransitionOptions

use of com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions in project 91Pop by DanteAndroid.

the class PictureAdapter method instantiateItem.

@NonNull
@Override
public View instantiateItem(@NonNull ViewGroup container, final int position) {
    View contentView = LayoutInflater.from(container.getContext()).inflate(R.layout.item_picture_adapter, container, false);
    PhotoView photoView = contentView.findViewById(R.id.photoView);
    final ProgressBar progressBar = contentView.findViewById(R.id.progressBar);
    String url = imageList.get(position);
    if (url.contains("meizitu.net")) {
        GlideApp.with(container).load(buildGlideUrl(url)).transition(new DrawableTransitionOptions().crossFade(300)).listener(new RequestListener<Drawable>() {

            @Override
            public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) {
                progressBar.setVisibility(View.GONE);
                return false;
            }

            @Override
            public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) {
                progressBar.setVisibility(View.GONE);
                return false;
            }
        }).into(photoView);
    } else {
        GlideApp.with(container).load(Uri.parse(url)).transition(new DrawableTransitionOptions().crossFade(300)).listener(new RequestListener<Drawable>() {

            @Override
            public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) {
                progressBar.setVisibility(View.GONE);
                return false;
            }

            @Override
            public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) {
                progressBar.setVisibility(View.GONE);
                return false;
            }
        }).into(photoView);
    }
    // Now just add PhotoView to ViewPager and return it
    container.addView(contentView, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
    photoView.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (onImageClickListener != null) {
                onImageClickListener.onImageClick(v, position);
            }
        }
    });
    photoView.setOnLongClickListener(new View.OnLongClickListener() {

        @Override
        public boolean onLongClick(View v) {
            if (onImageClickListener != null) {
                onImageClickListener.onImageLongClick(v, position);
            }
            return true;
        }
    });
    Logger.t(TAG).d("instantiateItem");
    return contentView;
}
Also used : RequestListener(com.bumptech.glide.request.RequestListener) Drawable(android.graphics.drawable.Drawable) TouchImageView(com.dante.custom.TouchImageView) PhotoView(com.github.chrisbanes.photoview.PhotoView) View(android.view.View) DataSource(com.bumptech.glide.load.DataSource) PhotoView(com.github.chrisbanes.photoview.PhotoView) DrawableTransitionOptions(com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions) Target(com.bumptech.glide.request.target.Target) ProgressBar(android.widget.ProgressBar) GlideException(com.bumptech.glide.load.engine.GlideException) Nullable(android.support.annotation.Nullable) NonNull(android.support.annotation.NonNull)

Aggregations

DrawableTransitionOptions (com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions)12 Uri (android.net.Uri)6 ImageView (android.widget.ImageView)5 Drawable (android.graphics.drawable.Drawable)2 View (android.view.View)2 Bitmap (android.graphics.Bitmap)1 NonNull (android.support.annotation.NonNull)1 Nullable (android.support.annotation.Nullable)1 AppCompatImageView (android.support.v7.widget.AppCompatImageView)1 StaggeredGridLayoutManager (android.support.v7.widget.StaggeredGridLayoutManager)1 LinearLayout (android.widget.LinearLayout)1 ProgressBar (android.widget.ProgressBar)1 DataSource (com.bumptech.glide.load.DataSource)1 GlideException (com.bumptech.glide.load.engine.GlideException)1 BitmapTransitionOptions (com.bumptech.glide.load.resource.bitmap.BitmapTransitionOptions)1 RequestListener (com.bumptech.glide.request.RequestListener)1 RequestOptions (com.bumptech.glide.request.RequestOptions)1 Target (com.bumptech.glide.request.target.Target)1 TouchImageView (com.dante.custom.TouchImageView)1 ExoVideoControlsMobile (com.flymegoc.exolibrary.widget.ExoVideoControlsMobile)1