<?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: Kuan Peng</title>
    <description>The latest articles on DEV Community by Kuan Peng (@kuanp).</description>
    <link>https://dev.to/kuanp</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%2F409111%2F79262c98-94c6-4e7c-881f-d8ce66f94dba.png</url>
      <title>DEV Community: Kuan Peng</title>
      <link>https://dev.to/kuanp</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/kuanp"/>
    <language>en</language>
    <item>
      <title>Learnings From Building A Weather App</title>
      <dc:creator>Kuan Peng</dc:creator>
      <pubDate>Fri, 03 Jul 2020 22:31:46 +0000</pubDate>
      <link>https://dev.to/kuanp/learnings-from-building-a-weather-app-3l88</link>
      <guid>https://dev.to/kuanp/learnings-from-building-a-weather-app-3l88</guid>
      <description>&lt;h1&gt;
  
  
  Summary
&lt;/h1&gt;

&lt;p&gt;This post is about learnings from my experience building apps  while following this &lt;a href="https://www.udemy.com/course/the-complete-android-oreo-developer-course"&gt;Udemy Course&lt;/a&gt;. &lt;br&gt;
I ended up adding quite a bit to the base app, and I'm glad I did - it was really good learning to experiment with different frameworks and such. It took some time - about 6 hours or so...&lt;/p&gt;
&lt;h2&gt;
  
  
  Class Goal
&lt;/h2&gt;

&lt;p&gt;Building a weather app, that fetches and displays information from an existing public API. &lt;/p&gt;
&lt;h3&gt;
  
  
  Class Learning Goal:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Learn how to talk to public APIs and parse JSON from responses.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--cfvmZysE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/lk0q3ftllig2nlf40fzf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--cfvmZysE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/lk0q3ftllig2nlf40fzf.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  My personal Goals
&lt;/h2&gt;

&lt;p&gt;As part of trying to build this app, I wanted to learn more about:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Dependency Injection&lt;/li&gt;
&lt;li&gt;JSON parsing frameworks&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Most importantly I wanted to build a beautiful app similar to the &lt;a href="https://www.google.com/url?sa=i&amp;amp;url=https%3A%2F%2Fwww.technologyreview.com%2F2013%2F04%2F26%2F178661%2Fyahoos-weather-app-has-no-cool-interactions-and-thats-amazing%2F&amp;amp;psig=AOvVaw0nXTLobnHpfv5eCPd64SEa&amp;amp;ust=1593900087465000&amp;amp;source=images&amp;amp;cd=vfe&amp;amp;ved=0CAIQjRxqFwoTCNDVpdeKsuoCFQAAAAAdAAAAABAD"&gt;Yahoo Weather app&lt;/a&gt;, which changed its background based on current location. &lt;/p&gt;
&lt;h2&gt;
  
  
  Result
&lt;/h2&gt;
&lt;h3&gt;
  
  
  github
&lt;/h3&gt;


&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--vJ70wriM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://practicaldev-herokuapp-com.freetls.fastly.net/assets/github-logo-ba8488d21cd8ee1fee097b8410db9deaa41d0ca30b004c0c63de0a479114156f.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/kuanp"&gt;
        kuanp
      &lt;/a&gt; / &lt;a href="https://github.com/kuanp/DaWeatherApp"&gt;
        DaWeatherApp
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;
&lt;h1&gt;
DaWeatherApp&lt;/h1&gt;
&lt;p&gt;See &lt;a href="https://dev.to/kuanp/learnings-from-building-a-weather-app-3l88" rel="nofollow"&gt;https://dev.to/kuanp/learnings-from-building-a-weather-app-3l88&lt;/a&gt;&lt;/p&gt;
&lt;/div&gt;



&lt;/div&gt;
&lt;br&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/kuanp/DaWeatherApp"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;br&gt;
&lt;/div&gt;
&lt;br&gt;


&lt;h3&gt;
  
  
  Screenshot / Demo
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--8CKskjz2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/lkyefxesc59yadtvn26l.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--8CKskjz2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/lkyefxesc59yadtvn26l.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/hA_wfRgF0Fk"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h3&gt;
  
  
  UX improvements to the base app
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Beautiful backgrounds appropriate to the City and the current weather in the city. &lt;/li&gt;
&lt;li&gt;Auto completion suggestions for city names; case insensitive search&lt;/li&gt;
&lt;li&gt;Toast messages for incorrect spelling&lt;/li&gt;
&lt;li&gt;Visible Search / Weather panels that doesn't obstruct view of the photos&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Learnings
&lt;/h2&gt;

&lt;h3&gt;
  
  
  APIs
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Leverage Unsplash for great images. Unsplash APIs are quite easy and useful; used the "portrait" mode to search for photos that doesn't require resizing as much&lt;/li&gt;
&lt;li&gt;API tokens can be stored locally via BuildConfigs and git-ignored so they don't appear on the searchable web. See this &lt;a href="https://guides.codepath.com/android/Storing-Secret-Keys-in-Android"&gt;guide&lt;/a&gt;. Not the most secure for production, but good enough for learning projects. &lt;/li&gt;
&lt;li&gt;
&lt;a href="https://square.github.io/retrofit/"&gt;Retrofit&lt;/a&gt; is such a nice library to use when the API use cases are super simple. It's ability to quickly generated a usable client with auto-json parsing abilities is great (make sure to use the converters like GsonConverter). &lt;/li&gt;
&lt;li&gt;Gson is a lot easier to use than I expected. Good synergy w/ Lombok. &lt;/li&gt;
&lt;li&gt;OkHttpInterceptors are good but a little bit of a pain. I read that OkHttpClients should be shared generally, but when they need to interface w/ separate services, I think we need to create a client for each service.
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Architecture learnings
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Dagger takes a little setting up to get going (you have to create an Application Class in addition to the basic activities, and the entry point is for some reason in the activity oncreate). But once it's set up, it's a great framework that makes dependencies super easy to manage. I'll try Hilt next. &lt;/li&gt;
&lt;li&gt;How to organize package structure for D.I. is still a mystery to me.&lt;/li&gt;
&lt;li&gt;Always use Java8. Streams are just too powerful to not use. &lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Android Learnings
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;AsyncTask isn't that bad on the surface... I probably should explore alternatives given it's deprecated. &lt;/li&gt;
&lt;li&gt;ArrayAdaptors are a lot more finicky that I had expected. They require a layout (either my own or from android) to know how render a TextView. I made the mistake of passing them the activity layout, not realizing that made the dropdown box render the whole activity and crash the app. &lt;/li&gt;
&lt;li&gt;Animating background changes seems to be a pain. Didn't figure out how to do this. Good next actions. &lt;/li&gt;
&lt;li&gt;Toast can have gravity and appear in customized locations on the screen.&lt;/li&gt;
&lt;li&gt;Hiding keyboard is hard, &lt;a href="https://stackoverflow.com/questions/1109022/close-hide-android-soft-keyboard"&gt;apparently&lt;/a&gt;. Also getting Enter key pressed to act like a submit button was interesting - use

&lt;code&gt;view.setOnKeyListener&lt;/code&gt;

.
* Careful when reading from file, because it could cost a lot of latency on startup. I honestly think I should've done it async...
* Semi-Transparent layouts can help display the image underneath and at the same time help with making texts more legible. &lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Further Meaningful Augmentations
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Add Animations/Transitions to photo changes, as I've mentioned&lt;/li&gt;
&lt;li&gt;Add Temperature, humidity, etc&lt;/li&gt;
&lt;li&gt;Save preferences&lt;/li&gt;
&lt;li&gt;Make the TextLayouts that make things legible a color gradient rather than a single grey color. This could also blur the background as well..&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That's all! Thanks for reading...&lt;/p&gt;

</description>
      <category>android</category>
      <category>java</category>
    </item>
    <item>
      <title>So You Think You Know Kpop (Android App)</title>
      <dc:creator>Kuan Peng</dc:creator>
      <pubDate>Mon, 29 Jun 2020 05:20:37 +0000</pubDate>
      <link>https://dev.to/kuanp/so-you-think-you-know-kpop-android-app-3781</link>
      <guid>https://dev.to/kuanp/so-you-think-you-know-kpop-android-app-3781</guid>
      <description>&lt;h1&gt;
  
  
  Summary
&lt;/h1&gt;

&lt;p&gt;Built a celebrity guessing app as part of clip #84 of &lt;em&gt;The Complete Android 8.0 Oreo Developer Course by Rob Percival and Nick Walter&lt;/em&gt;. &lt;/p&gt;

&lt;p&gt;The goal of this exercise was to practice downloading things from the internet using AyncTask (which is actually deprecated...). &lt;/p&gt;

&lt;p&gt;Deviated somewhat from the task at hand as the website used in the course is no longer available. So I drew inspiration from Kpop. &lt;/p&gt;

&lt;h1&gt;
  
  
  Code
&lt;/h1&gt;


&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--vJ70wriM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://practicaldev-herokuapp-com.freetls.fastly.net/assets/github-logo-ba8488d21cd8ee1fee097b8410db9deaa41d0ca30b004c0c63de0a479114156f.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/kuanp"&gt;
        kuanp
      &lt;/a&gt; / &lt;a href="https://github.com/kuanp/SoYouThinkYouKnowKpop"&gt;
        SoYouThinkYouKnowKpop
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      Modified version of Guess The Celebrity
    &lt;/h3&gt;
  &lt;/div&gt;
&lt;/div&gt;


&lt;h1&gt;
  
  
  Screenshot
&lt;/h1&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--WFUavBEm--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/8coqnlasuu1mv94j1i83.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--WFUavBEm--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/8coqnlasuu1mv94j1i83.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Main Challenge
&lt;/h2&gt;

&lt;p&gt;The biggest challenge for this assignment is finding a website that has nice looking HTML to parse. I sourced content from &lt;a href="https://kingchoice.me"&gt;https://kingchoice.me&lt;/a&gt;; this website contains a lot of "celebrity lists" with nice HTML.&lt;br&gt;&lt;br&gt;
For example: &lt;a href="https://kingchoice.me/topic-hot-100-kpop-idols-rankings-2019-close-dec-31-1225.html"&gt;https://kingchoice.me/topic-hot-100-kpop-idols-rankings-2019-close-dec-31-1225.html&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--hLIF8rE9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/iu5jt9wbnlczzin3227n.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--hLIF8rE9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/iu5jt9wbnlczzin3227n.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I also found it to be overly tedious to try to create a regex to search through HTML. After all, it's semi-structured information, so instead I used &lt;a href="https://jsoup.org/"&gt;Jsoup&lt;/a&gt; to parse the HTML and get the elements I needed. Others may want to do the same. Tutorials: &lt;a href="https://medium.com/@princessdharmy/getting-started-with-jsoup-in-android-594e89dc891f"&gt;link&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Additional interesting things of note
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Used Java8; the stream / lambda paradigm is very powerful&lt;/li&gt;
&lt;li&gt;Used Lombok; its EqualsAndHashCode capability is great for deduping objects. &lt;/li&gt;
&lt;li&gt;Always fun to try to break the logic into many classes&lt;/li&gt;
&lt;li&gt;Was too lazy to properly handle exceptions. Oh well...&lt;/li&gt;
&lt;li&gt;Wonder how to use Futures or other concurrency features; pretty sure I locked UI thread while loading stuff for this one. &lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>android</category>
      <category>java</category>
    </item>
    <item>
      <title>Just built a brain trainer app</title>
      <dc:creator>Kuan Peng</dc:creator>
      <pubDate>Mon, 15 Jun 2020 02:48:04 +0000</pubDate>
      <link>https://dev.to/kuanp/eh-just-listing-some-learnings-2554</link>
      <guid>https://dev.to/kuanp/eh-just-listing-some-learnings-2554</guid>
      <description>&lt;p&gt;Mostly a recording for my own use while I take on &lt;a href="https://www.udemy.com/course/the-complete-android-oreo-developer-course/learn/lecture/8339458#content"&gt;https://www.udemy.com/course/the-complete-android-oreo-developer-course/learn/lecture/8339458#content&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Uqe1dNSq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/4ixcb0gyrxrowpmgmnck.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Uqe1dNSq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/4ixcb0gyrxrowpmgmnck.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Summary of learnings:
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;lombok is useful, easy to use for android&lt;/li&gt;
&lt;li&gt;adding dependencies to projects is done via build.gradle&lt;/li&gt;
&lt;li&gt;Having a different activity allow users to use the "back" button as part of interactions. &lt;/li&gt;
&lt;li&gt;may start learning how to unit tests some of these things, getting a bit complex and need to catch bugs. &lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Some notes:
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;Might be a good idea to get a google play account so I can send the app to other people to sue&lt;/li&gt;
&lt;li&gt;Could implement difficulty level + highest score&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Time taken:
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;About 3 hours&lt;/li&gt;
&lt;li&gt;Trying to build a grid using Relative Layouts is a bit of a pain

&lt;ul&gt;
&lt;li&gt;Might want to use fragments or some other programmatic way to do this. Might just use GridView since it's convenient. &lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>android</category>
    </item>
  </channel>
</rss>
