2017-12-11 23 views
0

글라이드를 사용하여 이미지를로드 한 후 진행률 막대를 숨기려고합니다. 글라이드. 리스너()가 작동하지 않습니다. 아래 코드를 찾으십시오.이미지를로드 한 후 글라이드 수신기가 진행 막대를 숨기지 않습니다.

@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은 데이터 바인딩 데이터 바인딩 있지만 작동하지 않는 사용 사라지다로 가시성을 설정하기 위해 노력했다 .I 내 응용 프로그램에서 사용하고 있습니다.

<?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; } –

답변