<?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 Rishiraj Randive on Medium]]></title>
        <description><![CDATA[Stories by Rishiraj Randive on Medium]]></description>
        <link>https://medium.com/@randive.rishiraj?source=rss-8ec895a52fed------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*cLyFMujozlIm_0fM.</url>
            <title>Stories by Rishiraj Randive on Medium</title>
            <link>https://medium.com/@randive.rishiraj?source=rss-8ec895a52fed------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 23:27:42 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@randive.rishiraj/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[HTML Editing Simplified with Kotlin Script And Jsoup]]></title>
            <link>https://medium.com/@randive.rishiraj/html-editing-simplified-with-kotlin-script-and-jsoup-370d34ece159?source=rss-8ec895a52fed------2</link>
            <guid isPermaLink="false">https://medium.com/p/370d34ece159</guid>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[script]]></category>
            <category><![CDATA[jsoup]]></category>
            <category><![CDATA[html]]></category>
            <category><![CDATA[scripting]]></category>
            <dc:creator><![CDATA[Rishiraj Randive]]></dc:creator>
            <pubDate>Sun, 05 Nov 2023 01:00:18 GMT</pubDate>
            <atom:updated>2023-11-05T01:00:18.502Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PUhJSYJsiAMJjCF_yMkq8A.jpeg" /></figure><p>On rare occasions, I need to write a script to simplify some manual tasks I have to do either at work or in my personal project. Most of the time I used to write Python scripts just because it’s easy to get started. Python is not my preferred language so I would run into issues sometimes but it wasn’t difficult to find answers since Python is widely used. However, recently I came to know about <a href="https://kotlinlang.org/docs/custom-script-deps-tutorial.html">Kotlin scripting</a> and I decided to write my first Kotlin script to do a small HTML manipulation I wanted to do on multiple HTML files.</p><p>HTML manipulation can easily be done using <a href="https://jsoup.org/">Jsoup</a> library in Kotlin scripts. I find the Jsoup official documentation really helpful and thorough. In this article, we explore how we can use Jsoup to read HTML, extract information from HTML, and modify HTML.</p><p>We will use a simple HTML page for this article purpose which looks like this:</p><pre>&lt;!DOCTYPE html&gt;<br>&lt;html&gt;<br>  &lt;head&gt;<br>      &lt;title&gt;Page Title&lt;/title&gt;<br>  &lt;/head&gt;<br>  &lt;body&gt;<br>    &lt;h1&gt;We are in test HTML&lt;/h1&gt;<br>    &lt;div&gt;<br>      &lt;a href=&quot;https://www.google.com&quot;&gt;Take me to Google&lt;/a&gt;<br>      &lt;a href=&quot;https://www.spotify.com&quot;&gt;Take me to Spotify&lt;/a&gt;<br>      &lt;a href=&quot;https://www.youtube.com&quot;&gt;Take me to Youtube&lt;/a&gt;<br>    &lt;/div&gt;<br>  &lt;/body&gt;<br>&lt;/html&gt;</pre><h4>A quick note on the Kotlin script</h4><p>Make sure you have the correct Kotlin version installed. Scripts can be run using kotlinc -script &lt;script-name&gt;.main.kts or just kotlin &lt;script-name&gt;.main.kts . As you can see in these examples, make sure you name your script file with a suffix .main.kts</p><h4>Reading HTML file</h4><p>In Kotlin script you can provide the arguments when running the script. In this case, we will provide the path to the HTML file as an argument, and then in the script you can read the HTML file like this:</p><pre>val htmlFile = Jsoup.parse(File(&quot;${directory.absolutePath}/test.html&quot;), &quot;UTF-8&quot;)</pre><p>You can find elements in HTML using id, tag, class, and attribute. In this example let’s find an element using ID.</p><pre>val titleH1 = htmlFile.getElementById(&quot;title&quot;)</pre><p>This returns a nullable Element object and once you have the object you can extract information.</p><h4>Extracting information</h4><p>Jsoup provides a few options to extract different things from the Element object. The three ways we will be using here are element.html() , element.text() , and element.outerHtml()</p><p>For the test HTML in this example below are the outputs you will see for each</p><p>title?.html() and title?.text() =&gt; We are in test HTML</p><p>title?.outerHtml() =&gt; &lt;h1 id=&quot;title&quot;&gt;We are in test HTML&lt;/h1&gt;</p><p>As you will see if you want just the content of the element use html() or text() and if you need the entire HTML use outerHtml()</p><p>Jsoup also provides a way to select multiple elements using selector syntax which will return an array of elements as Elements You can iterate over these to perform any action.</p><p>Let’s see one example of using selector-syntax and reading using an attribute</p><pre>val links = htmlFile.select(&quot;div &gt; a&quot;)<br>val googleLink = links[0].attr(&quot;href&quot;) // this will return https://www.google.com</pre><h4>Modify HTML</h4><p>Finally, let’s look at how you can update/modify HTML. Jsoup provides easy ways to modify an existing attribute, set text values to existing HTML, and append or prepend HTML. We will use the links we have in our test HTML to demonstrate all the ways we can modify HTML</p><pre>// Modify attribute<br>links[0].attr(&quot;href&quot;, &quot;https://www.gmail.com&quot;)<br><br>// Set new text value<br>links[0].text(&quot;Take me to Gmail&quot;)<br><br>// Append to existing div<br>val firstDiv = htmlFile.select(&quot;div&quot;).first()<br>firstDiv?.append(&quot;&lt;a href=\&quot;https://www.reddit.com\&quot;&gt;Take me to Reddit&lt;/a&gt;&quot;)</pre><p>To make sure the changes are updated in your test file or create a new file add this at the end of your script</p><pre>File(&quot;${directory.absolutePath}/updated.html&quot;).writeText(htmlFile.html())</pre><p>Finally here’s the the full script we used here</p><pre>@file:DependsOn(&quot;org.jsoup:jsoup:1.14.3&quot;)<br><br>import java.io.File<br>import kotlin.system.exitProcess<br>import org.jsoup.Jsoup<br><br>val directory = File(args[0])<br><br>fun run() {<br>    println(&quot;Start....&quot;)<br><br>    /**<br>     * Reading HTML file<br>     */<br>    val htmlFile = Jsoup.parse(File(&quot;${directory.absolutePath}/test.html&quot;), &quot;UTF-8&quot;)<br>    val titleH1 = htmlFile.getElementById(&quot;title&quot;)<br><br>    /**<br>     * Extracting information<br>     */<br>    println(&quot;titleH1?.html() =&gt; ${titleH1?.html()}, titleH1?.text() =&gt; ${titleH1?.text()}, titleH1?.outerHtml() =&gt; ${titleH1?.outerHtml()}&quot;)<br>    val links = htmlFile.select(&quot;div &gt; a&quot;)<br>    val googleLink = links[0].attr(&quot;href&quot;)<br>    println(&quot;Google link $googleLink&quot;)<br><br>    /**<br>     * Modify HTML<br>     */<br>    // Modify attribute<br>    links[0].attr(&quot;href&quot;, &quot;https://www.gmail.com&quot;)<br><br>    // Set new text value<br>    links[0].text(&quot;Take me to Gmail&quot;)<br><br>    // Append<br>    val firstDiv = htmlFile.select(&quot;div&quot;).first()<br>    firstDiv?.append(&quot;&lt;a href=\&quot;https://www.reddit.com\&quot;&gt;Take me to Reddit&lt;/a&gt;&quot;)<br><br><br>    File(&quot;${directory.absolutePath}/updated.html&quot;).writeText(htmlFile.html())<br>    println(&quot;End....&quot;)<br>    exitProcess(0)<br>}<br><br>// Usage  kotlin &lt;script-name&gt;.main.kts &lt;directory where html file is&gt;<br>// Example -  kotlin kotlin-script-example.main.kts ~/Documents<br>run()</pre><h4>Final Thoughts</h4><p>I found Jsoup very easy to use and provides extensive ways of playing with HTML files in Kotlin script. Jsoup can also be used in other Kotlin projects like an Android app by adding the gradle dependencies. Refer to the <a href="https://jsoup.org/">official docs</a> of Jsoup for more information.</p><p>If you have tried Jsoup please share your experience and share any comments/feedback you have for my article.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=370d34ece159" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Using kotlinx.serialization in Ktor]]></title>
            <link>https://medium.com/@randive.rishiraj/using-kotlinx-serialization-in-ktor-6f416345ef0e?source=rss-8ec895a52fed------2</link>
            <guid isPermaLink="false">https://medium.com/p/6f416345ef0e</guid>
            <category><![CDATA[kotlinx]]></category>
            <category><![CDATA[kotlin-multiplatform]]></category>
            <category><![CDATA[kotlin-serialization]]></category>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[ktor]]></category>
            <dc:creator><![CDATA[Rishiraj Randive]]></dc:creator>
            <pubDate>Sat, 21 Oct 2023 22:28:03 GMT</pubDate>
            <atom:updated>2023-10-21T22:28:03.884Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ca3KduAYNLCcVUL8RVU6DA.png" /><figcaption>Kotlinx Serialization</figcaption></figure><p>In my previous <a href="https://medium.com/@randive.rishiraj/create-your-ktor-server-and-deploy-it-to-heroku-d2965d591f05">story</a>, we created a simple Ktor server and deployed it to Heroku. Now let’s build on the same project you can check the GitHub for the project <a href="https://github.com/rishirajrandive/ktor-login-sample">here</a></p><p>If you are creating a Ktor Server serving REST endpoints one thing you will definitely need is serializing and deserializing the request/response data. Through my experience of working in Android development, I am familiar with libraries like Gson and Jackson but I thought of exploring <a href="https://github.com/Kotlin/kotlinx.serialization">kotlinx.serialization</a> for my side project because of its Kotlin Multiplatform support. If you’re a Kotlin enthusiast, you’ll love its elegance.</p><p><strong><em>NOTE: </em></strong><em>kotlinx.serialization requires Kotlin compiler 1.4.0 or higher</em></p><h4>Adding dependencies</h4><p>Update the build.gradle.kts with dependencies for Content Negotiation and serialization</p><pre>implementation(&quot;io.ktor:ktor-server-content-negotiation:$ktor_version&quot;)<br>implementation(&quot;io.ktor:ktor-serialization-kotlinx-json:$ktor_version&quot;)</pre><p><em>Quick note on Content Negotiation, in the Ktor project it serves two purposes negotiating the media types between client/server and serializing/deserializing the content in a specific format. Ktor supports JSON, XML, CBOR, and ProtoBuf. We will be using JSON</em></p><p>You will also need to add the below plugin to your build.gradle.kts file otherwise the annotation @Serializable will be not recognized (you might see a warning if you don’t include this). Plugins for my project look like below, make sure to use relevant versions here.</p><pre>plugins {<br>    kotlin(&quot;jvm&quot;) version &quot;1.9.10&quot;<br>    id(&quot;io.ktor.plugin&quot;) version &quot;2.3.5&quot;<br>    id(&quot;org.jetbrains.kotlin.plugin.serialization&quot;) version &quot;1.8.0&quot;<br>}</pre><p>Run gradle sync and everything should build.</p><h4>Add models</h4><p>Now we can add the model classes which will represent request/response data. I added two simple login flow model classes which look like this:</p><pre>@Serializable<br>data class LoginRequestData(<br>    val email: String,<br>    val password: String<br>)<br><br>@Serializable<br>data class LoginResponseData(<br>    val id: String,<br>    val email: String,<br>)</pre><p>These are added to a new file LoginModel which is created in a new package model</p><h4>Add Serialization Plugin</h4><p>To start using kotlinx.serialization as a way to serialize/deserialize in our application we need to configure the plugin and add it to the application. Create a new file under plugin package named Serialization and add below to it:</p><pre>fun Application.configureSerialization() {<br>    install(ContentNegotiation) {<br>        json(Json {<br>            namingStrategy = JsonNamingStrategy.SnakeCase<br>        })<br>    }<br>}</pre><p>Using JsonNamigStrategy.SnakeCase is required if you want your underscores in JSON to be converted to snake case Kotlin data fields. As an example, date_of_birth: &quot;1 Jan 1990&quot; in JSON will be dateOfBirth = &quot;1 Jan 1990</p><p>Update your Application to include this configuration</p><pre>fun Application.module() {<br>    configureSerialization()<br>    configureRouting()<br>}</pre><h4>Testing time!!!</h4><p>Now to quickly test if everything we did so far is working as expected or not make a POST request using Postman and verify.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ftfZ1Po5GHq2u6oBDap3fQ.png" /></figure><p>We can also add a test for this by providing request data in JSON format as String and verify that the response has id, email, and expected email value. The final test looks like this:</p><pre>@Test<br>fun testLoginRequest() = testApplication {<br>    val requestData = &quot;{\n&quot; +<br>            &quot;    \&quot;email\&quot;: \&quot;test@gmail.com\&quot;,\n&quot; +<br>            &quot;    \&quot;password\&quot;: \&quot;12345678\&quot;\n&quot; +<br>            &quot;}&quot;<br>    val response = client.post(&quot;/login&quot;) {<br>        contentType(ContentType.Application.Json)<br>        setBody(requestData)<br>    }<br>    val responseBody = response.bodyAsText()<br>    assertEquals(HttpStatusCode.OK, response.status)<br>    assertNotNull(responseBody)<br>    assertEquals(true, responseBody.contains(&quot;id&quot;))<br>    assertEquals(true, responseBody.contains(&quot;email&quot;))<br>    assertEquals(true, responseBody.contains(&quot;test@gmail.com&quot;))<br>}</pre><h4>And we are done</h4><p>My experience so far with kotlinx.serialization library has been great, I struggled to understand a few things, especially working with date time, and timezones (topic for next story) but eventually it’s easy to use. Thanks for reading this story, please share your comments, feedback, or your experience using Ktor.</p><p>I’ll continue to add to the project so feel free to watch this <a href="https://github.com/rishirajrandive/ktor-login-sample">project</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6f416345ef0e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Create your Ktor server and deploy it to Heroku]]></title>
            <link>https://medium.com/@randive.rishiraj/create-your-ktor-server-and-deploy-it-to-heroku-d2965d591f05?source=rss-8ec895a52fed------2</link>
            <guid isPermaLink="false">https://medium.com/p/d2965d591f05</guid>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[ktor]]></category>
            <category><![CDATA[kotlin-multiplatform]]></category>
            <category><![CDATA[rest-api]]></category>
            <category><![CDATA[servers]]></category>
            <dc:creator><![CDATA[Rishiraj Randive]]></dc:creator>
            <pubDate>Tue, 10 Oct 2023 02:39:07 GMT</pubDate>
            <atom:updated>2023-10-11T01:20:11.694Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4aBfRqsFco67-aiA1EFFmg.png" /></figure><p>Till now I have been using NodeJS for creating servers for my side projects because I found it easy and I have a little bit of experience with Javascript. For my job, I work as an Android Engineer so Kotlin has become my preferred language (previously it was Java). When I found out about Ktor I was excited to try it out and see how easy it would be for me to start using Ktor for creating servers/backend for side projects. My experience so far with Ktor has been great and since Kotlin is the language I am most comfortable in, it was quicker for me to get the backend setup with Ktor. I also found the <a href="https://ktor.io/docs/welcome.html">official docs</a> very helpful, however, there were a few gotchas which I figured out as I was working with Ktor, hence thought of sharing with y’all.</p><p>In this article, we will go through the steps to deploy a simple <a href="https://ktor.io/">Ktor</a> server on Heroku.</p><h3>Prerequisites<strong>:</strong></h3><ol><li>Experience with using Kotlin</li><li>IntelliJ IDEA (I use the <a href="https://www.jetbrains.com/idea/download/?section=mac">community edition</a> because it’s free) as an IDE</li><li><a href="https://www.heroku.com/">Heroku</a> account</li><li><a href="https://devcenter.heroku.com/articles/heroku-cli">Heroku CLI</a></li></ol><h4><strong>TLDR:</strong> If you don’t want to read, check the complete project <a href="https://github.com/rishirajrandive/ktor-login-sample">here</a></h4><h3><strong>Setting up the project</strong></h3><ol><li>Only folks using IntelliJ IDEA Community Edition need to generate the project from here <a href="https://start.ktor.io/">https://start.ktor.io/</a>, otherwise, you create a new project directly in the IDE. I obviously generated the project.</li><li>You can specify the project name, package name, Ktor Version (leave it as it is if not sure), Engine (Netty), and configuration file (Code). Below is a screenshot for my setup, also you can add plugins as per your requirement but it’s possible to add them later as well.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wItlt97eY3eQYxsG6-ta6w.png" /></figure><ol><li>Now just hit the generate project button and it will start downloading the project zip. Unzip it and open the project in IntelliJ. Everything should be built and compiled.</li></ol><h3>Updating the generated project</h3><p>For the Ktor server, there are two ways of creating a server</p><ol><li>As a self-contained package (we will be using this)</li><li>Servlet</li></ol><p>Self-contained package servers also have two approaches, the generated project probably will be using EmbeddedServer which is one approach but the second approach i.e. using Engine a lot more easier and flexible (read this for more info)</p><ol><li>Let’s update the project to use Engine by adding application.conf file under the resources folder and add below:</li></ol><pre>ktor {<br> deployment { port = 8080 }<br> application {<br>  modules = [ &lt;your-project-package&gt;.ApplicationKt.module ]<br> }<br>}</pre><p>and update the Application.kt ‘s main function following</p><pre>fun main(args: Array&lt;String&gt;): Unit = io.ktor.server.netty.EngineMain.main(args)</pre><p>2. If you added the Routing plugin when generating the project you should have this already set up. Otherwise, you can add it by creating a few file Routing.kt under plugins package and add the below code. All this is doing is responding Hello World! when you hit the root URL.</p><pre>fun Application.configureRouting() {     <br>  routing {<br>    get(&quot;/&quot;) {<br>      call.respondText(&quot;Hello World!&quot;)         <br>    }     <br>  } <br>}</pre><p>3. Now, in your Application.kt file add below</p><pre>fun Application.module() {     <br>  configureRouting() <br>}</pre><p>Now go ahead and run the project by clicking the green arrow shown against the main method. If your setup is exactly the same as mentioned here you should see <a href="http://0.0.0.0:8080/">http://0.0.0.0:8080</a> URL in the console and if you open it you should see Hello World! on the browser. Just for reference below is how my project structure looked at this stage</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/716/1*mDo57UCxliwCB65CSPmRdw.png" /></figure><p>If it works so far your local setup is all done and now we can move on to deploying the project to Heroku.</p><h3>Setting up the project for Heroku</h3><ol><li>Update your application.conf so that Heroku can specify the port and for local you can continue using 8080 or anything else</li></ol><pre>ktor {   <br>  deployment {<br>     #LOCAL<br>     port = 8080<br>     <br>     port = ${?PORT}   <br>  }   <br>  application {<br>     modules = [&lt;package&gt;.ApplicationKt.module]   <br>  } <br>}</pre><p>2. Open build.gradle.kts the file and add stage a task that comes with an application plugin that we should already have</p><pre>tasks {     <br>  create(&quot;stage&quot;).dependsOn(&quot;installDist&quot;) <br>}</pre><p>3. Create a Procfile in the root directory of your project and add something similar to this. Make sure to grab the &lt;root-project-name&gt; from settings.gradle.kts file. In my case it was com.login.sample</p><pre>web: ./build/install/&lt;root-project-name&gt;/bin/&lt;root-project-name&gt;</pre><p>Once these 3 steps are done we can deploy the app to Heroku using CLI. Before you start make sure the git is initialized for the project.</p><h3>Deploy to Heroku</h3><ol><li>Commit the changes made above</li></ol><pre>git add . <br>git commit -m &quot;commit-message&quot;</pre><p>2. Log in to Heroku and create the project on it</p><p>heroku login heroku create &lt;project-name&gt;</p><p>3. Push the changes to Heroku that will trigger the deployment and if everything is successful you will get the generated link for your app. A sample log is shown here:</p><pre>git push heroku main  <br><br><br><br>remote: -----&gt; Compressing... <br>remote:        Done: 82.8M <br>remote: -----&gt; Launching... <br>remote:        Released v9 <br>remote:        &lt;https://ktor-sample-login-a867e88e63ba.herokuapp.com/&gt; deployed to Heroku <br>remote:  <br>remote: Verifying deploy... done. To &lt;https://git.heroku.com/ktor-sample-login.git&gt;</pre><p><strong>NOTE:</strong> Watch out for Java version mismatch between your local and Heroku, if you see an error during deployment, you can force Heroku to use the same version by specifying that in system.properties file which you need to create in your root directory. Check this <a href="https://devcenter.heroku.com/articles/java-support">link</a> for more details</p><p>That’s it! now you have the Ktor server deployed on the Heroku. Watch out for more step-by-step guides as I continue to build on this project.</p><p>Hope it helped and please share if there’s any feedback.</p><p>Thanks for reading!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d2965d591f05" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Parallelizing A Feature Across The Team]]></title>
            <link>https://medium.com/peloton-engineering/parallelizing-a-feature-across-the-team-de7014d1e769?source=rss-8ec895a52fed------2</link>
            <guid isPermaLink="false">https://medium.com/p/de7014d1e769</guid>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Rishiraj Randive]]></dc:creator>
            <pubDate>Thu, 08 Nov 2018 15:45:11 GMT</pubDate>
            <atom:updated>2018-11-08T15:45:11.251Z</atom:updated>
            <content:encoded><![CDATA[<p>Recently Peloton introduced a new feature called Programs and Collections. Peloton Programs are curated training plans that take the guesswork out of your training by creating a week-by-week schedule of workouts that incorporate expert instructor insight to help you reach a clearly-defined goal. Collections are classes grouped in our library by a specific theme, like special events, singalong rides, and more. We started off with three programs and nine Collections for our Bike, with plans to add more over time.</p><p>Programs and Collections was a huge cross-team effort. This feature is one of the best examples of how our Android Team parallelized work across 4 team members. The final product looks something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*qSXaw-dMzZiMMYmKZUmWqg.gif" /><figcaption>Programs and Collections</figcaption></figure><h4>How we divided the feature</h4><p>The feature has two screens. The first screen shows all the programs and collections’ thumbnails, while the second shows the details of a selected program/collection. We broke this down into four sections, and each team member was given the responsibility of one of these components:</p><ol><li><strong>List thumbnails</strong> — responsible for the program/collection thumbnail and all the metadata associated with it.</li><li><strong>Detail content</strong> — responsible for showing class thumbnails associated with a selected program or collection including scrolling behavior.</li><li><strong>Detail header</strong> — responsible for showing all the metadata associated with a selected program/collection and fading effect on scroll.</li><li><strong>Browse and navigation </strong>— responsible for overarching navigation and integration into the current product.</li></ol><p>Considering the entire feature these four seemed to be logical choices for smaller components because developers could work on their part without any overlap.</p><h4>How this helped us</h4><p>Using the divide and conquer approach helped us to keep the development process smooth and stress-free for developers. Some of the specific benefits we saw were:</p><ul><li><strong>Faster development:</strong> The way we divided the screens into chunks made it easy for a developer to work independently. Thanks to the architecture we follow at Peloton there were very few occasions on which we needed to deal with merge conflicts.</li><li><strong>Focused development: </strong>Developers were able to deliver optimized code for each component.</li><li><strong>Fewer bugs:</strong> Keeping sections smaller made it easy for developers to write clean code, write thoughtful tests, and make sure that their component worked as expected. The end result of combining all these small chunks gave an almost bug-free final feature.</li><li><strong>Small feedback loop:</strong> Each part represents a portion on the screen so it was easy for the product team to UAT it and provide feedback, instead of waiting for the entire feature to be completed.</li></ul><p><strong>Case Study: How focused development helped in delivering rock solid feature</strong></p><p>The end result looks great, but we also made sure that the user experience and app performance are both great too. When it comes to performance improvements developers often neglect to invest time in reducing Overdraw. As the name suggests Overdraw is the number of times a pixel on the screen is redrawn. Fortunately, you could easily check if your app is redrawing pixels on the screen by enabling <em>Show overdraw areas </em>in Developer options; the official docs give various ways to reduce the number of Overdraws and using this we reduced the number of overdraw on our screens.</p><p>For the small number of list items we have now, this doesn’t make a noticeable difference for the end user. However, in the future when we have more list items, performance tweaks like this will help us make the scrolling and overall end-user experience great. Below are some of the before and after screenshots showing the overdraws reduced.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*k3dalNLgwXTcGTJ74rq6Ww.png" /><figcaption>Before fixing the overdraw</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*A1desCH1h0YunShmWknY7g.png" /><figcaption>After fixing the overdraw</figcaption></figure><h4>Communication is the key</h4><p>We take pride in our team’s communication. When working on independent chunks that contribute to a bigger feature, it is important to communicate the changes. We often schedule quick chats to discuss the approach on something, which helps keep everyone on the same page, gives consistency to the code, and makes sure there were no surprises in pull requests, ultimately making a review of pull requests quick.</p><p><strong>Case Study: How communication made it easy to overcome a technical challenge</strong></p><p>Apart from occasional merge conflicts we never really had any major problems related to development. However, there was one technical challenge worth mentioning. The programs details screen required the section details to snap to the top upon clicking a section tab. However, RecyclerViews’ default behavior doesn’t allow this. Everyone had some suggestions, so we had a quick team chat to narrow down to one or two approaches. When the PR was finally created for this task, everyone on the team understood the approach we chose and was on the same page. Below are the screenshots for before and after the changes:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*Z7OUAkh-lKAzs2DHjCnOYw.gif" /><figcaption>Default scrolling behavior</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*hVTmbY7SsGFgC07I5c0QJg.gif" /><figcaption>Expected behavior</figcaption></figure><p>This is just one of the examples of how we parallelize work at Peloton. The divide and conquer approach helps in tackling big features, while we prepare for the fact that the implementation will be different for every feature. Regardless of the size of your team, this approach can help build a robust feature.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=de7014d1e769" width="1" height="1" alt=""><hr><p><a href="https://medium.com/peloton-engineering/parallelizing-a-feature-across-the-team-de7014d1e769">Parallelizing A Feature Across The Team</a> was originally published in <a href="https://medium.com/peloton-engineering">Peloton-Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[7 Steps to integrate Google ARCore Unity project to a native Android app]]></title>
            <link>https://medium.com/@randive.rishiraj/7-steps-to-integrate-google-arcore-unity-project-to-a-native-android-app-d85793ba0b37?source=rss-8ec895a52fed------2</link>
            <guid isPermaLink="false">https://medium.com/p/d85793ba0b37</guid>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[unity]]></category>
            <category><![CDATA[integrate]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[google-arcore]]></category>
            <dc:creator><![CDATA[Rishiraj Randive]]></dc:creator>
            <pubDate>Sat, 28 Oct 2017 07:45:41 GMT</pubDate>
            <atom:updated>2017-11-01T00:08:04.309Z</atom:updated>
            <cc:license>https://creativecommons.org/publicdomain/mark/1.0/</cc:license>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/519/1*sEIlHoUvD_28qz6qtwhMrA.png" /></figure><p>I am working on an Augmented Reality project for one of my courses at San Jose State University. We are using <a href="https://developers.google.com/ar/develop/unity/getting-started">Google ARCore with Unity</a> to develop the project but we also want to integrate this <a href="https://unity3d.com/">Unity</a> project into a native Android app to use some of the android-specific functionalities in the project.</p><p>So for the task of integrating Unity project into Android app, I struggled for some time. I found some helpful blogs or articles but I had to collect bits and pieces from different sources. Also, after doing all this, I was facing some issues which I’ll describe below.</p><p>This will give you a step by step guide for <strong>integrating </strong><a href="https://developers.google.com/ar/"><strong>Google ARCore</strong></a><strong> based Unity project into a native Android app</strong>, the prerequisite for this guide is:</p><ol><li>Should have completed the basic <a href="https://developers.google.com/ar/develop/unity/getting-started">Google ARCore tutorial for Unity</a>.</li><li>Know about <a href="https://guides.codepath.com/android">Android development</a>.</li></ol><p>Let’s start</p><p><strong>Step 1:</strong></p><p><strong>Export your Google ARCore Unity project</strong></p><p>If you have completed the <a href="https://developers.google.com/ar/develop/unity/getting-started">Google ARCore tutorial for Unity</a> you should be familiar with build settings, if not now is the best time to do it. Below are the build settings you need to specifically pay attention to, apart from settings shown in Google’s tutorial:</p><ol><li>Change <strong>Texture compression</strong> to <strong>ETC2</strong></li><li>Change <strong>Build system</strong> to <strong>Gradle</strong></li><li>Open <strong>Player settings</strong> -&gt; <strong>Other settings</strong></li><li>Change <strong>Install location </strong>to <strong>Automatic</strong> (I am not completely sure why other options didn’t work for me, but I think it’s best not to specify the location)</li></ol><p>Screenshot for reference:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OlHEx0IBA4ztNL50x-8X5A.png" /><figcaption>Settings for exporting the Google ARCore Unity project</figcaption></figure><p><strong>Step 2:</strong></p><p><strong>Now import the exported project in Android Studio</strong></p><p>If you are using Android Studio 3.0, select <strong>Import Project</strong> option and browse and point to the exported Unity project. You might get a popup complaining about Gradle wrapper, click Ok.</p><p>Gradle build might show error shown in screenshot below, which we will be fixing in next steps.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XiC3X5VK8bm_T6ZaIkDEoA.png" /><figcaption>Error you might see as soon as you import the project</figcaption></figure><p><strong>Step 3:</strong></p><p><strong>Change the imported Android project to library</strong></p><ol><li>Update the Gradle to latest (I used <strong>com.android.tools.build:gradle:3.0.0-rc2</strong>)</li><li>Comment the &lt;intent-filter&gt; lines from AndroidManifest.xml as this library will be invoked from other Android activity. Shown below:</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HpjO5U_An1CV8NzgcKfo1Q.png" /><figcaption>Commenting the &lt;intent-filter&gt; in manifest file</figcaption></figure><p>Finally, in build.gradle file:</p><ol><li>Change <strong>apply plugin: ‘com.android.application’ </strong>to <strong>apply plugin: ‘com.android.library’</strong></li><li>Remove <strong>applicationId</strong> under <strong>defaultConfig</strong></li></ol><p><strong>Step 4:</strong></p><p><strong>Assemble the project and generate the .aar file</strong></p><p>Find the Gradle task for assemble and click on it. Once done two .aar files (release and debug) will be generated under <strong>build/outputs/aar</strong>.</p><p><strong>Step 5:</strong></p><p><strong>Create a new native Android project and include the .aar</strong></p><ol><li>Once you have created a new Android project, create a new folder under <strong>src/mains/</strong> called <strong>libs</strong>.</li><li>Copy the release .aar file generated in <strong>Step 4</strong> to <strong>src/mains/libs</strong></li><li>Add dependency in module level build.gradle file like shown below(<strong>don’t sync yet</strong>)</li></ol><blockquote>compile(name: ‘your-aar-file-name’, ext: ‘aar’)</blockquote><p>Add below line to project level build.gradle file for successfully compiling the library (<strong>now you can sync</strong>)</p><blockquote>flatDir {dirs ‘src/main/libs’}</blockquote><p><strong>Step 6:</strong></p><p><strong>Resolve merger issue</strong></p><p>After Gradle sync in <strong>Step 5</strong>, you might get an error</p><blockquote>Manifest merger failed with multiple error, see logs</blockquote><p>Add tag to AndroidManifest.xml file:</p><blockquote>xmlns:tools=”http://schemas.android.com/tools&quot;</blockquote><p>And below line in <strong>&lt;application&gt;</strong> tag AndroidManifest.xml</p><blockquote>tools:replace=”android:icon,android:theme”</blockquote><p><strong>Step 7:</strong></p><p><strong>Start UnityPlayerActivity</strong></p><p>Then wherever you want your Unity project to kick in you can start the <strong>UnityPlayerActivity</strong> intent from your package. (While importing you will see classes from two packages, use the one from package you created while exporting the project from Unity).</p><p><strong>Troubleshooting</strong></p><p>Ideally, after following all the <strong>7 steps</strong> your app should run fine on your device but the app might crash and in logs, you might see an error like this:</p><blockquote>Google ARCore Error: java.lang.ClassNotFoundException: Didn’t find the class “com.unity3d.unitygar.GoogleAR”</blockquote><p>For some strange reason the .aar file didn’t take care of its libraries, so I copied the libraries from exported Unity project’s (folder) to new Android project <strong>src/main/libs</strong> folder. And then, add these lines to include these libraries in your build.</p><blockquote>compile(name: ‘libtango_3d_reconstruction_api’, ext:’aar’)</blockquote><blockquote>compile(name: ‘lighting_estimation’, ext:’aar’)</blockquote><blockquote>compile(name: ‘unityandroidpermissions’, ext:’aar’)</blockquote><blockquote>compile(name: ‘unitygar’, ext:’aar’)</blockquote><p>Recommended to Clean and Rebuild it.</p><p><strong>Note</strong>: If I am doing something wrong or unnecessary please feel free to comment and add your suggestions.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d85793ba0b37" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>