2017-12-11 27 views
0

グライドを使用してイメージをロードした後にプログレスバーを隠そうとしていますが、Glide.listener()は動作していません。私のアプリ.Iでデータバインディングを使用してグライドリスナーがイメージをロードした後にプログレスバーを非表示にしていません

@BindingAdapter({ 
       "bind:url" 
     }) 
     public void setImage(ImageView imageView, String url) { 
      if (url != null && url.trim().length() > 0) { 
        Glide.with(imageView.getContext()).load("http://" + url) 
         .override(200, 150) 
         .listener(new RequestListener<String, GlideDrawable>() { 
          @Override 
          public boolean onException(Exception e, String model, Target<GlideDrawable> target, boolean isFirstResource) { 
           bindFamilyMembers.imagebar.setVisibility(View.GONE); 
           return false; 
          } 

          @Override 
          public boolean onResourceReady(GlideDrawable resource, String model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) { 
           bindFamilyMembers.imagebar.setVisibility(View.GONE); 
           return false; 
          } 
         }) 
         .placeholder(R.drawable.bg_theme) 
         .error(R.drawable.bg_theme) 
         .into(imageView); 
       // Picasso.with(imageView.getContext()).load("http://" + url).resize(200, 150).error(R.drawable.ic_launcher_background).into(imageView); 
      } else { 

      } 
     } 

このコードのレイアウトはbelow.Imでは、ゴーンとデータバインディングが、その動作していないを使用して可視性を設定しようとしています。

<?xml version="1.0" encoding="utf-8"?> 
<layout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    xmlns:tools="http://schemas.android.com/tools"> 

    <data> 

     <variable 
      name="familyhandler" 
      type="com.estuate.smartfoam.dashboard.model.apiuser.FamilyMembers" /> 
    </data> 

    <LinearLayout 
     android:orientation="horizontal" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content"> 

     <RelativeLayout 
      android:id="@+id/rel" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content"> 


      <com.estuate.smartfoam.util.CircularImageView 
       android:id="@+id/member_image" 
       android:layout_width="120dp" 
       android:layout_marginTop="@dimen/linear_margin_10" 
       android:layout_height="100dp" 
       app:url="@{familyhandler.image}" /> 

      <ImageView 
       android:id="@+id/border" 
       android:layout_width="120dp" 
       android:layout_height="120dp" 
       android:visibility="gone" 
       android:background="@drawable/circular_img_selected" /> 

      <TextView 
       android:id="@+id/name" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="@{familyhandler.fullname}" 
       android:textColor="@color/blackColor" 
       android:textAllCaps="true" 
       android:layout_below="@id/member_image" 
       android:textSize="@dimen/text_size_16" 
       tools:text="Name" 
       android:layout_centerHorizontal="true" /> 

      <ProgressBar 
       android:id="@+id/imagebar" 
       android:layout_width="35dp" 
       android:layout_height="35dp" 
       android:background="@xml/progress" 
       android:visibility="visible" 
       android:layout_centerInParent="true" /> 

     </RelativeLayout> 

     <ImageView 
      android:id="@+id/adding_view" 
      android:layout_width="110dp" 
      android:layout_height="100dp" 
      android:layout_marginTop="@dimen/linear_margin_15" 
      android:visibility="gone" 
      android:src="@drawable/ic_add_material" 
      android:background="@drawable/circular_add" /> 

    </LinearLayout> 
</layout> 

グライドを使用してイメージを解析しましたが、進捗バーを停止できませんでした。この問題を解決するのに役立ちます。

+0

@Override 公共ブールonResourceReady(ビットマップリソース、ストリングモデル、ターゲットターゲット、ブールisFromMemoryCache、ブールisFirstResource){ holder.progressBar.setVisibility(View.GONE)。 holder.imageView.invalidate(); //この行を追加します return false; } –

答えて

0

ImageViewが表示されていない、または表示されていない場合は、表示されるバグのようです。私はここでの問題をオープンしました:https://github.com/bumptech/glide/issues/618

関連する問題