<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Shmuel Rosansky</title>
    <description>Tech musings and random streams of consciousness</description>
    <link>http://shmuelrosansky.com/</link>
    <atom:link href="http://shmuelrosansky.com/feed.xml" rel="self" type="application/rss+xml" />
    
      <item>
        <title>Learning Android Development</title>
        <description>&lt;p&gt;People have asked me how they can learn Android development. This is a list of free resources that I used in my growth as an Android Developer. I’m still learning and growing and I will try to keep this list current with new material. Please send me an email if you feel that I’ve missed something.&lt;/p&gt;

&lt;p&gt;###Beginner Android 
&lt;a href=&quot;http://www.vogella.com/tutorials/Android/article.html&quot;&gt;Vogella Android&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://www.youtube.com/playlist?list=PLE08A97D36D5A255F&quot;&gt;Android Bootcamp&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://developer.android.com/training/index.html&quot;&gt;Google Android&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://www.youtube.com/playlist?list=PLonJJ3BVjZW6hYgvtkaWvwAVvOFB7fkLa&quot;&gt;SlideNerd Begining Android&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Google IO 2010 - &lt;a href=&quot;https://www.youtube.com/watch?v=wDBM6wVEO70&quot;&gt;The World of ListView&lt;/a&gt; (even though ListView was replaced by RecyclerView this video is a must watch to learn fundamental concepts)&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://www.youtube.com/playlist?list=PLuR1PJnGR-IjZCTybri5Gj8l5eDbdB-uN&quot;&gt;TwistedEquations Tutorials&lt;/a&gt; - (1- 12 Begginer, 13+ Intermediate to Advanced)&lt;/p&gt;

&lt;p&gt;###Intermediate Android
&lt;a href=&quot;https://developer.android.com/training/best-ux.html&quot;&gt;Google’s UX (User Experince) best practices&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://www.google.com/design/spec/material-design/introduction.html&quot;&gt;Google’s Material Design specifcations&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://www.youtube.com/playlist?list=PLonJJ3BVjZW6CtAMbJz1XD8ELUs1KXaTD&quot;&gt;SlideNerd Andorid 5.0 Tutorials&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://www.youtube.com/playlist?list=PLonJJ3BVjZW5JdoFT0Rlt3ry5Mjp7s8cT&quot;&gt;SlideNerd Database Tutorials&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;####Important Google IO Conferences:
&lt;a href=&quot;https://www.youtube.com/watch?v=_CruQY55HOk&quot;&gt;Memory Managment&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://www.youtube.com/watch?v=lmv1dTnhLH4&amp;amp;list=PLWz5rJ2EKKc9WGUwq2gQ-coU3fSyexgOx&quot;&gt;What’s New in Android Developer Tools&lt;/a&gt; (Most of the videos in this playlist are very important)&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://www.youtube.com/watch?v=Jl3-lzlzOJI&quot;&gt;Android Design for UI Developers&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://www.youtube.com/watch?v=twmuBbC_oB8&quot;&gt;Android ProTips&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://developer.android.com/training/location/index.html&quot;&gt;Google’s Location Tutorial&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://www.youtube.com/watch?v=EisUfFS1IZk&quot;&gt;Android UI Patterns&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://android-developers.blogspot.com/&quot;&gt;Android Developers Blog&lt;/a&gt; (a must read)&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://www.youtube.com/user/gatorman55/videos&quot;&gt;Andrew Ruffolo Channel&lt;/a&gt; (he has a lot of good videos) -&lt;/p&gt;

&lt;p&gt;###Advanced Android
&lt;a href=&quot;https://www.youtube.com/watch?v=lHp3ht0Qfvk&quot;&gt;Graphics performance tips&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://www.youtube.com/watch?v=HXQhu6qfTVU&amp;amp;list=PLWz5rJ2EKKc9CBxr3BVjPTPoDPLdPIFCE&quot;&gt;Android Performance Patterns&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://www.youtube.com/watch?v=wyMyzZCbxAs&quot;&gt;Optimizing App Performance&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://www.youtube.com/watch?v=c4znvD-7VDA&quot;&gt;Writing Zippy Android Apps&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://developer.android.com/training/best-performance.html&quot;&gt;Google’s Best Practices for performance&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://www.youtube.com/watch?v=rWUyUYt9FMM&quot;&gt;Android Debugging - Method Profiling&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://www.youtube.com/watch?v=rjSwjYSBma4&quot;&gt;Learn how to performance tune an Android application&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://youtu.be/zH8o1VhmvGA&quot;&gt;Ten tips for memory management&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;###Useful Google Plus Groups
&lt;a href=&quot;https://plus.google.com/communities/116342551728637785407&quot;&gt;Android Performance Patterns&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://plus.google.com/communities/114791428968349268860&quot;&gt;Android Developer Tools&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://plus.google.com/communities/108905768919281054977&quot;&gt;Material Style Apps&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://plus.google.com/communities/116821616252548925340&quot;&gt;Material Design Apps&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://plus.google.com/communities/116667001535376136065&quot;&gt;Android App Design&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Remember, premature optimization is the root of all evil. 
&lt;a href=&quot;http://geekswithblogs.net/BlackRabbitCoder/archive/2010/06/13/premature-optimization-and-performance-anxiety.aspx&quot;&gt;See here&lt;/a&gt;
&lt;a href=&quot;https://en.wikibooks.org/wiki/Introduction_to_Software_Engineering/Architecture/Anti-Patterns&quot;&gt;and here.&lt;/a&gt;
It’s always best to get it working first and then optimize. Use Android profiling tools to identify ‘pain points’ and focus on those areas.&lt;/p&gt;

&lt;p&gt;Don’t forget about &lt;a href=&quot;http://stackoverflow.com&quot;&gt;Stackoverflow&lt;/a&gt;. It is a great place to ask (and answer) questions.&lt;/p&gt;

&lt;p&gt;Have fun and good luck!&lt;/p&gt;

</description>
        <pubDate>Thu, 28 Jan 2016 12:31:19 +0000</pubDate>
        <link>http://shmuelrosansky.com/learning/android/2016/01/28/learn-android/</link>
        <guid isPermaLink="true">http://shmuelrosansky.com/learning/android/2016/01/28/learn-android/</guid>
      </item>
    
      <item>
        <title>Shabbos Zmanim App</title>
        <description>&lt;p&gt;&lt;img src=&quot;/images/shabbos_zmanim_app_banner.jpg&quot; alt=&quot;Shabbos Zmanim App&quot; /&gt;
Three years ago I started developing my first Android app. Back then I was an IT guy, fixing computers and removing viruses, but that just didn’t appeal to me anymore. I wanted to write software and create apps. Shabbos Zmanim, and app to know when the Shabbat (Sabbath) starts and ends each week, was the first app I developed. It was a huge undertaking for me, but well worth the time and effort. What started as a small hobby with a few hundred downloads has evolved into a global app that catapulted my software development career.&lt;/p&gt;

&lt;blockquote&gt;
	  &lt;p&gt;
	  What started as a small hobby with a few hundred downloads and has evolved into a global app that catapulted my software development career.
	  &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The Jewish Sabbath begins at sunset on Friday and lasts until nightfall Saturday night. Every Friday afternoon Jews around the world light candles to signify the onset of the Sabbath. Because the Sabbath times are connected to sunset, the exact time changes with the seasons and depending on your location. Most people have calendars that show what time the Sabbath starts each week for a given location.&lt;/p&gt;

&lt;p&gt;One Friday morning I realized that there had to be a better way. Smartphones know our precise location and the date. Why not use that information to calculate the sunset time dynamically each week? That way anyone can know the correct Zmanim (times) wherever they are. Thus began Shabbos Zmanim.&lt;/p&gt;

&lt;p&gt;The development of the app has taught me a tremendous amount. Most importantly it taught me to believe in myself. I never would have dreamed of creating an app that is used by over thirty thousand people. But here I am today, with thirty two thousand downloads. The journey was a long one, involving numerous late night development sessions, a lot of beer, and many bags of M&amp;amp;Ms. I loved every moment of it.&lt;/p&gt;

&lt;blockquote&gt;
	  &lt;p&gt;
	  I loved every moment of it.
	  &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I learned that coding is hard, but so much fun. The feeling of frustration at why something isn’t working, only to realize that you mistyped a variable name or method. The feeling of joy when a user is happy with your project and sends you a message of thanks. The feeling of anxiety when you are about to launch an update and you are afraid of regressing a feature. This is the rollercoaster ride of software development, and it is a wild ride.&lt;/p&gt;

&lt;p&gt;Every day has successes and failures, but most importantly every day is a learning experience. Each mistake that I made was an opportunity to grow and learn. That time when my app crashed for users with a negative elevation taught me to validate sensor data and think about how the app can malfunction. The time when my app crashed on a specific phone and Android version taught me I need to test my apps better before launching them. I learned how to use analytics and metrics to improve my app and focus my efforts on the most used feature. I learned that I need to roll out releases slowly to my users because there will inevitably be an issue that I need to address.&lt;/p&gt;

&lt;p&gt;Now, as I launch the 4.0 update, I want to say thank you to each and every one of my users. You guys are the reason I spend time developing this app. Each piece of feedback I’ve received, both positive and negative, has helped me improve the app and my skills as a developer.&lt;/p&gt;

&lt;p&gt;So please, &lt;a href=&quot;https://play.google.com/store/apps/details?id=com.orbitdesign.easyzmanim_free&amp;amp;referrer=utm_source%3Dpersonal_website%26utm_medium%3Dblog_post&quot;&gt;download the app&lt;/a&gt;, leave some feedback, and of course, Shabbat Shalom!
	Shmuel Dovid Rosansky&lt;/p&gt;
</description>
        <pubDate>Mon, 07 Dec 2015 12:31:19 +0000</pubDate>
        <link>http://shmuelrosansky.com/android/2015/12/07/shabbos-zmanim/</link>
        <guid isPermaLink="true">http://shmuelrosansky.com/android/2015/12/07/shabbos-zmanim/</guid>
      </item>
    
      <item>
        <title>PNGs on a diet with WebP</title>
        <description>&lt;p&gt;Recently I was working on a project with a large amount of png files. Our designers had created a bunch of custom assets and animations for the project. After resizing the assets for different screen densities the project was left bloated from all the png files. It was compiling (with progaurd enabled) to over 150mb. Even though Google recently raised the apk size limit from 50mb to 100mb, we were still way oversized.&lt;/p&gt;

&lt;p&gt;I had read a while back about &lt;a href=&quot;https://developers.google.com/speed/webp/?hl=en&quot;&gt;Google’s webp&lt;/a&gt; image format and figured it would be worth a shot to try it out. Boy was I shocked. By converting our images from png format to webp format I was able to reduce our apk size from over 150mb to 34mb.&lt;/p&gt;

&lt;blockquote&gt;
	  &lt;p&gt;
	  I was able to reduce our apk size from over 150mb to 34mb.
	  &lt;/p&gt;
&lt;/blockquote&gt;

&lt;h4 id=&quot;but-what-about-compatibity&quot;&gt;But what about compatibity?&lt;/h4&gt;
&lt;p&gt;Webp is natively compatible with Android 4.0 and higher. This makes it the perfect solution for most modern projects.&lt;/p&gt;

&lt;p&gt;On Windows you can install &lt;a href=&quot;https://developers.google.com/speed/webp/docs/webp_codec&quot;&gt;this codec&lt;/a&gt; to enable you to view the images in any photo viewer. Unfortunately there is no such plugin from Google for Mac. I did find this &lt;a href=&quot;https://github.com/emin/WebPQuickLook&quot;&gt;tool&lt;/a&gt; for Mac, but I haven’t tried it.&lt;/p&gt;

&lt;h4 id=&quot;lets-do-it&quot;&gt;Let’s do it!&lt;/h4&gt;

&lt;p&gt;First you need to download the compiled binaries from &lt;a href=&quot;https://developers.google.com/speed/webp/docs/precompiled&quot;&gt;here&lt;/a&gt;.
To convert your png files you’ll want to run the cwebp executable. The &lt;a href=&quot;https://developers.google.com/speed/webp/docs/cwebp&quot;&gt;docs&lt;/a&gt; tell you eveything you need to know.&lt;/p&gt;

&lt;h4 id=&quot;warning&quot;&gt;Warning!&lt;/h4&gt;

&lt;p&gt;The Google Play store does not allow an apk to use .webp for the app icon. In in the Mac Bash script below I’ve set it to skip mipmap directories because that is where my app icons are. The Windows batch script does not check for this.&lt;/p&gt;

&lt;p&gt;Also, these scripts will overwrite your png file. Make sure to back them up!&lt;/p&gt;

&lt;h4 id=&quot;scripts&quot;&gt;Scripts&lt;/h4&gt;

&lt;p&gt;Here’s a Windows batch script I wrote to easily convert the entire project to webp. Just replace the two comments with your path structure.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-batch&quot; data-lang=&quot;batch&quot;&gt;@echo &lt;span class=&quot;na&quot;&gt;off&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;setlocal&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;enableextensions&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;enabledelayedexpansion&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;Converting&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;to&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;webp&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;script&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;by&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;Shmuel&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;Rosansky&lt;/span&gt;

&lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;Warning&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;this&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;will&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;convert&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;app&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;icons&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;also&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;!&lt;/span&gt;

&lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;Listing&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;all&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;png&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;files&lt;/span&gt;..
&lt;span class=&quot;kd&quot;&gt;SET&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;/A &lt;/span&gt;&lt;span class=&quot;kd&quot;&gt;COUNT&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;m&quot;&gt;0&lt;/span&gt;

&lt;span class=&quot;nb&quot;&gt;cd&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;path&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;to&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;your&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;res&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;folder&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;/r &lt;/span&gt;. &lt;span class=&quot;vm&quot;&gt;%%g&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(*&lt;/span&gt;.png&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;do&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;

&lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;vm&quot;&gt;%%g&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;Old&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;Size&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt;   &lt;span class=&quot;vm&quot;&gt;%%~zg&lt;/span&gt;

&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;path&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;to&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;webp&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;.exe&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;\cwebp.exe &lt;span class=&quot;vm&quot;&gt;%%g&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;-o &lt;/span&gt;&lt;span class=&quot;vm&quot;&gt;%%g&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;-q &lt;/span&gt;&lt;span class=&quot;m&quot;&gt;80&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;-alpha&lt;/span&gt;_cleanup &lt;span class=&quot;na&quot;&gt;-alpha&lt;/span&gt;_filter &lt;span class=&quot;kd&quot;&gt;best&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;-m &lt;/span&gt;&lt;span class=&quot;m&quot;&gt;6&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;-mt -af -short

&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;ren&lt;/span&gt; &lt;span class=&quot;vm&quot;&gt;%%g&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;.webp

&lt;span class=&quot;kd&quot;&gt;SET&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;/A &lt;/span&gt;&lt;span class=&quot;kd&quot;&gt;COUNT&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;+=&lt;/span&gt;&lt;span class=&quot;m&quot;&gt;1&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;File&lt;/span&gt; # &lt;span class=&quot;nv&quot;&gt;!COUNT!&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;----&lt;/span&gt;

 &lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
 &lt;span class=&quot;nb&quot;&gt;endlocal&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;If you perfer Mac here’s a bash script.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;find ./ &lt;span class=&quot;nt&quot;&gt;-type&lt;/span&gt; f &lt;span class=&quot;nt&quot;&gt;-name&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;*.png&quot;&lt;/span&gt; |while &lt;span class=&quot;nb&quot;&gt;read &lt;/span&gt;line
&lt;span class=&quot;k&quot;&gt;do  

if&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;[[&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$line&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;mipmap&quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;]]&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;then
  continue
fi&lt;/span&gt;
  	./cwebp &lt;span class=&quot;nv&quot;&gt;$line&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-o&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$line&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-q&lt;/span&gt; 80 &lt;span class=&quot;nt&quot;&gt;-alpha_cleanup&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-alpha_filter&lt;/span&gt; best &lt;span class=&quot;nt&quot;&gt;-m&lt;/span&gt; 6 &lt;span class=&quot;nt&quot;&gt;-mt&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-af&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-short&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;||&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;Convert to webp failed&apos;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;exit &lt;/span&gt;1&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
  	&lt;span class=&quot;nb&quot;&gt;mv&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$line&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;line&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;%.png&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;.webp&quot;&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;done&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;You can change the quality level by raising or lowering 80. I found no visible loss of image quality at 80. Remember, your users will be on small phone screens and will not be able to analyze every pixel like you can on your desktop.&lt;/p&gt;

</description>
        <pubDate>Sun, 11 Oct 2015 12:31:19 +0000</pubDate>
        <link>http://shmuelrosansky.com/webp/android/2015/10/11/webp-android/</link>
        <guid isPermaLink="true">http://shmuelrosansky.com/webp/android/2015/10/11/webp-android/</guid>
      </item>
    
      <item>
        <title>Jackson and Android</title>
        <description>&lt;p&gt;Json (or javascript object notiation) is a great way to transfer data over the web or persist data to disk. It is not the only way, but it is by far the most popular due to its clear-text format and ease of use. Developers love that you can read json and understand what it represents. Contrast this to a binary protocol (such as Google’s Protobuf library) which is faster and has a smaller data size, but cannot be read by humans. Readablity is the major reason why Json became the defacto standard for public api communication.&lt;/p&gt;

&lt;p&gt;There are a couple of ways to work with json on Android. You can use the standard Java/Android libraries, Google’s GSON library, or FasterXML’s Jackson library. There are &lt;a href=&quot;https://www.reddit.com/r/java/comments/340m5q/best_java_json_parser_gson_or_jackson&quot;&gt;discussions online&lt;/a&gt; which is the best to use and the generally accepted answer is Jackson. The native libraries are slow and cumbersome. GSON is the next best choice. It is really simple to use and a lot faster than the native libs. Jackson is (usally) the fastest one. But Jackson can be a bit confusing to setup.&lt;/p&gt;

&lt;p&gt;(Edit - Nov 2015 - Turns out that on Android GSON is faster for small Json strings. This is because Jackson has a longer initialization time. With larger Json strings the longer initialization time is made up by the faster proccessing time. But for shorter Json strings GSON is faster because it initializes faster.)&lt;/p&gt;

&lt;p&gt;####First, an overview of how Jackson works.&lt;/p&gt;

&lt;p&gt;In your project you need to create a model of the object which the api is sending you. Json is merely a textual representation of some object. Once you have a Pojo (plain old Java object) representing the Json object you can use that with Jackson. You have to give Jackson both the Json (either as a String or a Stream) and the class that you want to build. Jackson will then create an object of that class type using the json to fill its fields.&lt;/p&gt;

&lt;p&gt;####Great, lets do it!&lt;/p&gt;

&lt;p&gt;Step one is to add the Jackson library to your app’s gradle file.
(replace 2.5.3 with the latest version)&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-groovy&quot; data-lang=&quot;groovy&quot;&gt;&lt;span class=&quot;n&quot;&gt;compile&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;com.fasterxml.jackson.core:jackson-core:2.5.3&apos;&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;compile&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;com.fasterxml.jackson.core:jackson-annotations:2.5.3&apos;&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;compile&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;com.fasterxml.jackson.core:jackson-databind:2.5.3&apos;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;After you’ve added these lines Android Studio should prompt you to ‘sync gradle’. Do that. If that prompt doesn’t come up then you should run Build &amp;gt; Clean.&lt;/p&gt;

&lt;p&gt;Awesome, now you have Jackson added to your project.&lt;/p&gt;

&lt;p&gt;Next lets create a Pojo for the json that we’ll be using. For this example I will be using this &lt;a href=&quot;https://www.mashape.com/montanaflynn/dictionary&quot;&gt;dictionary api&lt;/a&gt; from Mashape. This is an example of the Json it returns for a search query ‘book’.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-json&quot; data-lang=&quot;json&quot;&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;definitions&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
      &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;text&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;A set of written, printed, or blank pages fastened along one side and encased between protective covers.&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
      &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;attribution&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;from The American Heritage® Dictionary of the English Language, 4th Edition&quot;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;},&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
      &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;text&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;A printed or written literary work.&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
      &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;attribution&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;from The American Heritage® Dictionary of the English Language, 4th Edition&quot;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;},&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
      &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;text&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;throw the book at  To reprimand or punish severely.&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
      &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;attribution&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;from The American Heritage® Dictionary of the English Language, 4th Edition&quot;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;We can see there are two Json objects here. The first is the Response object and that contains and array of Definition objects.&lt;/p&gt;

&lt;h4 id=&quot;building-the-java-models&quot;&gt;Building the Java models&lt;/h4&gt;

&lt;p&gt;We need Java models for these objects. To do that we head over to one of my favorite websites, &lt;a href=&quot;http://www.jsonschema2pojo.org/&quot;&gt;JsonSchema2Pojo&lt;/a&gt;. Copy the Json into the input box, set the ‘Source Type’ to Json, and hit ‘Generate’.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-java&quot; data-lang=&quot;java&quot;&gt;&lt;span class=&quot;kn&quot;&gt;package&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;com.example&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;java.util.HashMap&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;java.util.Map&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;javax.annotation.Generated&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;com.fasterxml.jackson.annotation.JsonAnyGetter&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;com.fasterxml.jackson.annotation.JsonAnySetter&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;com.fasterxml.jackson.annotation.JsonIgnore&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;com.fasterxml.jackson.annotation.JsonInclude&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;com.fasterxml.jackson.annotation.JsonProperty&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;com.fasterxml.jackson.annotation.JsonPropertyOrder&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;nd&quot;&gt;@JsonInclude&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;JsonInclude&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;Include&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;NON_NULL&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;nd&quot;&gt;@Generated&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;org.jsonschema2pojo&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;nd&quot;&gt;@JsonPropertyOrder&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;({&lt;/span&gt;
&lt;span class=&quot;s&quot;&gt;&quot;text&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt;
&lt;span class=&quot;s&quot;&gt;&quot;attribution&quot;&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;})&lt;/span&gt;
&lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Definition&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;

&lt;span class=&quot;nd&quot;&gt;@JsonProperty&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;text&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;kd&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;String&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;nd&quot;&gt;@JsonProperty&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;attribution&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;kd&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;String&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;attribution&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;nd&quot;&gt;@JsonIgnore&lt;/span&gt;
&lt;span class=&quot;kd&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Map&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Object&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;additionalProperties&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;HashMap&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Object&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;();&lt;/span&gt;

&lt;span class=&quot;cm&quot;&gt;/**
* 
* @return
* The text
*/&lt;/span&gt;
&lt;span class=&quot;nd&quot;&gt;@JsonProperty&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;text&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;String&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;getText&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;cm&quot;&gt;/**
* 
* @param text
* The text
*/&lt;/span&gt;
&lt;span class=&quot;nd&quot;&gt;@JsonProperty&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;text&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;setText&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;String&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;text&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;cm&quot;&gt;/**
* 
* @return
* The attribution
*/&lt;/span&gt;
&lt;span class=&quot;nd&quot;&gt;@JsonProperty&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;attribution&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;String&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;getAttribution&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;attribution&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;cm&quot;&gt;/**
* 
* @param attribution
* The attribution
*/&lt;/span&gt;
&lt;span class=&quot;nd&quot;&gt;@JsonProperty&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;attribution&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;setAttribution&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;String&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;attribution&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;attribution&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;attribution&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;nd&quot;&gt;@JsonAnyGetter&lt;/span&gt;
&lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Map&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Object&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;getAdditionalProperties&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;additionalProperties&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;nd&quot;&gt;@JsonAnySetter&lt;/span&gt;
&lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;setAdditionalProperty&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;String&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Object&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;value&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;additionalProperties&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;put&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;value&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-java&quot; data-lang=&quot;java&quot;&gt;&lt;span class=&quot;kn&quot;&gt;package&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;com.example&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;java.util.ArrayList&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;java.util.HashMap&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;java.util.List&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;java.util.Map&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;javax.annotation.Generated&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;com.fasterxml.jackson.annotation.JsonAnyGetter&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;com.fasterxml.jackson.annotation.JsonAnySetter&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;com.fasterxml.jackson.annotation.JsonIgnore&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;com.fasterxml.jackson.annotation.JsonInclude&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;com.fasterxml.jackson.annotation.JsonProperty&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;com.fasterxml.jackson.annotation.JsonPropertyOrder&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;nd&quot;&gt;@JsonInclude&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;JsonInclude&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;Include&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;NON_NULL&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;nd&quot;&gt;@Generated&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;org.jsonschema2pojo&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;nd&quot;&gt;@JsonPropertyOrder&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;({&lt;/span&gt;
&lt;span class=&quot;s&quot;&gt;&quot;definitions&quot;&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;})&lt;/span&gt;
&lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Response&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;

&lt;span class=&quot;nd&quot;&gt;@JsonProperty&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;definitions&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;kd&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;List&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;Definition&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;definitions&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;ArrayList&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;Definition&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;();&lt;/span&gt;
&lt;span class=&quot;nd&quot;&gt;@JsonIgnore&lt;/span&gt;
&lt;span class=&quot;kd&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Map&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Object&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;additionalProperties&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;HashMap&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Object&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;();&lt;/span&gt;

&lt;span class=&quot;cm&quot;&gt;/**
* 
* @return
* The definitions
*/&lt;/span&gt;
&lt;span class=&quot;nd&quot;&gt;@JsonProperty&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;definitions&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;List&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;Definition&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;getDefinitions&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;definitions&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;cm&quot;&gt;/**
* 
* @param definitions
* The definitions
*/&lt;/span&gt;
&lt;span class=&quot;nd&quot;&gt;@JsonProperty&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;definitions&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;setDefinitions&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;List&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;Definition&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;definitions&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;definitions&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;definitions&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;nd&quot;&gt;@JsonAnyGetter&lt;/span&gt;
&lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Map&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Object&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;getAdditionalProperties&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;additionalProperties&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;nd&quot;&gt;@JsonAnySetter&lt;/span&gt;
&lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;setAdditionalProperty&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;String&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Object&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;value&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;additionalProperties&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;put&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;value&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Boom. We now have our Java Pojo models. Add them to your project (I like to create a models package and put all my model objects there.)&lt;/p&gt;

&lt;h4 id=&quot;create-the-actual-java-objects-from-the-json&quot;&gt;Create the actual Java objects from the Json&lt;/h4&gt;

&lt;p&gt;In your project write code to get the Json. You can do this with HttpURLConnection, OkHttp, or just loading a String. Once you have the Json Stream or Json String these are the lines that do the magic:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-java&quot; data-lang=&quot;java&quot;&gt;&lt;span class=&quot;nc&quot;&gt;ObjectMapper&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;objectMapper&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;ObjectMapper&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;();&lt;/span&gt;
&lt;span class=&quot;nc&quot;&gt;Response&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;response&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;objectMapper&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;readValue&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;okhttpResponse&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;body&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;().&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;byteStream&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(),&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Response&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;We are creating a Jackson ObjectMapper and providing it with our input (in this case I used a Stream but you can replace that with a String) and the class that we want to build. Jackson handles everything else.&lt;/p&gt;

&lt;p&gt;That’s it. Now you have a Pojo for the server’s response. You can use it in your Java code wherever needed.&lt;/p&gt;
</description>
        <pubDate>Mon, 20 Jul 2015 12:31:19 +0000</pubDate>
        <link>http://shmuelrosansky.com/jackson/android/2015/07/20/jackson-android/</link>
        <guid isPermaLink="true">http://shmuelrosansky.com/jackson/android/2015/07/20/jackson-android/</guid>
      </item>
    
      <item>
        <title>Obligatory Hello World</title>
        <description>&lt;p&gt;I still remember the first line of code I wrote. It was a ‘Hello World’ written in python. Since then I’ve learnt that Hello World is more than just being polite, it’s part of our culture as programmers. In fact, one way to rank languages is by how fast you can write a Hello World program. In that respect, python is pretty awesome.&lt;/p&gt;

&lt;p&gt;On a side note, I recently picked up python again after a 7+ year hiatus. Back then I had no idea what I was doing, all I wanted to do was develop a video game. Yah, Rollercoaster Tycoon was that awesome. It made me dream of creating my own game one day. But I digress.&lt;/p&gt;

&lt;p&gt;Python turned out to be a fun and fast way of accomplishing a task that was needed. At first I was going to write something in Java to hit an api and do the work I needed. After firing up intellij I knew there had to be a better way.&lt;/p&gt;

&lt;blockquote&gt;
	  &lt;p&gt;
	  A software engineer must know his tools
	  &lt;/p&gt;
  &lt;footer&gt;&lt;a href=&quot;http://edusagar.com/articles/view/61/A-software-engineer-must-know-his-tools&quot;&gt;Pankaj Pal&lt;/a&gt;&lt;/footer&gt;
&lt;/blockquote&gt;

&lt;p&gt;Java is my best language, but for this task it just seemed overkill. Enter python.&lt;/p&gt;

&lt;p&gt;It took a bit of Googling to get up to speed after not using python for 7 years, but it was well worth it. Python is a ‘Hello Word’ friendly language and really easy to use.&lt;/p&gt;

&lt;p&gt;Lesson learned: Know your tools. If all you have is a hammer, everything looks like a nail.&lt;/p&gt;
</description>
        <pubDate>Wed, 15 Jul 2015 12:31:19 +0000</pubDate>
        <link>http://shmuelrosansky.com/random/2015/07/15/obligatory-hello-world/</link>
        <guid isPermaLink="true">http://shmuelrosansky.com/random/2015/07/15/obligatory-hello-world/</guid>
      </item>
    
  </channel>
</rss>
