本文整理汇总了Java中com.facebook.drawee.backends.pipeline.Fresco类的典型用法代码示例。如果您正苦于以下问题:Java Fresco类的具体用法?Java Fresco怎么用?Java Fresco使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Fresco类属于com.facebook.drawee.backends.pipeline包,在下文中一共展示了Fresco类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onViewCreated
import com.facebook.drawee.backends.pipeline.Fresco; //导入依赖的package包/类
@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);
}
示例2: onCreate
import com.facebook.drawee.backends.pipeline.Fresco; //导入依赖的package包/类
@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);
}
示例3: init
import com.facebook.drawee.backends.pipeline.Fresco; //导入依赖的package包/类
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);
}
示例4: onCreate
import com.facebook.drawee.backends.pipeline.Fresco; //导入依赖的package包/类
@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();
}
}
示例5: onBind
import com.facebook.drawee.backends.pipeline.Fresco; //导入依赖的package包/类
@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);
}
示例6: initAnimation
import com.facebook.drawee.backends.pipeline.Fresco; //导入依赖的package包/类
@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);
}
});
}
示例7: onCreate
import com.facebook.drawee.backends.pipeline.Fresco; //导入依赖的package包/类
@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));
}
示例8: loadThumb
import com.facebook.drawee.backends.pipeline.Fresco; //导入依赖的package包/类
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);
}
示例9: setImageSmall
import com.facebook.drawee.backends.pipeline.Fresco; //导入依赖的package包/类
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);
}
示例10: onCreate
import com.facebook.drawee.backends.pipeline.Fresco; //导入依赖的package包/类
@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);
}
示例11: setIconSource
import com.facebook.drawee.backends.pipeline.Fresco; //导入依赖的package包/类
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));
}
}
示例12: FrescoInit
import com.facebook.drawee.backends.pipeline.Fresco; //导入依赖的package包/类
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);
}
示例13: displayImage
import com.facebook.drawee.backends.pipeline.Fresco; //导入依赖的package包/类
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);
}
示例14: instantiateItem
import com.facebook.drawee.backends.pipeline.Fresco; //导入依赖的package包/类
@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;
}
示例15: onCreate
import com.facebook.drawee.backends.pipeline.Fresco; //导入依赖的package包/类
@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);
}