Fresco와 동일한 URI, 이미지 다시 로드

2683 단어
요구 사항
     DraweeView                    ,      DraweeView    。

문제, 실패할 때는 버튼이 표시되지만 버튼을 클릭하면 반응이 없습니다. 코드는 다음과 같습니다.
private void showDraweeView(PhotoDraweeView view, String url) {  
 Uri uri = Uri.parse(url);   
 if (null == uri) { return;  }  
 ControllerListener listener = new BaseControllerListener() {    

  public void onFinalImageSet(String id, ImageInfo imageInfo, Animatable animatable) {     
   super.onFinalImageSet(id, imageInfo, animatable);    
    if (imageInfo == null || mPhotoView == null) { return;  }              
    mPhotoView.update(imageInfo.getWidth(), imageInfo.getHeight());    
}      
 public void onFailure(String id, Throwable throwable) {        
    super.onFailure(id, throwable);   
     visibleButton(true);      
  }  
  };  
  DraweeController controller = Fresco.newDraweeControllerBuilder()
    .setUri(uri)          
    .setControllerListener(listener)       
    .setTapToRetryEnabled(true)        
    .build();   
  view.setController(controller); 
  GenericDraweeHierarchy hierarchy = new GenericDraweeHierarchyBuilder(mContext.getResources())            
   .setActualImageScaleType(ScalingUtils.ScaleType.FIT_CENTER)            
   .setProgressBarImage(new CustomProgressBar(mContext))       
   .build();  
    mPhotoView.setHierarchy(hierarchy);

}
수정된 코드
private void showDraweeView(PhotoDraweeView view, String url) {   
 GenericDraweeHierarchy hierarchy = new GenericDraweeHierarchyBuilder(mContext.getResources())            
     .setActualImageScaleType(ScalingUtils.ScaleType.FIT_CENTER)             
     .setProgressBarImage(new CustomProgressBar(mContext))   
     .build();
     mPhotoView.setHierarchy(hierarchy);
 Uri uri = Uri.parse(url);  
 if (null == uri) { return; } 
   ControllerListener listener = new BaseControllerListener() { 
   public void onFinalImageSet(String id, ImageInfo imageInfo, Animatable animatable) { 
       super.onFinalImageSet(id, imageInfo, animatable); 
       if (imageInfo == null || mPhotoView == null) { return; }            
       mPhotoView.update(imageInfo.getWidth(), imageInfo.getHeight());} 
   public void onFailure(String id, Throwable throwable) {
        super.onFailure(id, throwable); 
       visibleReloadView(true);
    } 
 };
DraweeController controller =  
Fresco.newDraweeControllerBuilder()    
    .setUri(uri)   
     .setControllerListener(listener)            
     .setTapToRetryEnabled(true)   
     .build(); 
view.setController(controller); 
}

사실은 setHierarchy(hierarchy)가 set Controller(controller) 뒤에서 호출되는 거예요.

좋은 웹페이지 즐겨찾기