<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Premith</title>
    <description>The latest articles on DEV Community by Premith (@premithk).</description>
    <link>https://dev.to/premithk</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F51165%2Fa3f046d5-fe8d-458e-85bd-ccf29c819421.png</url>
      <title>DEV Community: Premith</title>
      <link>https://dev.to/premithk</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/premithk"/>
    <language>en</language>
    <item>
      <title>How to use square‘s picasso library with firebase storage</title>
      <dc:creator>Premith</dc:creator>
      <pubDate>Mon, 13 Aug 2018 08:34:01 +0000</pubDate>
      <link>https://dev.to/premithk/how-to-use-squares-picasso-library-with-firebase-storage-1j21</link>
      <guid>https://dev.to/premithk/how-to-use-squares-picasso-library-with-firebase-storage-1j21</guid>
      <description>

&lt;p&gt;Recently i was migrating an app’s backend from parse to firebase. The move to firebase’s real-time database was a breeze with minor re-factoring. I hit a block when i wanted to load images stored in firebase storage into an android Imageview. The existing code had used the excellent picasso from square for image caching and the likes. Earlier i had stored the images as blobs inside my parse database. Firebase storage has image location coming in this format. gs://appname.appspot.com/Images/1.jpg.&lt;/p&gt;

&lt;p&gt;One option was to load the image location (http based)inside a field in the real time database and access it using picasso. This particular app had lot of images and i didn’t want to go that route. Reading through picasso’s documentation i came across picasso’s request handler. &lt;a href="https://square.github.io/picasso/2.x/picasso/com/squareup/picasso/RequestHandler.html"&gt;https://square.github.io/picasso/2.x/picasso/com/squareup/picasso/RequestHandler.html&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Actually the implementation was easy to code and simple enough. Below is the gist&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;  &lt;/div&gt;

&lt;p&gt;The changes while actual loading is that you need to create a picasso instance using the builder while passing our custom request handler. Eg:&lt;/p&gt;

&lt;p&gt;&lt;br&gt;
&lt;code&gt;picassoInstance= new  Picasso.Builder(this.activityContext.getApplicationContext())&lt;br&gt;
.addRequestHandler(new FireBaseRequestHandler())&lt;br&gt;
.build();&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;Then to load image into the imageview&lt;/p&gt;

&lt;p&gt;&lt;code&gt;picassoInstance.load(&amp;lt;firebasestorageurl&amp;gt;)&lt;br&gt;
.into(imageview);&lt;/code&gt;&lt;/p&gt;


</description>
      <category>android</category>
      <category>java</category>
      <category>picasso</category>
      <category>firebase</category>
    </item>
  </channel>
</rss>
