Java 类com.facebook.drawee.backends.pipeline.Fresco 实例源码

项目:GitHub    文件:ImageFormatOverrideExample.java   
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
  SimpleDraweeView simpleDraweeView = (SimpleDraweeView) view.findViewById(R.id.drawee_view);

  ImageDecodeOptions imageDecodeOptionsWithCustomDecoder = new ImageDecodeOptionsBuilder()
      .setCustomImageDecoder(CUSTOM_COLOR_DECODER)
      .build();

  AbstractDraweeController controller = Fresco.newDraweeControllerBuilder()
      .setImageRequest(
          ImageRequestBuilder.newBuilderWithResourceId(R.raw.custom_color1)
              .setImageDecodeOptions(imageDecodeOptionsWithCustomDecoder)
              .build())
      .build();
  simpleDraweeView.setController(controller);
}
项目:GitHub    文件:App.java   
@Override
public void onCreate() {
    super.onCreate();
    app=this;
    getScreen(this);
    Fresco.initialize(this);
    Recovery.getInstance()
            .debug(true)
            .recoverInBackground(false)
            .recoverStack(true)
            .mainPage(MainActivity.class)
            .init(this);
    String[] urls = getResources().getStringArray(R.array.url);
    String[] tips = getResources().getStringArray(R.array.title);
    List list = Arrays.asList(urls);
    images = new ArrayList(list);
    List list1 = Arrays.asList(tips);
    titles= new ArrayList(list1);
}
项目:GitHub    文件:BoxingFrescoLoader.java   
private void init(Context context) {
    ImagePipelineConfig.Builder builder = ImagePipelineConfig.newBuilder(context)
            .setDownsampleEnabled(true);
    String cache = BoxingFileHelper.getCacheDir(context);

    if (TextUtils.isEmpty(cache)) {
        throw new IllegalStateException("the cache dir is null");
    }
    if (cache != null) {
        DiskCacheConfig diskCacheConfig = DiskCacheConfig.newBuilder(context)
                .setBaseDirectoryPath(new File(cache))
                .setBaseDirectoryName(IMAGE_PIPELINE_CACHE_DIR)
                .setMaxCacheSize(MAX_DISK_CACHE_SIZE)
                .setMaxCacheSizeOnLowDiskSpace(MAX_DISK_CACHE_LOW_SIZE)
                .setMaxCacheSizeOnVeryLowDiskSpace(MAX_DISK_CACHE_VERYLOW_SIZE)
                .build();
        builder.setMainDiskCacheConfig(diskCacheConfig);
    }
    ImagePipelineConfig config = builder.build();
    Fresco.initialize(context, config);
}
项目:react-native-udesk    文件:UdeskZoomImageActivty.java   
@Override
protected void onCreate(Bundle arg0) {
    super.onCreate(arg0);

    try {
        if (!Fresco.hasBeenInitialized()) {
            UdeskSDKManager.getInstance().init(this);
        }
        setContentView(R.layout.udesk_zoom_imageview);
        zoomImageView = (PhotoDraweeView) findViewById(R.id.udesk_zoom_imageview);
        Bundle bundle = getIntent().getExtras();
        uri = bundle.getParcelable("image_path");
        UdeskUtil.loadImage(zoomImageView, uri);
        saveIdBtn = findViewById(R.id.udesk_zoom_save);
        saveIdBtn.setOnClickListener(this);
    } catch (Exception e) {
        e.printStackTrace();
    }catch (OutOfMemoryError error){
        error.printStackTrace();
    }

}
项目:GitHub    文件:FrescoHolder.java   
@Override
protected void onBind(String uriString) {
  Uri uri = Uri.parse(uriString);
  ImageRequestBuilder imageRequestBuilder =
      ImageRequestBuilder.newBuilderWithSource(uri);
  if (UriUtil.isNetworkUri(uri)) {
    imageRequestBuilder.setProgressiveRenderingEnabled(true);
  } else {
    imageRequestBuilder.setResizeOptions(new ResizeOptions(
        mImageView.getLayoutParams().width,
        mImageView.getLayoutParams().height));
  }
  DraweeController draweeController = Fresco.newDraweeControllerBuilder()
      .setImageRequest(imageRequestBuilder.build())
      .setOldController(mImageView.getController())
      .setControllerListener(mImageView.getListener())
      .setAutoPlayAnimations(true)
      .build();
  mImageView.setController(draweeController);
}
项目:GitHub    文件:ImageFormatKeyframesFragment.java   
@RequiresApi(api = Build.VERSION_CODES.HONEYCOMB)
private void initAnimation(View view) {
  mSimpleDraweeView = (SimpleDraweeView) view.findViewById(R.id.drawee_view);
  mSimpleDraweeView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
  DraweeController controller = Fresco.newDraweeControllerBuilder()
      .setOldController(mSimpleDraweeView.getController())
      .setUri(URI_KEYFRAMES_ANIMATION)
      .setAutoPlayAnimations(true)
      .build();
  mSimpleDraweeView.setController(controller);

  final SwitchCompat switchBackground = (SwitchCompat) view.findViewById(R.id.switch_background);
  switchBackground.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
    @Override
    public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
      mSimpleDraweeView.getHierarchy().setBackgroundImage(isChecked
          ? new CheckerBoardDrawable(getResources())
          : null);
    }
  });
}
项目:androidgithub    文件:PTApplication.java   
@Override
public void onCreate() {
    super.onCreate();
    sContext = this;
    appComponent = DaggerAppComponent.builder()
            .baseComponent(baseComponent)
            .build();

    Fresco.initialize(getApplicationContext(),
            ImagePipelineFactory.imagePipelineConfig(getApplicationContext()
                    , getAppComponent().okHttpClient()
                    , getCacheDir().getAbsolutePath()));

    //ImageLoader初始化
    ImageLoaderConfiguration configuration = new ImageLoaderConfiguration.Builder(this).build();
    ImageLoader.getInstance().init(configuration);

    DBManager.init(this);
    if (AccountHelper.isLogin())
        DBManager.initDefaultRealm(AccountHelper.getCurrentUid(), APPRealmMigration.VERSION, new APPRealmMigration());
    startService(new Intent(this, InitializeIntentService.class));
}
项目:GitHub    文件:MediaVariationsFragment.java   
private void loadThumb(
    SimpleDraweeView draweeView,
    Size size,
    ImageRequest.RequestLevel requestLevel) {
  ImageRequest request = ImageRequestBuilder.newBuilderWithSource(size.uri)
      .setMediaVariations(MediaVariations.newBuilderForMediaId(MEDIA_ID)
          .setForceRequestForSpecifiedUri(true)
          .build())
      .setLowestPermittedRequestLevel(requestLevel)
      .setResizeOptions(new ResizeOptions(draweeView.getWidth(), draweeView.getHeight()))
      .setCacheChoice(size.cacheChoice)
      .build();
  DraweeController controller = Fresco.newDraweeControllerBuilder()
      .setImageRequest(request)
      .setOldController(draweeView.getController())
      .build();
  draweeView.setController(controller);
}
项目:Watermark    文件:FrescoImageLoader.java   
public static void setImageSmall(String url,
                                 SimpleDraweeView simpleDraweeView,
                                 int width,
                                 int height,
                                 SquareRelativeLayout relativeLayout, boolean playGif) {

    Uri uri = Uri.parse(url);
    ImageRequest request = ImageRequestBuilder
            .newBuilderWithSource(uri)
            .setRotationOptions(RotationOptions.autoRotate())
            .setResizeOptions(new ResizeOptions(width, height))
            .setLowestPermittedRequestLevel(ImageRequest.RequestLevel.FULL_FETCH)
            .build();
    DraweeController controller = Fresco.newDraweeControllerBuilder()
            .setTapToRetryEnabled(true)
            .setImageRequest(request)
            .setAutoPlayAnimations(playGif)
            .setOldController(simpleDraweeView.getController())
            .build();
    relativeLayout.setLayoutParams(new RelativeLayout.LayoutParams(width - 5, height));
    simpleDraweeView.setController(controller);
}
项目:GitHub    文件:ScrollPerfApplication.java   
@Override
public void onCreate() {
  super.onCreate();
  final Config config = Config.load(this);
  ImagePipelineConfig.Builder imagePipelineConfigBuilder = ImagePipelineConfig.newBuilder(this)
      .setResizeAndRotateEnabledForNetwork(false)
      .setDownsampleEnabled(config.downsampling);
  if (WebpSupportStatus.sIsWebpSupportRequired) {
    imagePipelineConfigBuilder.experiment().setWebpSupportEnabled(config.webpSupportEnabled);
  }
  if (config.decodingThreadCount == 0) {
    imagePipelineConfigBuilder.setExecutorSupplier(
        new DefaultExecutorSupplier(Const.NUMBER_OF_PROCESSORS));
  } else {
    imagePipelineConfigBuilder.setExecutorSupplier(
        new ScrollPerfExecutorSupplier(Const.NUMBER_OF_PROCESSORS, config.decodingThreadCount));
  }
  imagePipelineConfigBuilder.experiment().setDecodeCancellationEnabled(config.decodeCancellation);
  DraweeConfig draweeConfig = DraweeConfig.newBuilder()
      .setDrawDebugOverlay(config.draweeOverlayEnabled)
      .build();
  Fresco.initialize(this, imagePipelineConfigBuilder.build(), draweeConfig);
}
项目:react-native-android-bottom-navigation    文件:RNBottomNavigation.java   
private void setIconSource(ReadableMap source, IconControllerListener controllerListener,
                           DraweeHolder holder) {
    String uri = source != null ? source.getString("uri") : null;

    if (uri == null) {
        controllerListener.setIconImageInfo(null);
        controllerListener.setDrawable(null);
    } else if (uri.startsWith("http://") || uri.startsWith("https://") ||
            uri.startsWith("file://")) {
        controllerListener.setIconImageInfo(getIconImageInfo(source));
        DraweeController controller = Fresco.newDraweeControllerBuilder()
                .setUri(Uri.parse(uri))
                .setControllerListener(controllerListener)
                .setOldController(holder.getController())
                .build();
        holder.setController(controller);
        holder.getTopLevelDrawable().setVisible(true, true);
    } else {
        controllerListener.setDrawable(getDrawableByName(uri));
    }
}
项目:richeditor    文件:AppManager.java   
private void FrescoInit() {
    DiskCacheConfig diskCacheConfig = DiskCacheConfig.newBuilder(this)
            .setMaxCacheSize(40 * ByteConstants.MB)
            .setBaseDirectoryPathSupplier(new Supplier<File>() {
                @Override
                public File get() {
                    return getCacheDir();
                }
            })
            .build();

    final FrescoCacheParams bitmapCacheParams = new FrescoCacheParams(activityManager);
    //Set<RequestListener> listeners = new HashSet<>();
    ImagePipelineConfig imagePipelineConfig = OkHttpImagePipelineConfigFactory.newBuilder(this, RetrofitClient.getInstance().getOkHttpClient())
            .setMainDiskCacheConfig(diskCacheConfig)
            .setBitmapMemoryCacheParamsSupplier(bitmapCacheParams)
            .setDownsampleEnabled(true)
            .build();
    Fresco.initialize(this, imagePipelineConfig);
}
项目:Zoomable    文件:MainActivity.java   
private void displayImage(SimpleDraweeView draweeView, String url) {
    GenericDraweeHierarchy hierarchy = draweeView.getHierarchy();
    //设置占位图
    if (hierarchy == null) {
        hierarchy = GenericDraweeHierarchyBuilder.newInstance(getResources())
                .setPlaceholderImage(getResources().getDrawable(R.mipmap.ic_launcher)
                        , ScalingUtils.ScaleType.CENTER).build();
        draweeView.setHierarchy(hierarchy);
    } else {
        hierarchy.setPlaceholderImage(getResources().getDrawable(R.mipmap.ic_launcher)
                , ScalingUtils.ScaleType.CENTER);
    }

    //构建ImageRequestBuilder,传入请求Uri
    ImageRequestBuilder requestBuilder = ImageRequestBuilder.newBuilderWithSource(Uri.parse(url));
    //构建Controller
    DraweeController controller = Fresco.newDraweeControllerBuilder()
            .setOldController(draweeView.getController())
            .setImageRequest(requestBuilder.build())
            .build();
    //设置图片,Fresco设置显示图片都是通过Controller来实现
    draweeView.setController(controller);
}
项目:Zoomable    文件:ZoomableViewPagerAdapter.java   
@Override
public Object instantiateItem(ViewGroup container, int position) {
    View view = LayoutInflater.from(mContext).inflate(R.layout.zoomable_view_pager_item, null);
    ZoomableDraweeView zoomableDraweeView = (ZoomableDraweeView) view.findViewById(R.id.zoomable_image);
    //允许缩放时切换
    zoomableDraweeView.setAllowTouchInterceptionWhileZoomed(true);
    //长按
    zoomableDraweeView.setIsLongpressEnabled(false);
    //双击击放大或缩小
    zoomableDraweeView.setTapListener(new DoubleTapGestureListener(zoomableDraweeView));

    DraweeController draweeController = Fresco.newDraweeControllerBuilder()
            .setUri(mPaths.get(position))
            .build();
    //加载图片
    zoomableDraweeView.setController(draweeController);
    container.addView(view);
    view.requestLayout();
    return view;
}
项目:jiansan-java    文件:App.java   
@Override
public void onCreate() {
    super.onCreate();

    app = this;

    // 存放所有activity的集合
    mActivityList = new ArrayList<>();

    // 渐进式图片
    ImagePipelineConfig config = ImagePipelineConfig.newBuilder(this)
            .setProgressiveJpegConfig(new SimpleProgressiveJpegConfig())
            .build();
    Fresco.initialize(this, config);

}
项目:GankIO_weex    文件:WXApplication.java   
@Override
  public void onCreate() {
    super.onCreate();
//    initDebugEnvironment(true, false, "DEBUG_SERVER_HOST");
    WXSDKEngine.addCustomOptions("appName", "WXSample");
    WXSDKEngine.addCustomOptions("appGroup", "WXApp");
    WXSDKEngine.initialize(this,
        new InitConfig.Builder()
            .setImgAdapter(new ImageAdapter())
            .build()
    );

    try {
      WXSDKEngine.registerModule("event", WXEventModule.class);
    } catch (WXException e) {
      e.printStackTrace();
    }
    Fresco.initialize(this);
    AppConfig.init(this);
    PluginManager.init(this);
  }
项目:RNLearn_Project1    文件:ImageLoaderModule.java   
@ReactMethod
public void queryCache(final ReadableArray uris, final Promise promise) {
  // perform cache interrogation in async task as disk cache checks are expensive
  new GuardedAsyncTask<Void, Void>(getReactApplicationContext()) {
    @Override
    protected void doInBackgroundGuarded(Void... params) {
      WritableMap result = Arguments.createMap();
      ImagePipeline imagePipeline = Fresco.getImagePipeline();
      for (int i = 0; i < uris.size(); i++) {
        String uriString = uris.getString(i);
        final Uri uri = Uri.parse(uriString);
        if (imagePipeline.isInBitmapMemoryCache(uri)) {
          result.putString(uriString, "memory");
        } else if (imagePipeline.isInDiskCacheSync(uri)) {
          result.putString(uriString, "disk");
        }
      }
      promise.resolve(result);
    }
  }.executeOnExecutor(GuardedAsyncTask.THREAD_POOL_EXECUTOR);
}
项目:CommentGallery    文件:CommentImageGrid.java   
private void refreshImageChild() {
    int childrenCount = getChildCount();
    if (childrenCount > 0) {
        for (int i = 0; i < childrenCount; i++) {
            ViewGroup childImageLayout = (ViewGroup) getChildAt(i);
            SimpleDraweeView childImageView = (SimpleDraweeView) childImageLayout.getChildAt(0);
            if (mOnItemClickListener != null) {
                final int finalI = i;
                childImageLayout.setOnClickListener(new OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        mOnItemClickListener.OnItemClick(finalI);
                    }
                });
            }
            ImageRequest request = ImageRequestBuilder.newBuilderWithSource(Uri.parse(mImageUrls.get(i)))
                    .setResizeOptions(new ResizeOptions(mItemWidth, mItemWidth))
                    .build();
            DraweeController controller = Fresco.newDraweeControllerBuilder()
                    .setImageRequest(request)
                    .setOldController(childImageView.getController())
                    .build();
            childImageView.setController(controller);
        }
    }
}
项目:Mobike    文件:MyApplication.java   
@Override
public void onCreate() {
    super.onCreate();
    CrashReport.initCrashReport(getApplicationContext(), "e1a62089c6", false);
    ImagePipelineConfig config = ImagePipelineConfig.newBuilder(this)
            .setProgressiveJpegConfig(new SimpleProgressiveJpegConfig())
            .build();
    Fresco.initialize(this, config);
    SDKInitializer.initialize(this);
    Bmob.initialize(this, "b0cb494256d9b86fc931ca930a055b75");
    Logger.addLogAdapter(new AndroidLogAdapter(){
        @Override
        public boolean isLoggable(int priority, String tag) {
            return true;// TODO: 2017/6/5
        }
    });
    sInstance = this;
    initUser();
}
项目:LiuAGeAndroid    文件:MainActivity.java   
/**
     * 清除缓存
     */
    private void clearCache() {
        // 清理新闻json数据 - 不清理json数据
//        NewsDALManager.shared.clearCache();

        // Fresco清除图片缓存
        ImagePipeline imagePipeline = Fresco.getImagePipeline();
        imagePipeline.clearCaches();

        // 清除缓存目录 - 清除所有缓存目录文件
        FileCacheUtils.clearAllCache(mContext);

        final KProgressHUD hud = ProgressHUD.show(mContext, "正在清理...");
        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                hud.dismiss();
                ProgressHUD.showInfo(mContext, "清理缓存完成");
            }
        }, 2000);

    }
项目:ModuleFrame    文件:FrescoUtil.java   
/**
 * 初始化
 */
public static void init(@NonNull Application application) {
    DiskCacheConfig diskCacheConfig = DiskCacheConfig.newBuilder(application)
            .setBaseDirectoryName(CACHE_DIR_NAME)
            .setBaseDirectoryPath(CacheUtil.getCacheDirectory(application, null))
            .build();
    ImagePipelineConfig config = ImagePipelineConfig.newBuilder(application)
            .setResizeAndRotateEnabledForNetwork(true)
            .setDownsampleEnabled(true)
            .setBitmapMemoryCacheParamsSupplier(new MemoryCacheParamsSupplier(
                    (ActivityManager) application.getSystemService(Context.ACTIVITY_SERVICE)))  // 内存缓存配置
            .setMainDiskCacheConfig(diskCacheConfig)    // 磁盘缓存配置
            .setCacheKeyFactory(DefaultCacheKeyFactory.getInstance())   // 自定义缓存key
            .build();
    Fresco.initialize(application, config);
}
项目:PicKing    文件:MyApplication.java   
@Override
public void onCreate() {
    super.onCreate();
    OkHttpClient okHttpClient = new OkHttpClient.Builder()
            .build();
    ImagePipelineConfig config = OkHttpImagePipelineConfigFactory.newBuilder(this, okHttpClient)
            .setMainDiskCacheConfig(getDiskCacheConfig())
            .setNetworkFetcher(new OkHttpNetworkFetcher(okHttpClient))
            .setDownsampleEnabled(true)
            .build();
    Fresco.initialize(this, config);

    Context context = getApplicationContext();
    String packageName = context.getPackageName();
    String processName = getProcessName(android.os.Process.myPid());
    CrashReport.UserStrategy strategy = new CrashReport.UserStrategy(context);
    strategy.setUploadProcess(processName == null || processName.equals(packageName));
    CrashReport.initCrashReport(getApplicationContext(), "0a6e92fb70", false, strategy);

    registerActivityLifecycleCallbacks(ActivityLifecycleHelper.build());
}
项目:PicKing    文件:FrescoUtil.java   
public static void setBlurFrescoController(SimpleDraweeView simpleDraweeView, String url, int iterations, int blurRadius) {
    try {
        Uri uri = Uri.parse(url);
        ImageRequest request = ImageRequestBuilder.newBuilderWithSource(uri)
                .setPostprocessor(new IterativeBoxBlurPostProcessor(iterations, blurRadius))
                .build();
        DraweeController controller = Fresco.newDraweeControllerBuilder()
                .setOldController(simpleDraweeView.getController())
                .setImageRequest(request)
                .build();
        simpleDraweeView.setController(controller);
    } catch (Exception e) {
        e.printStackTrace();
    }

}
项目:fast-list    文件:App.java   
@Override
public void onCreate() {
  super.onCreate();

  // di
  if (appComponent == null) {
    appComponent = DaggerAppComponent.builder()
        .appModule(new AppModule(this))
        .build();
  }
  getAppComponent().inject(this);

  // fresco
  ImagePipelineConfig imagePipelineConfig = OkHttpImagePipelineConfigFactory.newBuilder(this, mOkHttpClient)
      .setDownsampleEnabled(true)
      .build();
  Fresco.initialize(this, imagePipelineConfig);

  // logging
  if (BuildConfig.DEBUG) {
    Timber.plant(new ThreadAwareDebugTree());
  }
}
项目:GitHub    文件:AnimationApplication.java   
@Override
public void onCreate() {
    super.onCreate();
    FLog.setMinimumLoggingLevel(FLog.VERBOSE);
    Set<RequestListener> listeners = new HashSet<>();
    listeners.add(new RequestLoggingListener());
    ImagePipelineConfig config = ImagePipelineConfig.newBuilder(this)
            .setRequestListeners(listeners)
            .build();
    Fresco.initialize(this, config);
}
项目:LiuAGeAndroid    文件:CommentRecordActivity.java   
/**
 * 配置recyclerView资讯列表
 */
private void setupRecyclerView() {
    mNewsListRecyclerView.setLayoutManager(new LinearLayoutManager(mContext));
    newsListAdapter = new NewsListRecyclerViewAdapter(mContext);
    mNewsListRecyclerView.setAdapter(newsListAdapter);
    newsListAdapter.setOnItemTapListener(new NewsListRecyclerViewAdapter.OnItemTapListener() {
        @Override
        public void onItemTapListener(ArticleListBean articleListBean) {
            // 打开文章详情
            openArticleDetail(articleListBean);
        }
    });

    // 监听滚动
    mNewsListRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
        @Override
        public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
            switch (newState) {
                case RecyclerView.SCROLL_STATE_SETTLING:
                    if (!Fresco.getImagePipeline().isPaused()) {
                        Fresco.getImagePipeline().pause();
                    }
                    break;
                case RecyclerView.SCROLL_STATE_DRAGGING:
                case RecyclerView.SCROLL_STATE_IDLE:
                    if (Fresco.getImagePipeline().isPaused()) {
                        Fresco.getImagePipeline().resume();
                    }
                    break;
            }
        }
    });
}
项目:react-native-udesk    文件:UdeskUtil.java   
public static void loadFileFromSdcard(final Context context, final SimpleDraweeView draweeView, Uri loackUri, final int reqWidth, final int reqHeight) {
    ImageRequest request = ImageRequestBuilder.newBuilderWithSource(loackUri)
            .setRotationOptions(RotationOptions.autoRotate())
            .setLocalThumbnailPreviewsEnabled(true)
            .setResizeOptions(new ResizeOptions(dip2px(context, 140), dip2px(context, 220)))
            .build();
    DraweeController controller = Fresco.newDraweeControllerBuilder()
            .setImageRequest(request)
            .setOldController(draweeView.getController())
            .setTapToRetryEnabled(true)
            .setControllerListener(new BaseControllerListener<ImageInfo>() {
                @Override
                public void onFinalImageSet(String id, ImageInfo imageInfo, Animatable anim) {
                    if (imageInfo == null) {
                        return;
                    }

                    ViewGroup.LayoutParams layoutParams = draweeView.getLayoutParams();
                    int width = reqWidth;
                    int height = reqHeight;
                    int imgWidth = dip2px(context, 140);
                    int imgHight = dip2px(context, 220);
                    int bitScalew = getRatioSize(width, height, imgHight, imgWidth);
                    layoutParams.height = height / bitScalew;
                    layoutParams.width = width / bitScalew;
                    draweeView.requestLayout();
                }
            })
            .setAutoPlayAnimations(true)
            .build();
    draweeView.setController(controller);
}
项目:GitHub    文件:MediaVariationsFragment.java   
@Override
public boolean onOptionsItemSelected(MenuItem item) {
  if (item.getItemId() == R.id.media_variations_clear_cache) {
    Fresco.getImagePipeline().clearCaches();
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
      getActivity().recreate();
    } else {
      Toast.makeText(
          getActivity(),
          R.string.imagepipeline_media_variations_restart_toast,
          Toast.LENGTH_SHORT).show();
      getActivity().finish();
    }
    return true;
  } else if (item.getGroupId() == R.id.media_variations_modes) {
    for (Mode mode : Mode.values()) {
      if (mode.menuItemId == item.getItemId()) {
        setMode(mode);
        break;
      }
    }
    clearMainImageAndBitmapCache();
    item.setChecked(true);
  }

  return super.onOptionsItemSelected(item);
}
项目:GitHub    文件:MediaVariationsFragment.java   
private void setDraweeControllerForRequest(ImageRequest imageRequest) {
  DraweeController controller = Fresco.newDraweeControllerBuilder()
    .setImageRequest(imageRequest)
    .setOldController(mMainImageDraweeView.getController())
    .setRetainImageOnFailure(true)
    .build();
  mMainImageDraweeView.setController(controller);
}
项目:richeditor    文件:FrescoImageLoader.java   
@Override
public void bindImage(ImageView photoImageView, Uri uri, int width, int height) {
    DraweeView draweeView = (DraweeView) photoImageView;
    final ImageRequestBuilder requestBuilder = ImageRequestBuilder.newBuilderWithSource(uri);
    if (width > 0 && height > 0) {
        requestBuilder.setResizeOptions(new ResizeOptions(width, height));
    }
    ImageRequest imageRequest = requestBuilder.build();
    DraweeController controller = Fresco.newDraweeControllerBuilder()
            .setOldController(draweeView.getController())
            .setImageRequest(imageRequest).build();
    draweeView.setController(controller);
}
项目:FinalProject    文件:FrescoFactory.java   
public static DraweeController buildDraweeController(BaseFrescoImageView fresco){
    return Fresco.newDraweeControllerBuilder()
            .setImageRequest(fresco.getImageRequest())
            .setAutoPlayAnimations(fresco.isAnim())
            .setTapToRetryEnabled(fresco.getTapToRetryEnabled())
            .setLowResImageRequest(fresco.getLowImageRequest())
            .setControllerListener(fresco.getControllerListener())
            .setOldController(fresco.getDraweeController())
            .build();
}
项目:GitHub    文件:DraweeHierarchyFragment.java   
private void setUri(SimpleDraweeView draweeView, Uri uri, boolean retryEnabled) {
  draweeView.setController(Fresco.newDraweeControllerBuilder()
      .setOldController(draweeView.getController())
      .setTapToRetryEnabled(retryEnabled)
      .setUri(uri)
      .build());
}
项目:react-native-udesk    文件:UdeskSDKManager.java   
public void init(final Context context) {
    final int MAX_HEAP_SIZE = (int) Runtime.getRuntime().maxMemory();
    final int MAX_DISK_CACHE_SIZE = 300 * ByteConstants.MB;
    final int MAX_MEMORY_CACHE_SIZE = MAX_HEAP_SIZE / 3;
    final MemoryCacheParams bitmapCacheParams = new MemoryCacheParams(
            MAX_MEMORY_CACHE_SIZE,
            Integer.MAX_VALUE,
            MAX_MEMORY_CACHE_SIZE,
            Integer.MAX_VALUE,
            Integer.MAX_VALUE);

    DiskCacheConfig diskCacheConfig = DiskCacheConfig.newBuilder(context)
            .setMaxCacheSize(MAX_DISK_CACHE_SIZE)//最大缓存
            .setBaseDirectoryName("udesk")//子目录
            .setBaseDirectoryPathSupplier(new Supplier<File>() {
                @Override
                public File get() {
                    return UdeskUtil.getExternalCacheDir(context);
                }
            })
            .build();
    ImagePipelineConfig config = ImagePipelineConfig.newBuilder(context)
            .setBitmapMemoryCacheParamsSupplier(
                    new Supplier<MemoryCacheParams>() {
                        public MemoryCacheParams get() {
                            return bitmapCacheParams;
                        }
                    })
            .setMainDiskCacheConfig(diskCacheConfig)
            .setDownsampleEnabled(true)
            .setBitmapsConfig(Bitmap.Config.RGB_565)
            .build();

    Fresco.initialize(context, config);
}
项目:GitHub    文件:DraweeViewListAdapter.java   
@Override
public View getView(int position, View convertView, ViewGroup parent) {
  InstrumentedDraweeView draweeView;
  if (convertView == null) {
    final Context context = parent.getContext();
    GenericDraweeHierarchy gdh = DraweeUtil.createDraweeHierarchy(context, mConfig);
    draweeView = new InstrumentedDraweeView(context, gdh, mConfig);
    SizeUtil.setConfiguredSize(parent, draweeView, mConfig);
    draweeView.setPadding(mPaddingPx, mPaddingPx, mPaddingPx, mPaddingPx);
  } else {
    draweeView = (InstrumentedDraweeView) convertView;
  }
  final Uri uri = getItem(position);
  draweeView.initInstrumentation(uri.toString(), mPerfListener);
  ImageRequestBuilder imageRequestBuilder = ImageRequestBuilder
          .newBuilderWithSource(uri)
          .setResizeOptions(
                  new ResizeOptions(
                          draweeView.getLayoutParams().width,
                          draweeView.getLayoutParams().height));
  PipelineUtil.addOptionalFeatures(imageRequestBuilder, mConfig);
  // Create the Builder
  PipelineDraweeControllerBuilder builder = Fresco.newDraweeControllerBuilder()
          .setImageRequest(imageRequestBuilder.build());
  if (mConfig.reuseOldController) {
    builder.setOldController(draweeView.getController());
  }
  if (mConfig.instrumentationEnabled) {
    draweeView.setListener(builder);
  }
  draweeView.setController(builder.build());
  return draweeView;
}
项目:aftercare-app-android    文件:DCApplication.java   
@Override
public void onCreate() {
    super.onCreate();
    Fresco.initialize(this);
    Twitter.initialize(this);
    DCSharedPreferences.initialize(this);
}
项目:redux-observable    文件:SingleBannerComponentSpec.java   
@OnCreateLayout
static ComponentLayout onCreateLayout(ComponentContext c, @Prop SingleBannerSection payload) {
    final DraweeController controller = Fresco.newDraweeControllerBuilder()
            .setUri(payload.banner().imageUrl())
            .build();
    return Column.create(c)
            .child(
                    Text.create(c)
                            .text(payload.title())
                            .glyphWarming(true)
                            .textSizeSp(16)
                            .withLayout()
                            .paddingDip(TOP,8)
                            .paddingDip(BOTTOM,4)
                            .heightDip(44)
            )
            .paddingDip(LEFT, 8)
            .paddingDip(RIGHT, 8)
            .child(
                    FrescoImage.create(c)
                            .controller(controller)
                            .actualImageScaleType(
                                    ScalingUtils
                                            .ScaleType
                                            .CENTER_CROP
                            )
                            .withLayout()
                            .heightPx((int) (DisplayUtil.getScreenWidth(c) / payload.banner().ratio()))

            )
            .clickHandler(SingleBannerComponent.onClick(c))
            .build();
}
项目:GongXianSheng    文件:FrecoFactory.java   
/**
     * 自定义控件调用该方法显示
     * @param draweeView
     * @param uri
     * @param resizeOptions
     * @param defaultDrawable
     * @param scaleType
     */
    public void disPlay(DraweeView draweeView, Uri uri, String lowResUri, ResizeOptions resizeOptions, Drawable defaultDrawable, ScalingUtils.ScaleType scaleType, ControllerListener controllerListener) {
//        System.out.println(draweeView.hasHierarchy());
        if (!draweeView.hasHierarchy()) {
            setDefaultHierarchy(draweeView,defaultDrawable,scaleType);
        }
        ImageRequestBuilder imageRequestBuilder =
                ImageRequestBuilder.newBuilderWithSource(uri);
        if (UriUtil.isNetworkUri(uri)) {
            imageRequestBuilder.setProgressiveRenderingEnabled(true);
        }
        else {
            imageRequestBuilder.setLocalThumbnailPreviewsEnabled(true);
            imageRequestBuilder.setProgressiveRenderingEnabled(false);
            if ( resizeOptions != null ) {
                imageRequestBuilder.setResizeOptions(resizeOptions);
            }
        }
//        imageRequestBuilder.setAutoRotateEnabled(true);
//        imageRequestBuilder.setLowestPermittedRequestLevel(ImageRequest.RequestLevel.FULL_FETCH);
        DraweeController draweeController = Fresco.newDraweeControllerBuilder()
                .setImageRequest(imageRequestBuilder.build())
                .setOldController(draweeView.getController())
                .setLowResImageRequest(ImageRequest.fromUri(lowResUri))
                .setControllerListener(controllerListener)
                .build();
        draweeView.setController(draweeController);
    }
项目:CustomListView    文件:FrescoImageLoaderStrategy.java   
@Override
public void clear(Context ctx, FrescoImageConfig config) {
    Fresco.getImagePipeline().clearMemoryCaches();
    Fresco.getImagePipeline().clearCaches();
    Fresco.getImagePipeline().clearDiskCaches();
    String url = appendUrl(config.getUrl());
    ImagePipeline imagePipeline = Fresco.getImagePipeline();
    Uri uri = Uri.parse(url);
    imagePipeline.evictFromMemoryCache(uri);
}
项目:androidtools    文件:FrescoImageView.java   
@Override
public void setImageURI(Uri uri) {
    ImageRequestBuilder imageRequestBuilder = ImageRequestBuilder.newBuilderWithSource(uri)
            .setAutoRotateEnabled(true)
            .setLocalThumbnailPreviewsEnabled(true)
            .setResizeOptions(resizeOptions);
    ImageRequest request = imageRequestBuilder.build();
    DraweeController controller = Fresco.newDraweeControllerBuilder()
            .setAutoPlayAnimations(true)
            .setImageRequest(request)
            .setTapToRetryEnabled(false)//加载失败时点击重新加载
            .setOldController(getController())
            .build();
    setController(controller);
}
项目:Viajes    文件:HotelApp.java   
@Override
public void onCreate() {
    super.onCreate();
    MultiDex.install(this);
    //init firebase
    FirebaseDatabase.getInstance().setPersistenceEnabled(true);

    Fresco.initialize(this, ImagePipelineConfigFactory.getImagePipelineConfig(this));
}