<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Nicola Piriottu on Medium]]></title>
        <description><![CDATA[Stories by Nicola Piriottu on Medium]]></description>
        <link>https://medium.com/@nicola.piriottu?source=rss-2d22b34d0231------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*-OiZlA-ZKH5iN6p_-Yk7xA.jpeg</url>
            <title>Stories by Nicola Piriottu on Medium</title>
            <link>https://medium.com/@nicola.piriottu?source=rss-2d22b34d0231------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 19:37:39 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@nicola.piriottu/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[How to implement a modular UI on Android]]></title>
            <link>https://insights.overapp.com/how-to-implement-a-modular-ui-on-android-4061678fac0a?source=rss-2d22b34d0231------2</link>
            <guid isPermaLink="false">https://medium.com/p/4061678fac0a</guid>
            <category><![CDATA[android-development]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[overapp]]></category>
            <category><![CDATA[recyclerview]]></category>
            <category><![CDATA[kotlin]]></category>
            <dc:creator><![CDATA[Nicola Piriottu]]></dc:creator>
            <pubDate>Fri, 05 Aug 2022 17:19:58 GMT</pubDate>
            <atom:updated>2023-03-28T14:02:35.411Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AwSWuVJtVF0VniFQrUB8Ag.png" /></figure><p>How many times in a life cycle’s project we had to update the UI of an application, even in progress?<br>This, actually, might not be such a simple thing, especially when even the APIs change.</p><blockquote>In this article I would tell you about a new approach that will facilitate the resolution of this problem.<br>I’ll show you two examples where we will analyze the layout in order to subdivide it in simple and interchangeable blocks.<br>The focal point of this different approach is the creation of a list that has the task of organizing the display rules.</blockquote><p><a href="https://github.com/NicolaPiriottu/UseCase">GitHub - NicolaPiriottu/UseCase: Example UseCase by LiveData, ListAdapter, RecyclerView, Ktor</a></p><p>Working at <a href="https://medium.com/u/fbe7e07cf9d2">OverApp</a> I had the chance to implement an internal business pattern for the UI management. To do this, I used something that we called UIItem. This technique <strong>revolutionized my experience as a developer</strong> in the implementation of complex projects that use the <a href="https://developer.android.com/guide/topics/ui/layout/recyclerview">RecyclerView</a>.</p><p>As previously mentioned, the main actor is our <strong>list. </strong>Through a <strong>mapping</strong>, the list will allow us to create the UI display rules: at this point, it will be enough to <strong>change the order of the elements</strong> of the list to completely revolutionize the view.</p><p><em>Although initially it may seem complicated or cumbersome, </em><strong><em>in 4 steps </em></strong><em>we’ll have a modular code to represent our UI.</em></p><h4>Prerequisites:</h4><p>In order to succeed in this enterprise, the implementation of the pattern <a href="https://developer.android.com/topic/architecture">MVVM</a> is indispensable, not only for its versatility, but also because it’s <a href="https://developer.android.com/topic/libraries/architecture/viewmodel">ViewModel</a>’s task to do the <strong>mapping</strong> and delegate to the <a href="https://developer.android.com/reference/android/app/Activity">Activity</a> or <a href="https://developer.android.com/reference/android/app/Fragment">Fragment</a> the update of the view using <a href="https://developer.android.com/topic/libraries/architecture/livedata">LiveData</a>.</p><p><a href="https://ktor.io/">Ktor</a> knowledge is recommended, but don’t worry, I explained it <strong>in my previous</strong> <a href="https://medium.com/overapp-android/rest-api-with-ktor-on-android-13fd835cdf65"><strong>article</strong></a><strong>!</strong></p><h4>Implementation</h4><p>As already mentioned, in this article we focus on the modularity in the implementation phase of the UI. To do this, I prepared a project that includes two scenarios, each with their respective APIs created with the help of <a href="https://medium.com/u/f655e1e36628">Giorgio Fausto Canu</a>:</p><ul><li><strong>the first scenario</strong> is to build the UI and the project structure;</li><li><strong>the second scenario</strong> is to see modularity in action, that is, simulating having had changes to the UI and API.</li></ul><h3>Scenario 1:</h3><p>Let’s imagine we have to create a detail sheet which, initially, is structured in this way :</p><ul><li>item 1 : a title (with subtitle)</li><li>item 2 : an image</li><li>item 3: subtitle and description</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RwMp0EP0lcnhHanXqh8-7A.png" /></figure><p>Let’s consider the first <strong>API</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0afcd2f0825be898c657c72b119d6171/href">https://medium.com/media/0afcd2f0825be898c657c72b119d6171/href</a></iframe><h3>Step 1/4 :</h3><p>Let’s now pass to the implementation of the heart of this Pattern: t<strong>he creation of the </strong><a href="https://kotlinlang.org/docs/sealed-classes.html"><strong>sealed class</strong></a><strong>.</strong> Inside it, we implement an <a href="https://kotlinlang.org/docs/enum-classes.html"><strong>enum</strong></a> with the task of defining the items, that is the type of view to be shown in the <a href="https://developer.android.com/reference/android/widget/Adapter"><strong>adapter</strong></a>. <br>For each of them we represent the model with a <a href="https://kotlinlang.org/docs/data-classes.html"><strong>data class</strong></a>:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/cab832a789e3b9e512305af5604455c3/href">https://medium.com/media/cab832a789e3b9e512305af5604455c3/href</a></iframe><h3>Step 2/4:</h3><p>Let’s start with the representation of the models by creating the xml layout:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d28a36f8902fc55677d32a9f416e1664/href">https://medium.com/media/d28a36f8902fc55677d32a9f416e1664/href</a></iframe><p>and the corresponding <a href="https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerView.ViewHolder">ViewHolder</a> :</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/543b51b0f142a49dccfc572494d66b14/href">https://medium.com/media/543b51b0f142a49dccfc572494d66b14/href</a></iframe><p><strong>The other examples</strong> can be found in my <strong>GitHub</strong> that I mentioned at the beginning of the article.</p><h3>Step 3/4:</h3><p>Let’s move on to create the <a href="https://developer.android.com/reference/android/widget/Adapter">adapter</a>. <br>We implement <a href="https://developer.android.com/reference/androidx/recyclerview/widget/ListAdapter">ListAdapter</a>, which is going to manage the list updates, using simply <a href="https://developer.android.com/reference/androidx/recyclerview/widget/ListAdapter#submitList(java.util.List%3CT%3E)">submitList()</a> and no longer the <a href="https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerView.Adapter#notifyDataSetChanged()">notifyDataSetChanged()</a>. <br>Thanks to the <a href="https://developer.android.com/reference/android/support/v7/util/DiffUtil.html">DiffUtil</a> we also have checks on the equality of the elements.<br>For more information, check the <a href="https://medium.com/r?url=https%3A%2F%2Fdeveloper.android.com%2Freference%2Fandroidx%2Frecyclerview%2Fwidget%2FListAdapter"><strong>official guide</strong></a>.</p><p>Let’s observe the most important method: <strong>getItemViewType. </strong>Through the enum, PostType, implemented inside PostItem, it allows us to correctly and uniquely define the corresponding view.</p><p>Inside the <strong>onBindViewHolder</strong> method, we can see how the <strong>creation of ViewHolders</strong> is done by obtaining the reference of each element of the enum, thanks to <a href="https://kotlinlang.org/docs/enum-classes.html#working-with-enum-constants"><strong>values()</strong></a>, while its position is obtained through the <strong>viewType</strong>.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d94b1fac7fa983fd24f69b736f504df6/href">https://medium.com/media/d94b1fac7fa983fd24f69b736f504df6/href</a></iframe><h3>Step 4/4:</h3><p>We got to the most important part: the mapping of the response inside the ViewModel.<br>We create a <a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-list/">MutableList</a>, of the <strong>PostItem</strong> type (that is our <a href="https://kotlinlang.org/docs/sealed-classes.html">sealed class</a>). The MutableList allows us to build the UI for the management of the UIItems. Finally we implement the mapping: that is to create the rules of visibility that compose the UI.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/40a26873538ec93cb22062d3c91b1120/href">https://medium.com/media/40a26873538ec93cb22062d3c91b1120/href</a></iframe><p><strong><em>Now making a change is easy: just create the visibility rules and you’re done. No more wasted time when the UI changes!</em></strong></p><h3>Scenario 2:</h3><p>Let’s assume we need to make a change to the UI:<br>We have to <strong>remove the central image</strong>, which will take the <strong>place of the description</strong>, and then we have to <strong>add</strong> a new view called <strong>gallery</strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NMKyYRMzJ8lP1AhNH8Ozrg.png" /></figure><p>not only did they also provide us with the new API, here is the corresponding <strong>response</strong> :</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5b334d389a60b705777a0f89c7bd855a/href">https://medium.com/media/5b334d389a60b705777a0f89c7bd855a/href</a></iframe><p>we can see, from the JSON, that:<br>- <strong>title</strong> and <strong>subtitle</strong> are no longer a single object, but two <strong>separate </strong>objects<br>- the <strong>description</strong> object now has the text <strong>split</strong> on three different attributes.</p><p>Let’s repeat, for<strong> scenario 2,</strong> all 4 steps together to implement these changes.</p><h3>Step 1/4 :</h3><p>We update the sealed class by adding a new <strong>type</strong> called <strong>GALLERY </strong>inside the enum. After this we add the representation of the model in the <strong>data class</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ee21030850acd5c272756b90537ca683/href">https://medium.com/media/ee21030850acd5c272756b90537ca683/href</a></iframe><h3>Step 2/4 :</h3><p>Create the xml layout and its ViewHolder.</p><h3>Step 3/4 :</h3><p>Update the adapter to include the new type and the corresponding ViewHolder</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/52c8d10eab081e46e4cbe368f13df72f/href">https://medium.com/media/52c8d10eab081e46e4cbe368f13df72f/href</a></iframe><h3>Step 4/4 :</h3><p>We implement the new mapping to include <strong>the new set of rules</strong> to be displayed, changing the order and elements of the list.</p><ul><li>In the first place we always keep <strong>TitleUIItem;</strong></li><li>In second place we find <strong>DescriptionUIItem, </strong>which takes the place of <strong>ImageUIItem</strong>;<strong> </strong>since the text <strong>is split over three parts</strong> it will be concatenated<strong>.</strong></li><li>In third place we add <strong>GalleryUIItem</strong></li></ul><p>As you can see, the implementations is versatile and fast.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/367c9c0d50a6f9076ddea7ddf17ee2a2/href">https://medium.com/media/367c9c0d50a6f9076ddea7ddf17ee2a2/href</a></iframe><h4>Conclusion</h4><p>Initially implementing the UIItem pattern may seem complex, but doing so saves us time in case of UI modification / deletion, allowing for better maintenance of the code over time.</p><p>by <a href="https://medium.com/u/2d22b34d0231">Nicola Piriottu</a> and <a href="https://medium.com/u/f719c6732e8">Giampietro Fronteddu</a>, Android Developers at <a href="https://www.overapp.com/">OverApp</a>.</p><p><a href="https://it.linkedin.com/in/nicola-luigi-piriottu-ba429219b?original_referer=https%3A%2F%2Fwww.google.com%2F">Nicola Luigi Piriottu - Android Developer - OverApp | LinkedIn</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4061678fac0a" width="1" height="1" alt=""><hr><p><a href="https://insights.overapp.com/how-to-implement-a-modular-ui-on-android-4061678fac0a">How to implement a modular UI on Android</a> was originally published in <a href="https://insights.overapp.com/">OverApp</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[REST API with Ktor on Android]]></title>
            <link>https://insights.overapp.com/rest-api-with-ktor-on-android-13fd835cdf65?source=rss-2d22b34d0231------2</link>
            <guid isPermaLink="false">https://medium.com/p/13fd835cdf65</guid>
            <category><![CDATA[coroutine]]></category>
            <category><![CDATA[ktor]]></category>
            <category><![CDATA[android-development]]></category>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[mvvm]]></category>
            <dc:creator><![CDATA[Nicola Piriottu]]></dc:creator>
            <pubDate>Wed, 10 Nov 2021 08:30:39 GMT</pubDate>
            <atom:updated>2023-03-28T14:00:32.143Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DdbOwudTkMNfrLj30bKdzw.png" /></figure><p>Working as a Android Developer at OverApp, I had the opportunity to study and implement applications using <a href="https://ktor.io/">Ktor</a> a framework for creating asyncronous call to Rest API.</p><p><a href="https://github.com/NicolaPiriottu/KtorKotlin">GitHub - NicolaPiriottu/KtorKotlin: Use Ktor Kotlin</a></p><p>In this article, with the help of <a href="https://medium.com/u/f719c6732e8">Giampietro Fronteddu</a>, I will show you how to call all the main HTTP verbs of a <strong>rest api</strong>, in an application using the <a href="https://developer.android.com/jetpack/guide"><strong>MVVM</strong></a><strong> </strong>design pattern.</p><h4>Project structure</h4><p>The project i will create for this example is following the MVVM design pattern.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YJsgLP18zr88QiLB8ILOZw.png" /></figure><p>Using this pattern will allow us to create a flexible app, so that replacing Ktor with another library, for example <a href="https://square.github.io/retrofit/"><strong>Retrofit</strong></a>, will not require much effort as all the data access code is concentrated in a single point of the app.</p><blockquote>For this example we will se <a href="https://jsonplaceholder.typicode.com/">JSONPlaceholder</a>, a website that exposes a simple REST API with dummy data.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Bwl3XHi0B32NyalUPt-7Fw.png" /><figcaption><a href="https://jsonplaceholder.typicode.com/">https://jsonplaceholder.typicode.com/</a></figcaption></figure><h3>Ktor Requirements</h3><p>In order to function properly Ktor needs an HTTP <a href="https://ktor.io/docs/http-client-engines.html#apache"><strong>engine</strong></a><strong> </strong>and <a href="https://ktor.io/docs/json.html"><strong>Serialization/Deserialization</strong></a> Library. For this project we will use:</p><ol><li>The engine CIO (Coroutine-based I/O). <br>- <em>implementation “io.ktor:ktor-client-cio:1.6.3”</em></li><li>Te Ktor default Serialization/Deserialization (To parse <a href="https://ktor.io/docs/request.html">requests</a> and <a href="https://ktor.io/docs/response.html">responses</a>)<br>- <em>implementation ‘io.ktor:ktor-client-gson:1.6.3’</em></li><li>(Optional) Some <a href="https://ktor.io/docs/client-logging.html#install_feature"><strong>logging</strong></a> libraries to help with debugging.<br>- <em>implementation “io.ktor:ktor-client-logging:1.6.1”</em><br>- <em>implementation “ch.qos.logback:logback-classic:1.2.3”</em></li></ol><h3>Client implementation</h3><p>In this example, I’ll show you how to configure the client and make calls.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0cb9d4c5120213272f58f391254ff0a4/href">https://medium.com/media/0cb9d4c5120213272f58f391254ff0a4/href</a></iframe><ul><li>In this code snippet we configure the Ktor client:<br><em>private val client = HttpClient(CIO)<br></em>this lines instantiate the Ktor client using the CIO engine.</li><li>here we are configuring some default values(<a href="https://ktor.io/docs/default-request.html"><strong>DefaultRequest</strong></a><strong>)</strong> for our requests, for example we add a Bearer token to the <strong>Authorization</strong> Header .</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7f3d560429298613cb014242f9bfdba6/href">https://medium.com/media/7f3d560429298613cb014242f9bfdba6/href</a></iframe><ul><li>then we configure the serializer for the client</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d03b196940ccd1f328b775faad9b1da7/href">https://medium.com/media/d03b196940ccd1f328b775faad9b1da7/href</a></iframe><ul><li>finally we enable request/response to be shown in the Android Studio Terminal.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/57c260211c172e58132661b6ee90bf27/href">https://medium.com/media/57c260211c172e58132661b6ee90bf27/href</a></iframe><h4>Request example</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*h5psoPmnsLJWSC-mID6ODw.png" /></figure><h4>Response example</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0_tyaG-E9MIBfNBsvXZsaw.png" /></figure><h3><strong>How to e</strong>xecute Ktor request</h3><p><strong>Response validation<br></strong>Before we begin, we have to point out that calls need the <strong>try/catch</strong> construct to work.<br>It allows us to catch <a href="https://ktor.io/docs/response-validation.html">exceptions</a> when the status code is other than <strong>2xx</strong>.<br>I created a class, called <strong>NetworkResponseCode</strong>, which can return the error code based on the type of exception.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/81e2265a15bb0ce0d60d091e60e84471/href">https://medium.com/media/81e2265a15bb0ce0d60d091e60e84471/href</a></iframe><p>The response is passed through a sealed class called <strong>NetworkResponse</strong>.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a5bd494015f2081e64cfc314c0f43425/href">https://medium.com/media/a5bd494015f2081e64cfc314c0f43425/href</a></iframe><h3>Network Requests</h3><p>Let’s start with the response model named <strong>PostResponse</strong>.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/52ccb5bab31eb1f9b4b9f7a5ff7a3756/href">https://medium.com/media/52ccb5bab31eb1f9b4b9f7a5ff7a3756/href</a></iframe><h4>Repository</h4><p>Each request is built with these points:<br>1) <strong>API_WORKER.getClient()</strong> which exposes the .<strong>get, .post, .put, .delete</strong> methods passing the URL as a parameter.<br>2) Inside this block it’s possible to add <em>optional parameters</em>.<br>An example is <strong>parameter</strong>, that allows you to create <em>query strings</em>, for example:<br>https://jsonplaceholder.typicode.com/posts<strong>?id=5<br></strong>3) the response, in the event of a response with a <strong>2xx </strong>result<br>4) the error code based on the type of exception</p><ul><li><strong>GET request example</strong></li></ul><p>In this first example we created a function that returns a post with id = 5.<br>A <strong>response </strong>variable is created, of type<strong> HttpResponse</strong>, which allows obtaining the response of the call.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/54597d95e50d4d3ff69e1c3898a34607/href">https://medium.com/media/54597d95e50d4d3ff69e1c3898a34607/href</a></iframe><ul><li><strong>POST request example</strong></li></ul><p>Similarly to the GET, has an object that is passed to the optional <strong>body</strong> parameter.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f6ec0ec0d0afec448daf88383b177162/href">https://medium.com/media/f6ec0ec0d0afec448daf88383b177162/href</a></iframe><p>In this example, the function receives input parameters.<br>Through a <a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-hash-map/">hashMap</a> an object is constructed to put in the <strong>body</strong>.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/59c4f5175391d5e8f9f0c7b0aa844e3a/href">https://medium.com/media/59c4f5175391d5e8f9f0c7b0aa844e3a/href</a></iframe><ul><li><strong>DELETE request example</strong></li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b17ee3faba76b140e82367bdc4cad663/href">https://medium.com/media/b17ee3faba76b140e82367bdc4cad663/href</a></iframe><ul><li><strong>PUT request example</strong></li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d1890fd8497a035d51b3356944afe66c/href">https://medium.com/media/d1890fd8497a035d51b3356944afe66c/href</a></iframe><h3>Example of use within the ViewModel</h3><p>Now I show you how to implement the GET request to get a list of posts. For other requests you can refer to this <a href="https://github.com/NicolaPiriottu/KtorKotlin">project</a>.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c3f9d7c0176730486a142297d1bdd665/href">https://medium.com/media/c3f9d7c0176730486a142297d1bdd665/href</a></iframe><p>1) <strong>getPosts()</strong> creates and runs a coroutine by calling <strong>callPosts()</strong>.<strong><br></strong>2) <strong>callPosts()</strong> is a suspend, while <strong>Dispatchers.IO</strong> indicates that this coroutine isn’t executed on the <a href="https://developer.android.com/guide/components/processes-and-threads">Main thread</a>.<br><strong>NetworkResponse.Success</strong> : shows the list of posts.<br><strong>NetworkResponse.Error</strong> : shows the error code.</p><h3>Final Thoughts</h3><p>To better understand Ktor and this article, knowledge of these topics is recommended:</p><p><a href="https://developer.android.com/topic/libraries/architecture/viewmodel">ViewModel</a>, <a href="https://developer.android.com/topic/libraries/architecture/livedata">LiveData</a>, <a href="https://developer.android.com/kotlin/coroutines?gclid=Cj0KCQjw18WKBhCUARIsAFiW7Jz1WzvZzoqJHuSENX7hU_jo9uCYvqjVjGmq8OvzS_PHTmzzA7Y0t0gaAs4ZEALw_wcB&amp;gclsrc=aw.ds">Coroutines</a>, <a href="https://kotlinlang.org/docs/sealed-classes.html">sealed class</a>, <a href="https://kotlinlang.org/docs/data-classes.html">data class</a>, o<a href="https://kotlinlang.org/docs/object-declarations.html#object-declarations-overview">bject</a>.</p><p>Thank you for your attention, I hope it was a useful guide.</p><p>Created by <a href="https://medium.com/u/2d22b34d0231">Nicola Piriottu</a> and <a href="https://medium.com/u/f719c6732e8">Giampietro Fronteddu</a>, Android Mobile Developers at <a href="https://www.overapp.com/">OverApp</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=13fd835cdf65" width="1" height="1" alt=""><hr><p><a href="https://insights.overapp.com/rest-api-with-ktor-on-android-13fd835cdf65">REST API with Ktor on Android</a> was originally published in <a href="https://insights.overapp.com/">OverApp</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to update old projects and run them on Android 4+]]></title>
            <link>https://insights.overapp.com/how-to-update-old-projects-and-run-them-on-android-4-37d1e0de042?source=rss-2d22b34d0231------2</link>
            <guid isPermaLink="false">https://medium.com/p/37d1e0de042</guid>
            <category><![CDATA[android-studio]]></category>
            <category><![CDATA[gradle]]></category>
            <category><![CDATA[app-upgrade]]></category>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[android-development]]></category>
            <dc:creator><![CDATA[Nicola Piriottu]]></dc:creator>
            <pubDate>Tue, 12 Oct 2021 15:15:14 GMT</pubDate>
            <atom:updated>2023-03-28T14:03:43.227Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jg-li876e1NfKkkv8KUzeg.png" /></figure><p>While working as a Developer for <a href="https://www.overapp.com/">OverApp</a>, I happened to be working on a 2014/2015 project that is not supported by the latest version of <strong>Android Studio (Artic Fox)</strong>. In this article I will share with you the simple steps that, with the help of <a href="https://medium.com/u/f719c6732e8">Giampietro Fronteddu</a>, allowed me to update the project.</p><p>Step 1) running the application</p><p>I provided a version of Android Studio, available <a href="https://developer.android.com/studio/archive"><strong>here</strong></a>, that would allow you to compile the project. In my case I used <strong>Android Studio 3.0.1</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KSWByU5Qt9wGODTkimWGcQ.png" /></figure><p>For Mac users I recommend downloading the version with the <strong>.app</strong> extension, because it enables to <strong>run</strong> Android Studio directly <strong>without installing it</strong>.</p><p>Once the project has been imported, you will find one of these two screens:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/221/1*ajWxuf33g_BUvH1O7R99vg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/256/1*DRFqu2YR3uISiUo1DUoI5Q.png" /></figure><p>Starting the project this <a href="https://docs.gradle.org/current/userguide/what_is_gradle.html">Gradle</a> error appears:<br><strong>No such property: GradleVersion for class: JetGradlePlugin</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/816/1*G3l1c1ZwL_u2JTzQlJ2d9A.png" /></figure><p>This error is due to Android Studio failing to compile correctly.<br>To solve this problem we have to downgrade the <a href="https://docs.gradle.org/current/userguide/what_is_gradle.html">Gradle</a>;<strong> </strong><br>I chose <strong>Required Gradle version 2.10 </strong>which you can find in this <a href="https://gradle.org/releases/">link</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Jum_tofSIEjzFRo5wy2rpw.png" /></figure><p>while for <strong>Android Plugin Version 2.0.0</strong>, I chose the highlighted version, indicated in this <a href="https://developer.android.com/studio/releases/gradle-plugin">link</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3AFFw3BQUdRt6y0ixWVDXQ.png" /></figure><p>to apply the changes you need to go to:<br><em>File =&gt;Project Structure =&gt; Project </em><br>and copy the versions and click OK. Synchronization will be done.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/799/1*Igu0G5hJryrXGcdkrgJWYQ.png" /></figure><p>Now we can finally <strong>run the app</strong> and start upgrading the project.<br>Android Studio will now show a warning similar to these:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/551/1*Mforzub2ZN481qtuCLmIkQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*vfFKs_Ed-hgW1ZSUC36vqQ.png" /></figure><p>Run the update. Then go to:<br><em>fIle =&gt;Invalidate caches/restart</em></p><p><strong>Step 2) Start the project on Android Studio 4+</strong></p><p>Now run the project on the most up-to-date IDE, at startup you may see this warning:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/332/1*jyOQv-8ywuU2sDitzAK9Bw.png" /></figure><p>All normal, click on <strong>Trust Project</strong>.</p><p>Now comes the <strong>tricky</strong> part, you will have to update the deprecated libraries until you get an updated version.</p><p>To make it always go up:<br><em>file =&gt;Project Structure =&gt; Project</em></p><h4>Attention! I recommend that you save the current state of the project before proceeding.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/334/1*tZKVHKbEXU_IAcHZbIAn-w.png" /></figure><p>Then follow the Android Studio warnings to update the Gradle to the latest version.</p><p>You now have an updated project!</p><p>by <a href="https://medium.com/u/2d22b34d0231">Nicola Piriottu</a> and <a href="https://medium.com/u/f719c6732e8">Giampietro Fronteddu</a>, Android Mobile Developers at <a href="https://www.overapp.com/">OverApp</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=37d1e0de042" width="1" height="1" alt=""><hr><p><a href="https://insights.overapp.com/how-to-update-old-projects-and-run-them-on-android-4-37d1e0de042">How to update old projects and run them on Android 4+</a> was originally published in <a href="https://insights.overapp.com/">OverApp</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>