<?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: Raul Montero</title>
    <description>The latest articles on DEV Community by Raul Montero (@raulmonteroc).</description>
    <link>https://dev.to/raulmonteroc</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%2F53784%2F96cfe07b-a5a2-4df3-89ac-0b20b6055d68.jpg</url>
      <title>DEV Community: Raul Montero</title>
      <link>https://dev.to/raulmonteroc</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/raulmonteroc"/>
    <language>en</language>
    <item>
      <title>Remove committed file from a repository</title>
      <dc:creator>Raul Montero</dc:creator>
      <pubDate>Thu, 31 Oct 2019 14:30:27 +0000</pubDate>
      <link>https://dev.to/raulmonteroc/remove-committed-file-from-a-repository-1634</link>
      <guid>https://dev.to/raulmonteroc/remove-committed-file-from-a-repository-1634</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--zFdJqsYW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://raulmonteroc.com/wp-content/uploads/2019/10/gitignore.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--zFdJqsYW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://raulmonteroc.com/wp-content/uploads/2019/10/gitignore.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;No matter what kind of project you are working on, they all have auto-generated files that don’t need to go inside the remote repository, but more often than not, we find ourselves working on projects that have those files already pushed and end up having to deal with conflicts that could have been avoided otherwise.  &lt;/p&gt;

&lt;p&gt;Thankfully, there is a way to remove those files and make sure no other developer commits them ever again.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Remove the file locally
&lt;/h3&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;git &lt;span class="nb"&gt;rm&lt;/span&gt; &lt;span class="nt"&gt;-r&lt;/span&gt; &lt;span class="nt"&gt;--cached&lt;/span&gt; route/to/file.cs
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h3&gt;
  
  
  2. Prevent the file to be added ever again by adding it to the .gitignore definition.
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Open the terminal and navigate to the root of your project folder&lt;/li&gt;
&lt;li&gt;Enter &lt;code&gt;open .gitignore&lt;/code&gt; to open the gitignore file in your default text editor. If you don’t have one you can find one configured for your specific project in &lt;a href="https://www.gitignore.io/"&gt;gitignore.io&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Add the relative path of the file you wish to ignore. Here’s a sample ignoring the AndroidResource.designer.cs of a xamarin project
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# http://Xamarin.Android Resource.Designer.cs files&lt;/span&gt;

&lt;span class="k"&gt;**&lt;/span&gt;/&lt;span class="k"&gt;*&lt;/span&gt;.Android/&lt;span class="k"&gt;**&lt;/span&gt;/[Rr]esource.[Dd]esigner.cs
&lt;span class="k"&gt;**&lt;/span&gt;/&lt;span class="k"&gt;*&lt;/span&gt;.Droid/&lt;span class="k"&gt;**&lt;/span&gt;/[Rr]esource.[Dd]esigner.cs
&lt;span class="k"&gt;**&lt;/span&gt;/Android/&lt;span class="k"&gt;**&lt;/span&gt;/[Rr]esource.[Dd]esigner.cs
&lt;span class="k"&gt;**&lt;/span&gt;/Droid/&lt;span class="k"&gt;**&lt;/span&gt;/[Rr]esource.[Dd]esigner.cs
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h3&gt;
  
  
  3. Stash changed files
&lt;/h3&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;git add route/to/file.cs &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; git add .gitignore
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h3&gt;
  
  
  4. Commit changes
&lt;/h3&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;git commit &lt;span class="nt"&gt;-m&lt;/span&gt; &lt;span class="s2"&gt;"Removed auto-generated [file] from repository"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h3&gt;
  
  
  5. Push changes
&lt;/h3&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;git push origin master
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



</description>
      <category>git</category>
    </item>
    <item>
      <title>Mobile releases made easy with Appcenter.</title>
      <dc:creator>Raul Montero</dc:creator>
      <pubDate>Thu, 10 Oct 2019 00:32:34 +0000</pubDate>
      <link>https://dev.to/raulmonteroc/mobile-releases-made-easy-with-appcenter-hnc</link>
      <guid>https://dev.to/raulmonteroc/mobile-releases-made-easy-with-appcenter-hnc</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--e_N0wQXg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://raulmonteroc.com/wp-content/uploads/2019/10/Appcenter-header.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--e_N0wQXg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://raulmonteroc.com/wp-content/uploads/2019/10/Appcenter-header.jpg" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;This article is part of the &lt;a href="https://medium.com/@claudiosanchez/the-september-xamarin-best-practices-challenge-819e098c8314"&gt;October xamarin best practices challenge&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;




&lt;p&gt;Release, deployment, and distribution are some of the words we use to refer to the process of putting the latest features and enhancements of our application at the hands of our users. In the context of mobile apps, this translates to the process that allows our users to download the latest version of the app to see what’s new.  &lt;/p&gt;

&lt;p&gt;This is a process that tends to grow in complexity as our application evolves, needing more checks, validations, scripts to be run, testing environments to be created and so on, to ensure everything works and the users get the best experience possible. As you might expect, this causes the releases to become more delicate and error-prone (when done manually) as the time passes and therefore taking longer to arrive at our user’s hands.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;With Appcenter your app is a couple of clicks away from your users, every time, in every platform.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Thankfully, it doesn’t have to be like this. With tools like Appcenter, we can automatize most (if not all) of the steps of our release process to significantly reduce its complexity. Here, we are going to walk through the process of creating a release using the appcenter email release and while at it, understand the configuration options available to us..&lt;/p&gt;

&lt;h2&gt;
  
  
  Connect your apps to appcenter
&lt;/h2&gt;

&lt;p&gt;The first thing we need to do is access &lt;a href="https://appcenter.ms"&gt;Appcenter’s website&lt;/a&gt; and log in using your preferred service. It currently supports Microsoft, Github, Facebook, and Google.  &lt;/p&gt;

&lt;p&gt;Once you are inside, you should see a screen similar to this one.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--qD9Gj7fg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://raulmonteroc.com/wp-content/uploads/2019/09/Appcenter-start-screen-1-1024x816.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--qD9Gj7fg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://raulmonteroc.com/wp-content/uploads/2019/09/Appcenter-start-screen-1-1024x816.png" alt="Appcenter start screen"&gt;&lt;/a&gt;Appcenter start screen&lt;/p&gt;

&lt;p&gt;Click on the Add app button to start configuring our application.&lt;/p&gt;

&lt;p&gt;You will notice you’ll need to configure an app for each platform you support, even if you are using a cross-platform technology. For our case, we are going to use xamarin with apps releases for android and iOS. Fill in the name and platform of the app and click Ok to display it on the dashboard.  &lt;/p&gt;

&lt;p&gt;This is how the app setup looks like for the android app. For iOS, the configuration is the same, except we’ll select iOS instead.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Nq3zqQGP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://raulmonteroc.com/wp-content/uploads/2019/09/Appcenter-android-app-2-1024x816.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Nq3zqQGP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://raulmonteroc.com/wp-content/uploads/2019/09/Appcenter-android-app-2-1024x816.png" alt="Define applications on Appcenter"&gt;&lt;/a&gt;Define applications on AppCenter&lt;/p&gt;

&lt;p&gt;Once that’s done, your dashboard will be updated with two new applications, one for android and another for iOS.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s---JwSbrLQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://raulmonteroc.com/wp-content/uploads/2019/09/Dashboard-updated-1024x816.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s---JwSbrLQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://raulmonteroc.com/wp-content/uploads/2019/09/Dashboard-updated-1024x816.png" alt="Appcenter dashboard with apps"&gt;&lt;/a&gt;Dashboard with apps&lt;/p&gt;

&lt;p&gt;The last thing we need to do is to connect these applications to the repository where the source code is located.  &lt;/p&gt;

&lt;p&gt;To do so, we select either one of the applications available on the dashboard and once inside select the &lt;em&gt;Build&lt;/em&gt; option from the side menu. There you will find the available repository services Appcenter supports, find yours, look for your repository and click ok.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--1vxOBqpo--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://raulmonteroc.com/wp-content/uploads/2019/09/Appcenter-connect-to-repo-1024x766.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--1vxOBqpo--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://raulmonteroc.com/wp-content/uploads/2019/09/Appcenter-connect-to-repo-1024x766.png" alt="Connect to repository"&gt;&lt;/a&gt;Connect to repository&lt;/p&gt;

&lt;p&gt;After that, you should be able to see all the branches available from your repository indicating that the connection was performed successfully.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--keDOdxft--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://raulmonteroc.com/wp-content/uploads/2019/09/Appcenter-repo-connected-1024x766.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--keDOdxft--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://raulmonteroc.com/wp-content/uploads/2019/09/Appcenter-repo-connected-1024x766.png" alt="Appcenter connected repository screen"&gt;&lt;/a&gt;Connected repository&lt;/p&gt;

&lt;h2&gt;
  
  
  Defining automatic builds
&lt;/h2&gt;

&lt;p&gt;The next thing in the list is to configure the build so it knows how to build (and run) our app automatically, whenever new changes are added.&lt;/p&gt;

&lt;p&gt;Since we are already in the build tab of our application (from the previous step), we just need to select which branch we want to build and click on the &lt;em&gt;Configure Build&lt;/em&gt; button on the next screen.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--AKjkLgM5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://raulmonteroc.com/wp-content/uploads/2019/10/Screen-Shot-2019-10-02-at-3.31.15-PM-1024x771.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--AKjkLgM5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://raulmonteroc.com/wp-content/uploads/2019/10/Screen-Shot-2019-10-02-at-3.31.15-PM-1024x771.png" alt="Create build configuration"&gt;&lt;/a&gt;Create build configuration&lt;/p&gt;

&lt;p&gt;This action will display a side screen with all the options available for us to customize our build.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--F8zKYuwy--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://raulmonteroc.com/wp-content/uploads/2019/10/Screen-Shot-2019-10-02-at-4.34.10-PM-967x1024.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--F8zKYuwy--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://raulmonteroc.com/wp-content/uploads/2019/10/Screen-Shot-2019-10-02-at-4.34.10-PM-967x1024.png" alt="Appcenter build configuration details"&gt;&lt;/a&gt;Build configuration details&lt;/p&gt;

&lt;p&gt;It can be a bit overwhelming at first, but it’s actually quite simple once you understand the basics around it. Let’s dive into each option to see them in detail&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Project&lt;/strong&gt; : The .csproj file to build upon&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Configuration:&lt;/strong&gt; The build configuration to use, either Debug or release for android  and additional AdHoc and AppStore for iOS only&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;SDK Version&lt;/strong&gt; : The version of Xamarin.Android or Xamarin.iOSwe’ll be using to build our project.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Build Scripts:&lt;/strong&gt; Scripts to be run before or after the build is executed.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Build Frequency:&lt;/strong&gt; Either build this automatically on every push or manually whenever we click the build button directly on Appcenter.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Android App Bundle:&lt;/strong&gt; Specific to Android, tells Appcenter to use the new distribution mechanism for android apps. More info &lt;a href="https://developer.android.com/platform/technology/app-bundle"&gt;here&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Increment version code:&lt;/strong&gt; Automatically increment the build version of the app each time the build is run. This is especially useful if you are distributing to the stores where each build number must be unique.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Environment Variables:&lt;/strong&gt; This allows you to provide placeholders in your configuration files that are later replaced with the values provided here. Really useful when dealing with sensitive data you don’t want to store in the repository or values that change depending on the environment the app is run on.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Sign Builds:&lt;/strong&gt; We will see more of this later. For now, you can think of sign build as a way to certify the app’s binary to be safe to use and not harmful for users.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Test on a real device:&lt;/strong&gt; Configure UI Test to run on real devices available on the Appcenter’s device farm.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Advance: Build Status Badge:&lt;/strong&gt; Link to the badge with current build status. This is usually found in readme-files in repositories.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;With this new knowledge, it’s time to create our own build configuration that will let us know that our application was built correctly and was able to be launched on a real device.  &lt;/p&gt;

&lt;p&gt;Our setup will be as follows:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Set the &lt;strong&gt;project&lt;/strong&gt; to the android/iOS .csproj file&lt;/li&gt;
&lt;li&gt;Set the &lt;strong&gt;configuration&lt;/strong&gt; to Release mode on Android and Ad Hoc for iOS.&lt;/li&gt;
&lt;li&gt;Set the &lt;strong&gt;build frequency&lt;/strong&gt; to build on every push&lt;/li&gt;
&lt;li&gt;Enable the &lt;strong&gt;Android app bundle&lt;/strong&gt; when building the android app&lt;/li&gt;
&lt;li&gt;Enable &lt;strong&gt;test on a real device&lt;/strong&gt; to be sure it can be launched.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--R0D2KjFF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://raulmonteroc.com/wp-content/uploads/2019/10/Build-configuration-Android-965x1024.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--R0D2KjFF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://raulmonteroc.com/wp-content/uploads/2019/10/Build-configuration-Android-965x1024.png" alt="Appcenter build configuration"&gt;&lt;/a&gt;Basic Build configuration&lt;/p&gt;

&lt;p&gt;After setting the configuration, we should be able to create a build and be sure our app is building correctly without issues. Press the &lt;em&gt;Save and Build&lt;/em&gt; button to start running the build and after it finishes, you should see a screen similar to the one below, with all the logs, details and final status of the build performed.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--AB9-4c46--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://raulmonteroc.com/wp-content/uploads/2019/10/Android-build-result-1024x792.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--AB9-4c46--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://raulmonteroc.com/wp-content/uploads/2019/10/Android-build-result-1024x792.png" alt="Appcenter buil output"&gt;&lt;/a&gt;Buil output&lt;/p&gt;

&lt;h2&gt;
  
  
  Add release configuration
&lt;/h2&gt;

&lt;p&gt;Now that we are able to create builds automatically, we can focus on how to distribute it to users by email. To do so, we need two things:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Sign Builds.&lt;/li&gt;
&lt;li&gt;Add Sign build configuration to our build process in AppCenter.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;What is a signed build? Basically, it’s the signature of the author and it’s used to claim ownership of a given application. Without it, you can’t publish your app to either of the stores (AppStore or Play Store) or even run it on a real user’s device, so in order to distribute our app, we first need to have it properly signed.  &lt;/p&gt;

&lt;p&gt;The signing process of each platform is different and therefore requires different configuration steps to be performed for Appcenter to validate it as a signed build., we will see them in detail.&lt;/p&gt;

&lt;h4&gt;
  
  
  Sign Android builds
&lt;/h4&gt;

&lt;p&gt;The signing process in Android is straight forward, we just need to generate a keystore file and connect it to the build configuration we already have in place.  &lt;/p&gt;

&lt;p&gt;To create the file you can follow &lt;a href="https://developer.android.com/studio/publish/app-signing#generate-key"&gt;the official android guide&lt;/a&gt; or if using Xamarin, you can use &lt;a href="https://docs.microsoft.com/en-us/xamarin/android/deploy-test/signing/?tabs=macos"&gt;Microsoft’s guide using Visual Studio&lt;/a&gt;  &lt;/p&gt;

&lt;p&gt;With the keystore file at hand, we go to the build configuration (for our android app) in Appcenter and enable the sign builds option. We’ll need to attach the file and provide the keystore’s password and alias.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--1qM0QLUw--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://raulmonteroc.com/wp-content/uploads/2019/10/Screen-Shot-2019-10-09-at-10.25.59-AM.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--1qM0QLUw--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://raulmonteroc.com/wp-content/uploads/2019/10/Screen-Shot-2019-10-09-at-10.25.59-AM.png" alt="Sign Android Builds&amp;lt;br&amp;gt;
"&gt;&lt;/a&gt;Sign Android Builds&lt;/p&gt;

&lt;h4&gt;
  
  
  Sign iOS builds
&lt;/h4&gt;

&lt;p&gt;Unlike Android, Apple doesn’t allow us to run our app on just any device, not even on our development environment, to do so, we must sign our builds using two files:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Provisioning Profile (.mobileprovising)&lt;/li&gt;
&lt;li&gt;Certificate (.p12)&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Those files are created in our account inside the &lt;a href="https://developer.apple.com/"&gt;Apple developers portal&lt;/a&gt;, there we will need to specify which devices can install our app and what kind of services it will be using, then we’ll download the mobileprovising which contains all these details, along with a certificate file that must be installed on our mac which validates our identity as a developer of our app.  &lt;/p&gt;

&lt;p&gt;For a detailed guide on how to get those files, you can see the &lt;a href="https://help.apple.com/xcode/mac/current/#/dev60b6fbbc7"&gt;official guide&lt;/a&gt; or use &lt;a href="https://docs.microsoft.com/en-us/appcenter/build/ios/uploading-signing-files"&gt;Microsoft’s guide&lt;/a&gt; for a more visual walkthrough.&lt;/p&gt;

&lt;p&gt;Same as with android, now that we have the required files, we go to the build configuration (for our iOS app) in Appcenter and enable the sign build option, attaching the necessary files and providing the certificate password as well.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--6XPUiwUM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://raulmonteroc.com/wp-content/uploads/2019/10/Sign-iOS-Builds.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--6XPUiwUM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://raulmonteroc.com/wp-content/uploads/2019/10/Sign-iOS-Builds.png" alt="Sign iOS Builds"&gt;&lt;/a&gt;Sign iOS Builds&lt;/p&gt;

&lt;h4&gt;
  
  
  Releasing the app
&lt;/h4&gt;

&lt;p&gt;With the signed builds in place we have only one thing remaining, distribute the app to our users. We do so by enabling the option &lt;em&gt;“Distribute Build”&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--7NVCh1r7--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://raulmonteroc.com/wp-content/uploads/2019/10/Distribute-Builds.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--7NVCh1r7--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://raulmonteroc.com/wp-content/uploads/2019/10/Distribute-Builds.png" alt="Distribute iOS Release"&gt;&lt;/a&gt;Distribute Release&lt;/p&gt;

&lt;p&gt;Here you will see two options: Groups and Store. With groups, we’ll distribute it to a specific number of users via email while store will connect to the platform’s application store and distribute it directly there.  &lt;/p&gt;

&lt;p&gt;In this case, we will focus on the first one, groups. This is a good option when you want to deliver internal builds for testing purposes or even to provide key people with the latest available build.  &lt;/p&gt;

&lt;p&gt;There are two things to take into account in order for this to work properly:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;On android, be sure &lt;a href="https://android.gadgethacks.com/how-to/android-basics-enable-unknown-sources-sideload-apps-0161947/"&gt;to enable “applications from unknown sources” option&lt;/a&gt; on the device the app is going to be installed on.&lt;/li&gt;
&lt;li&gt;On iOS, be sure the provisioning profile type is either Apple distribution or iOS distribution and includes all the services your app is using.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Finally, if you want to modify the distribution list, you can do so by going to the distribute/groups option on the side menu and create additional user groups and add as many members as you need.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--MIXz_3Ms--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://raulmonteroc.com/wp-content/uploads/2019/10/Groups-1024x890.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--MIXz_3Ms--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://raulmonteroc.com/wp-content/uploads/2019/10/Groups-1024x890.png" alt="Appcenter distribution list configuration"&gt;&lt;/a&gt;Distribution list configuration&lt;/p&gt;

&lt;h2&gt;
  
  
  Final thoughts
&lt;/h2&gt;

&lt;p&gt;Awesome!, at this point, we have configured Appcenter to release a new version directly to our users every time a new change is added, automatically, without further interaction, allowing us to focus our efforts on other things, like creating more features and enhancements for our app.  &lt;/p&gt;

&lt;p&gt;The best thing is, once you get used to the process, it becomes a matter of minutes to configure an automatic release pipeline on any app you work with.&lt;/p&gt;

&lt;p&gt;A thing to notice here is that the release we just did is simple, in a production application we might need extra configuration to be done before releasing the app to our users. Thankfully, Appcenter has a few tricks left that enable support for more complex scenarios, such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Running pre and post scripts.&lt;/li&gt;
&lt;li&gt;Updating the value of different configuration variables, depending on the release type.&lt;/li&gt;
&lt;li&gt;Releasing the app directly to the platform’s application store for alpha, beta and production release.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Unfortunately, they didn’t make it into this post so it wouldn’t become too big and tedious to read. Nonetheless, they are important topics and we’ll be talking about these topics in a future post to make our release process as smooth as possible.&lt;/p&gt;

</description>
      <category>devops</category>
      <category>xamarin</category>
      <category>appreleases</category>
      <category>appcenter</category>
    </item>
    <item>
      <title>Recyclerview basics (Part 2): Adapters and ViewHolder</title>
      <dc:creator>Raul Montero</dc:creator>
      <pubDate>Thu, 21 Mar 2019 22:08:17 +0000</pubDate>
      <link>https://dev.to/raulmonteroc/recyclerview-basics-part-2-adapters-and-viewholder-36ek</link>
      <guid>https://dev.to/raulmonteroc/recyclerview-basics-part-2-adapters-and-viewholder-36ek</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--_6z1D426--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://raulmonteroc.com/wp-content/uploads/2019/01/recyclerview-basics-part-2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--_6z1D426--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://raulmonteroc.com/wp-content/uploads/2019/01/recyclerview-basics-part-2.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Welcome back! After having an introduction to what the recyclerview is, it is time to start digging into the details.  &lt;/p&gt;

&lt;p&gt;This time, we will be talking about the adapter and viewholder objects and how they work together. At this point, we know what they are and what roles they play, now it is time to take that knowledge into practice.  &lt;/p&gt;

&lt;p&gt;If this doesn’t make a lot of sense to you yet or this is your first post of the series, spare a couple of minutes to read the&lt;a href="https://raulmonteroc.com/?p=785"&gt;introduction to the recyclerview&lt;/a&gt; and then come back.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step One: Define our tasks.
&lt;/h2&gt;

&lt;p&gt;The first step to accomplishing anything is to have a clear goal and a series of steps and tasks to help us get us there. In this case, our goal is learning about adapters and viewholders and to achieve that, we are going to use a sample project, something simple that can illustrate the main usage of the adapters and viewholder without worrying too much about other details.  &lt;/p&gt;

&lt;p&gt;This android application will list all the countries with name and flag of all the folks that have come here to read at least once. When we are done we should have something similar to the image below&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--qLDQzGTx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://raulmonteroc.com/wp-content/uploads/2019/01/recylerview-basics-main-screen.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--qLDQzGTx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://raulmonteroc.com/wp-content/uploads/2019/01/recylerview-basics-main-screen.jpg" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Step Two: Add UI and resources.
&lt;/h2&gt;

&lt;p&gt;Now with a clear goal to pursue, the next step is adding the visual resources that the user will be interacting with, in this case, the flag images and the layout of the elements (more on this later).&lt;/p&gt;

&lt;h3&gt;
  
  
  Adding flag images
&lt;/h3&gt;

&lt;p&gt;For now, we are just going to import the images into our project to be able to use them when we are creating the UI (on a later step).&lt;br&gt;&lt;br&gt;
To get the images, simply go &lt;a href="https://github.com/RaulMonteroC/countryflags/tree/master/app/src/main/res"&gt;here&lt;/a&gt; and copy all the drawable folders into your project’s &lt;strong&gt;res&lt;/strong&gt; folder and wait for the project to sync.&lt;/p&gt;
&lt;h3&gt;
  
  
  Creating the UI
&lt;/h3&gt;

&lt;p&gt;The recyclerview has three components it uses to display data to the user:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The &lt;strong&gt;recyclerview tag&lt;/strong&gt; inside the fragment or activity that will contain it.&lt;/li&gt;
&lt;li&gt;The &lt;strong&gt;Layout&lt;/strong&gt; that describes how to display each individual element of the recyclerview.&lt;/li&gt;
&lt;li&gt;The &lt;strong&gt;LayoutManager&lt;/strong&gt; that describes how the elements are arranged inside the recyclerview.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We first start defining the recyclerview tag. In our case, we just need to edit the activity_main.xml layout file, removing all but the root container and then adding the recyclerview tag, ensuring it takes all the available space, as follows:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight xml"&gt;&lt;code&gt;&lt;span class="cp"&gt;&amp;lt;?xml version="1.0" encoding="utf-8"?&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;LinearLayout&lt;/span&gt; &lt;span class="na"&gt;xmlns:android=&lt;/span&gt;&lt;span class="s"&gt;"http://schemas.android.com/apk/res/android"&lt;/span&gt; 
              &lt;span class="na"&gt;xmlns:tools=&lt;/span&gt;&lt;span class="s"&gt;"http://schemas.android.com/tools"&lt;/span&gt; 
              &lt;span class="na"&gt;android:layout_width=&lt;/span&gt;&lt;span class="s"&gt;"match_parent"&lt;/span&gt; 
              &lt;span class="na"&gt;android:layout_height=&lt;/span&gt;&lt;span class="s"&gt;"match_parent"&lt;/span&gt; 
              &lt;span class="na"&gt;tools:context=&lt;/span&gt;&lt;span class="s"&gt;".MainActivity"&lt;/span&gt; 
              &lt;span class="na"&gt;android:orientation=&lt;/span&gt;&lt;span class="s"&gt;"vertical"&lt;/span&gt;&lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt; 

    &lt;span class="nt"&gt;&amp;lt;android.support.v7.widget.RecyclerView&lt;/span&gt; 
            &lt;span class="na"&gt;android:id=&lt;/span&gt;&lt;span class="s"&gt;"@+id/countryRecyclerView"&lt;/span&gt; 
            &lt;span class="na"&gt;android:layout_width=&lt;/span&gt;&lt;span class="s"&gt;"match_parent"&lt;/span&gt; 
            &lt;span class="na"&gt;android:layout_height=&lt;/span&gt;&lt;span class="s"&gt;"match_parent"&lt;/span&gt; 
            &lt;span class="na"&gt;tools:listitem=&lt;/span&gt;&lt;span class="s"&gt;"@layout/country_item"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt; 

&lt;span class="nt"&gt;&amp;lt;LinearLayout/&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;With that set, we can continue with the layout for each of the elements. Defining the layout is very straightforward, similarly to what we did before, we create a new xml layout file inside the layout folder, name it &lt;strong&gt;country_item.xml&lt;/strong&gt; and define it’s content the same way we would do with an activity or fragment.  &lt;/p&gt;

&lt;p&gt;In our case, to keep it simple, we just have the flag image on the left side, the text on the right side and a view serving as a line separator for each element. Here’s the code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight xml"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;android.support.constraint.ConstraintLayout&lt;/span&gt;
        &lt;span class="na"&gt;xmlns:android=&lt;/span&gt;&lt;span class="s"&gt;"http://schemas.android.com/apk/res/android"&lt;/span&gt;
        &lt;span class="na"&gt;xmlns:tools=&lt;/span&gt;&lt;span class="s"&gt;"http://schemas.android.com/tools"&lt;/span&gt;
        &lt;span class="na"&gt;xmlns:app=&lt;/span&gt;&lt;span class="s"&gt;"http://schemas.android.com/apk/res-auto"&lt;/span&gt;
        &lt;span class="na"&gt;android:layout_width=&lt;/span&gt;&lt;span class="s"&gt;"match_parent"&lt;/span&gt;
        &lt;span class="na"&gt;android:layout_height=&lt;/span&gt;&lt;span class="s"&gt;"@dimen/country_item_size"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;ImageView&lt;/span&gt;
            &lt;span class="na"&gt;android:id=&lt;/span&gt;&lt;span class="s"&gt;"@+id/countryFlag"&lt;/span&gt;
            &lt;span class="na"&gt;android:layout_width=&lt;/span&gt;&lt;span class="s"&gt;"@dimen/flag_size"&lt;/span&gt;
            &lt;span class="na"&gt;android:layout_height=&lt;/span&gt;&lt;span class="s"&gt;"match_parent"&lt;/span&gt;
            &lt;span class="na"&gt;app:layout_constraintStart_toStartOf=&lt;/span&gt;&lt;span class="s"&gt;"parent"&lt;/span&gt;
            &lt;span class="na"&gt;tools:srcCompat=&lt;/span&gt;&lt;span class="s"&gt;"@drawable/dominican_republic"&lt;/span&gt;
            &lt;span class="na"&gt;android:padding=&lt;/span&gt;&lt;span class="s"&gt;"@dimen/normal_padding"&lt;/span&gt;
            &lt;span class="na"&gt;android:contentDescription=&lt;/span&gt;&lt;span class="s"&gt;"@string/country_flag_description"&lt;/span&gt;&lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;TextView&lt;/span&gt;
            &lt;span class="na"&gt;android:id=&lt;/span&gt;&lt;span class="s"&gt;"@+id/countryName"&lt;/span&gt;
            &lt;span class="na"&gt;android:layout_width=&lt;/span&gt;&lt;span class="s"&gt;"wrap_content"&lt;/span&gt;
            &lt;span class="na"&gt;android:layout_height=&lt;/span&gt;&lt;span class="s"&gt;"wrap_content"&lt;/span&gt;
            &lt;span class="na"&gt;app:layout_constraintStart_toEndOf=&lt;/span&gt;&lt;span class="s"&gt;"@id/countryFlag"&lt;/span&gt;
            &lt;span class="na"&gt;app:layout_constraintTop_toTopOf=&lt;/span&gt;&lt;span class="s"&gt;"parent"&lt;/span&gt;
            &lt;span class="na"&gt;app:layout_constraintBottom_toBottomOf=&lt;/span&gt;&lt;span class="s"&gt;"parent"&lt;/span&gt;
            &lt;span class="na"&gt;tools:text=&lt;/span&gt;&lt;span class="s"&gt;"Dominican Republic"&lt;/span&gt;
            &lt;span class="na"&gt;android:textSize=&lt;/span&gt;&lt;span class="s"&gt;"@dimen/normal_text_size"&lt;/span&gt;&lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;View&lt;/span&gt;
            &lt;span class="na"&gt;android:layout_width=&lt;/span&gt;&lt;span class="s"&gt;"match_parent"&lt;/span&gt;
            &lt;span class="na"&gt;android:layout_height=&lt;/span&gt;&lt;span class="s"&gt;"1dp"&lt;/span&gt;
            &lt;span class="na"&gt;android:background=&lt;/span&gt;&lt;span class="s"&gt;"@color/country_element_separator"&lt;/span&gt;
            &lt;span class="na"&gt;app:layout_constraintBottom_toBottomOf=&lt;/span&gt;&lt;span class="s"&gt;"parent"&lt;/span&gt;&lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/android.support.constraint.ConstraintLayout&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;A few things to notice here:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;I used a ConstraintLayout because I find it easier (and more performant) to describe the layout this way, this is not the only way to do it, you could have used a LinearLayout or even a GridLayout.&lt;/li&gt;
&lt;li&gt;I use @dimen/key and @color/key to prevent using hardcoded size and color values. This works just like @strings/key and the strings.xml file.&lt;/li&gt;
&lt;li&gt;I avoid using match_parent on the height property to prevent a single element from taking all the screen space. In this case, I used a specific value but wrap_content could be used if it made sense to you.&lt;/li&gt;
&lt;li&gt;I use the tools namespace to define values that are only visible for the previewer such as the name and image of the country.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;What about the layout manager? Well, for this case, we are going to use the LinearLayoutManager object which organizes the layout into a list of elements where each row takes all the width available, we are setting it up in our final step.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step Three: Implementing the Adapter and ViewHolder classes
&lt;/h2&gt;

&lt;p&gt;With all the resources at hand, we can now focus on getting data to the recyclerview. We do that with the adapter and ViewHolder objects.&lt;br&gt;&lt;br&gt;
If you remember from the &lt;a href="https://raulmonteroc.com/?p=785"&gt;last post&lt;/a&gt;, the adapter object is in charge to get data from the model, process it and send it to the recyclerview using ViewHolder objects as a way to bind (display) the data to the UI since they are representations from the kotlin/java side of each row’s element.  &lt;/p&gt;

&lt;p&gt;With that said, it is time to create our adapter class and get the data through. The first step is creating the adapter and viewholder classes each one inheriting from their corresponding superclasses&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The adapter class inherits from &lt;code&gt;Adapter&amp;lt;VH extends RecyclerView.ViewHolder&amp;gt;&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;The viewholder class inherits from &lt;code&gt;RecyclerView.ViewHolder&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Then, we will have to implement the inherited methods from the base adapter class, each one with a different purpose:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;OnCreateViewHolder:&lt;/strong&gt; Returns the viewholder (representation from kotlin/java code) for each row&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;GetItemCount:&lt;/strong&gt; Returns the total number of elements&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;OnBindViewHolder:&lt;/strong&gt; Bind the data from the model to the UI&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;When we add all that, we end up with the skeleton code for both classes, as follows:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight kotlin"&gt;&lt;code&gt;&lt;span class="k"&gt;package&lt;/span&gt; &lt;span class="nn"&gt;com.raulmonteroc.countryflags&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;android.support.v7.widget.RecyclerView&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;android.view.LayoutInflater&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;android.view.View&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;android.view.ViewGroup&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;android.widget.ImageView&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;android.widget.TextView&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;com.raulmonteroc.countryflags.CountryAdapter.FlagViewHolder&lt;/span&gt;

&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;CountryAdapter&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;RecyclerView&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Adapter&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;FlagViewHolder&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

    &lt;span class="k"&gt;override&lt;/span&gt; &lt;span class="k"&gt;fun&lt;/span&gt; &lt;span class="nf"&gt;onCreateViewHolder&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;p0&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;ViewGroup&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;p1&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Int&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="nc"&gt;FlagViewHolder&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="k"&gt;override&lt;/span&gt; &lt;span class="k"&gt;fun&lt;/span&gt; &lt;span class="nf"&gt;getItemCount&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt; &lt;span class="nc"&gt;Int&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="k"&gt;override&lt;/span&gt; &lt;span class="k"&gt;fun&lt;/span&gt; &lt;span class="nf"&gt;onBindViewHolder&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;p0&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;FlagViewHolder&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;p1&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Int&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;FlagViewHolder&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;itemView&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;View&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;RecyclerView&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;ViewHolder&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;itemView&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Now, it’s time to implement all the methods:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;For the &lt;strong&gt;onCreateViewHolder&lt;/strong&gt; , we just need to return a viewholder object and since the view holder constructor needs a view, we’ll just inflate the XML layout we just created earlier for the rows and pass that view instance to the new viewholder’s constructor.&lt;/li&gt;
&lt;li&gt;For the &lt;strong&gt;getItemCount&lt;/strong&gt; , we will pass a collection of elements to the adapter’s constructor to hold all the elements and use that collection’s size to return the number of elements involved.&lt;/li&gt;
&lt;li&gt;For the *&lt;em&gt;onBindViewHolder, *&lt;/em&gt; we will create a bind method on the viewholder object where we get the element from the layout(the layout we passed in the first method we implemented) and assign the values of the model object we pass through, just like we would do with any activity or fragment.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I know this could be a bit abstract without code to see, so here’s the completed adapter code with all the functionality described above.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight kotlin"&gt;&lt;code&gt;&lt;span class="k"&gt;package&lt;/span&gt; &lt;span class="nn"&gt;com.raulmonteroc.countryflags&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;android.support.v7.widget.RecyclerView&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;android.view.LayoutInflater&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;android.view.View&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;android.view.ViewGroup&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;android.widget.ImageView&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;android.widget.TextView&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;com.raulmonteroc.countryflags.CountryAdapter.FlagViewHolder&lt;/span&gt;

&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;CountryAdapter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="kd"&gt;val&lt;/span&gt; &lt;span class="py"&gt;countries&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;List&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Country&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;)&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;RecyclerView&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Adapter&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;FlagViewHolder&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

    &lt;span class="k"&gt;override&lt;/span&gt; &lt;span class="k"&gt;fun&lt;/span&gt; &lt;span class="nf"&gt;onCreateViewHolder&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;parent&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;ViewGroup&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;viewType&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Int&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="nc"&gt;FlagViewHolder&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="kd"&gt;val&lt;/span&gt; &lt;span class="py"&gt;layoutInflater&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;LayoutInflater&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;from&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;parent&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="kd"&gt;val&lt;/span&gt; &lt;span class="py"&gt;view&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;layoutInflater&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;inflate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;R&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;layout&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;country_item&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;parent&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="k"&gt;false&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nc"&gt;FlagViewHolder&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;view&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="k"&gt;override&lt;/span&gt; &lt;span class="k"&gt;fun&lt;/span&gt; &lt;span class="nf"&gt;getItemCount&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;countries&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;size&lt;/span&gt;

    &lt;span class="k"&gt;override&lt;/span&gt; &lt;span class="k"&gt;fun&lt;/span&gt; &lt;span class="nf"&gt;onBindViewHolder&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;viewHolder&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;FlagViewHolder&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;position&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Int&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;viewHolder&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;bind&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;countries&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;position&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;

    &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;FlagViewHolder&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;itemView&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;View&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;RecyclerView&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;ViewHolder&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;itemView&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

        &lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="kd"&gt;val&lt;/span&gt; &lt;span class="py"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nc"&gt;TextView&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;itemView&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;findViewById&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;R&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;countryName&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="kd"&gt;val&lt;/span&gt; &lt;span class="py"&gt;flag&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nc"&gt;ImageView&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;itemView&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;findViewById&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;R&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;countryFlag&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

        &lt;span class="k"&gt;fun&lt;/span&gt; &lt;span class="nf"&gt;bind&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;country&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Country&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;text&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;country&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;
            &lt;span class="n"&gt;flag&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;setImageResource&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;country&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;flagImageResource&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h2&gt;
  
  
  Step Four: Connect the recyclerview to the activity.
&lt;/h2&gt;

&lt;p&gt;Now that we have all the pieces working, what’s left is to connect them together, more specifically, make the adapter, recyclerview and activity work like a fine-tuned orchestra.&lt;/p&gt;

&lt;p&gt;We do that by setting up some recyclerview properties and make sure they are called from the onCreate method, here are the steps:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Get an instance of the recyclerview using findViewById&lt;/li&gt;
&lt;li&gt;Set the layout manager to the LinearLayoutManager to render the Recylerview as a list of items&lt;/li&gt;
&lt;li&gt;Set the adapter property
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight kotlin"&gt;&lt;code&gt;&lt;span class="k"&gt;package&lt;/span&gt; &lt;span class="nn"&gt;com.raulmonteroc.countryflags&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;android.support.v7.app.AppCompatActivity&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;android.os.Bundle&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;android.support.v7.widget.LinearLayoutManager&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;android.support.v7.widget.RecyclerView&lt;/span&gt;

&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;MainActivity&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;AppCompatActivity&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;lateinit&lt;/span&gt; &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="py"&gt;countryRecyclerView&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;RecyclerView&lt;/span&gt;

    &lt;span class="k"&gt;override&lt;/span&gt; &lt;span class="k"&gt;fun&lt;/span&gt; &lt;span class="nf"&gt;onCreate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;savedInstanceState&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Bundle&lt;/span&gt;&lt;span class="p"&gt;?)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;super&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;onCreate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;savedInstanceState&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="nf"&gt;setContentView&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;R&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;layout&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;activity_main&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="nf"&gt;setupRecyclerView&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="k"&gt;fun&lt;/span&gt; &lt;span class="nf"&gt;setupRecyclerView&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;countryRecyclerView&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;findViewById&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;R&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;countryRecyclerView&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;countryRecyclerView&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;layoutManager&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;LinearLayoutManager&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;countryRecyclerView&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;adapter&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;CountryAdapter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;CountrySeed&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;seed&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;       
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;You can note here a &lt;strong&gt;seed()&lt;/strong&gt; method is passed when initializing the adapter, this is simply to provide the data the recyclerview is going to display.   &lt;/p&gt;

&lt;p&gt;Here’s the code&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight kotlin"&gt;&lt;code&gt;&lt;span class="k"&gt;package&lt;/span&gt; &lt;span class="nn"&gt;com.raulmonteroc.countryflags&lt;/span&gt;
&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;CountrySeed&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

    &lt;span class="k"&gt;fun&lt;/span&gt; &lt;span class="nf"&gt;seed&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt; &lt;span class="nc"&gt;List&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Country&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="kd"&gt;val&lt;/span&gt; &lt;span class="py"&gt;countries&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;listOf&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Country&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;(&lt;/span&gt;
            &lt;span class="nc"&gt;Country&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Brazil"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;R&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;drawable&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;brazil&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
            &lt;span class="nc"&gt;Country&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Canada"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;R&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;drawable&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;canada&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
            &lt;span class="nc"&gt;Country&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"China"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;R&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;drawable&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;china&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
            &lt;span class="nc"&gt;Country&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Dominican Republic"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;R&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;drawable&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;dominican_republic&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
            &lt;span class="nc"&gt;Country&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Germany"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;R&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;drawable&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;germany&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
            &lt;span class="nc"&gt;Country&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"India"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;R&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;drawable&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;india&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
            &lt;span class="nc"&gt;Country&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Netherlands"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;R&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;drawable&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;netherlands&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
            &lt;span class="nc"&gt;Country&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"norway"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;R&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;drawable&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;norway&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
            &lt;span class="nc"&gt;Country&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Peru"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;R&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;drawable&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;peru&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
            &lt;span class="nc"&gt;Country&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Philippines"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;R&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;drawable&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;philipines&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
            &lt;span class="nc"&gt;Country&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Poland"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;R&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;drawable&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;poland&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
            &lt;span class="nc"&gt;Country&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Romania"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;R&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;drawable&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;romania&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
            &lt;span class="nc"&gt;Country&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"South Africa"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;R&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;drawable&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;south_africa&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
            &lt;span class="nc"&gt;Country&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Spain"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;R&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;drawable&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;spain&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
            &lt;span class="nc"&gt;Country&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Sweden"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;R&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;drawable&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;sweden&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
            &lt;span class="nc"&gt;Country&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"United Kingdom"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;R&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;drawable&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;united_kingdom&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
            &lt;span class="nc"&gt;Country&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"United States"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;R&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;drawable&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;united_states&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;countries&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sortedBy&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;it&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;countries&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h2&gt;
  
  
  Coming up next
&lt;/h2&gt;

&lt;p&gt;Now we got a working recyclerview, with data and a custom layout for its elements, and only with a bit of effort, that’s great right?.   &lt;/p&gt;

&lt;p&gt;Following up in our recyclerview series, we will be updating this project to enable the recyclerview to respond to touch gestures such as drag and swipes   &lt;/p&gt;

&lt;p&gt;See you then!&lt;/p&gt;

</description>
      <category>android</category>
      <category>kotlin</category>
      <category>development</category>
    </item>
    <item>
      <title>Recyclerview basics (Part 1): Introduction</title>
      <dc:creator>Raul Montero</dc:creator>
      <pubDate>Thu, 14 Mar 2019 14:00:10 +0000</pubDate>
      <link>https://dev.to/raulmonteroc/recyclerview-basics-part-1-introduction-3225</link>
      <guid>https://dev.to/raulmonteroc/recyclerview-basics-part-1-introduction-3225</guid>
      <description>&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fraulmonteroc.com%2Fwp-content%2Fuploads%2F2019%2F03%2Frecyclerview-basics-part-1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fraulmonteroc.com%2Fwp-content%2Fuploads%2F2019%2F03%2Frecyclerview-basics-part-1.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The Recyclerview is the replacement of the Listview with a simpler API, better performance and a couple of new nice extra features. If you don’t know what a ListView is, don’t worry, you won’t need to in order to understand the recyclerview, simply think of it as a UI component used to represent related items in a list with scrolling capabilities.&lt;/p&gt;

&lt;h2&gt;
  
  
  Components of a Recyclerview
&lt;/h2&gt;

&lt;p&gt;The Recyclerview is mainly used to list related elements together, however, the way you do it can be dramatically customized to make your users have a unique experience in your app. Things such as determine how the elements are arranged together, enable custom views per element, respond to touch gestures, among other options, are available for you.&lt;/p&gt;

&lt;p&gt;These options are not directly accessible from the Recyclerview object itself, instead, a group of related objects is used for each specific configuration, allowing for cleaner code and reusability.&lt;/p&gt;

&lt;p&gt;Along the course of series we will be working with the most relevant components of the Recyclerview but for now, I’ll leave a little description as a tease to what we will working with next, here they are:&lt;/p&gt;

&lt;h4&gt;
  
  
  ViewHolder
&lt;/h4&gt;

&lt;p&gt;The view holder object is a static representation of an element inside the Recyclerview, accessible from kotlin or java code. The main responsibility of the ViewHolder is to display each element with bound data from the adapter object.&lt;/p&gt;

&lt;h4&gt;
  
  
  Adapter
&lt;/h4&gt;

&lt;p&gt;The Recyclerview doesn’t work with the data directly, it is only responsible for displaying it on the screen. The data management is done via an &lt;strong&gt;adapter&lt;/strong&gt; object which in turn uses ViewHolder objects as containers for each element’s data. The adapter is tasked with three things:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Serve as an Intermediary between the model data and the Recyclerview object.&lt;/li&gt;
&lt;li&gt;Bind the provided data to each ViewHolder object.&lt;/li&gt;
&lt;li&gt;Determine which XML layout should be used to load the ViewHolders.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  LayoutManager
&lt;/h4&gt;

&lt;p&gt;The Recyclerview is in charge of the display of the elements of the list but &lt;em&gt;the way&lt;/em&gt; it does that is delegated to a &lt;strong&gt;LayoutManager&lt;/strong&gt; object. Android provides a few layout managers built-in such as the &lt;code&gt;LinearLayoutManager&lt;/code&gt; and &lt;code&gt;GridLayoutManager&lt;/code&gt; but you can also provide your own if you want a more tailored experience for your Recyclerview.&lt;/p&gt;

&lt;h4&gt;
  
  
  ItemTouchHelper
&lt;/h4&gt;

&lt;p&gt;Once we have our adapter setup and our layout manager selected, we can enable our Recyclerview to respond to touch gestures such as dragging elements or swiping to the side. For these purposes, we use the &lt;strong&gt;ItemTouchHelper&lt;/strong&gt; object.&lt;/p&gt;

&lt;h2&gt;
  
  
  Next Step
&lt;/h2&gt;

&lt;p&gt;Now that we have a rough understanding of what a Recyclerview is, what the components are and what they can do, we are ready to start a small coding adventure.&lt;/p&gt;

&lt;p&gt;On the following post, we will be working with the Recyclerview’s ViewHolder &amp;amp; Adapter components to create a simple list of elements to put all this theory into action.&lt;/p&gt;

</description>
      <category>android</category>
      <category>kotlin</category>
    </item>
    <item>
      <title>Setup a splash-screen on Xamarin.Forms</title>
      <dc:creator>Raul Montero</dc:creator>
      <pubDate>Tue, 26 Feb 2019 15:41:19 +0000</pubDate>
      <link>https://dev.to/raulmonteroc/setup-a-splash-screen-on-xamarin-forms-4ena</link>
      <guid>https://dev.to/raulmonteroc/setup-a-splash-screen-on-xamarin-forms-4ena</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--nsPMB74Y--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://raulmonteroc.com/wp-content/uploads/2019/02/Splash-Screen-banner.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--nsPMB74Y--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://raulmonteroc.com/wp-content/uploads/2019/02/Splash-Screen-banner.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A splash screens it’s what we call to those screens that show up at the beginning of an app and last only while the application loads.  &lt;/p&gt;

&lt;p&gt;This is a common design pattern in general mobile development, allowing the user to receive feedback immediately after touching an app’s icon, showing them something right from the beginning instead of staring at a black screen until the application finishes loading.  &lt;/p&gt;

&lt;p&gt;Best of all, adding a splash screen is simple, so you’ll get a better user experience without much effort. Let’s begin!&lt;/p&gt;

&lt;h2&gt;
  
  
  Creating a splash-screen
&lt;/h2&gt;

&lt;p&gt;Before we begin, we need to understand is that there is &lt;strong&gt;no cross-platform way of adding a splash screen&lt;/strong&gt;. This is because of the Xamarin.Forms library loads &lt;strong&gt;after&lt;/strong&gt; MainActivity/AppDelegate finishes loading and by that time it’s too late, we need something to display &lt;strong&gt;before and during&lt;/strong&gt; those classes load, after all, that’s what splash screens are all about.  &lt;/p&gt;

&lt;p&gt;With that in mind, what’s left is to create the splash-screen file and configuration on each platform. In our case, the splash-screen will consist of a logo and a background color.&lt;/p&gt;

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

&lt;p&gt;The first thing we need is the logo image. Android defines how to add images and ensure it looks good on every platform, you can read about it &lt;a href="https://developer.android.com/training/multiscreen/screendensities#TaskProvideAltBmp"&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After that, we are to create the splash screen file, which loads the image and sets the background we need. For that, we are going to define an XML drawable, here’s the code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight xml"&gt;&lt;code&gt;&lt;span class="cp"&gt;&amp;lt;?xml version="1.0" encoding="utf-8"?&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;layer-list&lt;/span&gt; &lt;span class="na"&gt;xmlns:android=&lt;/span&gt;&lt;span class="s"&gt;"http://schemas.android.com/apk/res/android"&lt;/span&gt;&lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;item&lt;/span&gt; &lt;span class="na"&gt;android:drawable=&lt;/span&gt;&lt;span class="s"&gt;"@color/splash\_background"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;item&lt;/span&gt; &lt;span class="na"&gt;android:gravity=&lt;/span&gt;&lt;span class="s"&gt;"center"&lt;/span&gt;&lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt; 
        &lt;span class="nt"&gt;&amp;lt;bitmap&lt;/span&gt; &lt;span class="na"&gt;android:src=&lt;/span&gt;&lt;span class="s"&gt;"@drawable/splash"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;/item&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/layer-list&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Here, we defined a &lt;a href="https://developer.android.com/guide/topics/resources/drawable-resource#LayerList"&gt;layer-list&lt;/a&gt; which essentially allows us to have a background color and an image background at the same time, having the first &amp;lt;item&amp;gt; define the background color and the second one the image logo centered on the screen.&lt;/p&gt;

&lt;p&gt;With that in place, then we define a new style to set this drawable as the background and ensure it takes up all the screen available on the device by removing any action/status bar, here’s the code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight xml"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;style&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"Splash"&lt;/span&gt; &lt;span class="na"&gt;parent=&lt;/span&gt;&lt;span class="s"&gt;"Theme.AppCompat.Light.NoActionBar"&lt;/span&gt;&lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;item&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"android:windowBackground"&lt;/span&gt;&lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;@drawable/splash/_screen/&lt;span class="err"&gt;&amp;lt;&lt;/span&gt;/item/&amp;gt;
    &lt;span class="nt"&gt;&amp;lt;item&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"android:windowNoTitle"&lt;/span&gt;&lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;true&lt;span class="nt"&gt;&amp;lt;/item&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;item&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"android:windowFullscreen"&lt;/span&gt;&lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;true&lt;span class="nt"&gt;&amp;lt;/item&amp;gt;&lt;/span&gt; 
&lt;span class="nt"&gt;&amp;lt;/style&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Finally, we create a new activity called SplashActivity where we configure it as the MainLauncher (be sure to remove it from the MainActivity.cs) and make it use the new style we defined.&lt;br&gt;&lt;br&gt;
Then, we start the MainActivity from the OnCreate() method, that way, it loads the screen that starts up the rest of the app once it’s ready.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nf"&gt;Activity&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Label&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"SplashActivity"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Theme&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"@style/Splash"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;MainLauncher&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;true&lt;/span&gt;&lt;span class="p"&gt;)]&lt;/span&gt; 
&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;SplashActivity&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;Activity&lt;/span&gt; 
&lt;span class="p"&gt;{&lt;/span&gt; 
    &lt;span class="k"&gt;protected&lt;/span&gt; &lt;span class="k"&gt;override&lt;/span&gt; &lt;span class="k"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;OnCreate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Bundle&lt;/span&gt; &lt;span class="n"&gt;savedInstanceState&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; 
    &lt;span class="p"&gt;{&lt;/span&gt; 
        &lt;span class="k"&gt;base&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;OnCreate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;savedInstanceState&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; 
        &lt;span class="nf"&gt;StartActivity&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;typeof&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;MainActivity&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt; 
        &lt;span class="nf"&gt;Finish&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; 
    &lt;span class="p"&gt;}&lt;/span&gt; 
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Some additional notes :&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The call to Finish is to ensure the activity doesn’t stay up on memory while the app is running since we won’t need it ever again.&lt;/li&gt;
&lt;li&gt;We created a new activity instead of using the MainActivity because the drawable we defined becomes the background of the activity and therefore we would end up overriding the background property on each Xamarin.forms page.&lt;/li&gt;
&lt;li&gt;We use an XML drawable and not a standard layout because this approach is much faster.&lt;/li&gt;
&lt;/ol&gt;

&lt;h4&gt;
  
  
  iOS
&lt;/h4&gt;

&lt;p&gt;As with Android, on iOS we need to include the logo image according to the apple standards to ensure it looks good in all their supported resolutions, you can find the guide &lt;a href="https://developer.apple.com/design/human-interface-guidelines/ios/icons-and-images/image-size-and-resolution/"&gt;here&lt;/a&gt;.  &lt;/p&gt;

&lt;p&gt;With all the images at hand, it’s time to add it to our project and to do so we are going add them to a special folder called &lt;strong&gt;Assets.xcassets.&lt;/strong&gt; We can find it on the iOS project section inside the solution explorer window.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Dag7D9hM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://raulmonteroc.com/wp-content/uploads/2019/02/Assets.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Dag7D9hM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://raulmonteroc.com/wp-content/uploads/2019/02/Assets.png" alt="Assets.xcassets folder location where the splash screen images should be located."&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Double click it and a new tab window will appear. Here, we will find a sidebar with name identifiers for the images (on the left side) and placeholders to put our images at the right side.  &lt;/p&gt;

&lt;p&gt;What will do next, is right-click on the sidebar and select &lt;strong&gt;new image set&lt;/strong&gt; and give it a name (I used &lt;em&gt;splash&lt;/em&gt; for mine). After that, what’s left is to add the images. Drag &amp;amp; drop the image files into the first row of placeholder boxes according to the resolutions defined by Apple.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--H49zdGke--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://raulmonteroc.com/wp-content/uploads/2019/02/Splash-iOS-1024x664.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--H49zdGke--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://raulmonteroc.com/wp-content/uploads/2019/02/Splash-iOS-1024x664.png" alt="Assets.xcassets window where the splash screen images should be located."&gt;&lt;/a&gt;&lt;br&gt;&lt;/p&gt;

&lt;p&gt;Finally, what’s left is to update the &lt;strong&gt;LaunchScreen.storyboard&lt;/strong&gt; to include our new image, define its constraints to ensure its always centered and set up the background color, all from the Visual Studio iOS designer, no code required.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--4qvI5oKN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://raulmonteroc.com/wp-content/uploads/2019/02/Splash-storyboard-1024x664.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--4qvI5oKN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://raulmonteroc.com/wp-content/uploads/2019/02/Splash-storyboard-1024x664.png" alt="Splash screen preview in the iOS designer on Visual Studio for mac."&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you don’t have a lot of experience working with the iOS designer, check out &lt;a href="https://docs.microsoft.com/en-us/xamarin/ios/app-fundamentals/images-icons/launch-screens?tabs=macos"&gt;this guide&lt;/a&gt; from Microsoft which explains it step by step.&lt;/p&gt;

</description>
      <category>xamarin</category>
      <category>android</category>
      <category>ios</category>
      <category>csharp</category>
    </item>
    <item>
      <title>Find yourself a mentor</title>
      <dc:creator>Raul Montero</dc:creator>
      <pubDate>Sat, 11 Aug 2018 01:13:43 +0000</pubDate>
      <link>https://dev.to/raulmonteroc/find-yourself-a-mentor-3fod</link>
      <guid>https://dev.to/raulmonteroc/find-yourself-a-mentor-3fod</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--25iTjQRI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/dfzo7wjg89l78lirlnm3.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--25iTjQRI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/dfzo7wjg89l78lirlnm3.jpg" alt="Mentor acronym"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Originally posted at &lt;a href="https://raulmonteroc.com/career-development/find-yourself-a-mentor/"&gt;https://raulmonteroc.com&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What is a mentor?
&lt;/h2&gt;

&lt;p&gt;There is a lot of definitions for a mentor, but the general idea is someone with vast experience in an area willing to teach/transmit that knowledge to someone else. Essentially, someone who takes the time to help you grow in a specific area.&lt;/p&gt;

&lt;h2&gt;
  
  
  Benefits of a mentorship
&lt;/h2&gt;

&lt;p&gt;When I started developing software I had no clear path to what I wanted to do so I would pick up anything that seems interesting, no matter how unrelated it was from my tech stack or what would be the benefit of doing it. I was a drifting boat until I started meeting people sharing my interest but were a little bit ahead on the journey. They provided me with insight, experience and opened my eyes to new opportunities and ways to improve myself. &lt;strong&gt;This is what a mentor does.&lt;/strong&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;The main reason to have one is to avoid tunnel vision about your future and your ideas&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The main reason to have one is to avoid tunnel vision about your future and your ideas, show you new things and find ways to continuously improve yourself in a given area through his/her example, experience and knowledge.&lt;/p&gt;

&lt;p&gt;In short, a mentor shows you their path and their experience so you can improve and move faster on your own journey.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where to find mentors.
&lt;/h2&gt;

&lt;p&gt;Chances are you already have one. A mentoring relationship does not necessarily go on explicitly, it often evolves naturally. An old teacher you often talk to, an approachable boss or a senior coworker/student are some examples.&lt;br&gt;
If for some reason you don't have any of those, don't worry, you can also find a lot of people interested in helping you. But how do you find them? There are a few options that come to mind:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Work on an open source project.&lt;/strong&gt; The open source community is full of people wanting to help out. Select a project that matches your skill level and interests and start pushing some code. Start small and ask for help from any of the regular contributors. You will find one or two regularly reaching out. That's the starting point.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Work on interesting projects with interesting people.&lt;/strong&gt; You can find a mentor next to you at work or university. When someone is working on a project, offer help. Help is always appreciated, no matter how much or how little.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Go to developer's reunions.&lt;/strong&gt; One of the best ways to find people like-minded is the local development community. Like the other cases, reach out, talk with others and stay in touch. You will find more than one in the same path you are and a couple a few steps further.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What's Next
&lt;/h2&gt;

&lt;p&gt;A mentor's job is to be a guide, your's is to have an idea to where you want to go or what your goal is for the next year or two and be aware of the reason why you spent time learning those languages and platforms. Do you want to become a front-end dev? a back-end? a mobile? What is your main tech stack? Why do you spend time learning those things in the first place? What do you want to achieve?&lt;/p&gt;

&lt;p&gt;Those questions are yours to answer, they mark the journey you will take moving forward. You don't need to have all the answers but you do need to have a general idea. Once you do that, then you can ask for your mentor for guidance.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Remember, a mentor is simply a guide, the path is yours to take&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;After all, that, how much you improve and how fast is entirely up to you. In the end, you will be the one putting up the hours to get better but they will be much better invested when knowing what to learn and how from people that came before you.&lt;/p&gt;

</description>
      <category>careerdevelopment</category>
      <category>career</category>
      <category>learning</category>
    </item>
    <item>
      <title>Variables and types in kotlin</title>
      <dc:creator>Raul Montero</dc:creator>
      <pubDate>Thu, 09 Aug 2018 03:47:14 +0000</pubDate>
      <link>https://dev.to/raulmonteroc/variables-and-types-in-kotlin-2heg</link>
      <guid>https://dev.to/raulmonteroc/variables-and-types-in-kotlin-2heg</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--F5e5_4Fk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://raulmonteroc.com/wp-content/uploads/2018/07/kotlin_800x320-1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--F5e5_4Fk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://raulmonteroc.com/wp-content/uploads/2018/07/kotlin_800x320-1.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;All languages are different but at the same time, they have a lot of things in common, a lot of similar components.&lt;/p&gt;

&lt;p&gt;Chances are, this is not your first language and therefore you are familiar with the concept of variables and the different common types you could expect in a language. Still, I’m going to walk you through the bits and pieces where kotlin is different so you are able to start feeling comfortable with the language’s philosophy and way to do things.&lt;/p&gt;

&lt;p&gt;Let’s start.&lt;/p&gt;

&lt;h1&gt;
  
  
  Variables
&lt;/h1&gt;

&lt;p&gt;A variable’s job is simple, assign a value and give it a name to be called for later. Kotlin takes this simple concept and adds some additional rules to enhance code performance and readability.&lt;/p&gt;

&lt;h4&gt;
  
  
  Declaration
&lt;/h4&gt;

&lt;p&gt;In Kotlin, variable declarations have a simple structure :&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;var (or val) keyword to indicate the start of a variable declaration.&lt;/li&gt;
&lt;li&gt;The name of the variable.&lt;/li&gt;
&lt;li&gt;two dots followed by the variable’s type. (optional)&lt;/li&gt;
&lt;li&gt;an equal sign to assign a value to the variable.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Here is an example in action of a variable declaration&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight kotlin"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Using var &lt;/span&gt;
&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="py"&gt;a&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Something Interesting"&lt;/span&gt; 

&lt;span class="c1"&gt;// Using val &lt;/span&gt;
&lt;span class="kd"&gt;val&lt;/span&gt; &lt;span class="py"&gt;b&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Something even more interesting"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;As you can see, we can declare a variable either using var or val keywords. The main difference between them is &lt;strong&gt;mutability&lt;/strong&gt; or the capacity to change. With var, you can change the value of the variable while with val you can not, and when I say value I mean instance since in kotlin everything is an object. The object’s properties are able to change but not the instance it refers to when we use val.&lt;/p&gt;

&lt;p&gt;Another interesting thing to note is that val-declared variables behave similar to constant values but with one major difference: val allows to assign it an expression that will resolve into a value, while the const only permits a primitive or string literals.&lt;/p&gt;

&lt;p&gt;Here we can see an example of val vs const&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight kotlin"&gt;&lt;code&gt;&lt;span class="kd"&gt;val&lt;/span&gt; &lt;span class="py"&gt;value&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nc"&gt;Int&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;+&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="c1"&gt;// Valid const &lt;/span&gt;

&lt;span class="kd"&gt;val&lt;/span&gt; &lt;span class="py"&gt;constant&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nc"&gt;Int&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;+&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="c1"&gt;//Invalid const &lt;/span&gt;
&lt;span class="kd"&gt;val&lt;/span&gt; &lt;span class="py"&gt;constant2&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nc"&gt;Int&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="c1"&gt;//Valid&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;And here with var and val&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight kotlin"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Using var &lt;/span&gt;
&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="py"&gt;a&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nc"&gt;Int&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt; 
&lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;6&lt;/span&gt; &lt;span class="c1"&gt;// Valid &lt;/span&gt;

&lt;span class="c1"&gt;// Using val &lt;/span&gt;
&lt;span class="kd"&gt;val&lt;/span&gt; &lt;span class="py"&gt;b&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nc"&gt;Int&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt; 
&lt;span class="n"&gt;b&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;6&lt;/span&gt; &lt;span class="c1"&gt;// Invalid&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h4&gt;
  
  
  Initialization
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://raulmonteroc.com/mobile/kotlin/nullability-in-kotlin/"&gt;Kotlin doesn’t allow null values out of the box&lt;/a&gt;, which means you can’t declare a variable without assigning it a value right away, at least not with the standard declaration. Even using nullable values, due to kotlin’s readability-promoting philosophy, you are required to assign the value explicitly (even null) when declaring the variable’s initial state.&lt;/p&gt;

&lt;p&gt;But what about the cases where we don’t know the value of the variable right away, like for example with instance variables in a class? We can do it, but we do it by telling kotlin our intent &lt;em&gt;explicitly&lt;/em&gt;. We do this by using the keyword  &lt;strong&gt;lateinit&lt;/strong&gt; before the variable declaration.&lt;/p&gt;

&lt;p&gt;You can think of the &lt;strong&gt;lateinit&lt;/strong&gt; as a promise. A promise to initialize the variable at a later time _before _you try to use it. The compiler then believes in you and let you do it your way, but just in case you are feeling a bit adventurous, it will throw an exception if you try to access it before assigning a value.&lt;/p&gt;

&lt;p&gt;Now, let’s see this in action&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight kotlin"&gt;&lt;code&gt;&lt;span class="c1"&gt;//Without lateinit &lt;/span&gt;
&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="py"&gt;a&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nc"&gt;Int&lt;/span&gt; &lt;span class="c1"&gt;//Error &lt;/span&gt;
&lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt; &lt;span class="c1"&gt;//Error &lt;/span&gt;

&lt;span class="c1"&gt;//With lateinit &lt;/span&gt;
&lt;span class="k"&gt;lateinit&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nc"&gt;Int&lt;/span&gt; &lt;span class="c1"&gt;// valid &lt;/span&gt;
&lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;toString&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="c1"&gt;// Throws exception &lt;/span&gt;

&lt;span class="n"&gt;b&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt; 
&lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;toString&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="c1"&gt;// valid&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h4&gt;
  
  
  Duck-typing
&lt;/h4&gt;

&lt;p&gt;Kotlin is a &lt;a href="https://hackernoon.com/i-finally-understand-static-vs-dynamic-typing-and-you-will-too-ad0c2bd0acc7"&gt;statically-typed language&lt;/a&gt;, which means all variables types are evaluated at compile-time, but that doesn’t mean you need to specify the variable type explicitly. Kotlin has a system called duck-typing that allows it to infer the type based on the value it is being assigned to, saving you the need to do it yourself.&lt;/p&gt;

&lt;p&gt;Do not be confused with the dynamic typing characteristic that is present in other languages (javascript, for example) that let you change the variable’s type at run-time depending on the value it holds. Although kotlin can infer the variable type, &lt;strong&gt;this happens at compile-time&lt;/strong&gt; and once a variable type has been determined it can never be changed.&lt;/p&gt;

&lt;h1&gt;
  
  
  Types
&lt;/h1&gt;

&lt;p&gt;Here we will discuss the common types (or kind of information) a variable can hold out of the box. Most of them should be very familiar to you but at the same time, they come with a small twist.&lt;/p&gt;

&lt;h4&gt;
  
  
  Numbers
&lt;/h4&gt;

&lt;p&gt;Numbers (in any of their variants) are objects and as such, they hold methods and properties.&lt;/p&gt;

&lt;p&gt;In the particular case of running kotlin on top of the JVM, those numbers are stored as primitives and in case a nullable number is used, the boxing/unboxing process is done automatically.&lt;/p&gt;

&lt;p&gt;Something curious in kotlin is that numbers are not implicitly cast. That means you can’t assign an int variable to a long one without doing a cast beforehand.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight kotlin"&gt;&lt;code&gt;&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="py"&gt;small&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nc"&gt;Int&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt; 
&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="py"&gt;large&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nc"&gt;Long&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;small&lt;/span&gt; &lt;span class="c1"&gt;// Invalid &lt;/span&gt;

&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="py"&gt;larger&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nc"&gt;Long&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Long&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="n"&gt;small&lt;/span&gt; &lt;span class="c1"&gt;//Valid&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Another curious thing is you can add any number of underscore characters to a number literal to make it more readable and the kotlin compiler will remove those underscores and use the remaining number as its value.&lt;/p&gt;

&lt;p&gt;This means,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight kotlin"&gt;&lt;code&gt;&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="py"&gt;number1&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nc"&gt;Int&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="err"&gt;\&lt;/span&gt;&lt;span class="n"&gt;_000&lt;/span&gt; 
&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="py"&gt;numer2&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nc"&gt;Int&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1000&lt;/span&gt; 
&lt;span class="n"&gt;number1&lt;/span&gt; &lt;span class="p"&gt;==&lt;/span&gt; &lt;span class="n"&gt;numer2&lt;/span&gt; &lt;span class="c1"&gt;//Evaluates to true&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h4&gt;
  
  
  Characters
&lt;/h4&gt;

&lt;p&gt;Characters represent a single letter or number and pretty much any symbol you can find in the ASCII table. You define them using single quotes.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight kotlin"&gt;&lt;code&gt;&lt;span class="kd"&gt;val&lt;/span&gt; &lt;span class="py"&gt;c&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Char&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="sc"&gt;'C'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;In some languages, you can use the numeric representation of a character to compare to an int. In kotlin this doesn’t happen out of the box, instead, you must use the method toInt() to do the conversion.&lt;/p&gt;

&lt;h4&gt;
  
  
  Strings
&lt;/h4&gt;

&lt;p&gt;If you have done any text manipulation in the past you will feel comfortable with strings in kotlin. The way kotlin handles strings is very standard, the methods and properties are very straightforward and easy to understand.&lt;/p&gt;

&lt;p&gt;Here are a few key points about this data type:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;A String is a collection of characters&lt;/strong&gt;, therefore can use the collection’s way of accessing their elements by using the indexing operator, and also have access to the collection’s methods to manipulate its contents.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Strings are immutable&lt;/strong&gt;, which means any operation that “modifies” an existing string, what does, in reality, is dispatching the previous string and creating a new one with the result.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;There are two types of strings&lt;/strong&gt;, the ones that are escaped and the ones that aren’t. With the first type, any special character must be included explicitly through the use of special escape characters whereas the other one is sufficient to be included in the string literal.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;You can evaluate variables and expressions inside a string&lt;/strong&gt;. The process is called string templates and you use it prepending the currency sign ($) before a variable or wrap it with curly braces in the case its an expression.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Alright, it’s time to put the words into actions with some examples. First, let’s use the indexing operator to get a character in a given position of a string. Just like with arrays, you use the variable name next to the opening and closing brackets with a number inside indicating the position of the element you want.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight kotlin"&gt;&lt;code&gt;&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="py"&gt;text&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"This is a text!"&lt;/span&gt; &lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="c1"&gt;// Returns h&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Now, let’s see how to escape vs not escape string compare to each other. Do notice that the raw string (not escaped) variant requires three double quotes while the escaped one just two.&lt;/p&gt;

&lt;p&gt;In this example, we can see the escaped string doesn’t recognize the line break (newline) character inside the text while the other one does. If we wanted to have a line break, inside the escaped string we had to add the escaped character (\n) explicitly.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight kotlin"&gt;&lt;code&gt;&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="py"&gt;escaped&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"first line second line"&lt;/span&gt; &lt;span class="c1"&gt;// Throws a compiler error var raw:String = """first line second line""" // Valid&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Finally,  we’ll see how to get a variable’s value or execute an expression from inside the string literal&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight kotlin"&gt;&lt;code&gt;&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="py"&gt;age&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nc"&gt;Int&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"29"&lt;/span&gt; 
&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="py"&gt;text&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Hello!, I'm Raul and I'm $age years old"&lt;/span&gt; &lt;span class="c1"&gt;// That prints Hello!, I'm Raul and I'm 29 years old &lt;/span&gt;
&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="py"&gt;expression&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"1+1 = ${1+1}"&lt;/span&gt; &lt;span class="c1"&gt;// That prints 1+1 = 2&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h1&gt;
  
  
  To be continued …
&lt;/h1&gt;

&lt;p&gt;I hope this was enough information to give you a rough idea of how kotlin interacts with variables and types. There is still a bit more to cover about kotlin’s main data types but we got off a good start.&lt;/p&gt;

&lt;p&gt;Next up we’ll see arrays and collections and how they work and interact with the information they hold. We will also see Pairs which is a kotlin-specific type, very similar to tuples in other languages.&lt;/p&gt;

&lt;p&gt;This post is part of a series aimed to give you an introduction to the language and a taste of the way kotlin does things. You can find it here: &lt;br&gt;
&lt;a href="https://raulmonteroc.com/mobile/kotlin/a-guide-to-the-kotlin-language/"&gt;A guide to the kotlin language&lt;/a&gt;&lt;/p&gt;

</description>
      <category>kotlin</category>
    </item>
    <item>
      <title>A guide to the Kotlin language</title>
      <dc:creator>Raul Montero</dc:creator>
      <pubDate>Wed, 01 Aug 2018 03:09:34 +0000</pubDate>
      <link>https://dev.to/raulmonteroc/a-guide-to-the-kotlin-language-336f</link>
      <guid>https://dev.to/raulmonteroc/a-guide-to-the-kotlin-language-336f</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--F5e5_4Fk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://raulmonteroc.com/wp-content/uploads/2018/07/kotlin_800x320-1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--F5e5_4Fk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://raulmonteroc.com/wp-content/uploads/2018/07/kotlin_800x320-1.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Have you heard of kotlin? It’s a relatively new language &lt;a href="https://blog.jetbrains.com/kotlin/2016/02/kotlin-1-0-released-pragmatic-language-for-jvm-and-android/"&gt;officially launched in 2016&lt;/a&gt; by &lt;a href="https://www.jetbrains.com/"&gt;JetBrains&lt;/a&gt;. They originally created the language as a more flexible and expressive alternative to Java, with the ability to run on top of the JVM, allowing developers to use kotlin and java code interchangeably in a project.&lt;/p&gt;

&lt;p&gt;Since then, a lot has happened, kotlin can now do a few extra tricks:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;It is officially supported on Android (and Android Studio) since Google &lt;a href="https://www.youtube.com/watch?v=d8ALcQiuPWs"&gt;announced it&lt;/a&gt; on the Google I/O of 2017.&lt;/li&gt;
&lt;li&gt;Trans-compile to javascript (as CoffeeScript or Typescript do)&lt;/li&gt;
&lt;li&gt;Run without a VM using &lt;a href="https://kotlinlang.org/docs/reference/native-overview.html"&gt;kotlin native&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Run on top iOS and mac os with interop with Objective-C&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I started learning kotlin not too long ago and found it quite interesting the way it handles things and the expressiveness it adds in an environment known for its verbose nature. The more I learned about the language, the more I enjoyed it. So I decided to share my thoughts and experiences with it by writing a mini blog series that can expose the language’s pragmatic nature and philosophy.&lt;/p&gt;

&lt;p&gt;I hope this serves you as much as it has to me and even if you don’t end up using it, at least you can take with you the kotlin way of thinking.&lt;/p&gt;

&lt;h1&gt;
  
  
  Let’s dive in
&lt;/h1&gt;

&lt;p&gt;Kotlin has numerous features some you can find in other languages and some other are very unique to kotlin but what all of those feature have in common is the promotion of concise and expressive code as part of the language philosophy.&lt;/p&gt;

&lt;p&gt;I’ll leave here the table of contents with a brief description of what you will encounter. Feel free to read it in any order you prefer.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Unfortunately, not all posts are available yet since this is an on-going series but you are welcome to read those that are ready. I’ll be posting the updates here and &lt;a href="https://twitter.com/raulmonteroc"&gt;twitter&lt;/a&gt;, so don’t forget to subscribe.&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://raulmonteroc.com/mobile/kotlin/variables-and-types-in-kotlin/"&gt;Variables and types.&lt;/a&gt; Variables in Kotlin are a bit different from what we are used to. Here we are going to explore the difference as well as the type system used and how it compares to other languages.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Arrays and collections.&lt;/strong&gt;  We use data to interact with our application and the way we do that is using arrays and collections. In this section, we will learn about the particularities of these data structures how and how to take the most advantage.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://raulmonteroc.com/mobile/kotlin/nullability-in-kotlin/"&gt;Nullability.&lt;/a&gt; Nullability is a very interesting topic on kotlin, mainly because unlike other strongly typed languages, it doesn’t allow null values out of the box protecting your code against the famous NullPointerException&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Operators&lt;/strong&gt;. Every language has operators to express logic in a straight-forward way. Kotlin uses the one we are used to in C-descendants languages and also provides a few of its own.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Flow control and loops.&lt;/strong&gt;  If you have been programming in any other language you must be used to flow control and loops, on kotlin we add a little sugar on top to make it even more expressive and easier to read.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Classes and Object Oriented Programming.&lt;/strong&gt;  Have you developed in _any _OOP language you surely will feel comfortable with this topic  *&lt;em&gt;but *&lt;/em&gt; as usual, Kotlin take this a bit further with composable objects, default implementations and even simpler ways to express and declare classes.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Generics.&lt;/strong&gt;  Have you used a collection of a particular type? Something like Array&amp;lt;String&amp;gt;? Here we will learn how to use a template on your class that you can pass a type later on to provide extra flexibility and reusability, and just like collections, you will feel you have multiple classes and only wright one.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>kotlin</category>
      <category>android</category>
      <category>array</category>
      <category>case</category>
    </item>
    <item>
      <title>Nullability in kotlin, a pragmatic approach.</title>
      <dc:creator>Raul Montero</dc:creator>
      <pubDate>Wed, 25 Jul 2018 01:25:32 +0000</pubDate>
      <link>https://dev.to/raulmonteroc/nullability-in-kotlin-a-pragmatic-approach-ep6</link>
      <guid>https://dev.to/raulmonteroc/nullability-in-kotlin-a-pragmatic-approach-ep6</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--F5e5_4Fk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://raulmonteroc.com/wp-content/uploads/2018/07/kotlin_800x320-1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--F5e5_4Fk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://raulmonteroc.com/wp-content/uploads/2018/07/kotlin_800x320-1.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Coming from other strongly-typed languages like Java or C#, the NullPointerException is one of the most common exceptions you can find, providing long debug sessions simply because a null reference was passed around and eventually called for.&lt;/p&gt;

&lt;p&gt;Kotlin addressed this issue at a compiler-level, using it to throw errors when trying to assign a value to an object that has the &lt;strong&gt;potential&lt;/strong&gt; to contain null values,  *&lt;em&gt;unless *&lt;/em&gt; you explicitly let kotlin know that is the intended behavior, and even then, you need a special syntax to access that object’s methods from thereon.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight kotlin"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Java and C# &lt;/span&gt;
&lt;span class="n"&gt;string&lt;/span&gt; &lt;span class="n"&gt;str&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;null&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// valid&lt;/span&gt;

&lt;span class="c1"&gt;//Kotlin &lt;/span&gt;
&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="py"&gt;str&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;null&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// not valid&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;In the above code, you can see, kotlin doesn’t even allow the assignation of null value to a variable, if you wish to do so you must use a nullable type, which is kotlin’s way to tell the compiler that this variable has the potential to hold null values.&lt;/p&gt;

&lt;p&gt;You indicate this adding a question mark at the end of the variable’s type, as follows&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight kotlin"&gt;&lt;code&gt;&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="py"&gt;str&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt;&lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;null&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// valid&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;This code does compile and allows you to use variables holding null values in kotlin by stating it explicitly to the compiler that this is your intent.&lt;/p&gt;

&lt;p&gt;Now, &lt;strong&gt;there is a catch&lt;/strong&gt;. Remember the special syntax we talk about earlier? Well, now is the time to use it. You see, once a variable contains a nullable type you can’t use the dot notation anymore, so you must take one of two approaches when calling one the object’s methods or properties:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Use the double bang syntax(!!)&lt;/strong&gt; to access the method and throw a runtime exception if a null value is encountered.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Use the safe-call syntax (?.)&lt;/strong&gt; to access the method and return the null value (if encountered) while keeping the workflow of the program intact
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight kotlin"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Alternative 1: Throw an exception &lt;/span&gt;
&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="py"&gt;nullError&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt;&lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;null&lt;/span&gt; &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="py"&gt;count1&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;nullError&lt;/span&gt;&lt;span class="o"&gt;!!&lt;/span&gt;&lt;span class="nf"&gt;length&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="c1"&gt;// Throws an exception &lt;/span&gt;

&lt;span class="c1"&gt;// Alternative 2 : Return the null value &lt;/span&gt;
&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="py"&gt;returnValue&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt;&lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;null&lt;/span&gt; &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="py"&gt;count2&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;returnValue&lt;/span&gt;&lt;span class="o"&gt;?.&lt;/span&gt;&lt;span class="n"&gt;length&lt;/span&gt; &lt;span class="c1"&gt;// Returns the null value and keep the program running &lt;/span&gt;

&lt;span class="c1"&gt;// dot notation &lt;/span&gt;
&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="py"&gt;invalidSyntax&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt;&lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;null&lt;/span&gt; &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="py"&gt;count3&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;invalidSyntax&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;length&lt;/span&gt; &lt;span class="c1"&gt;//Not valid for nullable types. A compile error is thrown&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h2&gt;
  
  
  Elvis Operator
&lt;/h2&gt;

&lt;p&gt;Although kotlin does not encourage the usage of null values, the language provides a null check operator for those cases where you must interact with them simplifying the code and making it more readable. The operator is called the Elvis operator (?:) and works as follows:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Evaluate the expression at the right of the operator&lt;/li&gt;
&lt;li&gt;If it returns null, then evaluate and return the expression on the left side and return it&lt;/li&gt;
&lt;li&gt;If not, return the right side
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight kotlin"&gt;&lt;code&gt;&lt;span class="c1"&gt;// right side invalid &lt;/span&gt;
&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="py"&gt;str&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt;&lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;null&lt;/span&gt; &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="py"&gt;count&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;str&lt;/span&gt; &lt;span class="o"&gt;?:&lt;/span&gt; &lt;span class="s"&gt;""&lt;/span&gt; &lt;span class="c1"&gt;// right side is null, evaluate and return the left side &lt;/span&gt;

&lt;span class="c1"&gt;//right side valid &lt;/span&gt;
&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="py"&gt;validStr&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Test"&lt;/span&gt; &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="py"&gt;count&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;validStr&lt;/span&gt; &lt;span class="o"&gt;?:&lt;/span&gt; &lt;span class="s"&gt;""&lt;/span&gt; &lt;span class="c1"&gt;// right side is not null, return the right side without evaluating the left&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;The approach to work with null values in kotlin is very pragmatic, you get compiler validation at the expense of not using null values unless explicitly stating it using special syntax which in turn makes you want to avoid them as much as possible and at it, preventing unwanted NullPointerExcepetions.&lt;/p&gt;

&lt;p&gt;From my perspective, this is a great tradeoff. I know I won’t miss those exceptions one bit.&lt;/p&gt;

&lt;p&gt;This post is part of a series aimed to give you an introduction to the language and a taste of the way kotlin does things. You can find it here:&lt;a href="https://raulmonteroc.com/mobile/kotlin/a-guide-to-the-kotlin-language/"&gt; A guide to the kotlin language&lt;/a&gt;&lt;/p&gt;

</description>
      <category>kotlin</category>
      <category>code</category>
      <category>development</category>
      <category>doublebang</category>
    </item>
    <item>
      <title>Demystifying Remote Work, the truth and the myth</title>
      <dc:creator>Raul Montero</dc:creator>
      <pubDate>Thu, 12 Apr 2018 02:44:42 +0000</pubDate>
      <link>https://dev.to/raulmonteroc/demystifying-remote-work-the-truth-and-the-myth-2c1g</link>
      <guid>https://dev.to/raulmonteroc/demystifying-remote-work-the-truth-and-the-myth-2c1g</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--btJuMo9M--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://raulmonteroc.com/wp-content/uploads/2018/04/Remote-Working-1-e1524101448590.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--btJuMo9M--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://raulmonteroc.com/wp-content/uploads/2018/04/Remote-Working-1-e1524101448590.jpeg" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Ah, working on the beach (or mountains), having time to yourself, no boss breathing behind your neck, in other words, freedom while still being a responsible adult. Sounds good, right? The idea of remote work really is appealing. When the location becomes optional a lot of ideas comes to mind.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Unfortunately, the reality of remote work is not as the media and the internet make it sound.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Remote work is awesome but not everybody likes it nor is it for everyone. The problem is, only a portion of the experience gets the spotlight, while the other you can only get an insight from someone else already in the remote boat.&lt;/p&gt;

&lt;h3&gt;
  
  
  What remote work really is about
&lt;/h3&gt;

&lt;p&gt;Remote work is (surprisingly) really about work. In fact, I would say as a remote worker you need to work harder than your on-site counter-part. Here is why :&lt;/p&gt;

&lt;h4&gt;
  
  
  1. You are not physically there
&lt;/h4&gt;

&lt;p&gt;Other people can’t see you work, which means you need to make yourself present by the job you do, the solutions you provide and your contributions to your team.&lt;/p&gt;

&lt;h4&gt;
  
  
  2. There is no tech support.
&lt;/h4&gt;

&lt;p&gt;You use your own hardware with your own setup and as such you are responsible for it. You are in charge of maintaining it clean, updated and virus-free and even have a backup computer in case your main one fails you. There are some companies who alleviate this a bit, but at the end of the day, you are still in charge of keeping everything in order.&lt;/p&gt;

&lt;h4&gt;
  
  
  3. Working spaces are not as easy to come by
&lt;/h4&gt;

&lt;p&gt;Let’s be honest, you can work one day or two at the beach when the work is light, but that’s no place when you really need to focus. For most cases, you will need a quiet, comfortable space where you can hear your own thoughts and be free of external distractions.&lt;br&gt;&lt;br&gt;
This is not as easy as it sounds, getting your family used to the fact you are at home but are not available takes time. Ideally, you should find a place where you can use exclusively for work at home or get a membership at a near coworking space.&lt;/p&gt;

&lt;h4&gt;
  
  
  4. You get paid by the hour.
&lt;/h4&gt;

&lt;p&gt;Most remote contracts are paid by worked hours instead of having a fixed salary. This serves as a double edge sword, on one end, you can get an extra cash when you need it by working a bit more but on the other end, if you made 38 hours a given week, you don’t get paid 40. Some companies have policies for this kind of things, but not all of them.&lt;/p&gt;

&lt;h4&gt;
  
  
  5. You don’t get the social factor
&lt;/h4&gt;

&lt;p&gt;As a remote worker, you don’t interact with people as much. This gives you a boost in productivity but also privates you from the natural daily social interaction, this may seem little for the less social kind of people, but trust me, it weights over time if not taken seriously.&lt;/p&gt;

&lt;h3&gt;
  
  
  Still, working remote is awesome
&lt;/h3&gt;

&lt;p&gt;I know, seeing remote work as a whole, may seem a little discouraging or even a challenge, but let me tell you, working remote can be described in one word, freedom.&lt;/p&gt;

&lt;p&gt;Depending on the kind of person you are, this is going to be a good thing or not. Having freedom will let you do things the way it works best for you.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;You can work anywhere.&lt;/strong&gt; This goes way beyond working at the beach, this means you tap into the international market which expands exponentially your possibilities and depending where you live, you can take advantage of the difference in economies, earning like you live in a high-cost city, while living in a lower-cost one, making your earnings more meaningful.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;No more sitting on a desktop or chair you don’t like&lt;/strong&gt;. Now you can adjust your work environment to your style, making you feel more comfortable and ergonomic even.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Your rules.&lt;/strong&gt; Now you can select an operating system, tools and environment in general that makes you most productive, adjusted to your work style.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Final Thoughts
&lt;/h3&gt;

&lt;p&gt;In the end, remote work is an amazing modality and an excellent way for you to work the way that suits you best. Yes, not everything is pink-colored, there are some things you must take in account before diving in, but for the most part, working remotely, in my opinion, is the best way to work while maintaining a balanced and healthy life, on your own terms.&lt;/p&gt;

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