Can someone please explain the real difference between ImageView and com.facebook.drawee.view.SimpleDraweeView.and why fresco not use imageview.?
can we upload a image on server through fresco? if yes please share code..
Can someone please explain the real difference between ImageView and com.facebook.drawee.view.SimpleDraweeView.and why fresco not use imageview.?
can we upload a image on server through fresco? if yes please share code..
Unlike Codo's answer that discusses the "deeper" difference between these classes (see The Image Pipeline section here), I'll discuss the usability difference.
Going over the source code of SimpleDraweeView
and related classes one can see the following inheritance hierarchy:
public class SimpleDraweeView extends GenericDraweeView
public class GenericDraweeView extends DraweeView<GenericDraweeHierarchy>
public class DraweeView<DH extends DraweeHierarchy> extends ImageView
The following description appears before the class definition of DraweeView
:
Although
ImageView
is subclassed instead of subclassingView
directly, this class does not supportImageView
'ssetImageXxx
,setScaleType
and similar methods. ExtendingImageView
is a short term solution in order to inherit some of its implementation (padding calculations, etc.). This class is likely to be converted to extendView
directly in the future, so avoid usingImageView
's methods and properties (T5856175).
So we know that DraweeView
presently inherits from ImageView
- which usually means that "it does everything ImageView
does and more" (with the exceptions discussed in the comment block above). This simplistic approach can give you a general idea but ignores the most important aspect of compatibility with Fresco.
The Fresco docs explain how to use drawees, and you can see right from their XML definition that they are much more customizable than ImageView
:
<com.facebook.drawee.view.SimpleDraweeView
android:id="@+id/my_image_view"
android:layout_width="20dp"
android:layout_height="20dp"
fresco:fadeDuration="300"
fresco:actualImageScaleType="focusCrop"
fresco:placeholderImage="@color/wait_color"
fresco:placeholderImageScaleType="fitCenter"
fresco:failureImage="@drawable/error"
fresco:failureImageScaleType="centerInside"
fresco:retryImage="@drawable/retrying"
fresco:retryImageScaleType="centerCrop"
fresco:progressBarImage="@drawable/progress_bar"
fresco:progressBarImageScaleType="centerInside"
fresco:progressBarAutoRotateInterval="1000"
fresco:backgroundImage="@color/blue"
fresco:overlayImage="@drawable/watermark"
fresco:pressedStateOverlayImage="@color/red"
fresco:roundAsCircle="false"
fresco:roundedCornerRadius="1dp"
fresco:roundTopLeft="true"
fresco:roundTopRight="false"
fresco:roundBottomLeft="false"
fresco:roundBottomRight="true"
fresco:roundWithOverlayColor="@color/corner_color"
fresco:roundingBorderWidth="2dp"
fresco:roundingBorderColor="@color/border_color"
/>
As for uploads - it seems like Fresco is only intended for downloading images. You might want to look into Robospice/Retrofit for your uploading needs.
The facebook provides its own ImageView, So rather than creating your own CustomView or ImageView you can use their View.
But, Remember you could have a less control on it as compared with your own Custom View.
This gives you a complete package and Functionality for a Button, View or Anything like that.
Like this here for Rounded Corners of a ImageView
<de.hdodenhof.circleimageview.CircleImageView
android:layout_width="50dp"
android:layout_height="50dp"
android:id="@+id/userImage"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp" />
Android versions before Android 5 have serious problems with handling a large number of images. Android 2 has problems if they are on the Java heap and Android 4 doesn't properly release them if you don't destroy the activity.
So Fresco moves images to the native heap (Android 2) and implements its own reference counting for Android 4 in order to know when the image is no longer reference and can be recycled.
They replace ImageView
with SimpleDrawView
in order to have full control about the references to the images. In fact, only there low level API gives you direct access to the image at all. Otherwise their approach with reference counting would work.