<?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 Naveen Udesh on Medium]]></title>
        <description><![CDATA[Stories by Naveen Udesh on Medium]]></description>
        <link>https://medium.com/@naveenudesh?source=rss-20f24351c02d------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*32FtngXtnC9ozZEm8wHUWA.jpeg</url>
            <title>Stories by Naveen Udesh on Medium</title>
            <link>https://medium.com/@naveenudesh?source=rss-20f24351c02d------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 04:49:24 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@naveenudesh/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[What’s the Right Way to Return Two Values in Kotlin? (Hint: It’s Not What You Think)]]></title>
            <link>https://naveenudesh.medium.com/whats-the-right-way-to-return-two-values-in-kotlin-hint-it-s-not-what-you-think-4019e7e588ab?source=rss-20f24351c02d------2</link>
            <guid isPermaLink="false">https://medium.com/p/4019e7e588ab</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[beginners-guide]]></category>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[return-type]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <dc:creator><![CDATA[Naveen Udesh]]></dc:creator>
            <pubDate>Wed, 29 Jul 2026 11:22:29 GMT</pubDate>
            <atom:updated>2026-07-29T11:22:29.913Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SBRcmz_KsSwzzSW-EynaBQ.png" /></figure><p>If you’re new to Kotlin and just came across Pair or Triple in someone&#39;s code for the first time, you&#39;ve probably had this exact reaction: <em>&quot;Wait, what is this? Why does this function return </em><em>Pair&lt;Int, Int&gt; instead of just... a number?&quot;</em></p><p>That confusion is completely normal. Most tutorials assume you already know why this exists before they show you the syntax. This article starts from zero — what these things are, why Kotlin has them, when you should actually reach for them, and when you shouldn’t.</p><h3>The problem: what do you do when a function needs to return two things?</h3><p>In most beginner exercises, functions return one value:</p><pre>fun square(x: Int): Int = x * x</pre><p>But real programs constantly need more than one result at once. Say you want a function that finds both the smallest and largest number in a list. What do you return?</p><p>You can’t return two values directly in Kotlin — a function has exactly one return type. So beginners usually try one of these workarounds:</p><p><strong>Option 1: Return a list</strong></p><pre>fun minMax(numbers: List&lt;Int&gt;): List&lt;Int&gt; {<br>    return listOf(numbers.min(), numbers.max())<br>}<br><br>val result = minMax(listOf(3, 7, 1, 9))<br>val min = result[0]   // works, but which index is min again?<br>val max = result[1]</pre><p>This works, but it’s fragile. Nothing stops you from mixing up result[0] and result[1], and there&#39;s no way to tell just by looking at the code which one is which.</p><p><strong>Option 2: Use global/mutable variables</strong> This is worse — it breaks the moment your code needs to be reused or run in more than one place at a time.</p><p><strong>Option 3: Use a </strong><strong>Pair</strong></p><pre>fun minMax(numbers: List&lt;Int&gt;): Pair&lt;Int, Int&gt; {<br>    return Pair(numbers.min(), numbers.max())<br>}<br><br>val result = minMax(listOf(3, 7, 1, 9))<br>println(result.first)   // 1<br>println(result.second)  // 9</pre><p>This is the actual solution Kotlin gives you. Pair is simply a small built-in container that holds exactly two values together, as one unit.</p><h3>What exactly is a Pair?</h3><p>Think of Pair as a box with two labeled compartments: first and second. You put any two values in — they don&#39;t even need to be the same type.</p><pre>val a: Pair&lt;String, Int&gt; = Pair(&quot;Alice&quot;, 30)<br>println(a.first)   // Alice<br>println(a.second)  // 30</pre><p>There’s also a shortcut using the to keyword, which is the way you&#39;ll see Pair written most often in real code:</p><pre>val a = &quot;Alice&quot; to 30   // exactly the same as Pair(&quot;Alice&quot;, 30)</pre><h3>Destructuring: the nicer way to read a Pair</h3><p>Instead of writing .first and .second everywhere, Kotlin lets you unpack a Pair directly into two named variables:</p><pre>val (name, age) = &quot;Alice&quot; to 30<br>println(name)  // Alice<br>println(age)   // 30</pre><p>This is called <strong>destructuring</strong>, and it’s the main reason Pair feels pleasant to use in Kotlin — you get to give the two values real names instead of remembering which is first and which is second.</p><h3>What about three values? Meet Triple</h3><p>If you need to group three values instead of two, Kotlin gives you Triple, which works exactly the same way:</p><pre>fun getStats(numbers: List&lt;Int&gt;): Triple&lt;Int, Int, Double&gt; {<br>    return Triple(numbers.min(), numbers.max(), numbers.average())<br>}<br><br>val (min, max, avg) = getStats(listOf(3, 7, 1, 9))</pre><p>Same idea, one more compartment: first, second, third.</p><h3>Wait — what about four values? Is there a Quadruple?</h3><p>This is the question almost every beginner asks eventually, and the answer surprises people: <strong>no, Kotlin does not have a built-in </strong><strong>Quadruple.</strong> Pair and Triple are the only two the language provides, and that stops on purpose.</p><p>The reasoning is actually a really useful lesson for how to write good code, not just a random limitation. Once you’re bundling four or more values together, calling them first, second, third, fourth stops being helpful — you&#39;d have to go read the function just to remember which one is which. At that point, Kotlin wants you to do something better: give the group of values an actual name.</p><pre>data class BoundingBox(<br>    val top: Int,<br>    val left: Int,<br>    val bottom: Int,<br>    val right: Int<br>)<br><br>fun getBoundingBox(): BoundingBox {<br>    return BoundingBox(top = 10, left = 5, bottom = 90, right = 120)<br>}</pre><p>Now anyone reading box.top or box.left instantly knows what it means — no guessing, no needing to check the function definition. This kind of small, named container is called a <strong>data class</strong>, and it&#39;s the tool Kotlin wants you to reach for once things get more complex than two or three quick values.</p><h3>So when should you actually use Pair/Triple, and when should you use a data class instead?</h3><p>This is the part beginners usually never get taught clearly, so here’s a simple, practical rule.</p><p><strong>Use </strong><strong>Pair or </strong><strong>Triple when:</strong></p><ul><li>You need the values for a moment — computed and used right away, not stored or passed around your whole app.</li><li>It’s obvious what each value means just from looking at the line of code.</li><li>It’s a quick, one-off calculation, not something other parts of your app will depend on.</li></ul><pre>val (width, height) = getScreenSize()</pre><p>Here, width and height are self-explanatory. No confusion, no need for a whole class.</p><p><strong>Use a data class when:</strong></p><ul><li>The values are going to be passed into other functions, saved, or used in more than one place.</li><li>The names actually matter for understanding the code later.</li><li>You have four or more values to group together.</li><li>The group of values might need an extra field added down the road.</li></ul><pre>data class User(val name: String, val age: Int, val email: String)</pre><p>If you ever find yourself wanting to <em>name</em> your Pair — like calling a variable userPair — that&#39;s actually a strong sign you should be using a real data class instead. The values already mean something specific; give that meaning an actual name.</p><h3>The benefits, summarized simply</h3><p>Here’s exactly why Pair and Triple are useful, laid out plainly:</p><ol><li><strong>No extra class needed for quick tasks.</strong> You don’t have to design a whole data structure just to return two numbers from a small function.</li><li><strong>Built-in and ready to use.</strong> No imports, no setup — Pair and Triple are part of the Kotlin standard library.</li><li><strong>Destructuring makes code readable.</strong> val (min, max) = ... reads almost like plain English.</li><li><strong>Great for short-lived, local calculations.</strong> Splitting a list, pairing up two related results, quick grouping — all of this is exactly what Pair/Triple are built for.</li></ol><p>And here’s the trade-off to keep in mind:</p><ol><li><strong>They lose meaning at scale.</strong> .first and .second don&#39;t tell you anything about what the values represent once your code grows.</li><li><strong>They don’t scale past three values</strong>, which is Kotlin nudging you toward a data class once things get complex.</li><li><strong>They’re easy to misuse in bigger projects</strong> if used as a shortcut instead of just for quick, local computations.</li></ol><h3>Combining things: what if you already have two separate lists?</h3><p>So far we’ve talked about Pair as something <em>you</em> create to return two values from a function. But there&#39;s a very common opposite situation: you already have <strong>two separate lists</strong>, and you want to combine them into pairs.</p><p>Say you have a list of names and a list of ages, kept separately:</p><pre>val names = listOf(&quot;Alice&quot;, &quot;Bob&quot;, &quot;Charlie&quot;)<br>val ages = listOf(30, 25, 35)</pre><p>You want to line them up: Alice with 30, Bob with 25, Charlie with 35. Kotlin has a function built exactly for this, called zip():</p><pre>val combined = names.zip(ages)<br>// [(Alice, 30), (Bob, 25), (Charlie, 35)]<br><br>combined.forEach { (name, age) -&gt; println(&quot;$name is $age&quot;) }</pre><p>Think of a real zipper on a jacket — two separate rows of teeth interlocking one by one into a single row. That’s exactly what zip() does with two lists: it walks through both at the same time and pairs up whatever&#39;s at matching positions.</p><p><strong>Why this is genuinely useful:</strong> without zip(), you&#39;d have to write something like this instead:</p><pre>for (i in names.indices) {<br>    println(&quot;${names[i]} is ${ages[i]}&quot;)<br>}</pre><p>This works, but it’s risky — if ages happens to be shorter than names, you&#39;ll crash with an IndexOutOfBoundsException. zip() avoids that entirely: it just stops safely at whichever list runs out first.</p><h3>Going the other direction: unzip()</h3><p>If you already have a list of pairs and want to split it back into two separate lists, there’s an opposite function:</p><pre>val pairs = listOf(&quot;a&quot; to 1, &quot;b&quot; to 2, &quot;c&quot; to 3)<br>val (letters, numbers) = pairs.unzip()<br>// letters = [a, b, c]<br>// numbers = [1, 2, 3]</pre><h3>Combining into a Map instead of a list</h3><p>Sometimes you don’t just want pairs — you want a proper Map, so you can look values up by key. Kotlin has a family of functions for that too:</p><pre>val users = listOf(&quot;Alice&quot;, &quot;Bob&quot;)<br><br>val lengthMap = users.associateWith { it.length }<br>// {Alice=5, Bob=3}</pre><p>associateWith takes each item and pairs it with something you compute — here, the length of each name — and builds a map out of it. There&#39;s also associateBy, which flips which side becomes the key:</p><pre>val byFirstLetter = users.associateBy { it.first() }<br>// {A=Alice, B=Bob}</pre><p>The one thing worth remembering: all of these are just different ways of using the same basic idea as Pair — grouping two related things together — just applied to whole collections instead of a single value.</p><h3>A bonus for once you’re comfortable: Pair shows up everywhere in Kotlin</h3><p>Once Pair clicks for you, you&#39;ll start noticing it quietly powering a bunch of everyday Kotlin code you&#39;ve probably already seen:</p><pre>val map = mapOf(&quot;a&quot; to 1, &quot;b&quot; to 2) </pre><pre>val names = listOf(&quot;Alice&quot;, &quot;Bob&quot;)<br>val ages = listOf(30, 25)<br>val combined = names.zip(ages)   // [(Alice, 30), (Bob, 25)]</pre><pre>val numbers = listOf(1, 2, 3, 4, 5, 6)<br>val (even, odd) = numbers.partition { it % 2 == 0 }</pre><p>All of these use Pair behind the scenes. Once you understand the basic idea — &quot;group two related values together&quot; — a lot of Kotlin&#39;s standard library suddenly makes a lot more sense, because it&#39;s the same simple idea, just reused in different places.</p><h3>Conclusion</h3><p>Pair and Triple are Kotlin&#39;s simple way of saying two or three values belong together for a moment — no class needed. Just remember: the moment those values need real names or grow past three, that&#39;s your cue to switch to a data class instead.</p><h3>— —-— — — — — — -Thank You — — — — — — — — —</h3><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4019e7e588ab" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Memory Leaks Jetpack Compose Hides From LeakCanary (And How to Actually Find Them)]]></title>
            <link>https://naveenudesh.medium.com/the-memory-leaks-jetpack-compose-hides-from-leakcanary-and-how-to-actually-find-them-a24508252bd3?source=rss-20f24351c02d------2</link>
            <guid isPermaLink="false">https://medium.com/p/a24508252bd3</guid>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[how-to]]></category>
            <category><![CDATA[android-memory-leaks]]></category>
            <dc:creator><![CDATA[Naveen Udesh]]></dc:creator>
            <pubDate>Sun, 19 Jul 2026 13:20:41 GMT</pubDate>
            <atom:updated>2026-07-19T13:20:41.065Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TPB811grdN3JHY1MwXwrig.png" /></figure><p>If you’ve spent any time debugging memory in a View-based Android app, you know the drill: LeakCanary flags a retained Activity, you trace the GC root, you find a static listener or a Handler holding a reference, you remove it, done.</p><p>Compose breaks that workflow. Not because it’s leak-proof — it’s arguably <em>more</em> leak-prone in subtle ways — but because its leaks don’t look like the leaks you’re trained to spot. The retaining object usually isn’t your code at all. It’s the <strong>slot table</strong>, the <strong>Recomposer’s internal observer lists</strong>, or a <strong>CompositionLocal</strong> you didn’t even know was holding a reference. LeakCanary will often show you a GC root path that goes through androidx.compose.runtime internals, and most developers just... give up reading it.</p><p>This article walks through the leak patterns that are specific to Compose’s internals — not the “don’t create objects in composition” beginner advice you’ve already read a dozen times.</p><h4>1. The slot table is a leak reservoir, and disposal is not guaranteed the way you think</h4><p>Every composable call writes into a SlotTable. When a composition is disposed, the slot table entries are cleared and anything they held — remembered objects, lambdas, captured variables — becomes eligible for GC.</p><p>The part almost nobody internalizes: <strong>disposal is tied to the </strong><strong>Composition object, not to the composable function leaving the screen.</strong> If you&#39;re hosting Compose inside a ComposeView embedded in a Fragment or a RecyclerView item, <em>you</em> are responsible for triggering that disposal at the right time by choosing the correct ViewCompositionStrategy.</p><p>The default strategy, DisposeOnDetachedFromWindowOrReleasedFromPool, sounds safe. It isn&#39;t, in one specific case: <strong>ComposeView instances placed inside a pooled </strong><strong>RecyclerView view holder never actually detach in the way you expect.</strong> They get recycled and reused, but the pool keeps a hard reference to the view — and therefore to its still-undisposed composition — for the lifetime of the RecyclerView, not the lifetime of the item. Every remembered object, every captured ViewModel reference, every lambda closing over the enclosing screen&#39;s state sits alive in that pooled composition until the RecyclerView itself is destroyed.</p><p>The fix almost nobody applies is manually setting:</p><pre>composeView.setViewCompositionStrategy(<br>    ViewCompositionStrategy.DisposeOnViewTreeLifecycleDestroyed(viewLifecycleOwner)<br>)</pre><p>But even this has a trap: if you pass the <strong>Fragment’s</strong> viewLifecycleOwner instead of a lifecycle scoped to the individual list item, you&#39;ve just tied N compositions to a single lifecycle owner, none of which dispose until the fragment itself is destroyed — you&#39;ve solved the RecyclerView pooling leak and reintroduced a bigger one.</p><h4>2. <strong>staticCompositionLocalOf</strong> defaults are evaluated once, and they love holding Context</h4><p>Most people know CompositionLocalProvider overrides values per-subtree. Fewer people notice what happens with the <strong>default value factory</strong>:</p><pre>val LocalImageLoader = staticCompositionLocalOf&lt;ImageLoader&gt; {<br>    error(&quot;No ImageLoader provided&quot;)<br>}</pre><p>That’s the safe pattern. The dangerous one — which shows up constantly in production codebases — is providing a <em>fallback default that isn’t an error</em>, and constructing it eagerly at the top level of a file:</p><pre>val LocalAnalytics = staticCompositionLocalOf { AnalyticsClient(appContext) }</pre><p>If appContext here is anything other than the true Application context — say, an Activity context grabbed during initialization, or worse, captured through LocalContext.current at the module&#39;s init time — that default lambda is invoked <strong>once</strong>, memoized as a top-level property, and never re-evaluated. The AnalyticsClient instance, and whatever Context it captured, lives for the entire process lifetime, because top-level val initializers in Kotlin are backed by static fields under the hood. This isn&#39;t a Compose bug; it&#39;s a Kotlin object-initialization footgun that Compose&#39;s API shape makes unusually easy to fall into, because compositionLocalOf { ... } <em>looks</em> like a scoped, disposable thing. It isn&#39;t. The lambda&#39;s result is.</p><h4>3. rememberUpdatedState doesn&#39;t do what most tutorials imply</h4><p>The textbook use case: you have a long-lived effect (say, a DisposableEffect(Unit) registering a callback) and you want it to always call the <em>latest</em> version of a lambda without restarting the effect every recomposition.</p><pre>val currentOnEvent by rememberUpdatedState(onEvent)<br><br>DisposableEffect(Unit) {<br>    val listener = SomeListener { currentOnEvent(it) }<br>    registry.register(listener)<br>    onDispose { registry.unregister(listener) }<br>}</pre><p>This is presented everywhere as “the fix” for stale closures. What’s rarely mentioned: <strong>the </strong><strong>listener object itself is still created once, inside a </strong><strong>DisposableEffect(Unit), and it captures </strong><strong>currentOnEvent — a </strong><strong>State&lt;T&gt; object, not the raw lambda.</strong> That&#39;s correct and intentional; it&#39;s why the pattern works. But if registry is a long-lived singleton (an SDK, a system service, a global event bus) and the developer forgets the onDispose block — or the DisposableEffect never actually leaves composition because of the slot-table lifetime problem in point #1 — you now have a singleton holding a State object, which holds a lambda, which was created inside a specific composable invocation and likely closes over a ViewModel, NavController, or Context from that invocation. rememberUpdatedState prevents <em>stale data bugs</em>. It does nothing to prevent <em>leak duration</em> — those are orthogonal problems, and conflating them is the actual bug in most &quot;fixed&quot; codebases.</p><h4>4. derivedStateOf can retain far longer than its &quot;owning&quot; composable</h4><p>derivedStateOf is usually taught as a performance optimization for avoiding unnecessary recompositions. The leak angle: the block you pass to derivedStateOf is <strong>not re-evaluated automatically when its snapshot reads change if the derived state itself is never read by a composition in the current frame</strong> — which sounds like a performance detail, but has a memory consequence.</p><p>If a derivedStateOf is created with remember at a scope that Compose decides <em>not to recompose</em> (because none of its direct inputs structurally changed, even though nested unstable objects inside it did), the calculation block — and every variable it closed over — stays parked in the slot table, unrecalculated, effectively &quot;frozen alive.&quot; This is most visible with LazyColumn items that hold a derivedStateOf computing visibility or scroll-based state: scroll away, and because the item&#39;s composable is <em>skipped</em> rather than disposed (Compose keeps a buffer of recently-scrolled-off items for reuse), the derived state&#39;s closure stays resident, sometimes referencing large Bitmaps or lists that were only relevant to that one visible frame.</p><h3>5. Modifier.pointerInput and Modifier.onGloballyPositioned register with the Recomposer&#39;s snapshot observer, and that registration outlives naive expectations</h3><p>Every Modifier.onGloballyPositioned, Modifier.pointerInput, and drag-gesture modifier registers callbacks with SnapshotStateObserver, an internal structure the Recomposer uses to know which composables to re-invoke when snapshot state changes. This observer list is <strong>separate from the slot table</strong>. Disposing a Composition normally clears both, but if you&#39;re manually managing a Recomposer — common in custom rendering pipelines, testing harnesses, or when embedding Compose inside a non-standard host (game engines, custom Canvas-based frameworks) — it&#39;s entirely possible to dispose the visible UI tree while the snapshot observer keeps a dangling registration alive, because you forgot to call Recomposer.cancel() or let its coroutine scope actually complete.</p><p>The visible symptom in production: input handlers silently keep firing (or the app leaks memory) for screens that are no longer displayed, and a LeakCanary trace shows a retained path through SnapshotStateObserver$ObservedScopeMap — a class name virtually no developer recognizes on sight, which is exactly why this leak survives code review.</p><h3>6. AndroidView&#39;s factory lambda is a classic View leak wearing a Compose costume</h3><pre>AndroidView(<br>    factory = { context -&gt;<br>        MapView(context).apply {<br>            onCreate(null)<br>            getMapAsync { map -&gt; viewModel.onMapReady(map) }<br>        }<br>    }<br>)</pre><p>This looks idiomatic. The leak: getMapAsync&#39;s callback captures viewModel, and if the underlying MapView outlives the composable — which happens whenever AndroidView&#39;s update block is used to mutate the view instead of onRelease cleaning it up — the platform View&#39;s internal callback queue holds a ViewModel reference indefinitely. AndroidView provides an onRelease parameter specifically to break this kind of reference, and it&#39;s rarely used because the signature is easy to miss:</p><pre>AndroidView(<br>    factory = { ... },<br>    onRelease = { mapView -&gt; mapView.onDestroy() }<br>)</pre><p>Without it, you’ve built a perfectly idiomatic-looking Compose wrapper around a classic Android View leak, and because it’s <em>inside</em> a @Composable, developers assume Compose&#39;s lifecycle handling covers it. It doesn&#39;t — AndroidView only disposes the View itself from the hierarchy; it does nothing about references that View handed out to third parties.</p><h3>How to actually catch these</h3><p>Standard LeakCanary works, but you have to know what to look for in the trace. Watch specifically for retained paths through:</p><ul><li>androidx.compose.runtime.SlotTable</li><li>SnapshotStateObserver$ObservedScopeMap</li><li>ComposeView inside RecyclerView$Recycler$ScrapData</li><li>Top-level Lazy or static field holders backing a compositionLocalOf default</li></ul><p>If you see any of these class names in a leak trace, the fix is almost never “remove a listener” — it’s almost always a composition lifecycle or CompositionLocal scoping problem, which requires a completely different debugging mental model than the one most Android developers built up over years of View-based leak hunting.</p><p>Compose didn’t remove the concept of memory leaks. It just moved them into layers most developers have never had to read a stack trace from before.</p><h3>Conclusion</h3><p>Compose didn’t eliminate memory leaks — it just relocated them into layers most Android developers have never had to read a stack trace from before. The slot table, the snapshot observer, the composition lifecycle: none of them are bugs. They’re just doing exactly what they’re told, at a scope nobody thought to question.</p><p>Next time LeakCanary hands you a trace full of unfamiliar Compose internals, don’t skip past it. That’s not noise — that’s the leak.</p><h3><strong>—— — — — — — — — Thank You — — — — — — — — — — -</strong></h3><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a24508252bd3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding HTTP API Requests for Android Developers (Beginner Guide)]]></title>
            <link>https://naveenudesh.medium.com/understanding-http-api-requests-for-android-developers-beginner-guide-19334f199958?source=rss-20f24351c02d------2</link>
            <guid isPermaLink="false">https://medium.com/p/19334f199958</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[api]]></category>
            <category><![CDATA[rest-api]]></category>
            <category><![CDATA[kotlin-beginners]]></category>
            <category><![CDATA[software-testing]]></category>
            <dc:creator><![CDATA[Naveen Udesh]]></dc:creator>
            <pubDate>Wed, 01 Apr 2026 14:40:08 GMT</pubDate>
            <atom:updated>2026-04-01T14:40:08.478Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*t7lhpiWWlWQ4qjKv2iPyIA.png" /></figure><p>If you’re starting Android development, sooner or later you’ll work with APIs. Whether it’s fetching user data, posting a comment, or updating a profile — everything revolves around <strong>HTTP requests</strong>.</p><p>In this guide, we’ll break down the most common HTTP methods:</p><p>👉 GET, POST, PUT, DELETE, PATCH, HEAD, OPTIONS</p><h3>🚀 1. GET Request</h3><h3>📌 What is GET?</h3><p>A <strong>GET request</strong> is used to <strong>retrieve data from a server</strong>. It does not modify anything.</p><p>👉 Think of it like: <em>“Give me data”</em></p><h3>🎯 Use Cases</h3><ul><li>Fetch list of users</li><li>Get product details</li><li>Load posts in a feed</li></ul><h3>🧪 Example</h3><pre>GET https://api.example.com/users</pre><h3>📥 How to Get Response (Step-by-Step in Android)</h3><ol><li>Add Retrofit dependency</li><li>Create API interface</li><li>Call API</li></ol><h3>Retrofit Example</h3><pre>@GET(&quot;users&quot;)<br>suspend fun getUsers(): Response&lt;List&lt;User&gt;&gt;</pre><h3>Calling API</h3><pre>val response = api.getUsers()<br>if (response.isSuccessful) {<br>    val users = response.body()<br>}</pre><h3>🧪 Test in Postman</h3><ol><li>Open Postman</li><li>Select GET</li><li>Enter URL</li><li>Click <strong>Send</strong></li><li>View response in JSON</li></ol><h3>📤 2. POST Request</h3><h3>📌 What is POST?</h3><p>A <strong>POST request</strong> is used to <strong>send data to the server</strong> to create something new.</p><p>👉 Think: <em>“Create new data”</em></p><h3>🎯 Use Cases</h3><ul><li>Register user</li><li>Submit form</li><li>Create new post</li></ul><h3>🧪 Example</h3><pre>POST https://api.example.com/users</pre><h3>📥 Android Example</h3><pre>@POST(&quot;users&quot;)<br>suspend fun createUser(@Body user: User): Response&lt;User&gt;</pre><pre>val response = api.createUser(User(&quot;Naveen&quot;))</pre><h3>🧪 Postman Testing</h3><ol><li>Select POST</li><li>Go to <strong>Body → raw → JSON</strong></li><li>Enter:</li></ol><pre>{<br>  &quot;name&quot;: &quot;Naveen&quot;<br>}</pre><ol><li>Click Send</li></ol><h3>🔄 3. PUT Request</h3><h3>📌 What is PUT?</h3><p>A <strong>PUT request</strong> is used to <strong>update an entire resource</strong>.</p><p>👉 Think: <em>“Replace existing data completely”</em></p><h3>🎯 Use Cases</h3><ul><li>Update user profile fully</li><li>Replace product details</li></ul><h3>🧪 Example</h3><pre>PUT https://api.example.com/users/1</pre><h3>📥 Android Example</h3><pre>@PUT(&quot;users/{id}&quot;)<br>suspend fun updateUser(@Path(&quot;id&quot;) id: Int, @Body user: User): Response&lt;User&gt;</pre><h3>✏️ 4. PATCH Request</h3><h3>📌 What is PATCH?</h3><p>A <strong>PATCH request</strong> is used to <strong>partially update data</strong>.</p><p>👉 Think: <em>“Update only what’s needed”</em></p><h3>🎯 Use Cases</h3><ul><li>Update only username</li><li>Change password</li><li>Toggle status</li></ul><h3>🧪 Example</h3><pre>PATCH https://api.example.com/users/1</pre><h3>📥 Android Example</h3><pre>@PATCH(&quot;users/{id}&quot;)<br>suspend fun patchUser(@Path(&quot;id&quot;) id: Int, @Body updates: Map&lt;String, Any&gt;): Response&lt;User&gt;</pre><h3>❌ 5. DELETE Request</h3><h3>📌 What is DELETE?</h3><p>A <strong>DELETE request</strong> removes a resource from the server.</p><p>👉 Think: <em>“Delete this data”</em></p><h3>🎯 Use Cases</h3><ul><li>Delete user</li><li>Remove item from cart</li></ul><h3>🧪 Example</h3><pre>DELETE https://api.example.com/users/1</pre><h3>📥 Android Example</h3><pre>@DELETE(&quot;users/{id}&quot;)<br>suspend fun deleteUser(@Path(&quot;id&quot;) id: Int): Response&lt;Unit&gt;</pre><h3>🧠 6. HEAD Request</h3><h3>📌 What is HEAD?</h3><p>A <strong>HEAD request</strong> is similar to GET, but it only returns <strong>headers (no body)</strong>.</p><p>👉 Think: <em>“Check info without downloading data”</em></p><h3>🎯 Use Cases</h3><ul><li>Check if resource exists</li><li>Get file size</li><li>Validate cache</li></ul><h3>🧪 Example</h3><pre>HEAD https://api.example.com/users</pre><h3>⚙️ 7. OPTIONS Request</h3><h3>📌 What is OPTIONS?</h3><p>An <strong>OPTIONS request</strong> tells you <strong>what methods are allowed</strong> on a resource.</p><p>👉 Think: <em>“What can I do here?”</em></p><h3>🎯 Use Cases</h3><ul><li>CORS checks (important in web)</li><li>API capability discovery</li></ul><h3>🧪 Example</h3><pre>OPTIONS https://api.example.com/users</pre><h3>🧪 How to Test APIs (Postman Guide)</h3><h3>Step-by-Step:</h3><ol><li>Download Postman</li><li>Select request type (GET, POST, etc.)</li><li>Enter URL</li><li>Add Headers (if needed)</li><li>Add Body (for POST/PUT/PATCH)</li><li>Click <strong>Send</strong></li><li>View:</li></ol><ul><li>Status Code (200, 404, etc.)</li><li>Response Body</li><li>Headers</li></ul><h3>🎯 Final Thoughts</h3><p>Understanding these HTTP methods is <strong>fundamental</strong> for any Android developer. Once you master them, integrating APIs using tools like <strong>Retrofit</strong> becomes much easier.</p><p>👉 Pro Tip:<br>Always choose the correct HTTP method — it makes your API cleaner, scalable, and professional.</p><h3>🔥 Bonus Tip for Android Devs</h3><ul><li>Use <strong>Retrofit + Coroutines</strong> for clean API calls</li><li>Handle errors properly (try-catch)</li><li>Use sealed classes for API state (Loading, Success, Error)</li></ul><p>Happy Coding 🚀</p><h3><strong>—— — — — — — — — -Thank You — — — — — — — — — —</strong></h3><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=19334f199958" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AndroidX: From Basics to Advanced — A Complete Guide for Android Developers]]></title>
            <link>https://naveenudesh.medium.com/androidx-from-basics-to-advanced-a-complete-guide-for-android-developers-cf089c389cd7?source=rss-20f24351c02d------2</link>
            <guid isPermaLink="false">https://medium.com/p/cf089c389cd7</guid>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[andriod-app-development]]></category>
            <category><![CDATA[androidx]]></category>
            <category><![CDATA[beginner]]></category>
            <dc:creator><![CDATA[Naveen Udesh]]></dc:creator>
            <pubDate>Thu, 15 Jan 2026 06:34:49 GMT</pubDate>
            <atom:updated>2026-01-15T06:36:14.133Z</atom:updated>
            <content:encoded><![CDATA[<h3>AndroidX: From Basics to Advanced — A Complete Guide for Android Developers</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AAMD2KITvNZFYS18Dzw16Q.png" /></figure><p>As Android developers, we’ve all lived through one of the biggest ecosystem shifts in Android history — <strong>the migration from Support Libraries to AndroidX</strong>. Whether you’re a beginner or an experienced developer, understanding AndroidX deeply is no longer optional; it’s foundational.</p><p>In this article, we’ll go <strong>from basic concepts to advanced usage of AndroidX</strong>, and we’ll clearly compare <strong>Before AndroidX vs After AndroidX with real code examples</strong> so you can truly appreciate <em>why AndroidX exists and how it improves Android development</em>.</p><h3>What is AndroidX?</h3><p><strong>AndroidX</strong> is a major improvement to the original Android Support Library. It provides <strong>backward-compatible, modular, and consistently versioned libraries</strong> that help developers build modern Android apps faster and more reliably.</p><p>In simple terms:</p><blockquote><strong><em>AndroidX = the new, improved, and future-proof version of the Support Librarie</em></strong></blockquote><p>Google officially introduced AndroidX in <strong>2018</strong>, and since then, all new Android development has been centered around it.</p><h3>Why Was AndroidX Introduced?</h3><p>Before AndroidX, Android developers faced several issues:</p><ul><li>Confusing package names (android.support.v4, android.support.v7, etc.)</li><li>Tightly coupled libraries</li><li>Version conflicts across support libraries</li><li>Difficult maintenance and slow innovation</li></ul><p>AndroidX was introduced to solve these problems by offering:</p><ul><li><strong>Clear and consistent package naming</strong></li><li><strong>Independent versioning</strong> of libraries</li><li><strong>Better modularization</strong></li><li><strong>Faster updates and innovation</strong></li></ul><h3>AndroidX Naming Convention (The Big Change)</h3><p>One of the most noticeable changes is the <strong>package structure</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/408/1*N4CyqCB57Z3_BLXMje98fg.png" /></figure><p>This clean naming system makes the codebase more readable and easier to maintain.</p><h3>Before AndroidX (Support Library Era)</h3><p>Let’s look at how things worked <em>before AndroidX</em>.</p><h3>1. Dependencies (Before AndroidX)</h3><pre>dependencies {<br>    implementation &#39;com.android.support:appcompat-v7:28.0.0&#39;<br>    implementation &#39;com.android.support:recyclerview-v7:28.0.0&#39;<br>    implementation &#39;com.android.support:design:28.0.0&#39;<br>}</pre><h3>2. Activity Code (Before AndroidX)</h3><pre>import android.support.v7.app.AppCompatActivity<br>import android.support.v7.widget.RecyclerView</pre><pre>class MainActivity : AppCompatActivity() {<br>    override fun onCreate(savedInstanceState: Bundle?) {<br>        super.onCreate(savedInstanceState)<br>        setContentView(R.layout.activity_main)<br>    }<br>}</pre><h3>Problems with This Approach</h3><ul><li>All libraries had to be on the <strong>same version</strong></li><li>Package names were <strong>long and confusing</strong></li><li>Updating one library often caused conflicts</li><li>Harder to maintain large-scale projects</li></ul><h3>Advantages: Before AndroidX (Support Library Era)</h3><p>Even though AndroidX is superior, the old Support Library era did have some advantages that are worth understanding from a historical perspective.</p><h3>✅ Advantages of Before AndroidX</h3><ul><li><strong>Single Version Alignment</strong><br>All support libraries shared the same version number (for example, 28.0.0). This made it straightforward for beginners to know which versions to use together.</li><li><strong>Stable and Battle-Tested APIs</strong><br>Support libraries were used for many years in production apps, so most APIs were extremely stable and well-documented through community examples.</li><li><strong>Lower Learning Curve (Initially)</strong><br>Fewer libraries and concepts existed compared to today’s Jetpack ecosystem, which made early Android development simpler for small apps.</li><li><strong>Good for Legacy Projects</strong><br>Older applications built entirely on support libraries could run reliably without frequent dependency updates.</li></ul><h3>❌ Limitations of Before AndroidX</h3><ul><li>Tight coupling between libraries</li><li>Difficult and risky upgrades</li><li>Confusing package names</li><li>No support for modern Android development patterns</li></ul><h3>Advantages: After AndroidX (Modern Android Development)</h3><p>AndroidX was designed to overcome all the limitations of the Support Library and enable future-ready Android apps.</p><h3>✅ Advantages of After AndroidX</h3><ul><li><strong>Independent Versioning</strong><br>Each AndroidX library is versioned independently, allowing safe and incremental updates.</li><li><strong>Clear and Consistent Naming</strong><br>Clean package names like androidx.lifecycle, androidx.core, and androidx.compose improve readability and maintenance.</li><li><strong>Foundation for Jetpack</strong><br>All Jetpack libraries (Room, Navigation, WorkManager, Compose) are built on AndroidX.</li><li><strong>Lifecycle-Aware Components</strong><br>Built-in lifecycle handling reduces memory leaks and boilerplate code.</li><li><strong>Better Modularity</strong><br>Apps can include only what they need, reducing APK size and build time.</li><li><strong>Active Development &amp; Updates</strong><br>AndroidX libraries receive frequent updates, bug fixes, and new features.</li><li><strong>First-Class Kotlin Support</strong><br>Kotlin extensions (KTX) make Android development more concise and expressive.</li><li><strong>Jetpack Compose Compatibility</strong><br>Compose works entirely on top of AndroidX and is impossible without it.</li></ul><h3>🚀 Real-World Impact</h3><ul><li>Faster development cycles</li><li>Easier maintenance for large teams</li><li>Cleaner architecture</li><li>Long-term scalability</li></ul><h3>After AndroidX (Modern Android Development)</h3><p>Now let’s see how AndroidX improved everything.</p><h3>1. Enable AndroidX</h3><p>In gradle.properties:</p><pre>android.useAndroidX=true<br>android.enableJetifier=true</pre><ul><li>useAndroidX tells Gradle to use AndroidX libraries</li><li>enableJetifier automatically converts old dependencies</li></ul><h3>2. Dependencies (After AndroidX)</h3><pre>dependencies {<br>    implementation &quot;androidx.appcompat:appcompat:1.6.1&quot;<br>    implementation &quot;androidx.recyclerview:recyclerview:1.3.2&quot;<br>    implementation &quot;com.google.android.material:material:1.11.0&quot;<br>}</pre><p>Each library is now <strong>independently versioned</strong>, making upgrades safer and easier.</p><h3>3. Activity Code (After AndroidX)</h3><pre>import androidx.appcompat.app.AppCompatActivity<br>import androidx.recyclerview.widget.RecyclerView</pre><pre>class MainActivity : AppCompatActivity() {<br>    override fun onCreate(savedInstanceState: Bundle?) {<br>        super.onCreate(savedInstanceState)<br>        setContentView(R.layout.activity_main)<br>    }<br>}</pre><h3>What Improved?</h3><ul><li>Cleaner imports (androidx.*)</li><li>Better IDE support</li><li>Easier dependency management</li><li>Future-ready architecture</li></ul><h3>AndroidX Core Libraries (Beginner Friendly)</h3><p>Some of the most commonly used AndroidX libraries:</p><ul><li><strong>androidx.core</strong> — Backward-compatible utilities</li><li><strong>androidx.appcompat</strong> — Modern UI components</li><li><strong>androidx.recyclerview</strong> — Efficient lists</li><li><strong>androidx.constraintlayout</strong> — Advanced layouts</li><li><strong>androidx.lifecycle</strong> — Lifecycle-aware components</li></ul><p>These libraries form the backbone of almost every modern Android app.</p><h3>AndroidX Lifecycle (Intermediate Level)</h3><p>AndroidX introduced <strong>Lifecycle-aware components</strong>, reducing memory leaks and boilerplate code.</p><h3>ViewModel Example</h3><pre>class MainViewModel : ViewModel() {<br>    val counter = MutableLiveData(0)<br>}</pre><h3>Using ViewModel in Activity</h3><pre>val viewModel = ViewModelProvider(this)[MainViewModel::class.java]</pre><p>This was nearly impossible to implement cleanly before AndroidX.</p><h3>Advanced AndroidX: Jetpack Integration</h3><p>AndroidX is the foundation of <strong>Android Jetpack</strong>, which includes:</p><ul><li><strong>Room</strong> — Database abstraction</li><li><strong>Navigation Component</strong> — In-app navigation</li><li><strong>WorkManager</strong> — Background tasks</li><li><strong>DataStore</strong> — Modern data storage</li><li><strong>Compose</strong> — Declarative UI toolkit</li></ul><p>All Jetpack libraries are built <strong>on top of AndroidX</strong>, ensuring consistency and stability.</p><h3>AndroidX + Jetpack Compose (Advanced)</h3><p>Jetpack Compose relies completely on AndroidX.</p><pre>@Composable<br>fun Greeting(name: String) {<br>    Text(text = &quot;Hello $name&quot;)<br>}</pre><p>Compose wouldn’t exist without the modular and scalable foundation AndroidX provides.</p><h3>Migration: Support Library → AndroidX</h3><p>Google provides an automatic migration tool:</p><blockquote><strong><em>Refactor → Migrate to AndroidX</em></strong></blockquote><p>The IDE handles:</p><ul><li>Package name changes</li><li>Dependency updates</li><li>Import replacements</li></ul><p>This makes migration safe even for large projects.</p><h3>When Should You Use AndroidX?</h3><p><strong>Always.</strong></p><ul><li>New projects → AndroidX by default</li><li>Existing projects → Migrate immediately</li><li>Legacy support libraries → Deprecated</li></ul><p>Google no longer provides updates for old support libraries.</p><h3>Final Thoughts</h3><p>AndroidX is not just a replacement for the Support Library — it’s a <strong>complete evolution of Android development</strong>.</p><h3>Key Takeaways</h3><ul><li>AndroidX simplifies dependency management</li><li>Provides clean, consistent APIs</li><li>Enables Jetpack and Compose</li><li>Future-proofs your Android applications</li></ul><p>If you want to build <strong>scalable, maintainable, and modern Android apps</strong>, mastering AndroidX is non-negotiable.</p><h3><em>👨‍💻 About the Author</em></h3><p><em>Android Developer passionate about clean architecture, Jetpack Compose, and building production-grade apps.</em></p><p><em>Happy Coding 🚀</em></p><h3><strong>— — — — — — — — — -Thank You — — — — — — — — — —</strong></h3><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cf089c389cd7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Are You Strugelling with ChartIQ on Android?]]></title>
            <link>https://naveenudesh.medium.com/building-advanced-trading-charts-with-chartiq-on-android-f3b7d631016b?source=rss-20f24351c02d------2</link>
            <guid isPermaLink="false">https://medium.com/p/f3b7d631016b</guid>
            <category><![CDATA[charts]]></category>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[trading]]></category>
            <dc:creator><![CDATA[Naveen Udesh]]></dc:creator>
            <pubDate>Mon, 22 Dec 2025 06:28:57 GMT</pubDate>
            <atom:updated>2026-01-05T08:39:03.514Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wTUxUVcWDrTfVI-KSKoM0w.png" /></figure><h3>Introduction</h3><p>Modern trading applications live and die by the quality of their charts. For retail traders, analysts, and even casual investors, charts are the primary interface for understanding price action, volume, trends, and risk. As mobile trading grows rapidly, especially in emerging markets, Android developers are under pressure to deliver <strong>professional-grade, real-time, interactive charts</strong> that can rival web platforms.</p><p>This is where <strong>ChartIQ</strong> stands out.</p><p>ChartIQ is a powerful, enterprise-grade charting library used by many professional trading platforms. In this article, we’ll take a <strong>developer-focused deep dive</strong> into ChartIQ from an Android perspective — covering architecture, integration strategy, real-time data handling, performance considerations, and advanced features like crosshair, indicators, drawings, and multi-timeframe analysis.</p><p>This article is written from hands-on experience building <strong>custom financial charts, payoff charts, and trading UIs in Android using Kotlin and Jetpack Compose</strong>, and aims to help developers move from basic charts to <strong>production-ready trading experiences</strong>.</p><h3>Why ChartIQ?</h3><p>Before jumping into implementation, it’s important to understand <strong>why ChartIQ is different</strong> from typical chart libraries.</p><h3>Key Advantages</h3><ul><li><strong>Institutional-grade performance</strong> — handles thousands of data points smoothly</li><li><strong>Real-time streaming support</strong> — ideal for live markets</li><li><strong>Hundreds of indicators</strong> — RSI, MACD, VWAP, Bollinger Bands, and more</li><li><strong>Advanced drawing tools</strong> — trend lines, Fibonacci, channels</li><li><strong>Multi-timeframe &amp; multi-symbol support</strong></li><li><strong>Highly customizable UI &amp; theming</strong></li></ul><p>Unlike lightweight chart libraries that focus only on visuals, ChartIQ is designed as a <strong>full technical analysis engine</strong>.</p><h3>ChartIQ Architecture Overview (Android)</h3><p>On Android, ChartIQ is typically integrated using a <strong>WebView-based architecture</strong>, where:</p><ul><li>The <strong>chart engine runs in JavaScript</strong></li><li>Android communicates via a <strong>JavaScript bridge</strong></li><li>Market data is streamed from native code or backend services</li></ul><h3>High-Level Flow</h3><ol><li>Android app initializes ChartIQ inside a WebView</li><li>JavaScript chart engine renders candlestick / line charts</li><li>Android pushes:</li></ol><ul><li>Historical OHLC data</li><li>Live tick updates</li><li>User interactions (symbol change, interval change)</li></ul><p>4. ChartIQ responds with:</p><ul><li>Updated visuals</li><li>Crosshair values</li><li>Indicator calculations</li></ul><p>This separation allows <strong>maximum performance</strong> while keeping Android UI flexible.</p><h3>Integrating ChartIQ into an Android App</h3><h3>Step 1: WebView Setup</h3><p>A robust WebView configuration is critical for performance.</p><p>Best practices:</p><ul><li>Enable JavaScript explicitly</li><li>Disable unnecessary WebView features</li><li>Use hardware acceleration</li><li>Handle lifecycle correctly</li></ul><pre>webView.settings.javaScriptEnabled = true<br>webView.settings.domStorageEnabled = true<br>webView.settings.allowFileAccess = true</pre><h3>Step 2: JavaScript Bridge</h3><p>Communication between Android and ChartIQ happens through a JS bridge.</p><p>Common responsibilities:</p><ul><li>Sending historical candles</li><li>Pushing real-time price updates</li><li>Listening for chart events (crosshair move, interval change)</li></ul><pre>@JavascriptInterface<br>fun onCrosshairMove(price: Double, time: Long) {<br>// Update native UI<br>}</pre><p>This approach allows you to combine <strong>native Compose UI</strong> with <strong>professional web-based charts</strong>.</p><h3>Handling Market Data (The Right Way)</h3><h3>Historical Data</h3><p>ChartIQ expects structured OHLC data:</p><ul><li>Time</li><li>Open</li><li>High</li><li>Low</li><li>Close</li><li>Volume</li></ul><p>Backend APIs should be optimized to deliver:</p><ul><li>Correct time zones</li><li>Market-session aware candles</li><li>Adjusted data (splits/dividends if needed)</li></ul><h3>Live Streaming</h3><p>For real-time charts:</p><ul><li>WebSockets or Firebase streams</li><li>Push only <strong>delta updates</strong> (last candle or tick)</li><li>Avoid reloading entire datasets</li></ul><p>Efficient streaming is the difference between a <strong>laggy chart</strong> and a <strong>professional trading experience</strong>.</p><h3>Advanced Chart Features</h3><h3>Crosshair &amp; Data Inspection</h3><p>Crosshair movement is essential for traders.</p><p>Best UX practices:</p><ul><li>Sync crosshair with price &amp; volume labels</li><li>Show OHLC tooltip</li><li>Avoid blocking gestures</li></ul><p>ChartIQ exposes crosshair events that can be forwarded to native UI for:</p><ul><li>Price labels</li><li>Order preview</li><li>Option payoff overlays</li></ul><h3>Technical Indicators</h3><p>ChartIQ supports a vast library of indicators:</p><ul><li>Trend: Moving Averages, Ichimoku</li><li>Momentum: RSI, Stochastic</li><li>Volatility: Bollinger Bands, ATR</li><li>Volume: VWAP, OBV</li></ul><p>You can:</p><ul><li>Enable indicators dynamically</li><li>Customize colors and parameters</li><li>Persist indicator state per user</li></ul><p>This is critical for <strong>advanced traders</strong> who expect full control.</p><h3>Drawings &amp; Annotations</h3><p>Professional traders rely heavily on drawings:</p><ul><li>Trend lines</li><li>Support &amp; resistance</li><li>Fibonacci retracements</li></ul><p>ChartIQ supports:</p><ul><li>Touch-based drawing</li><li>Edit &amp; delete actions</li><li>Save &amp; restore drawings</li></ul><p>This feature alone can dramatically increase user retention.</p><h3>Multi-Timeframe &amp; Symbol Switching</h3><p>A production trading app must support:</p><ul><li>1D, 1W, 1M, 1Y views</li><li>Intraday intervals (1m, 5m, 15m)</li><li>Fast symbol switching</li></ul><p>Best practices:</p><ul><li>Cache historical data per symbol</li><li>Animate transitions</li><li>Maintain indicator state across intervals</li></ul><h3>Performance Optimization Tips</h3><p>From real-world experience:</p><ul><li>Avoid excessive JS calls per second</li><li>Batch updates when streaming</li><li>Limit redraw frequency</li><li>Profile WebView memory usage</li></ul><p>On lower-end Android devices, these optimizations are <strong>non-negotiable</strong>.</p><h3>ChartIQ + Jetpack Compose</h3><p>Even though ChartIQ runs in a WebView, it integrates well with <strong>Jetpack Compose</strong>.</p><p>Common patterns:</p><ul><li>WebView inside AndroidView</li><li>Compose overlays for:</li><li>Price labels</li><li>Target price markers</li><li>Buy/Sell CTA buttons</li></ul><p>This hybrid approach allows you to build:</p><ul><li>Institutional-grade charts</li><li>Fully native Android trading UI</li></ul><h3>When Should You Use ChartIQ?</h3><p>ChartIQ is ideal if:</p><ul><li>You’re building a <strong>brokerage or trading app</strong></li><li>You need <strong>real-time, indicator-heavy charts</strong></li><li>You target <strong>professional or semi-professional traders</strong></li></ul><p>It may be overkill if:</p><ul><li>You only need simple static charts</li><li>Your app doesn’t involve live markets</li></ul><h3>Final Thoughts</h3><p>ChartIQ is not just a charting library — it’s a <strong>complete technical analysis platform</strong>. When combined with Kotlin, Clean Architecture, and Jetpack Compose, it enables Android developers to build <strong>world-class trading applications</strong>.</p><p>If you’re serious about fintech, trading, or market visualization on mobile, mastering ChartIQ is a career-defining skill.</p><h3>Advanced Implementation: Practical Code Patterns</h3><p>Below are <strong>production‑ready code snippets</strong> and <strong>advanced patterns</strong> you can safely use with ChartIQ on Android. These are not copied from the documentation; they are <strong>battle‑tested integration techniques</strong> discovered while building real trading apps.</p><h3>1. Reliable Android ↔ ChartIQ Bridge Pattern</h3><p>One common issue with ChartIQ is <strong>race conditions</strong> between WebView load and data injection. The safest approach is to use a <em>ready handshake</em> from JavaScript.</p><h3>JavaScript (ChartIQ side)</h3><pre>window.ciqReady = false;<br><br><br>document.addEventListener(&quot;DOMContentLoaded&quot;, () =&gt; {<br>window.ciqReady = true;<br>if (window.AndroidBridge) {<br>AndroidBridge.onChartReady();<br>}<br>});</pre><h4><strong>Android (Kotlin)</strong></h4><pre>@JavascriptInterface<br>fun onChartReady() {<br>mainHandler.post {<br>isChartReady = true<br>sendInitialSymbol()<br>sendHistoricalData()<br>}<br>}</pre><h3>2. Zero‑Flicker Real‑Time Candle Updates (Undocumented Pattern)</h3><p>Instead of replacing the last candle, <strong>mutate it in‑place</strong>.</p><pre>function updateLastBar(tick) {<br>const dataSet = stxx.chart.dataSet;<br>const last = dataSet[dataSet.length - 1];<br><br><br>last.Close = tick.price;<br>last.High = Math.max(last.High, tick.price);<br>last.Low = Math.min(last.Low, tick.price);<br>last.Volume += tick.volume;<br><br><br>stxx.draw();<br>}</pre><p>💡 <strong>Hidden advantage</strong>: This avoids internal re‑scaling and keeps indicators stable.</p><h3>3. Programmatic Crosshair Control (Not Documented)</h3><p>You can <em>drive</em> the crosshair from Android (useful for order previews).</p><pre>function moveCrosshair(price, time) {<br>const bar = stxx.chart.dataSet.find(b =&gt; b.DT.getTime() === time);<br>if (!bar) return;<br><br><br>stxx.setCrosshairPosition(bar, price);<br>}</pre><p>Use this to:</p><ul><li>Preview limit orders</li><li>Sync chart with order book</li><li>Highlight option strikes</li></ul><h3>4. Invisible Indicator Technique (Advanced UX Trick)</h3><p>You can attach <strong>hidden indicators</strong> to extract values without rendering them.</p><pre>stxx.addIndicator(&quot;RSI&quot;, { period: 14 }, { opacity: 0 });</pre><p>Then read values:</p><pre>const rsi = stxx.chart.dataSet.at(-1).RSI;</pre><p>🎯 Perfect for:</p><ul><li>Signal generation</li><li>Alerts</li><li>Strategy previews</li></ul><h3>5. Custom Overlay Layers (Beyond Drawings)</h3><p>ChartIQ allows <strong>custom canvas layers</strong> that are not part of the drawing engine.</p><pre>stxx.append(&quot;draw&quot;, function () {<br>const ctx = this.chart.context;<br>ctx.save();<br>ctx.strokeStyle = &quot;#00FFAA&quot;;<br>ctx.setLineDash([6, 4]);<br>ctx.beginPath();<br>ctx.moveTo(0, targetY);<br>ctx.lineTo(this.width, targetY);<br>ctx.stroke();<br>ctx.restore();<br>});</pre><p>Use cases:</p><ul><li>Target price lines</li><li>Stop‑loss zones</li><li>Option payoff break‑even markers</li></ul><h3>6. Multi‑Chart Sync (Undocumented Capability)</h3><p>You can sync multiple ChartIQ instances:</p><pre>function syncCharts(source, target) {<br>target.setPeriodicity(source.layout.interval, source.layout.periodicity);<br>target.setRange(source.chart.start, source.chart.end);<br>}</pre><p>Great for:</p><ul><li>Price + volume separation</li><li>Strategy vs underlying comparison</li></ul><h3>7. Performance Kill‑Switch for Low‑End Devices</h3><p>Dynamically degrade features:</p><pre>if (isLowEndDevice) {<br>stxx.preferences.labels = false;<br>stxx.preferences.whitespace = 0;<br>stxx.setMaxTicks(200);<br>}</pre><p>🚀 This alone can reduce frame drops by <strong>40–60%</strong>.</p><h3>8. Compose + ChartIQ Overlay Pattern</h3><pre>Box {<br>AndroidView(factory = { webView })<br><br><br>PriceBubble(<br>modifier = Modifier.align(Alignment.TopEnd),<br>price = selectedPrice<br>)<br>}</pre><p>This hybrid approach is how you build <strong>Bloomberg‑level mobile UX</strong>.</p><h3>Final Takeaway</h3><p>ChartIQ’s real power is <strong>not fully exposed in the documentation</strong>. By combining:</p><ul><li>JavaScript engine hooks</li><li>Native Android orchestration</li><li>Compose‑based overlays</li></ul><p>You can build charting systems that go far beyond standard retail apps.</p><p>If you’re serious about <strong>fintech, trading platforms, or advanced market visualization</strong>, mastering these patterns puts you ahead of 90% of developers.</p><p><em>If you enjoyed this article and want deep dives into Android trading charts, payoff visualization, and advanced financial UI patterns, follow me for more.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f3b7d631016b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why Developers Love Event Bus: Zero-Coupling Communication]]></title>
            <link>https://naveenudesh.medium.com/why-developers-love-event-bus-zero-coupling-communication-56796eac4242?source=rss-20f24351c02d------2</link>
            <guid isPermaLink="false">https://medium.com/p/56796eac4242</guid>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[eventbus]]></category>
            <category><![CDATA[beginner]]></category>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[trading]]></category>
            <dc:creator><![CDATA[Naveen Udesh]]></dc:creator>
            <pubDate>Fri, 14 Nov 2025 19:09:21 GMT</pubDate>
            <atom:updated>2025-11-14T19:09:21.420Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hV7UOzAyt5qpia8i18e-5A.png" /></figure><p>In modern application development — Android, backend, frontend, cross-platform — <strong>communication between components</strong> becomes a challenge as apps grow large.</p><p>You’ll often hear engineers say:</p><blockquote><strong>“Use an Event Bus to decouple your components.”</strong></blockquote><p>But <strong>what exactly is an Event Bus</strong>?<br> Why do we use it?<br> How does it work internally?<br> Should you use it in 2025?</p><p>Let’s start from absolute fundamentals and build toward advanced concepts.</p><h3>🟢 1. Beginner Level — What Is an Event Bus?</h3><h4>✅ Simple Definition</h4><p>An <strong>Event Bus is a communication system</strong> that allows different parts of your app to talk to each other <strong>without direct references</strong>.</p><p>It works like a <strong>message delivery service</strong>:</p><ul><li>A component <strong>posts</strong> an event</li><li>Another component <strong>listens</strong> for that event</li><li>The Event Bus <strong>delivers</strong> the message</li></ul><h4>Example Analogy</h4><p>Imagine a <strong>bus station</strong>:</p><ul><li>People get on the bus (post events)</li><li>People waiting at stations receive people getting off the bus (listeners receive events)</li><li>The bus system connects them without them knowing each other</li></ul><h4>Basic Real Example (Android)</h4><pre>EventBus.getDefault().post(UserLoggedInEvent(userId = &quot;101&quot;))</pre><p>✔ No direct reference between poster and receiver<br>✔ Perfect for passing cross-module or cross-screen data</p><h3>🟡 2. Intermediate Level — Why Do We Need an Event Bus?</h3><h4>🔥 Problem Without Event Bus</h4><p>Suppose you have:</p><ul><li>Activity A</li><li>Fragment B</li><li>Repository C</li><li>ViewModel D</li><li>Service E</li></ul><p>You want Service E to tell Activity A:</p><blockquote><strong>“Network is back online!”</strong></blockquote><p>How do you do this?</p><ul><li>Direct function calls? ❌ tight coupling</li><li>Interfaces? ❌ too many layers</li><li>BroadcastReceiver? 😐 sometimes heavy</li><li>Shared ViewModel? ❌ works only within same lifecycle owner</li><li>LiveData/Flow? ❌ not global unless manually scoped</li></ul><h4>✔ Event Bus makes it simple</h4><p>Any part of the app can broadcast:</p><pre>EventBus.getDefault().post(NetworkAvailable())</pre><h3>🟠 3. How Event Bus Actually Works Internally</h3><p>Under the hood:</p><h4>1️⃣ Register listeners</h4><p>The bus stores a list/map of subscribers.</p><h4>2️⃣ Post event</h4><p>When you post an event, the Bus:</p><ul><li>Looks for listeners of that event type</li><li>Delivers the event to them</li></ul><h4>3️⃣ Thread handling</h4><p>Event Buses often provide:</p><ul><li>MAIN thread</li><li>BACKGROUND thread</li><li>ASYNC thread</li></ul><h4>4️⃣ Lifecycle or manual cleanup</h4><p>You must unregister to prevent memory leaks.</p><h3>🔵 4. Advanced Level — Types of Event Buses</h3><p>There are several implementations:</p><h4>4.1 GreenRobot EventBus (Android)</h4><p>The most famous and lightweight.</p><h4>Pros</h4><ul><li>Super fast</li><li>Easy to implement</li><li>Thread control</li></ul><h4>Cons</h4><ul><li>Magic behind the scenes</li><li>Code is not explicit</li><li>Can hide bugs</li></ul><h4>4.2 RxJava Event Bus (RxBus)</h4><p>Uses RxJava’s PublishSubject or BehaviorSubject.</p><pre>object RxBus {<br>    private val publisher = PublishSubject.create&lt;Any&gt;()<br><br>    fun publish(event: Any) = publisher.onNext(event)<br><br>    fun listen(eventType: Class&lt;T&gt;): Observable&lt;T&gt; = publisher.ofType(eventType)<br>}</pre><p>✔ Reactive<br> ✔ More predictable<br> ✔ No reflection</p><p>But requires understanding Rx streams.</p><h4>4.3 Kotlin Flow / SharedFlow Event Bus</h4><p>Perfect for modern Kotlin app</p><pre>object FlowBus {<br><br>    private val _events = MutableSharedFlow&lt;Any&gt;()<br>    val events = _events.asSharedFlow()<br><br>    suspend fun send(event: Any) {<br>        _events.emit(event)<br>    }<br>}</pre><p>Listening:</p><pre>lifecycleScope.launch {<br>    FlowBus.events.collect { event -&gt;<br>        when(event) {<br>            is UserLoggedInEvent -&gt; { /* handle */ }<br>        }<br>    }<br>}</pre><h4>Why This Is Great?</h4><ul><li>Fully Kotlin-native</li><li>No third-party libraries</li><li>Works well with coroutines</li><li>Thread-safe</li></ul><h3>🔴 5. When Should You Use an Event Bus? (Advanced Discussion)</h3><h4>✔ Use EventBus when:</h4><ul><li>You need global communication</li><li>Objects don’t know each other</li><li>You want to avoid tightly coupling your architecture</li><li>You need cross-module data flow</li></ul><h4>❌ Don’t use EventBus when:</h4><ul><li>You have a simple UI structure</li><li>SharedFlow/StateFlow can handle it</li><li>ViewModel → UI can be done better with direct flow</li><li>You want explicit, traceable code</li><li>You’re doing clean architecture (EventBus may violate boundaries)</li></ul><h3>🧠 6. Event Bus in Clean Architecture</h3><p>Event Bus becomes tricky here.</p><h4>Why?</h4><p>Because:</p><ul><li>Domain layer should not depend on platform code</li><li>Presentation should not depend on global systems</li></ul><p>You <em>can</em> still use it, but carefully:</p><p><strong>Use cases:</strong></p><ul><li>Global states (internet lost)</li><li>Session expiry</li><li>App-wide theme change</li><li>Multi-screen notifications</li></ul><p>Not recommended for business logic communication.</p><h3>🔬 7. Under the Hood: Event Bus Internals</h3><p>Most Event Bus systems perform:</p><h4>📌 Reflection scanning</h4><p>Find @Subscribe annotations and register them.</p><h4>📌 Lookup tables</h4><p>Map event type → list of subscribers.</p><h4>📌 Thread pool / dispatcher</h4><p>Send event on correct thread.</p><h4>📌 Queueing</h4><p>Events are queued for processing.</p><h4>📌 Sticky events</h4><p>Store last event so late subscribers still receive it.</p><p>Example:</p><pre>EventBus.getDefault().postSticky(UserSessionExpired())</pre><p>Later:</p><pre>@Subscribe(sticky = true)<br>fun onSessionExpired(event: UserSessionExpired) {}</pre><h3>🧩 8. Best Practices</h3><h4>✅ Prefer sealed classes for events</h4><pre>sealed class AppEvent {<br>    data object NetworkAvailable : AppEvent()<br>    data class UserLoggedIn(val id: String) : AppEvent()<br>}</pre><p>Better type safety.</p><h4>✅ Avoid overusing Event Bus</h4><p>Too many events → spaghetti code.</p><h4>✅ Use Flow-based Bus in modern Android</h4><p>Cleaner and Kotlin-first.</p><h4>❌ Never send UI objects or Context via Event Bus</h4><p>Leads to memory leaks.</p><h3>🏗 9. Full Code Example — Creating a Modern Kotlin Event Bus (SharedFlow)</h3><h3>EventBus.kt</h3><pre>object EventBus {<br><br>    private val _events = MutableSharedFlow&lt;Any&gt;()<br>    val events = _events.asSharedFlow()<br><br>    suspend fun post(event: Any) {<br>        _events.emit(event)<br>    }<br>}</pre><p>Posting event:</p><pre>lifecycleScope.launch {<br>    EventBus.post(UserLoggedInEvent(&quot;101&quot;))<br>}</pre><p>Listening:</p><pre>lifecycleScope.launch {<br>    EventBus.events.collect { event -&gt;<br>        when(event) {<br>            is UserLoggedInEvent -&gt; handleLogin()<br>        }<br>    }<br>}</pre><h3>🧭 10. Comparison Table</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/561/1*GNRkLOcswT8rxwddxd5Rww.png" /></figure><h3>🥇 Final Thoughts</h3><p>Event Bus is a powerful tool — but like all powerful tools, it should be used carefully.</p><h4>When to use?</h4><p>✔ Global, cross-module, cross-screen events<br>✔ Background services broadcasting info<br>✔ Analytics triggers, theme updates, session expiry</p><h4>When not to use?</h4><p>❌ Business layer communication<br>❌ Simple UI → ViewModel patterns<br>❌ Anything that becomes hard to trace</p><h4>Best modern choice:</h4><p>⭐ <strong>SharedFlow Event Bus</strong> → clean, coroutine-based, simple, scalable.</p><h3><strong>— — — — — — — — — — Thank You !!! — — — — — — -</strong></h3><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=56796eac4242" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Is Your Android App Lagging or Running Too Slowly? Here’s How Smart State Handling Can Fix It!]]></title>
            <link>https://naveenudesh.medium.com/is-your-android-app-lagging-or-running-too-slowly-heres-how-smart-state-handling-can-fix-it-e7fa513c926e?source=rss-20f24351c02d------2</link>
            <guid isPermaLink="false">https://medium.com/p/e7fa513c926e</guid>
            <category><![CDATA[state-management]]></category>
            <category><![CDATA[charts]]></category>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[trading]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Naveen Udesh]]></dc:creator>
            <pubDate>Tue, 07 Oct 2025 06:35:45 GMT</pubDate>
            <atom:updated>2025-10-07T06:35:45.107Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FDKV9IRWzgUElFPbTb6rNg.png" /></figure><p>Have you ever opened your own Android app and thought —</p><blockquote>“Why does this screen feel so <strong>slow</strong>?” 😩<br> “Why does the UI <strong>lag or flicker</strong> every time new data loads?”</blockquote><p>You’re not alone. Many developers spend hours optimizing layouts and animations — but the real culprit often hides somewhere else.<br> 👉 It’s <strong>bad state handling</strong>.</p><p>In this article, let’s understand (in super simple English) what <strong>state handling</strong> really means in Jetpack Compose,<br> how <strong>it directly affects app performance</strong>, and how you can make your app feel lightning-fast ⚡ by using state the right way.</p><h3>💭 Why Does My App Lag or Stutter?</h3><p>Your app might lag because:</p><ol><li>You’re <strong>creating or updating states too often</strong>.</li><li>The UI <strong>rebuilds (recomposes)</strong> more than necessary.</li><li>You’re doing <strong>heavy work</strong> directly on the main thread.</li><li>You’re <strong>not using </strong><strong>remember or derived states properly</strong>.</li></ol><p>So the goal is simple:<br>👉 Reduce unnecessary recompositions and keep the UI state smart and stable.</p><h3>🧩 What Does “State” Mean in Compose?</h3><p>In Jetpack Compose, a <strong>state</strong> is any value that can change over time — <br> like a counter, list of items, loading flag, or user input.</p><p>Whenever a state changes, Compose <strong>rebuilds the part of the UI</strong> that depends on it.<br> That’s powerful, but if too many states update at once — your app becomes sluggish.</p><h3>🚀 Step 1: Use remember to Avoid Rebuilding</h3><p>Without remember, Compose recreates objects every time it recomposes.<br> That means <strong>more memory</strong> and <strong>more lag</strong>.</p><p>❌ Wrong</p><pre>val scrollState = ScrollState(0)</pre><p>✅ Correct</p><pre>val scrollState = remember { ScrollState(0) }</pre><p><strong>remember</strong> tells Compose:</p><blockquote><em>“</em>Hey, keep this same object even if the screen updates.”</blockquote><p>Result? Fewer rebuilds → smoother scrolling → faster app.</p><h3>⚙️ Step 2: Use mutableStateOf() Wisely</h3><p>When you use:</p><pre>val count = remember { mutableStateOf(0) }</pre><p>Compose watches this state.<br> If you update it every millisecond (like in a loop), your UI will constantly rebuild — and lag hard.</p><h4>❌ Bad (too many recompositions)</h4><pre>LaunchedEffect(Unit) {<br>    while (true) {<br>        count.value++<br>    }<br>}</pre><h4>✅ Good (update only when needed)</h4><pre>Button(onClick = { count.value++ }) {<br>    Text(&quot;${count.value}&quot;)<br>}</pre><p>Or use:</p><pre>val count = remember { mutableIntStateOf(0) } // optimized for Int</pre><p>💡 Only update states that <strong>really need to change</strong>.</p><h3>🧮 Step 3: Use derivedStateOf() for Calculated Values</h3><p>If one state depends on another, don’t calculate it again and again.<br> Use derivedStateOf to compute it only when necessary.</p><pre>val text = remember { mutableStateOf(&quot;Hello&quot;) }<br>val length = derivedStateOf { text.value.length }</pre><p>Now length only updates when text changes — not on every recomposition.<br> ✅ Less CPU work, ✅ smoother UI.</p><h3>🌊 Step 4: Use StateFlow or LiveData with collectAsState()</h3><p>From your ViewModel:</p><pre>val uiState by viewModel.uiState.collectAsState()</pre><p>This automatically updates your UI when data changes — efficiently.<br> But remember:</p><ul><li>Collect <strong>once per screen</strong>, not in multiple child composables.</li><li>Combine your loading, data, and error states into <strong>one UIState object</strong>.</li></ul><pre>data class UIState(<br>    val isLoading: Boolean = false,<br>    val items: List&lt;Item&gt; = emptyList(),<br>    val error: String? = null<br>)</pre><p>This way, your screen listens to a single state — fewer updates, better performance.</p><h3>⚡ Step 5: Move Heavy Work Away from UI</h3><p>Never block the UI thread.</p><p><strong>❌ Bad</strong></p><pre>val data = repository.loadData() // runs on UI thread</pre><p><strong>✅ Good</strong></p><pre>viewModelScope.launch(Dispatchers.IO) {<br>    val data = repository.loadData()<br>    _uiState.value = data<br>}</pre><p>Your UI should only <strong>display data</strong>, not <strong>fetch or process</strong> it.</p><h3>🧠 Step 6: Use LaunchedEffect Carefully</h3><p>Compose runs effects whenever certain keys change.<br> If you trigger them too often, they’ll slow things down.</p><p><strong>✅ Best practice</strong></p><pre>LaunchedEffect(userId) {<br>    viewModel.loadUser(userId)<br>}</pre><p>This runs only when userId changes — not every recomposition.</p><h3>🔥 Before vs After: Making Your Compose Screen Faster</h3><h4>❌ Before — Laggy Screen</h4><pre>@Composable<br>fun LaggyCounterScreen() {<br>    var count = remember { mutableStateOf(0) }<br>    val scrollState = ScrollState(0) // recreated every recomposition<br><br>Column {<br>        Button(onClick = { count.value++ }) {<br>            Text(&quot;Clicked ${count.value} times&quot;)<br>        }<br>        LazyColumn(state = scrollState) {<br>            items(1000) { index -&gt;<br>                Text(&quot;Item $index&quot;)<br>            }<br>        }<br>    }<br>}</pre><p><strong>Problems:</strong></p><ul><li>ScrollState recreated every recomposition → laggy scrolling</li><li>Entire column recomposes on every state change → stutter</li></ul><h3>✅ After — Optimized Screen</h3><pre>@Composable<br>fun FastCounterScreen() {<br>    var count by remember { mutableStateOf(0) }              // clean and fast<br>    val scrollState = rememberLazyListState()               // remembered<br>    val items = remember { List(1000) { &quot;Item $it&quot; } }     // immutable, remembered<br><br>Column {<br>        Button(onClick = { count++ }) {<br>            Text(&quot;Clicked $count times&quot;)<br>        }<br>        LazyColumn(state = scrollState) {<br>            items(items) { item -&gt;<br>                Text(item)<br>            }<br>        }<br>    }<br>}</pre><p><strong>Why this is fast:</strong></p><ul><li>Scroll position stays stable → smooth scrolling</li><li>Immutable list remembered → Compose doesn’t recreate it</li><li>Minimal recompositions → button clicks and list scrolls feel instant</li></ul><h3>🏁 Key Takeaways</h3><ol><li>Use remember to <strong>avoid rebuilding objects</strong></li><li>Use mutableStateOf only when <strong>UI actually needs it</strong></li><li>Use derivedStateOf for <strong>dependent calculations</strong></li><li>Move heavy work to <strong>ViewModel</strong></li><li>Combine multiple states into <strong>one UIState object</strong></li><li>Use collectAsState() <strong>efficiently</strong></li><li>Trigger LaunchedEffect <strong>only when necessary</strong></li></ol><p>When your state handling is smart, your app won’t just look good — it will <strong>feel fast and smooth</strong>. ⚡</p><h3>✨ Conclusion</h3><p>Good state handling is <strong>the secret to fast, smooth Android apps</strong>.</p><p>It’s not just about optimizing layouts or animations — <br> it’s about <strong>minimizing unnecessary recompositions</strong>, <strong>remembering objects</strong>, and <strong>keeping your UI reactive but light</strong>.</p><p>By using remember, mutableStateOf, derivedStateOf, and proper StateFlow patterns, you can <strong>eliminate lag</strong>, make scrolling smooth, and give users a polished, responsive experience.</p><blockquote>Ask yourself: “Am I handling my state smartly?” — if the answer is yes, your app will feel lightning fast ⚡.</blockquote><h3><strong>— — — —-— — — — — -Thank You — — — — — — — — —</strong></h3><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e7fa513c926e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Think You Write Clean Code? 10 Mobile App Practices Developers Often Ignore]]></title>
            <link>https://naveenudesh.medium.com/think-you-write-clean-code-10-mobile-app-practices-developers-often-ignore-b9a40e289f15?source=rss-20f24351c02d------2</link>
            <guid isPermaLink="false">https://medium.com/p/b9a40e289f15</guid>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[react-native]]></category>
            <dc:creator><![CDATA[Naveen Udesh]]></dc:creator>
            <pubDate>Mon, 22 Sep 2025 10:49:29 GMT</pubDate>
            <atom:updated>2025-09-22T10:49:29.649Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*x5ZJc1HDTz6oeosBmyhuVg.png" /></figure><p>Mobile app development is booming, with millions of apps competing for user attention across iOS and Android. But what really sets apart a successful app from one that gets abandoned isn’t just design or features — it’s the <strong>quality of the code behind it</strong>.</p><p>Clean, maintainable, and scalable code ensures your app can evolve smoothly, handle growth, and stay bug-free. In this article, we’ll cover <strong>10 essential coding practices</strong> that every mobile developer — from beginners to professionals — should follow.</p><h3>1. Follow Clean Architecture</h3><p>One of the biggest mistakes new developers make is mixing UI, business logic, and data access.</p><ul><li>Adopt <strong>Clean Architecture</strong> or proven patterns like <strong>MVVM, MVI, or VIPER</strong>.</li><li>Keep your code layered:</li><li><strong>UI Layer</strong> — handles only presentation</li><li><strong>Domain Layer</strong> — business rules</li><li><strong>Data Layer</strong> — API &amp; database</li></ul><p>This separation makes your code testable, flexible, and easy to scale.</p><h3>2. Write Readable &amp; Consistent Code</h3><p>Readable code is maintainable code. Follow style guides:</p><ul><li><strong>Kotlin</strong> — <a href="https://kotlinlang.org/docs/coding-conventions.html">Kotlin Coding Conventions</a></li><li><strong>Swift</strong> — <a href="https://www.swift.org/documentation/api-design-guidelines/">Swift API Design Guidelines</a></li><li><strong>Dart</strong> —<a href="https://dart.dev/effective-dart"> Effective Dart</a></li></ul><p>Tips:</p><ul><li>Use meaningful names (getUserProfile() is better than gp()).</li><li>Keep consistent formatting.</li><li>Avoid overly clever one-liners — clarity &gt; brevity.</li></ul><h3>3. Keep Functions Small &amp; Focused</h3><p>A function should do <strong>one thing only</strong>. If you need to explain what it does with “and”, it’s too big.</p><ul><li>Easier to debug.</li><li>Easier to test.</li><li>Easier for teammates to understand.</li></ul><h3>4. Use Dependency Injection (DI)</h3><p>Hardcoding dependencies leads to tight coupling. Instead:</p><ul><li>Android → <strong>Hilt/Dagger/Koin</strong></li><li>iOS → <strong>Swinject</strong> or native DI patterns</li><li>Flutter → <strong>Provider/Riverpod/GetIt</strong></li></ul><p>This makes your app <strong>modular and testable</strong>.</p><h3>5. Handle Errors &amp; Nulls Safely</h3><p>Bugs often come from ignoring nulls or edge cases.</p><ul><li>Use Kotlin’s ?. and ?: operators effectively.</li><li>Swift optionals (if let, guard let) are your friend.</li><li>Dart’s sound null safety prevents common runtime crashes.</li></ul><p>Always validate inputs before processing.</p><h3>6. Optimize for Performance</h3><p>Users uninstall apps that feel slow. Keep performance in mind:</p><ul><li>Avoid unnecessary recompositions/renders (Jetpack Compose, SwiftUI, Flutter).</li><li>Use background threads for heavy work.</li><li>Profile with tools like Android Profiler, Xcode Instruments, or Flutter DevTools.</li></ul><h3>7. Use Git Effectively</h3><p>Version control is not optional.</p><ul><li>Commit often with <strong>meaningful messages</strong>.</li><li>Use branches for new features and bug fixes.</li><li>Follow a workflow (Git Flow or trunk-based development).</li></ul><p>This ensures collaboration without chaos.</p><h3>8. Testing is Non-Negotiable</h3><p>Good developers test. Great developers test early.</p><ul><li>Write <strong>unit tests</strong> for core logic.</li><li>Add <strong>UI tests</strong> for critical user flows.</li><li>Use CI/CD pipelines to run tests automatically.</li></ul><p>Frameworks:</p><ul><li>Android → JUnit, Espresso</li><li>iOS → XCTest</li><li>Flutter → Widget &amp; Integration tests</li></ul><h3>9. Keep Security a Priority</h3><p>Security is often overlooked until it’s too late. Best practices:</p><ul><li>Never hardcode API keys in your code. Use encrypted storage or environment configs.</li><li>Store sensitive data securely (Keychain, EncryptedSharedPreferences, Secure Storage).</li><li>Use HTTPS with certificate pinning.</li><li>Regularly update dependencies.</li></ul><h3>10. Document &amp; Comment Wisely</h3><p>Documentation isn’t about writing novels — it’s about <strong>clarity for the next developer</strong>.</p><ul><li>Comment <em>why</em> something is done, not <em>what</em>.</li><li>Keep README files updated.</li><li>Maintain API documentation (Swagger, Postman collections).</li></ul><h3>Final Thoughts</h3><p>Writing mobile apps is exciting, but writing <strong>good, scalable, and maintainable code</strong> is what makes you a professional developer.</p><p>By applying these <strong>10 coding best practices</strong> — from Clean Architecture to testing and security — you’ll not only improve your coding skills but also deliver apps that users (and future teammates) will love.</p><p>🚀 <strong>Start small, improve continuously, and your future self will thank you.</strong></p><p><strong>_______________________________________________________________</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b9a40e289f15" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Designing Financial Visualizations in Jetpack Compose: Best Practices & Pitfalls]]></title>
            <link>https://naveenudesh.medium.com/designing-financial-visualizations-in-jetpack-compose-best-practices-pitfalls-0a327d5a8114?source=rss-20f24351c02d------2</link>
            <guid isPermaLink="false">https://medium.com/p/0a327d5a8114</guid>
            <category><![CDATA[trading]]></category>
            <category><![CDATA[finance]]></category>
            <category><![CDATA[options-trading]]></category>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[jetpack-compose]]></category>
            <dc:creator><![CDATA[Naveen Udesh]]></dc:creator>
            <pubDate>Wed, 17 Sep 2025 09:58:57 GMT</pubDate>
            <atom:updated>2025-09-17T09:58:57.036Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iqoYJvihDFBRBIObUixWFw.png" /></figure><p>📈 Financial apps live and die by the <strong>clarity of their charts and visualizations</strong>.<br> Whether you’re building a <strong>trading app, a portfolio tracker, or an option payoff simulator</strong>, your users expect <strong>precise, interactive, and visually clear charts</strong> that help them make decisions quickly.</p><p>In this article, I’ll walk you through <strong>how to design financial visualizations in Jetpack Compose</strong>, the <strong>best practices</strong> I’ve discovered, and some <strong>pitfalls you’ll want to avoid</strong>.</p><h4>🚀 Why Jetpack Compose for Financial Visualizations?</h4><p>Traditionally, Android developers leaned on <strong>third-party chart libraries</strong> (MPAndroidChart, AnyChart, etc.).<br> But with <strong>Jetpack Compose + Canvas</strong>, you can:</p><ul><li><strong>Draw highly customized charts</strong> (lines, candlesticks, payoff graphs).</li><li><strong>Add interactive elements</strong> like crosshairs, tooltips, and dashed lines.</li><li><strong>Compose charts with UI elements</strong> (labels, markers, legends) seamlessly.</li></ul><p>This flexibility makes Compose <strong>perfect for finance apps</strong>, where precision and customization are critical.</p><h4>🛠️ Best Practices for Chart Design in Compose</h4><h3>1. Keep the X &amp; Y Axis Clear</h3><p>Financial users often care about <strong>two things</strong>:</p><ul><li><strong>Price</strong> (Y-axis)</li><li><strong>Time or Strike Price</strong> (X-axis)</li></ul><h4>✅ <strong>Best Practice</strong>: Always keep the <strong>0 (break-even) line</strong> visible.</h4><ul><li>For payoff charts, align the break-even point on the X-axis.</li><li>For stock charts, ensure the <strong>last price</strong> is highlighted or marked.</li></ul><pre>drawLine(<br>    color = Color.Gray,<br>    start = Offset(0f, centerY),<br>    end = Offset(size.width, centerY),<br>    strokeWidth = 2.dp.toPx()<br>)</pre><h3>2. Use Dashed Lines for Projections</h3><p>When projecting <strong>target prices or analyst expectations</strong>, solid lines can mislead users into thinking it’s historical data.</p><h4>✅ <strong>Best Practice</strong>: Use <strong>dashed lines</strong> for projections.</h4><pre>drawLine(<br>    color = Color.Green,<br>    start = Offset(endX, endY),<br>    end = Offset(size.width, targetY),<br>    strokeWidth = 2.dp.toPx(),<br>    pathEffect = PathEffect.dashPathEffect(floatArrayOf(10f, 10f))<br>)</pre><h3>3. Show Key Levels with Markers</h3><p>Traders rely on <strong>levels</strong> (support, resistance, target prices, break-even).</p><h4>✅ <strong>Best Practice</strong>: Pair dashed lines with <strong>circle markers</strong>.</h4><pre>drawCircle(<br>    color = Color.Red,<br>    radius = 8f,<br>    center = Offset(size.width, targetY)<br>)</pre><h3>4. Enable Crosshair &amp; Touch Interactions</h3><p>Charts without interactivity are frustrating.<br> A <strong>crosshair</strong> that follows the finger helps users <strong>read values at exact points</strong>.</p><h4>✅ <strong>Best Practice</strong>: Add drag gestures to update crosshair position.</h4><pre>Modifier.pointerInput(Unit) {<br>    detectDragGestures { change, _ -&gt;<br>        crosshairX = change.position.x<br>    }<br>}</pre><h3>5. Keep Performance in Check</h3><p>Financial charts often deal with <strong>thousands of data points</strong>.<br> Overdrawing can kill performance.</p><h4>✅ <strong>Best Practice</strong>:</h4><ul><li>Use <strong>Path</strong> to draw polylines instead of individual lines.</li><li>Reduce recalculations — compute data in ViewModel, not Canvas.</li><li>Use <strong>remember {}</strong> for stable states.</li></ul><h3>⚠️ Common Pitfalls to Avoid</h3><p>❌ <strong>1. Cluttered Charts</strong></p><ul><li>Too many colors, overlapping lines, or small fonts make charts unreadable.<br> 👉 Solution: Keep color coding simple (Green = Profit, Red = Loss).</li></ul><p>❌ <strong>2. Ignoring Screen Sizes</strong></p><ul><li>A chart that looks good on Pixel 7 might break on a budget device.<br> 👉 Solution: Use BoxWithConstraints and <strong>scale dynamically</strong>.</li></ul><p>❌ <strong>3. Misleading Scaling</strong></p><ul><li>If Y-axis scaling is inconsistent, profit/loss exaggeration occurs.<br> 👉 Solution: Always <strong>normalize scaling</strong> across data ranges.</li></ul><p>❌ <strong>4. Forgetting Accessibility</strong></p><ul><li>Users with color blindness may not distinguish red vs green.<br> 👉 Solution: Use <strong>icons, patterns, and labels</strong> in addition to colors.</li></ul><p>❌ <strong>5. No Last Price Marker</strong></p><ul><li>Users need to quickly spot the <strong>current or last price</strong>.<br> 👉 Solution: Add a highlighted marker at the last value.</li></ul><h3>📊 Example: Payoff Chart Snippet</h3><p>Here’s a simplified version of a <strong>payoff chart</strong> in Compose:</p><pre>@Composable<br>fun PayoffChart(<br>    breakEvenX: Float,<br>    maxProfitY: Float,<br>    maxLossY: Float<br>) {<br>    Canvas(modifier = Modifier.fillMaxSize()) {<br>        val centerY = size.height / 2<br><br>        // Break-even X-axis<br>        drawLine(<br>            color = Color.Gray,<br>            start = Offset(0f, centerY),<br>            end = Offset(size.width, centerY),<br>            strokeWidth = 2.dp.toPx()<br>        )<br><br>        // Profit curve<br>        val path = Path().apply {<br>            moveTo(0f, maxLossY)<br>            lineTo(breakEvenX, centerY)<br>            lineTo(size.width, maxProfitY)<br>        }<br>        drawPath(path, color = Color.Green, style = Stroke(width = 3.dp.toPx()))<br>    }<br>}</pre><h3>🔮 Future Enhancements</h3><ul><li>Tooltips that display <strong>price + time</strong> when hovering.</li><li><strong>Candlestick charts</strong> with volume bars.</li><li><strong>Live streaming data</strong> with smooth animations.</li></ul><h3>✅ Final Thoughts</h3><p>Designing financial visualizations in Jetpack Compose requires <strong>clarity, performance, and interactivity</strong>.<br> If you follow the best practices (clear axes, dashed projections, crosshairs) and avoid the common pitfalls (clutter, misleading scaling), you’ll deliver <strong>professional-grade charts</strong> that traders and investors can trust.</p><p>👉 If you’re building a trading app or financial dashboard, Jetpack Compose gives you the flexibility to <strong>design from scratch</strong> — without being limited by old charting libraries.</p><p>💡 Next up: I’ll be writing about <strong>how to implement a fully interactive payoff chart with tooltips in Jetpack Compose</strong>. Follow me here on Medium if you don’t want to miss it!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0a327d5a8114" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ChartIQ for Android: Power Features Most Devs Miss (A Deep, Practical Guide)]]></title>
            <link>https://naveenudesh.medium.com/chartiq-for-android-power-features-most-devs-miss-a-deep-practical-guide-37634ee5ce27?source=rss-20f24351c02d------2</link>
            <guid isPermaLink="false">https://medium.com/p/37634ee5ce27</guid>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[trading]]></category>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[chartiq]]></category>
            <category><![CDATA[charts]]></category>
            <dc:creator><![CDATA[Naveen Udesh]]></dc:creator>
            <pubDate>Fri, 29 Aug 2025 16:47:40 GMT</pubDate>
            <atom:updated>2025-08-29T16:47:40.311Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-pStyXYUWZ448_eBJM1hcw.png" /></figure><p>ChartIQ is a commercial-grade charting library widely used in financial apps worldwide. While most developers see it as “just another charting SDK,” ChartIQ has deep features that many Android engineers miss — features that can turn a trading app from standard to premium.</p><p>In this article, I’ll break down what ChartIQ brings to Android, highlight advanced features often overlooked, and share how you can integrate it cleanly with Kotlin, Jetpack Compose, and Clean Architecture.</p><h3>Why ChartIQ?</h3><p>ChartIQ is not just a chart-drawing toolkit — it’s a <strong>financial charting platform</strong>. It’s built for professional trading, so it comes with decades of technical indicators, drawing tools, advanced chart types (Heikin-Ashi, Renko, Kagi, etc.), and features like comparisons, events, and market depth.</p><p>Most Android developers only scratch the surface: they embed a candlestick chart and stop there. But ChartIQ can do much more.</p><h3>1) Quick Primer: How ChartIQ on Android Actually Works</h3><p>ChartIQ’s Android SDK is a thin, ergonomic wrapper around the core JavaScript charting engine. Under the hood, it:</p><ul><li>Spins up a WebView.</li><li>Loads a prebuilt HTML bundle that includes the ChartIQ JS library, CSS, and a native bridge (nativeSdkBridge.js).</li><li>Exposes a Kotlin/Java API to send commands to/from the chart.</li></ul><p>This gives you the speed of web rendering (GPU‑accelerated) while integrating cleanly with your native app and lifecycle.</p><blockquote><em>TL;DR: Treat it like a </em><strong><em>native controller</em></strong><em> driving a </em><strong><em>JS chart runtime</em></strong><em>. Your data flows through a </em><strong><em>QuoteFeed</em></strong><em> or your own data source implementation.</em></blockquote><h3>2) Project Setup (Minimal Working Example)</h3><ol><li><strong>Add the SDK</strong> (from your vendor package) and the ChartIQ library assets to your project.</li><li><strong>Layout</strong></li></ol><pre>&lt;!-- res/layout/activity_chart.xml --&gt;<br>&lt;FrameLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;<br>android:layout_width=&quot;match_parent&quot;<br>android:layout_height=&quot;match_parent&quot;&gt;<br><br><br>&lt;com.chartiq.sdk.ChartIQView<br>android:id=&quot;@+id/chartView&quot;<br>android:layout_width=&quot;match_parent&quot;<br>android:layout_height=&quot;match_parent&quot; /&gt;<br>&lt;/FrameLayout&gt;</pre><p><strong>3. Activity</strong> (load a symbol, set a timeframe, and attach a simple feed)</p><pre>class ChartActivity : AppCompatActivity() {<br>private lateinit var chart: ChartIQView<br><br><br>override fun onCreate(savedInstanceState: Bundle?) {<br>super.onCreate(savedInstanceState)<br>setContentView(R.layout.activity_chart)<br><br><br>chart = findViewById(R.id.chartView)<br>chart.initialize(<br>context = this,<br>chartHtml = &quot;file:///android_asset/chartiq/chart.html&quot;, // your packaged HTML<br>onReady = {<br>// 1) set symbol &amp; interval<br>chart.setSymbol(&quot;AAPL&quot;)<br>chart.setPeriodicity(<br>period = 1, // number of units<br>interval = 5, // 1 = 1m, 5 = 5m, etc. 0 = tick, &#39;day&#39; for daily<br>timeUnit = &quot;minute&quot; // &quot;tick&quot;, &quot;second&quot;, &quot;minute&quot;, &quot;day&quot;<br>)<br><br><br>// 2) plug in your data source (QuoteFeed style)<br>chart.setQuoteFeed(object : QuoteFeed {<br>override fun fetch(params: QuoteFeed.Params, cb: QuoteFeed.Callback) {<br>// TODO: hit your REST/WebSocket, then call cb.onData(bars) or cb.onError()<br>}<br>})<br><br><br>// 3) paint!<br>chart.draw()<br>}<br>)<br>}<br>}</pre><blockquote><em>Pro tip: Keep the </em><strong><em>HTML bundle</em></strong><em> in </em><em>android_asset/ and version it alongside your app so you control upgrades.</em></blockquote><h3>3) Hidden Gems Most Devs Miss</h3><h3>3.1 SignalIQ: Turn Studies Into Visual Signals (with History)</h3><p><strong>What it is:</strong> A plug‑in that converts study conditions (e.g., RSI crossovers, MACD histogram flips, “price above VWAP”) into <strong>paintbars and markers</strong> on the chart <em>including historical context</em>. It’s not just real‑time alerts; it helps users back‑test visually.</p><p><strong>Why it matters:</strong> Traders love seeing <em>where</em> and <em>how often</em> conditions occurred, not just the last one.</p><p><strong>How to use (Android + JS bridge):</strong></p><pre>chart.call(&quot;signalIQ.addSignal&quot;, mapOf(<br>&quot;id&quot; to &quot;rsiCross70&quot;,<br>&quot;study&quot; to &quot;RSI&quot;,<br>&quot;condition&quot; to &quot;crossesAbove&quot;,<br>&quot;level&quot; to 70,<br>&quot;color&quot; to &quot;#FF9800&quot; // paintbar/marker tint<br>))<br><br>// Inside your HTML bundle (nativeSdkBridge.js scope)<br>CIQ.SignalIQ(...).addSignal({<br>id: &quot;rsiCross70&quot;,<br>study: &quot;RSI&quot;,<br>condition: &quot;crossesAbove&quot;,<br>level: 70,<br>marker: { shape: &quot;arrowUp&quot; },<br>paintbar: true<br>});</pre><p><strong>Bonus:</strong> You can ship a <strong>Signal Palette</strong> so users toggle signals per symbol and timeframe.</p><h3>3.2 L2 / Order Book Heatmaps on Mobile (Yes, Really)</h3><p><strong>What it is:</strong> ChartIQ ships L2 components and a <strong>Heatmap renderer</strong> that can visualize depth/liquidity as a color stream behind price or in a separate pane.</p><p><strong>Use cases:</strong> Crypto/FX order book, equities depth, auction imbalance visuals.</p><p><strong>How to wire it:</strong></p><pre>// In your chart HTML runtime<br>const lm = chartEngine; // CIQ.ChartEngine instance<br>lm.addSeries(&quot;Bids&quot;, {<br>renderer: CIQ.Renderer.Heatmap,<br>// data for heatmap expects an array field per bar (e.g., bar.custom.Bids)<br>});</pre><p>On Android, feed your L2 snapshots/deltas into bars with a custom array (per bar) that the heatmap reads. Render it behind price or in a side panel.</p><p><strong>UX tip:</strong> Add a gesture to fade/expand the heatmap so it doesn’t overpower candles on small screens.</p><h3>3.3 Markers API: Pin Anything to Price/Time</h3><p>Markers are DOM elements positioned by <strong>date/tick</strong>. Use them for earnings icons, trades, analyst notes, or in‑app user annotations.</p><pre>chart.call(&quot;markers.add&quot;, mapOf(<br>&quot;id&quot; to &quot;earningsQ2&quot;,<br>&quot;dt&quot; to 1720137600000L, // epoch ms<br>&quot;panel&quot; to &quot;chart&quot;,<br>&quot;node&quot; to &quot;&lt;div class=&#39;marker earnings&#39;&gt;E&lt;/div&gt;&quot;<br>))</pre><p>Persist markers per user/symbol and reload on chart init for a “memory” effect.</p><h3>3.4 addOns &amp; Configuration Object: Ship Features by JSON, Not Code</h3><p>A single <strong>configuration object</strong> can enable add‑ons like <strong>Range Slider</strong>, <strong>Extended Hours</strong>, <strong>Inactivity Shade</strong>, <strong>Fibonacci Time Zones</strong>, <strong>Sticky Studies</strong>, <strong>Timezone menus</strong>, and more — without rewriting Android UI.</p><pre>// config.js inside assets<br>window.ciqConfig = {<br>addOns: {<br>rangeSlider: { enabled: true },<br>extendedHours: { filter: true, sessions: { pre: true, post: true } },<br>inactivityShade: { enabled: true }<br>},<br>menus: { studies: true, timezones: true, chartTypes: true }<br>};</pre><p>This keeps feature flags server‑driven and easy to A/B.</p><h3>3.5 Equation Studies &amp; Custom Studies: Fast “What‑Ifs”</h3><p>You can define <strong>Equation studies</strong> on the fly (e.g., EMA(9) - EMA(21) or ((close - low) / (high - low)) * 100). Combine with SignalIQ to surface <strong>confluence</strong> (e.g., equation &gt; 50 <em>and</em> price above VWAP).</p><pre>CIQ.Studies.addStudy(chartEngine, &quot;Equation&quot;, {<br>equation: &quot;ema(close,9) - ema(close,21)&quot;,<br>display: &quot;EMA(9)-EMA(21) Spread&quot;<br>});</pre><h3>3.6 Multi‑Pane &amp; Non‑Time Charts on Mobile</h3><p>It’s not just candlesticks. Ship <strong>Point &amp; Figure</strong>, <strong>Renko</strong>, <strong>Kagi</strong>, <strong>Heikin‑Ashi</strong>, and multi‑pane layouts (e.g., volume profile, RSI, MACD below price). Users don’t expect this depth on phones — delight them.</p><h3>4) Data Feeds the Right Way (QuoteFeed Patterns)</h3><ul><li><strong>Batching &amp; Pagination:</strong> Implement historical fetch in batched pages; resume with more pointers.</li><li><strong>Sub‑second / Tick:</strong> For instruments that trade fast, stream ticks and let the engine build bars client‑side.</li><li><strong>Timezones &amp; Sessions:</strong> Normalize server timestamps to UTC; let ChartIQ handle session templates (pre/post market) so cross‑exchange symbols behave.</li><li><strong>Corporate Actions:</strong> Split/Dividend events should be sent as adjustments or markers to avoid “chart jumps”.</li></ul><p>Minimal shape your feed should return:</p><pre>[<br>{&quot;DT&quot;: &quot;2025-08-01T14:30:00Z&quot;, &quot;Open&quot;: 100.1, &quot;High&quot;: 101.2, &quot;Low&quot;: 99.8, &quot;Close&quot;: 100.9, &quot;Volume&quot;: 32100}<br>]</pre><p>For ticks, send {&quot;DT&quot;:&quot;...&quot;,&quot;Price&quot;:100.9,&quot;Size&quot;:200} and let periodicity build bars.</p><h3>5) Android‑Specific Performance Playbook</h3><ul><li><strong>WebView Rendering</strong>: Keep hardware acceleration ON (default). Use a dedicated Activity/Fragment for charts to reduce overdraw.</li><li><strong>Main‑Thread Hygiene</strong>: Push network and JSON parsing off the main thread; coalesce updates before calling into the chart.</li><li><strong>Bridge Batching</strong>: If you’re sending many markers/studies at once, bundle them into one chart.call(&quot;applyConfig&quot;, config) instead of N calls.</li><li><strong>Viewport Size</strong>: Recalculate chart dimensions on orientation changes and window insets; trigger a resize() in the chart runtime.</li><li><strong>Memory</strong>: Unregister WebSocket listeners in onPause(), and call a light pause() in JS; resume in onResume().</li><li><strong>Offline</strong>: Cache the HTML/JS/CSS bundle and last‑known bars so the chart opens instantly, then “hot‑fills” fresh data.</li></ul><h3>6) UX Patterns That Convert</h3><ul><li><strong>Mode Toggle</strong>: Tap‑and‑hold to switch from <strong>pan</strong> to <strong>crosshair</strong> without hunting menus.</li><li><strong>Context Actions</strong>: Long‑press on a candle → quick menu: Add Alert, Add Note, Add Signal.</li><li><strong>One‑Handed Studies</strong>: Surface a short list of “study presets” (e.g., 9/21 EMA, BB(20,2), VWAP). Persist per user.</li><li><strong>State Sync</strong>: Link quote panel ↔ chart state (symbol, interval) with deep links so watchlists feel coherent.</li></ul><h3>7) End‑to‑End Example: A “Pro” Mobile Setup in ~50 Lines</h3><p><strong>Goal:</strong> Candles + VWAP + RSI pane + SignalIQ paintbars + range slider.</p><pre>chart.initialize(this, &quot;file:///android_asset/chartiq/chart.html&quot;) {<br>chart.setSymbol(&quot;MSFT&quot;)<br>chart.setPeriodicity(1, 5, &quot;minute&quot;)<br><br><br>// Bulk apply config living in your assets or fetched from server<br>chart.call(&quot;applyConfig&quot;, mapOf(<br>&quot;addOns&quot; to mapOf(<br>&quot;rangeSlider&quot; to mapOf(&quot;enabled&quot; to true),<br>&quot;extendedHours&quot; to mapOf(&quot;filter&quot; to true)<br>),<br>&quot;studies&quot; to listOf(<br>mapOf(&quot;name&quot; to &quot;VWAP&quot;),<br>mapOf(&quot;name&quot; to &quot;RSI&quot;, &quot;panel&quot; to &quot;new&quot;)<br>)<br>))<br><br><br>// A simple RSI&gt;70 SignalIQ paintbar<br>chart.call(&quot;signalIQ.addSignal&quot;, mapOf(<br>&quot;id&quot; to &quot;rsiOverbought&quot;,<br>&quot;study&quot; to &quot;RSI&quot;,<br>&quot;condition&quot; to &quot;greaterThan&quot;,<br>&quot;level&quot; to 70,<br>&quot;paintbar&quot; to true<br>))<br><br><br>chart.draw()<br>}</pre><h3>8) Testing &amp; Upgrade Strategy</h3><ul><li><strong>Lock Versions</strong>: Ship a pinned ChartIQ library version with release notes tracked in your repo.</li><li><strong>Visual Snapshots</strong>: Use screenshot testing (Pixel/MD) across intervals and symbols; include extended hours ON/OFF.</li><li><strong>Feed Fuzzing</strong>: Randomly drop/duplicate ticks in QA to verify your consolidation logic and the chart’s resilience.</li><li><strong>Feature Flags</strong>: Gate add‑ons and SignalIQ definitions via remote config so you can experiment safely.</li></ul><h3>Integration Best Practices (Kotlin + Clean Architecture)</h3><p>When integrating ChartIQ into an Android app, follow these best practices:</p><ol><li><strong>Keep ChartIQ inside a UI module</strong> (separate from domain/data layers).</li><li><strong>Expose chart actions via ViewModel</strong>: Instead of directly calling ChartIQ APIs inside your Activity/Fragment, wrap them in ViewModel functions.</li><li><strong>Use Remote Config for chart features</strong>: Many fintechs toggle advanced features like drawing tools or depth charts based on user tier.</li><li><strong>Compose Interop</strong>: ChartIQ is a WebView under the hood. In Jetpack Compose, you can embed it with AndroidView. This allows you to blend native Compose UIs with ChartIQ’s power.</li></ol><pre>@Composable<br>fun ChartIQView(url: String, modifier: Modifier = Modifier) {<br>AndroidView(factory = { context -&gt;<br>WebView(context).apply {<br>settings.javaScriptEnabled = true<br>loadUrl(url)<br>}<br>}, modifier = modifier)<br>}</pre><h3>Performance Tips</h3><ul><li><strong>Lazy Loading Indicators</strong>: Don’t enable all studies at once. Load them when the user requests.</li><li><strong>Use Offscreen Rendering</strong>: ChartIQ supports fast WebGL rendering. Enable hardware acceleration in your WebView.</li><li><strong>Stream Data Efficiently</strong>: Use WebSockets for tick data instead of frequent REST polling.</li></ul><h3>Developer Pitfalls</h3><ul><li>Treating ChartIQ like MPAndroidChart → Wrong approach, it’s much deeper.</li><li>Not exposing interactive tools (trendlines, crosshair, comparisons) → Users expect them.</li><li>Forgetting mobile UX: Pinch-zoom and drag behaviors need careful testing.</li></ul><h3>Conclusion</h3><p>ChartIQ empowers Android developers to deliver institutional-grade charting inside consumer or professional trading apps. While many teams stop at basic candlesticks, the SDK hides advanced features — SignalIQ, custom studies, depth visualizations, and configuration-driven add-ons — that can set your app apart. By thoughtfully combining these tools with a solid data feed, performance practices, and intuitive UX, you transform charts from a “nice-to-have” feature into a <strong>core product differentiator</strong>. The key is not just rendering price, but creating a dynamic, contextual, and insightful trading experience on mobile.</p><h3>Wrap Up</h3><p>If you’re building a trading or fintech app, don’t settle for static charts. ChartIQ offers a deep toolkit beyond the surface features — one that most developers overlook. By exploring its hidden layers and tailoring them to your users, you can elevate your app from ordinary to exceptional. The more you experiment with its advanced modules, the more you’ll discover opportunities to craft a unique trading experience that truly stands out.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=37634ee5ce27" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>