【问题标题】:how can i dismiss the progress bar dialog after image is loaded into the imageview from firebase storage with glide使用滑翔将图像从firebase存储加载到imageview后,我如何关闭进度条对话框
【发布时间】:2018-06-06 12:31:30
【问题描述】:

将图像加载到 imageview 进度条后也可见,它不会关闭

   StorageReference gsReference = FirebaseStorage.getInstance().getReferenceFromUrl("gs://project-b2310.appspot.com/computer/cm_fifth/cg_winter_15.1.jpg");
        StorageReference gsReference1 = FirebaseStorage.getInstance().getReferenceFromUrl("gs://project-b2310.appspot.com/computer/cm_fifth/cg_winter_15.2.jpg");
        final ProgressDialog pd = new ProgressDialog(this);
        pd.setTitle("Loading");
        pd.show();
        Glide.with(paper_loader.this).using(new FirebaseImageLoader()).load(gsReference).into(img);
        Glide.with(paper_loader.this).using(new FirebaseImageLoader()).load(gsReference1).into(img1);
        if (img.getDrawable() != null) {
            pd.dismiss();
        }
        if (img1.getDrawable() != null) {
            pd.dismiss();
        }

【问题讨论】:

    标签: android firebase firebase-storage android-glide


    【解决方案1】:

    这个问题可以通过一点代码来解决:

    pd.show();
    Glide.with(getActivity())
         .load(args.getString(IMAGE_TO_SHOW))
         .listener(new RequestListener<String, GlideDrawable>() {
             @Override
             public boolean onException(Exception e, String model, Target<GlideDrawable> target, boolean isFirstResource) {
                 return false;
             }
    
             @Override
             public boolean onResourceReady(GlideDrawable resource, String model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) {
                 pd.dismiss();
                 return false;
             }
         })
         .into(imageFrame)
    ;

    会像魅力一样工作,干杯...

    ps:抱歉在sn-p发帖

    【讨论】:

    • 你可以使用dismiss()和show()方法来代替setVisibilty(GONE)或者setVisibilty(VISIBLE),因为这个答案只是为了给你展示监听加载的listenener整理... |给定方法不显示的原因是这些方法只能设置为 Views,但是对于 Progressdialog,这些方法的等价物是不同的。
    猜你喜欢
    • 1970-01-01
    • 2016-05-31
    • 1970-01-01
    • 2020-05-10
    • 1970-01-01
    • 1970-01-01
    • 2018-11-05
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多