com.facebook.drawee.backends.pipeline.Fresco Java Examples

The following examples show how to use com.facebook.drawee.backends.pipeline.Fresco. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ImageLoaderModule.java    From react-native-GPay with MIT License 7 votes vote down vote up
@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);
}
 
Example #2
Source File: WXApplication.java    From weex with Apache License 2.0 6 votes vote down vote up
@Override
public void onCreate() {
  super.onCreate();
  initDebugEnvironment(false, "DEBUG_SERVER_HOST");
  WXSDKEngine.addCustomOptions("appName", "WXSample");
  WXSDKEngine.addCustomOptions("appGroup", "WXApp");
  WXSDKEngine.initialize(this,
                         new InitConfig.Builder()
                             .setImgAdapter(new ImageAdapter())
                             .setDebugAdapter(new PlayDebugAdapter())
                             .build()
                        );

  try {
    Fresco.initialize(this);
    WXSDKEngine.registerComponent("richtext", RichText.class);
    WXSDKEngine.registerModule("render", RenderModule.class);
    WXSDKEngine.registerModule("event", WXEventModule.class);

    WXSDKEngine.registerModule("myModule", MyModule.class);

  } catch (WXException e) {
    e.printStackTrace();
  }

}
 
Example #3
Source File: FrescoHolder.java    From fresco with MIT License 6 votes vote down vote up
@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);
}
 
Example #4
Source File: LithoSampleApplication.java    From litho with Apache License 2.0 6 votes vote down vote up
@Override
public void onCreate() {
  super.onCreate();

  Fresco.initialize(this);
  SoLoader.init(this, false);

  if (FlipperUtils.shouldEnableFlipper(this)) {
    final FlipperClient client = AndroidFlipperClient.getInstance(this);
    final DescriptorMapping descriptorMapping = DescriptorMapping.withDefaults();
    LithoFlipperDescriptors.add(descriptorMapping);
    client.addPlugin(new InspectorFlipperPlugin(this, descriptorMapping));
    client.addPlugin(new SectionsFlipperPlugin(true));
    client.start();
  }
}
 
Example #5
Source File: ImageViewerAdapter.java    From photo-viewer with Apache License 2.0 6 votes vote down vote up
private void setController(String url, ReadableMap headers) {
			PipelineDraweeControllerBuilder controllerBuilder = Fresco.newDraweeControllerBuilder();
//			controllerBuilder.setUri(url);
			controllerBuilder.setOldController(drawee.getController());
			controllerBuilder.setControllerListener(getDraweeControllerListener(drawee));
			controllerBuilder.setAutoPlayAnimations(true);
			if (imageRequestBuilder != null) {
				imageRequestBuilder.setSource(Uri.parse(url));
				controllerBuilder.setImageRequest(imageRequestBuilder.build());
			}
//			support load local image just like React Native do

			ImageSource imageSource = new ImageSource(getContext(), url);
			ImageRequestBuilder imageRequestBuilder1 = ImageRequestBuilder.newBuilderWithSource(imageSource.getUri());
//			support headers
			ImageRequest imageRequest = ReactNetworkImageRequest.fromBuilderWithHeaders(imageRequestBuilder1, headers);

			controllerBuilder.setImageRequest(imageRequest);


			drawee.setController(controllerBuilder.build());
		}
 
Example #6
Source File: DraweeViewHolder.java    From fresco with MIT License 6 votes vote down vote up
/** @param uri The Uri to show into the DraweeView for this Holder */
public void bind(Uri uri) {
  mDraweeView.initInstrumentation(uri.toString(), mPerfListener);
  ImageRequestBuilder imageRequestBuilder =
      ImageRequestBuilder.newBuilderWithSource(uri)
          .setResizeOptions(
              new ResizeOptions(
                  mDraweeView.getLayoutParams().width, mDraweeView.getLayoutParams().height));
  PipelineUtil.addOptionalFeatures(imageRequestBuilder, mConfig);
  // Create the Builder
  PipelineDraweeControllerBuilder builder =
      Fresco.newDraweeControllerBuilder().setImageRequest(imageRequestBuilder.build());
  if (mConfig.reuseOldController) {
    builder.setOldController(mDraweeView.getController());
  }
  mDraweeView.setListener(builder);
  mDraweeView.setController(builder.build());
}
 
Example #7
Source File: SingleImageInterceptor.java    From Flora with MIT License 6 votes vote down vote up
private void load(Uri uri, SimpleDraweeView draweeView, int width, int height) {
    ImageRequest request = ImageRequestBuilder.newBuilderWithSource(uri)
            .setResizeOptions(new ResizeOptions(width, height))
            .setProgressiveRenderingEnabled(true)
            .setAutoRotateEnabled(true)
            .build();

    PipelineDraweeController controller =
            (PipelineDraweeController) Fresco.newDraweeControllerBuilder()
                    .setImageRequest(request)
                    .setOldController(draweeView.getController())
                    .setAutoPlayAnimations(true)
                    .build();

    draweeView.setController(controller);
}
 
Example #8
Source File: HorizonMainApplication.java    From triviums with MIT License 6 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();

    //Fabric for Crashlytics
    Fabric.with(this, new Crashlytics());

    //HyperLog for Remote Logging
    //HyperLog.initialize(this);
    //HyperLog.setLogLevel(Log.VERBOSE);

    instance = this;

    //Fresco for image library
    Fresco.initialize(this);
}
 
Example #9
Source File: MainActivity.java    From QuickNews with MIT License 6 votes vote down vote up
@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Fresco.initialize(this);
        JPushInterface.init(this);
        System.out.println("JPushInterface.getRegistrationID");
        JPushInterface.init(getApplicationContext());
        String rid = JPushInterface.getRegistrationID(getApplicationContext());
        System.out.println("JPushInterface.getRegistrationID" + rid);
        setContentView(R.layout.activity_main);
        ActionBar actionBar = getSupportActionBar();
        actionBar.hide();


        initView();


        mNetReceiver = new NetWorkChangeReceiver();
        IntentFilter filter = new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION);
        registerReceiver(mNetReceiver, filter);
        NetWorkState.mNetState = NetWorkState.isConn(MainActivity.this);


//        registerMessageReceiver();  // used for receive msg

    }
 
Example #10
Source File: MyApplication.java    From PicKing with Apache License 2.0 6 votes vote down vote up
@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());
}
 
Example #11
Source File: FacebookImageUtil.java    From imsdk-android with MIT License 6 votes vote down vote up
public static void loadWithCache(String url, final SimpleDraweeView target,ImageRequest.CacheChoice type,boolean playAnim)
{
    if (target == null) return;

    Uri uri = Uri.parse(url);
    ImageRequestBuilder builder = ImageRequestBuilder.newBuilderWithSource(uri);
    ImageRequest request = builder
            .setCacheChoice(type)
            .build();
    final PipelineDraweeControllerBuilder pipelineDraweeControllerBuilder = Fresco.newDraweeControllerBuilder()
            .setImageRequest(request)
            .setAutoPlayAnimations(playAnim)
            .setOldController(target.getController());
    handler.post(new Runnable() {
        @Override
        public void run() {
            DraweeController controller = pipelineDraweeControllerBuilder.build();
            target.setController(controller);
        }
    });

}
 
Example #12
Source File: GalleryActivity.java    From phphub-android with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    String imageUrl = getIntent().getStringExtra(IMAGE_URL);
    if (!TextUtils.isEmpty(imageUrl)) {
        PipelineDraweeControllerBuilder builder = Fresco.newDraweeControllerBuilder();
        builder.setUri(Uri.parse(imageUrl));
        builder.setOldController(photoView.getController());
        builder.setControllerListener(new BaseControllerListener<ImageInfo>() {
            @Override
            public void onFinalImageSet(String id, ImageInfo imageInfo, Animatable animatable) {
                super.onFinalImageSet(id, imageInfo, animatable);
                if (imageInfo == null || photoView == null) {
                    return;
                }
                photoView.update(imageInfo.getWidth(), imageInfo.getHeight());
            }
        });
        photoView.setController(builder.build());
    }
}
 
Example #13
Source File: WXApplication.java    From WeexOne with MIT License 6 votes vote down vote up
@Override
  public void onCreate() {
    super.onCreate();
//    initDebugEnvironment(false, "DEBUG_SERVER_HOST");
    WXSDKEngine.addCustomOptions("appName", "WXSample");
    WXSDKEngine.addCustomOptions("appGroup", "WXApp");
    WXSDKEngine.initialize(this,
        new InitConfig.Builder()
            .setImgAdapter(new ImageAdapter())
            .build()
    );

    Fresco.initialize(this);
    AppConfig.init(this);
    ExtensionManager.registerComponents(AppConfig.getComponents());
    ExtensionManager.registerModules(AppConfig.getModules());

  }
 
Example #14
Source File: BaseApplication.java    From FlyWoo with Apache License 2.0 6 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();
    if (instance == null) {
        instance = this;
    }
    sendFileStates = new HashMap<String, FileState>();
    recieveFileStates = new HashMap<String, FileState>();
    mAvatarCache = new HashMap<String, SoftReference<Bitmap>>();
    // ActivitiesManager.init(getApplicationContext()); // 初始化活动管理器
    // L.setLogStatus(isPrintLog); // 设置是否显示日志

    //初始化Fresco库
    Fresco.initialize(this);

    initEmoticons();
    initNotification();
    initFolder();

  //  bus = new Bus();
}
 
Example #15
Source File: ImageAdapter.java    From TLint with Apache License 2.0 6 votes vote down vote up
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
    Image image = images.get(position);
    holder.image = image;
    if (image == null) {
        return;
    }
    holder.ivCheck.setVisibility(View.VISIBLE);
    holder.ivCheck.setImageResource(selectedImages.contains(image) ? R.drawable.ap_gallery_checked
            : R.drawable.ap_gallery_normal);
    int width = 100, height = 100;
    ImageRequest request =
            ImageRequestBuilder.newBuilderWithSource(Uri.fromFile(new File(image.path)))
                    .setResizeOptions(new ResizeOptions(width, height))
                    .build();
    PipelineDraweeController controller =
            (PipelineDraweeController) Fresco.newDraweeControllerBuilder()
                    .setOldController(holder.ivPhoto.getController())
                    .setImageRequest(request)
                    .build();
    holder.ivPhoto.setController(controller);
}
 
Example #16
Source File: UWXInit.java    From ucar-weex-core with Apache License 2.0 6 votes vote down vote up
public static void init(Application context) {
        UWXSDKManager.initialize(context);
//        WXSDKEngine.addCustomOptions("scheme", "portal");
//        WXSDKEngine.addCustomOptions(WXConfig.appGroup, "portal");
//        WXSDKEngine.addCustomOptions(WXConfig.appName, "portal");
        WXSDKEngine.initialize(context,
                new InitConfig.Builder()
                        .setImgAdapter(new FrescoImageAdapter())
                        .setJSExceptionAdapter(new JSExceptionAdapter())
                        .setDebugAdapter(new DebugAdapter())
                        .build()
        );
        try {
            WXSDKEngine.registerModule("UNavigator", UWXNavigatorModule.class);
            WXSDKEngine.registerModule("UScheme", UWXSchemeModule.class);
            WXSDKEngine.registerModule("UGlobalEvent", UWXGlobalEventModule.class);
            WXSDKEngine.registerModule("navigator", UWXNavigatorModule2.class);
        } catch (WXException e) {
            e.printStackTrace();
        }
        Fresco.initialize(context);
    }
 
Example #17
Source File: CommentImageGrid.java    From CommentGallery with Apache License 2.0 6 votes vote down vote up
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);
        }
    }
}
 
Example #18
Source File: UserInfoActivity.java    From meiShi with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Fresco.initialize(this);
    setContentView(R.layout.activity_user_info);
    setStateBarColor(R.color.colorPrimaryDark);
    mUserEntity = App.getInstance().getOauthUserEntity().getUser();
    video = mUserEntity.getVideos_count() + "\n" + getString(R.string.video);
    reposts = mUserEntity.getReposts_count() + "\n" + getString(R.string.reposts);
    following = mUserEntity.getFriends_count() + "\n" + getString(R.string.following);
    followers = mUserEntity.getFollowers_count() + "\n" + getString(R.string.following);
    mUserInfoHeader = new UserInfoHeader(this, findView(R.id.layout_header_view));
    mUserInfoHeader.bindData(mUserEntity);
    setUpCommonBackTooblBar(R.id.toolbar, " ");
    CollapsingToolbarLayout collapsingToolbar = (CollapsingToolbarLayout) findViewById(R.id.collapsing_toolbar);
    collapsingToolbar.setTitle(getString(R.string.title_home));
    collapsingToolbar.setExpandedTitleColor(Color.TRANSPARENT);
    mViewPager = (ViewPager) findViewById(R.id.viewpager);
    setupViewPager(mViewPager);
    TabLayout tabLayout = (TabLayout) findViewById(R.id.sliding_tabs);
    tabLayout.addTab(tabLayout.newTab().setText(video));
    tabLayout.addTab(tabLayout.newTab().setText(reposts));
    tabLayout.addTab(tabLayout.newTab().setText(followers));
    tabLayout.addTab(tabLayout.newTab().setText(following));
    tabLayout.setupWithViewPager(mViewPager);
}
 
Example #19
Source File: ReactToolbar.java    From react-native-GPay with MIT License 6 votes vote down vote up
/**
 * Sets an icon for a specific icon source. If the uri indicates an icon
 * to be somewhere remote (http/https) or on the local filesystem, it uses fresco to load it.
 * Otherwise it loads the Drawable from the Resources and directly returns it via a callback
 */
private void setIconSource(ReadableMap source, IconControllerListener controllerListener, DraweeHolder holder) {

  String uri = source != null ? source.getString(PROP_ICON_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));
  }

}
 
Example #20
Source File: AMapMarker.java    From react-native-amap with MIT License 6 votes vote down vote up
public void setImage(String uri) {
    if (uri == null) {
        iconBitmapDescriptor = null;
        update();
    } else if (uri.startsWith("http://") || uri.startsWith("https://") ||
            uri.startsWith("file://")) {
        ImageRequest imageRequest = ImageRequestBuilder
                .newBuilderWithSource(Uri.parse(uri))
                .build();

        ImagePipeline imagePipeline = Fresco.getImagePipeline();
        dataSource = imagePipeline.fetchDecodedImage(imageRequest, this);
        DraweeController controller = Fresco.newDraweeControllerBuilder()
                .setImageRequest(imageRequest)
                .setControllerListener(mLogoControllerListener)
                .setOldController(logoHolder.getController())
                .build();
        logoHolder.setController(controller);
    } else {
        iconBitmapDescriptor = getBitmapDescriptorByName(uri);
        update();
    }
}
 
Example #21
Source File: TestModuleApplication.java    From JD-Test with Apache License 2.0 6 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();
    if (LeakCanary.isInAnalyzerProcess(this)) {
        return;
    }
    if(CommonConfig.DEBUG){
        LeakCanary.install(this);
        ARouter.openLog();     // 打印日志
        ARouter.openDebug();   // 开启调试模式(如果在InstantRun模式下运行,必须开启调试模式!线上版本需要关闭,否则有安全风险)
    }

    ARouter.init(this);
    //CrashReport.initCrashReport(getApplicationContext(), "93f0e37549", CommonConfig.DEBUG);
    Fresco.initialize(this);
    GlobalAppComponent.init(this);
}
 
Example #22
Source File: DialogView.java    From actor-platform with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
public void layoutReady(DialogLayout res) {
    super.layoutReady(res);

    draweeHolder.onAttach();
    if (res.getImageRequest() != null) {
        draweeHolder.setController(Fresco.newDraweeControllerBuilder()
                .setImageRequest(res.getImageRequest())
                .setOldController(draweeHolder.getController())
                .build());
    } else {
        draweeHolder.setController(Fresco.newDraweeControllerBuilder()
                .setOldController(draweeHolder.getController())
                .build());
    }
}
 
Example #23
Source File: App.java    From LiuAGeAndroid with MIT License 5 votes vote down vote up
@Override
    public void onCreate() {
        super.onCreate();

        app = this;

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

        // 初始化app异常处理器 - 打包的时候开启
//        CrashHandler handler = CrashHandler.getInstance();
//        handler.init(getApplicationContext());

        // 初始化OkHttpUtils
        OkHttpClient okHttpClient = new OkHttpClient.Builder()
                .connectTimeout(10000L, TimeUnit.MILLISECONDS)
                .readTimeout(10000L, TimeUnit.MILLISECONDS)
                //其他配置
                .build();
        OkHttpUtils.initClient(okHttpClient);

        // 初始化Fresco
        ImagePipelineConfig config = ImagePipelineConfig.newBuilder(this)
                .setProgressiveJpegConfig(new SimpleProgressiveJpegConfig())
                .build();
        Fresco.initialize(this, config);

        // 初始化ShareSDK
        ShareSDK.initSDK(this);

        // 初始化JPush
        JPushInterface.setDebugMode(true);
        JPushInterface.init(this);

        // 更新用户登录状态
        UserBean.updateUserInfoFromNetwork(new UserBean.OnUpdatedUserInfoListener());

    }
 
Example #24
Source File: ViewPagerActivity.java    From ZoomableDraweeView-sample with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Fresco.initialize(this);
    FLog.setMinimumLoggingLevel(FLog.VERBOSE);

    setContentView(R.layout.activity_view_pager);

    vpGallery = (ViewPager) findViewById(R.id.vp_gallery);
    vpGallery.setAdapter(new GalleryAdapter());
}
 
Example #25
Source File: ImageFragment.java    From TLint with Apache License 2.0 5 votes vote down vote up
@Override
public void initData() {
    showContent(true);
    ImageRequest request = ImageRequestBuilder.newBuilderWithSource(Uri.parse(url))
            .setProgressiveRenderingEnabled(true)
            .build();

    GenericDraweeHierarchy hierarchy =
            new GenericDraweeHierarchyBuilder(getResources()).setProgressBarImage(
                    new ImageLoadProgressBar(new ImageLoadProgressBar.OnLevelChangeListener() {
                        @Override
                        public void onChange(int level) {
                            if (level > 100 && progress.getVisibility() == View.VISIBLE) {
                                progress.setVisibility(View.GONE);
                            }
                        }
                    }, ResourceUtil.getThemeColor(getActivity()))).build();
    hierarchy.setActualImageScaleType(ScalingUtils.ScaleType.FIT_CENTER);

    PipelineDraweeControllerBuilder controller = Fresco.newDraweeControllerBuilder();
    controller.setControllerListener(listener);
    controller.setImageRequest(request);
    controller.setOldController(image.getController());
    controller.setAutoPlayAnimations(true);
    image.setHierarchy(hierarchy);
    image.setController(controller.build());
}
 
Example #26
Source File: App.java    From APlayer with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onTrimMemory(int level) {
  super.onTrimMemory(level);
  Timber.v("onTrimMemory, %s", level);

  Completable
      .fromAction(() -> {
        switch (level) {
          case ComponentCallbacks2.TRIM_MEMORY_UI_HIDDEN:
            // 释放UI
            break;
          case ComponentCallbacks2.TRIM_MEMORY_RUNNING_MODERATE:
          case ComponentCallbacks2.TRIM_MEMORY_RUNNING_LOW:
          case ComponentCallbacks2.TRIM_MEMORY_RUNNING_CRITICAL:
            // 释放不需要资源
            Fresco.getImagePipeline().clearMemoryCaches();
            break;
          case ComponentCallbacks2.TRIM_MEMORY_BACKGROUND:
          case ComponentCallbacks2.TRIM_MEMORY_MODERATE:
          case ComponentCallbacks2.TRIM_MEMORY_COMPLETE:
            // 尽可能释放资源
            Timber.v("");
            Fresco.getImagePipeline().clearMemoryCaches();
            break;
          default:
            break;
        }
      })
      .subscribeOn(AndroidSchedulers.mainThread())
      .subscribe();
}
 
Example #27
Source File: LithoLabApplication.java    From litho with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate() {
  super.onCreate();

  SoLoader.init(this, false);
  Fresco.initialize(this);
}
 
Example #28
Source File: SplashActivity.java    From fingerpoetry-android with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Fresco.initialize(this);
    PushAgent.getInstance(getApplicationContext()).onAppStart();
    setContentView(R.layout.activity_splash);
    ButterKnife.bind(this);
    container = this.findViewById(R.id.splash_container);

    CommonHelper.updateDeviceToken(getApplicationContext());

    initAlarm();
    jumpNext();
}
 
Example #29
Source File: FrescoUtils.java    From SprintNBA with Apache License 2.0 5 votes vote down vote up
public static PipelineDraweeControllerBuilder getPreController(String url, final PhotoDraweeView draweeView) {
    ImageRequest request = ImageRequestBuilder.newBuilderWithSource(Uri.parse(url))
            .setProgressiveRenderingEnabled(true)
            .build();

    PipelineDraweeControllerBuilder controller = Fresco.newDraweeControllerBuilder();
    controller.setImageRequest(request);
    controller.setOldController(draweeView.getController());
    controller.setAutoPlayAnimations(true);
    return controller;
}
 
Example #30
Source File: PostItemAnimatedView.java    From redgram-for-reddit with GNU General Public License v3.0 5 votes vote down vote up
private DraweeController getDraweeController(PostItem item) {
    Uri thumbnailUri = Uri.parse(item.getThumbnail());
    ImageRequest thumbnail = ImageRequestBuilder.newBuilderWithSource(thumbnailUri)
            .build();

    PipelineDraweeControllerBuilder builder = Fresco.newDraweeControllerBuilder()
            .setImageRequest(thumbnail)
            .setOldController(thumbnailView.getController());

    return builder.build();
}