<?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 Shiraz Muhammad on Medium]]></title>
        <description><![CDATA[Stories by Shiraz Muhammad on Medium]]></description>
        <link>https://medium.com/@shiraz990?source=rss-e44300520258------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*yA9xHKtF7grjtkaaYL_dRQ.jpeg</url>
            <title>Stories by Shiraz Muhammad on Medium</title>
            <link>https://medium.com/@shiraz990?source=rss-e44300520258------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 06:14:56 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@shiraz990/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[AppForge: Smarter Android Code Reviews — Right on Your Laptop]]></title>
            <link>https://medium.com/@shiraz990/appforge-smarter-android-code-reviews-right-on-your-laptop-091c8801fcb6?source=rss-e44300520258------2</link>
            <guid isPermaLink="false">https://medium.com/p/091c8801fcb6</guid>
            <category><![CDATA[ai-agent]]></category>
            <category><![CDATA[qwen2-5]]></category>
            <category><![CDATA[deepseek]]></category>
            <category><![CDATA[gemma2]]></category>
            <category><![CDATA[ollama]]></category>
            <dc:creator><![CDATA[Shiraz Muhammad]]></dc:creator>
            <pubDate>Sun, 02 Aug 2026 20:29:24 GMT</pubDate>
            <atom:updated>2026-08-02T21:17:37.703Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ftl9hxHUiCOvYFBmxwyo6w.png" /></figure><h4><strong>AI-powered quality checks for Android apps, without sending your code to the cloud.</strong></h4><p>Android apps get complicated fast. What starts as a clean project slowly picks up problems: unfinished TODOs, unsafe code, old libraries, missing tests, and architecture that no longer matches the original plan. Most of these issues stay hidden until a release is close — or until something breaks. Lint tools catch some of it. Cloud AI tools can catch more, but they often require uploading your source code. For many teams, that is not an option.</p><h4><strong>AppForge </strong>sits in the middle.</h4><p>It reviews your Android project on your own machine, explains what needs attention, and helps you improve the code — privately and clearly.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FGX-qguivW64%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DGX-qguivW64&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FGX-qguivW64%2Fhqdefault.jpg&amp;type=text%2Fhtml&amp;schema=youtube" width="640" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/ce06589bb18c0f926ec9f21a2617cd8c/href">https://medium.com/media/ce06589bb18c0f926ec9f21a2617cd8c/href</a></iframe><h4><strong>Github Code Repository:</strong></h4><p><a href="https://github.com/shiraz990/appforge.git">GitHub - shiraz990/appforge</a></p><h3><strong>What AppForge Does</strong></h3><p>AppForge is a local Android code review tool. You give it your project path, click analyze, and it checks your app from several important angles:</p><ol><li><strong>Architecture </strong>— Is the project structured well (for example, MVVM with repositories)?</li></ol><p>2. <strong>Code quality</strong> — Are there TODOs, debug prints, risky null checks, or outdated APIs?</p><p>3. <strong>Security </strong>— Are there secrets in code, unsafe HTTP links, or known library vulnerabilities (CVEs)?</p><p>4. <strong>Testing </strong>— Does the project have meaningful test coverage?</p><p>5. <strong>Performance and release readiness </strong>— Is the app in good shape to ship?</p><p>At the end, you get a clear health score, detailed findings, fix suggestions, and a report you can share with your team.</p><h3><strong>Why It Runs Locally</strong></h3><p>AppForge uses local AI models through Ollama. Your project stays on your computer.</p><p>That matters if you work with:</p><ol><li>Private or client code</li></ol><p>2. Fintech, healthcare, or regulated products</p><p>3. Any team that cannot send source code to external AI services</p><p>4. You still get AI-assisted review. You do not give up control of your codebase.</p><h3>How to Set Up and Run AppForge</h3><p>You do not need a cloud account. A new user can get started in a few minutes.</p><h4>What you need</h4><ul><li>Python 3.11 or newer</li><li>Ollama (for local AI models)</li><li>An Android project on your machine to analyze</li></ul><h3>Step 1: Install Python</h3><p>Download Python from <a href="https://www.python.org/downloads/">python.org</a>.</p><p>During installation on Windows, check <strong>Add Python to PATH</strong>.</p><p>Confirm it works:</p><pre>python --version</pre><h3>Step 2: Install Ollama</h3><p>Download Ollama from <a href="https://ollama.com/">ollama.com</a>.</p><p>After installing, start it:</p><pre>ollama serve</pre><h3>Step 3: Download the AI models</h3><p>Open a new terminal and pull the three models AppForge uses:</p><pre>ollama pull deepseek-coder:1.3b<br>ollama pull qwen2.5-coder:3b<br>ollama pull gemma2:2b</pre><p>This is a one-time download. It may take a few minutes depending on your internet speed.</p><h3>Step 4: Get the AppForge project</h3><p>Clone or download the AppForge repository, then open a terminal inside the project folder.</p><pre>git clone https://github.com/shiraz990/appforge.git<br>cd appforge</pre><h3>Step 5: Install Python packages</h3><pre>pip install streamlit plotly pandas requests</pre><p>Optional (for PDF export):</p><pre>pip install weasyprint</pre><h3>Step 6: Launch AppForge</h3><pre>streamlit run app_professional.py</pre><p>Your browser should open at:</p><pre>http://localhost:8501</pre><p>If it does not open automatically, paste that link into your browser.</p><h3>Step 7: Analyze your Android project</h3><ol><li>In the sidebar, keep the options you want enabled (AI Review, Auto-Fix, CVE Scanning, Compose Analysis).</li><li>Paste the full path to your Android project.</li><li>Example (Windows): C:\Users\yourname\AndroidStudioProjects\MyApp</li><li>Click <strong>Analyze Project</strong>.</li><li>Review the health score, findings, and AI assessments.</li><li>Apply suggested fixes only after reviewing them.</li><li>Export an HTML or PDF report if you want to share results.</li></ol><h3>Quick tip</h3><p>Before analyzing, check the sidebar:</p><ul><li>If it says <strong>Ollama Running</strong>, you are ready for AI review.</li><li>If it says <strong>Ollama Not Found</strong>, run ollama serve again and refresh the page.</li></ul><p>That is the full setup. After the first run, you usually only need Step 2 and Step 6.</p><h3>The Model Council (In Plain Terms)</h3><p>Instead of relying on one AI model for everything, AppForge uses three local models with clear roles:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/771/1*4yNgUVJemTR1p7xpLtr3PA.png" /></figure><p>Importantly, AppForge does not invent findings. It first scans your project for real signals — file counts, architecture patterns, CVEs, code issues — and then uses AI to explain those results in clear language.</p><p>So the review stays tied to <em>your</em> project, not generic advice.</p><h3>What You Get After Analysis</h3><h3>1. Health score</h3><p>A simple overall score, plus category scores for architecture, quality, security, testing, and performance.</p><h3>2. Practical findings</h3><p>Things like:</p><ul><li>Hardcoded API keys or passwords</li><li>http:// links that should be https://</li><li>Risky !! null assertions</li><li>Deprecated Android APIs</li><li>Missing ViewModels, repositories, or tests</li><li>Jetpack Compose issues</li><li>Vulnerable dependencies</li></ul><h3>3. Auto-fix suggestions</h3><p>For common problems, AppForge can suggest fixes. It creates backups before applying changes, so you stay in control.</p><h3>4. Shareable reports</h3><p>Export HTML or PDF summaries for pull requests, sprint reviews, audits, or stakeholder updates.</p><h3>Who It Helps</h3><p><strong>Developers</strong> get faster feedback before a PR.<br><strong>Tech leads</strong> get a shared picture of project health.<br><strong>Security teams</strong> get useful checks without moving code off-device.<br><strong>Managers</strong> get clear reports instead of vague “the code feels messy” conversations.</p><h3>The Idea Behind AppForge</h3><p>Good Android quality should be easy to see and easy to act on.</p><p>AppForge is built around three simple rules:</p><ol><li><strong>Keep code local</strong></li><li><strong>Base findings on real project evidence</strong></li><li><strong>Make results easy to understand and fix</strong></li></ol><p>It does not replace Android Studio, CI, or human review. It makes those workflows stronger.</p><h3>Final Thought</h3><p>If you have ever opened an Android project and wondered,<br>“Is this actually ready to ship — and can we check that without uploading our code?”</p><p>AppForge is built to answer that.</p><p>Forge better Android code. Keep it private. Ship with more confidence.</p><h3>About AppForge</h3><p><strong>AppForge</strong> is a privacy-first Android intelligence tool for local code review, security checks, Compose analysis, AI assessments, auto-fix suggestions, and professional reporting.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=091c8801fcb6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building an Android Code Review Agent with Python, Streamlit, and Qwen2.5-Coder (via Ollama)]]></title>
            <link>https://medium.com/@shiraz990/building-an-android-code-review-agent-with-python-streamlit-and-qwen2-5-coder-via-ollama-5b6862a4d19d?source=rss-e44300520258------2</link>
            <guid isPermaLink="false">https://medium.com/p/5b6862a4d19d</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[ollama]]></category>
            <category><![CDATA[ai-agent]]></category>
            <category><![CDATA[streamlit]]></category>
            <category><![CDATA[qwen]]></category>
            <dc:creator><![CDATA[Shiraz Muhammad]]></dc:creator>
            <pubDate>Fri, 26 Jun 2026 11:50:54 GMT</pubDate>
            <atom:updated>2026-06-26T11:50:54.956Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*s86MAPQD9GOicGj7.png" /><figcaption>AI reviewing code</figcaption></figure><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FJeG28TjVKKw%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DJeG28TjVKKw&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FJeG28TjVKKw%2Fhqdefault.jpg&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/b01b228a2e9439c0fc3a262b35bc8799/href">https://medium.com/media/b01b228a2e9439c0fc3a262b35bc8799/href</a></iframe><p>This is a follow-along build guide. By the end, you’ll have a small tool that:</p><ol><li>Scans any Android project on your computer</li><li>Counts things like TODOs, missing ViewModels, and leaked API keys</li><li>Turns that into a 0–100 health score</li><li>Sends a summary to a local AI model that writes a written review — like a senior engineer leaving comments on your PR</li><li>Shows all of it in a simple web dashboard</li></ol><p>Everything runs on your own machine. Your code never gets uploaded anywhere.</p><p>We’ll build five files, one at a time, and <strong>test each one before moving to the next</strong> — so if something breaks, you’ll know exactly which step caused it.</p><h3>What you need before starting</h3><p>Tool Why How to check Python 3.9+ Runs everything python3 --version pip Installs packages pip --version <a href="https://ollama.com/">Ollama</a> Runs the AI model locally ollama --version</p><p>Install the two Python packages we need:</p><pre>pip install streamlit</pre><p>Then pull a small AI model (about 1GB, runs fine on a laptop CPU):</p><pre>ollama pull qwen2.5-coder:1.5b</pre><p>Create a project folder and cd into it:</p><pre>mkdir android-intelligence-agent<br>cd android-intelligence-agent</pre><p>You should end up with these five files by the end:</p><pre>android-intelligence-agent/<br>├── scanner.py        # Step 1 — find and read project files<br>├── analyzer.py        # Step 2 — count problems, calculate a score<br>├── ai_reviewer.py      # Step 3 — ask the AI for a written review<br>├── app.py             # Step 4 — the dashboard you actually look at<br>└── test_ai.py          # used during Step 3 to test the AI in isolation</pre><h3>Step 1 — Find and read the project’s files</h3><p><strong>Goal:</strong> point this script at an Android project folder, get back a list of every Kotlin/Java/XML file and its contents.</p><p>Create scanner.py:</p><pre>import os<br></pre><pre>def read_file(path):<br>    try:<br>        with open(path, &quot;r&quot;, encoding=&quot;utf-8&quot;) as f:<br>            return f.read()<br>    except:<br>        return &quot;&quot;<br></pre><pre>def scan_project(project_path):</pre><pre>    project = {<br>        &quot;kotlin_files&quot;: [],<br>        &quot;java_files&quot;: [],<br>        &quot;xml_files&quot;: [],<br>        &quot;gradle_files&quot;: [],<br>        &quot;manifest&quot;: &quot;&quot;,<br>        &quot;toml&quot;: &quot;&quot;,<br>        &quot;files&quot;: []<br>    }</pre><pre>    for root, dirs, files in os.walk(project_path):</pre><pre>        # Don&#39;t waste time scanning generated/build folders<br>        dirs[:] = [d for d in dirs if d not in [&quot;build&quot;, &quot;.gradle&quot;, &quot;.idea&quot;, &quot;.git&quot;]]</pre><pre>        for file in files:<br>            full_path = os.path.join(root, file)</pre><pre>            if file.endswith(&quot;.kt&quot;):<br>                content = read_file(full_path)<br>                project[&quot;kotlin_files&quot;].append(full_path)<br>                project[&quot;files&quot;].append({&quot;name&quot;: file, &quot;path&quot;: full_path, &quot;type&quot;: &quot;kotlin&quot;, &quot;content&quot;: content})</pre><pre>            elif file.endswith(&quot;.java&quot;):<br>                content = read_file(full_path)<br>                project[&quot;java_files&quot;].append(full_path)<br>                project[&quot;files&quot;].append({&quot;name&quot;: file, &quot;path&quot;: full_path, &quot;type&quot;: &quot;java&quot;, &quot;content&quot;: content})</pre><pre>            elif file.endswith(&quot;.xml&quot;):<br>                content = read_file(full_path)<br>                project[&quot;xml_files&quot;].append(full_path)<br>                project[&quot;files&quot;].append({&quot;name&quot;: file, &quot;path&quot;: full_path, &quot;type&quot;: &quot;xml&quot;, &quot;content&quot;: content})<br>                if file == &quot;AndroidManifest.xml&quot;:<br>                    project[&quot;manifest&quot;] = content</pre><pre>            elif file in (&quot;build.gradle&quot;, &quot;build.gradle.kts&quot;):<br>                project[&quot;gradle_files&quot;].append(read_file(full_path))</pre><pre>            elif file == &quot;libs.versions.toml&quot;:<br>                project[&quot;toml&quot;] = read_file(full_path)</pre><pre>    return project</pre><p><strong>What’s actually happening here, in plain terms:</strong></p><ul><li>os.walk() walks every folder inside your project, one folder at a time.</li><li>dirs[:] = [...] is the one line worth slowing down on — it removes build/, .gradle/, etc. from the list <em>before</em> Python walks into them. Skip this and you&#39;ll spend ten seconds scanning compiled bytecode for no reason.</li><li>Every file we care about gets saved twice: once into a list of paths (so you can print “47 Kotlin files”), and once into one big files list with its full content (so the next step can read inside it).</li></ul><h3>✅ Test it</h3><p>In the same folder, run this in a Python shell (python3) or a scratch file:</p><pre>from scanner import scan_project</pre><pre>project = scan_project(&quot;/path/to/some/android/project&quot;)<br>print(&quot;Kotlin files:&quot;, len(project[&quot;kotlin_files&quot;]))<br>print(&quot;XML files:&quot;, len(project[&quot;xml_files&quot;]))</pre><p>You should see real numbers printed. If you see 0 for everything, double check the path you passed in — that&#39;s almost always the issue.</p><h3>Step 2 — Count the problems, calculate a score</h3><p><strong>Goal:</strong> take the project dict from Step 1 and turn it into numbers: how many ViewModels exist, how many TODOs are left, what technologies are used, and one overall health score.</p><p>Create analyzer.py. We&#39;ll build it in four small pieces — paste them into the file in order.</p><h3>2a. Detect which libraries the project uses</h3><p>This just searches the Gradle files for familiar names. No fancy parsing needed.</p><pre>import re<br></pre><pre>def analyze_project(project):</pre><pre>    files = project[&quot;files&quot;]<br>    result = {}</pre><pre>    kotlin_files = activities = fragments = services = receivers = 0<br>    compose = viewmodels = repositories = tests = 0<br>    todo = fixme = println = logd = http = apikey = large_files = 0</pre><pre>    technologies = {<br>        &quot;Jetpack Compose&quot;: False, &quot;Material3&quot;: False, &quot;Navigation&quot;: False,<br>        &quot;Coroutines&quot;: False, &quot;Hilt&quot;: False, &quot;Retrofit&quot;: False,<br>        &quot;Room&quot;: False, &quot;WorkManager&quot;: False<br>    }</pre><pre>    recommendations = []</pre><pre>    gradle_text = &quot;\n&quot;.join(project[&quot;gradle_files&quot;]) + &quot;\n&quot; + project[&quot;toml&quot;]</pre><pre>    if &quot;compose&quot; in gradle_text.lower(): technologies[&quot;Jetpack Compose&quot;] = True<br>    if &quot;material3&quot; in gradle_text.lower(): technologies[&quot;Material3&quot;] = True<br>    if &quot;navigation&quot; in gradle_text.lower(): technologies[&quot;Navigation&quot;] = True<br>    if &quot;retrofit&quot; in gradle_text.lower(): technologies[&quot;Retrofit&quot;] = True<br>    if &quot;room&quot; in gradle_text.lower(): technologies[&quot;Room&quot;] = True<br>    if &quot;workmanager&quot; in gradle_text.lower(): technologies[&quot;WorkManager&quot;] = True<br>    if &quot;coroutines&quot; in gradle_text.lower(): technologies[&quot;Coroutines&quot;] = True<br>    if &quot;hilt&quot; in gradle_text.lower(): technologies[&quot;Hilt&quot;] = True</pre><h3>2b. Loop through every Kotlin/Java file and count patterns</h3><p>Add this next, still inside analyze_project:</p><pre>for file in files:</pre><pre>        if file[&quot;type&quot;] not in [&quot;kotlin&quot;, &quot;java&quot;]:<br>            continue</pre><pre>        kotlin_files += 1<br>        code = file[&quot;content&quot;]<br>        lower = code.lower()</pre><pre>        if len(code) &gt; 15000: large_files += 1<br>        if &quot;activity&quot; in code: activities += 1<br>        if &quot;fragment&quot; in code: fragments += 1<br>        if &quot;service&quot; in code: services += 1<br>        if &quot;receiver&quot; in code: receivers += 1<br>        if &quot;@composable&quot; in lower: compose += lower.count(&quot;@composable&quot;)<br>        if &quot;viewmodel&quot; in lower: viewmodels += 1<br>        if &quot;repository&quot; in lower: repositories += 1<br>        if &quot;@test&quot; in lower: tests += 1</pre><pre>        todo += lower.count(&quot;todo&quot;)<br>        fixme += lower.count(&quot;fixme&quot;)<br>        println += lower.count(&quot;println(&quot;)<br>        logd += lower.count(&quot;log.d&quot;)<br>        http += lower.count(&quot;http://&quot;)</pre><pre>        if re.search(r&#39;AIza[0-9A-Za-z\-_]{35}&#39;, code):<br>            apikey += 1</pre><p>The one line that deserves a closer look: re.search(r&#39;AIza[0-9A-Za-z\-_]{35}&#39;, code). That pattern matches the shape of a Google API key. It&#39;s how this catches accidentally committed secrets.</p><h3>2c. Turn the counts into a 0–100 score</h3><pre>health = 100<br>    health -= todo<br>    health -= fixme<br>    health -= println<br>    health -= logd<br>    health -= http * 5<br>    health -= apikey * 10<br>    health -= large_files * 3<br>    if viewmodels == 0: health -= 5<br>    if repositories == 0: health -= 5<br>    if health &lt; 0: health = 0</pre><p>Plain English: start at a perfect 100, and subtract points for each problem found. A leaked API key costs 10 points. A stray TODO costs 1. These numbers are a starting point — feel free to tune them once you see real results.</p><h3>2d. Build the recommendation list and return everything</h3><pre>if viewmodels == 0: recommendations.append(&quot;⚠ No ViewModel detected. Consider using MVVM.&quot;)<br>    if repositories == 0: recommendations.append(&quot;⚠ No Repository layer detected.&quot;)<br>    if not technologies[&quot;Navigation&quot;]: recommendations.append(&quot;⚠ Jetpack Navigation is not detected.&quot;)<br>    if not technologies[&quot;Hilt&quot;]: recommendations.append(&quot;⚠ Hilt dependency injection is missing.&quot;)<br>    if not technologies[&quot;Room&quot;]: recommendations.append(&quot;⚠ Room database is not detected.&quot;)<br>    if todo &gt; 0: recommendations.append(f&quot;⚠ {todo} TODO comments found.&quot;)<br>    if println &gt; 0: recommendations.append(f&quot;⚠ Remove {println} println() statements.&quot;)<br>    if apikey &gt; 0: recommendations.append(&quot;🚨 Possible API Key found.&quot;)</pre><pre>    result[&quot;health_score&quot;] = health<br>    result[&quot;kotlin_files&quot;] = kotlin_files<br>    result[&quot;activities&quot;] = activities<br>    result[&quot;fragments&quot;] = fragments<br>    result[&quot;services&quot;] = services<br>    result[&quot;receivers&quot;] = receivers<br>    result[&quot;compose&quot;] = compose<br>    result[&quot;viewmodels&quot;] = viewmodels<br>    result[&quot;repositories&quot;] = repositories<br>    result[&quot;tests&quot;] = tests<br>    result[&quot;technologies&quot;] = technologies<br>    result[&quot;recommendations&quot;] = recommendations<br>    result[&quot;rules&quot;] = {<br>        &quot;todo&quot;: todo, &quot;fixme&quot;: fixme, &quot;println&quot;: println,<br>        &quot;logd&quot;: logd, &quot;http&quot;: http, &quot;apikey&quot;: apikey, &quot;large&quot;: large_files<br>    }</pre><pre>    return result</pre><h3>✅ Test it</h3><pre>from scanner import scan_project<br>from analyzer import analyze_project</pre><pre>project = scan_project(&quot;/path/to/some/android/project&quot;)<br>result = analyze_project(project)</pre><pre>print(&quot;Health score:&quot;, result[&quot;health_score&quot;])<br>print(&quot;Recommendations:&quot;, result[&quot;recommendations&quot;])</pre><p>You should see a number between 0 and 100, and a short list of warnings. If the score is always exactly 100 with zero warnings, your project path probably isn’t pointing at real source files — go back and check Step 1 first.</p><h3>Step 3 — Get a written review from a local AI</h3><p><strong>Goal:</strong> take the numbers from Step 2, describe them in plain English, and have a local AI model write a short review of the project — like a senior dev’s PR comment.</p><p>Make sure Ollama is actually running first:</p><pre>ollama list</pre><p>You should see qwen2.5-coder:1.5b in the list. If not, go back and run ollama pull qwen2.5-coder:1.5b.</p><p>Create ai_reviewer.py:</p><pre>import subprocess<br>import re<br>import os<br></pre><pre>def clean_output(text):<br>    &quot;&quot;&quot;Ollama prints terminal control codes even with colors off.<br>    This strips them out so the text is actually readable.&quot;&quot;&quot;<br>    ansi_escape = re.compile(r&#39;\x1B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~])&#39;)<br>    return ansi_escape.sub(&#39;&#39;, text)<br></pre><pre>def review_project(project_summary):</pre><pre>    prompt = f&quot;&quot;&quot;<br>You are a Staff Android Engineer with 15 years of experience.<br>Analyze ONLY the information provided below.<br>DO NOT invent missing information. If something is missing, explain its impact.</pre><pre>Return your review using these sections:<br># Overall Summary<br># Architecture Review (Score /10, Strengths, Weaknesses, Recommendations)<br># Code Quality (Score /10, Strengths, Weaknesses, Recommendations)<br># Security (Score /10, Potential Risks, Recommendations)<br># Priority Fixes (top 10 improvements, in order)</pre><pre>Here is the Android project summary:</pre><pre>{project_summary}</pre><pre>Keep the review professional and concise.<br>&quot;&quot;&quot;</pre><pre>    try:<br>        response = subprocess.run(<br>            [&quot;ollama&quot;, &quot;run&quot;, &quot;qwen2.5-coder:1.5b&quot;],<br>            input=prompt,<br>            capture_output=True,<br>            text=True,<br>            encoding=&quot;utf-8&quot;,<br>            env={**os.environ, &quot;NO_COLOR&quot;: &quot;1&quot;}<br>        )</pre><pre>        if response.returncode != 0:<br>            return f&quot;Ollama Error:\n{response.stderr}&quot;</pre><pre>        return clean_output(response.stdout).strip()</pre><pre>    except Exception as e:<br>        return f&quot;Error while generating review: {str(e)}&quot;</pre><p><strong>Two things worth understanding, not just copying:</strong></p><ul><li><strong>Why strip ANSI codes?</strong> Without clean_output(), the text you get back has invisible terminal characters mixed in — you&#39;ll see literal garbage like [9D[K in the middle of words. NO_COLOR=1 reduces this but doesn&#39;t eliminate it, so the regex cleanup stays necessary.</li><li><strong>Why the strict prompt rules?</strong> Small models (1.5B parameters) will confidently make things up if you let them — claiming there’s a test suite when there isn’t one, for example. Telling it explicitly <em>“don’t invent missing information”</em> and giving it a rigid template to fill in produces far more trustworthy, consistent output.</li></ul><h3>✅ Test it</h3><p>Create a separate file, test_ai.py, so you can test the AI step <em>without</em> needing a real Android project yet:</p><pre>from ai_reviewer import review_project</pre><pre>summary = &quot;&quot;&quot;<br>Health Score: 84<br>Compose: Yes<br>ViewModels: 0<br>Repositories: 0</pre><pre>Warnings<br>No Repository<br>No ViewModel<br>2 TODO comments<br>&quot;&quot;&quot;</pre><pre>print(review_project(summary))</pre><p>Run it:</p><pre>python3 test_ai.py</pre><p>The first run will be slow (the model is loading into memory) — give it 10–30 seconds. You should get back a structured, multi-section review. If you get an error instead, it’s almost always one of:</p><ul><li>Ollama isn’t running → run ollama serve in another terminal</li><li>Model name typo → check it matches exactly what ollama list shows</li></ul><h3>Step 4 — Put it all together in a dashboard</h3><p><strong>Goal:</strong> a simple web page where you type in a project path, click a button, and see everything from Steps 1–3.</p><p>Create app.py:</p><pre>import streamlit as st<br>from scanner import scan_project<br>from analyzer import analyze_project<br>from ai_reviewer import review_project</pre><pre>st.set_page_config(page_title=&quot;Android Intelligence Agent&quot;, page_icon=&quot;🤖&quot;, layout=&quot;wide&quot;)<br>st.title(&quot;🤖 Android Intelligence Agent&quot;)</pre><pre>project_path = st.text_input(&quot;Android Project Path&quot;, &quot;/path/to/your/android/project&quot;)</pre><pre>if st.button(&quot;Analyze Project&quot;):</pre><pre>    with st.spinner(&quot;Scanning Android Project...&quot;):<br>        project = scan_project(project_path)<br>        result = analyze_project(project)</pre><pre>    health = result[&quot;health_score&quot;]<br>    if health &gt;= 90:<br>        st.success(f&quot;🟢 Android Health Score : {health}/100&quot;)<br>    elif health &gt;= 70:<br>        st.warning(f&quot;🟡 Android Health Score : {health}/100&quot;)<br>    else:<br>        st.error(f&quot;🔴 Android Health Score : {health}/100&quot;)</pre><pre>    st.header(&quot;📊 Project Overview&quot;)<br>    col1, col2, col3 = st.columns(3)<br>    with col1:<br>        st.metric(&quot;Kotlin Files&quot;, result[&quot;kotlin_files&quot;])<br>        st.metric(&quot;Activities&quot;, result[&quot;activities&quot;])<br>    with col2:<br>        st.metric(&quot;ViewModels&quot;, result[&quot;viewmodels&quot;])<br>        st.metric(&quot;Repositories&quot;, result[&quot;repositories&quot;])<br>    with col3:<br>        st.metric(&quot;Fragments&quot;, result[&quot;fragments&quot;])<br>        st.metric(&quot;Tests&quot;, result[&quot;tests&quot;])</pre><pre>    st.header(&quot;🛠 Technologies&quot;)<br>    for tech, found in result[&quot;technologies&quot;].items():<br>        st.success(&quot;✅ &quot; + tech) if found else st.error(&quot;❌ &quot; + tech)</pre><pre>    if result[&quot;recommendations&quot;]:<br>        st.header(&quot;📌 Recommendations&quot;)<br>        for rec in result[&quot;recommendations&quot;]:<br>            st.warning(rec)</pre><pre>    st.header(&quot;🤖 AI Review&quot;)<br>    summary = f&quot;&quot;&quot;<br>Project Health Score : {result[&#39;health_score&#39;]}<br>ViewModels : {result[&#39;viewmodels&#39;]}<br>Repositories : {result[&#39;repositories&#39;]}<br>Recommendations:<br>{chr(10).join(result[&#39;recommendations&#39;])}<br>&quot;&quot;&quot;<br>    with st.spinner(&quot;AI is reviewing your project...&quot;):<br>        st.info(review_project(summary))</pre><p><strong>The one design choice worth noticing:</strong> the UI builds a plain-text summary string and hands <em>that</em> to review_project() — not the raw result dictionary. This is what lets you swap out the rules engine, the prompt, or even the AI model later without anything else in the app needing to change. Each piece only ever talks to the next one through plain text or a plain dict.</p><h3>✅ Run it</h3><pre>streamlit run app.py</pre><p>This opens a browser tab. Paste in the path to a real Android project, hit <strong>Analyze Project</strong>, and within a few seconds you should see the health score, the metrics, and finally the AI’s written review.</p><h3>Troubleshooting checklist</h3><p>Problem Likely cause All metrics show 0 Wrong project path, or the folder has no .kt/.java files Garbled text like [9D[K in the AI review You skipped clean_output() in ai_reviewer.py AI review is empty or errors out Ollama isn&#39;t running, or the model name doesn&#39;t match ollama list First AI review takes 30+ seconds Normal — the model is loading into memory the first time Score is always 100 The analyzer ran on zero files — check Step 1&#39;s test output first</p><h3>What to build next, once this works</h3><ul><li>Make the score weights (the -1, -5, -10 numbers in Step 2c) configurable instead of hardcoded</li><li>Analyze the XML layout files too — the scanner already collects them, nothing reads them yet</li><li>Cache the AI’s response so re-running the same project doesn’t re-query the model every time</li><li>Ask the model for structured JSON instead of free text, so the review can be displayed as its own scored sections instead of a wall of text</li></ul><p>You now have a fully working, five-file pipeline that scans, scores, and writes a review of any Android project — running entirely on your own machine.</p><blockquote><strong>Repo</strong> : <a href="https://github.com/shiraz990/android-intelligence-agent.git">https://github.com/shiraz990/android-intelligence-agent.git</a></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5b6862a4d19d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ Experimenting with Cursor AI for Android Development — The Good, The Bad, and The Reality]]></title>
            <link>https://medium.com/@shiraz990/experimenting-with-cursor-ai-for-android-development-the-good-the-bad-and-the-reality-e43471109a66?source=rss-e44300520258------2</link>
            <guid isPermaLink="false">https://medium.com/p/e43471109a66</guid>
            <category><![CDATA[androiddev]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[android-apps]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[cursor-ai]]></category>
            <dc:creator><![CDATA[Shiraz Muhammad]]></dc:creator>
            <pubDate>Sat, 01 Nov 2025 19:34:56 GMT</pubDate>
            <atom:updated>2025-11-01T19:45:26.985Z</atom:updated>
            <content:encoded><![CDATA[<h3>🚀 Experimenting with Cursor AI for Android Development — The Good, The Bad, and The Reality</h3><h3>👋 Introduction</h3><p>As part of our ongoing exploration into AI-assisted development tools for Android, I recently conducted a proof of concept (POC) using <strong>Cursor AI</strong> — an AI-powered coding assistant that integrates seamlessly with modern development environments like <strong>Android Studio</strong>.</p><p>The objective was to evaluate Cursor AI’s potential to <strong>enhance developer productivity and code quality</strong> across different stages of Android app development — from <strong>UI creation</strong> and <strong>API integration</strong> to <strong>ViewModel logic</strong>, <strong>unit testing</strong>, and <strong>auto-documentation</strong>.</p><p>This initiative is part of our broader effort to assess tools similar to <strong>GitHub Copilot</strong> before making an enterprise licensing decision. To ensure meaningful insights, I focused on end-to-end Android use cases, including:<br> 🧩 Generating UI layouts (Jetpack Compose or XML)<br> 🌐 Implementing API services and repository layers<br> 🧠 Building ViewModel logic with Kotlin and StateFlow<br> 🧪 Generating and refining unit tests<br> 📝 Auto-documenting and reviewing existing code</p><p>This article outlines how I configured <strong>Cursor Pro</strong> within <strong>Android Studio</strong>, built a <strong>Weather App POC</strong> using its AI capabilities, and evaluated its overall impact on <strong>development efficiency, consistency, and maintainability</strong>.</p><h3>💡 Why Cursor AI?</h3><p>Android projects often involve repeating patterns — repository setup, Retrofit integration, ViewModel wiring, and test scaffolding.<br> While we already follow solid architecture patterns and maintain a high standard of code quality, automating these <strong>repetitive but non-creative tasks</strong> can significantly reduce setup time and free up focus for <strong>design decisions and performance optimization</strong>.</p><p>Cursor AI’s tight code-context understanding, multiple model support (GPT-5, Claude 4.5, Grok Code Fast, etc.), and inline chat capabilities made it a strong candidate for structured evaluation.</p><h3>⚙️ Setting Up Cursor AI (Pro Plan)</h3><p>Below is the actual setup I used with our <strong>Cursor Team Plan (Pro)</strong> configuration.</p><h3>1️⃣ Install &amp; Open Project</h3><ul><li>Download Cursor from <a href="https://cursor.sh/">https://cursor.sh</a> and sign in with your team account.</li><li>Open your Android project folder (File → Open Folder).</li><li>(Optional) Install VS Code extensions: <strong>Kotlin</strong>, <strong>Gradle Tasks</strong>, <strong>Android XML Tools</strong></li></ul><h3>2️⃣ Enable Models</h3><p>In <strong>Settings → Models</strong>, toggle on relevant back-end models:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/983/1*h2JhZokiPS1RIS7xmB07yw.png" /></figure><p>Restart Cursor if toggles don’t apply immediately.</p><h3>3️⃣ Define Rules &amp; Context</h3><p>Create two simple files at your project root:</p><h4>.cursorrules</h4><pre>You are a senior Android engineer.  <br>Use Kotlin, Jetpack Compose, Hilt, Retrofit, and StateFlow.  <br>Prefer MVVM + Repository pattern and write clean, production-ready code.  <br>Include unit tests using MockK + JUnit5.</pre><h4>projectinstructions.txt</h4><pre>Build a simple Weather App that fetches real-time weather data,  <br>displays it via Jetpack Compose UI,  <br>and uses ViewModel + Repository architecture.</pre><h3>4️⃣ Choose Mode</h3><ul><li><strong>Normal Mode</strong>: step-by-step code suggestions and reviews.</li><li><strong>Agent Mode</strong>: autonomous planning and file generation.<br> For the POC, I used both — Agent mode for scaffolding, Normal mode for refinement.</li></ul><h3>5️⃣ Validate Gradle Setup</h3><p>Ensure a working Gradle configuration:</p><pre>plugins {<br>    id(&quot;com.android.application&quot;)<br>    id(&quot;org.jetbrains.kotlin.android&quot;)<br>}<br><br>android {<br>    compileSdk = 34<br>    defaultConfig {<br>        applicationId = &quot;com.example.weatherapp&quot;<br>        minSdk = 24<br>        targetSdk = 34<br>    }<br>}</pre><p>Check with:</p><pre>./gradlew assembleDebug</pre><h3>🌤️ The Weather App POC</h3><p>To evaluate Cursor’s effectiveness end-to-end, I asked it to build a <strong>Weather App</strong> featuring:</p><ul><li>Jetpack Compose UI for live weather display</li><li>Retrofit + Repository pattern for API calls</li><li>ViewModel logic using StateFlow</li><li>Unit Tests (MockK + JUnit5)</li><li>Auto-documentation for public APIs</li></ul><p>Below is how each stage performed.</p><h3>🧱 1. UI Generation (Compose)</h3><p>Prompt:</p><blockquote><em>“Generate a Jetpack Compose screen showing city name, temperature, and description. Add a loading state.”</em></blockquote><p>Result: Cursor created a fully functional composable with state handling and preview annotations — syntactically correct, following Compose best practices.</p><p><strong>Verdict:</strong> Excellent. Generated UI code was modern and clean. Minor adjustments were needed for theme integration.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hJ6RPtpjFBJuY2ngHGJljw.png" /><figcaption>🧱 1. UI Generation (Compose)-Cursor AI</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1AwvVXLL5IcleKYO7Isa4Q.png" /><figcaption>🧱 1. UI Generation (Compose)-Cursor AI</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vRA57xfy-zyJs22tDMYDEA.png" /><figcaption>🧱 1. UI Generation (Compose)-Android Studio</figcaption></figure><h3>🌐 2. API Service + Repository</h3><p>Prompt:</p><blockquote><em>“Implement a Retrofit service to fetch current weather from OpenWeatherMap API and wrap it in a repository class.”</em></blockquote><p>Cursor generated:</p><ul><li>WeatherApiService.kt with endpoint annotations</li><li>WeatherRepository.kt using Kotlin coroutines</li><li>Correct suspend functions and base URL setup</li></ul><p><strong>Verdict:</strong> Efficient and accurate. Needed only API key injection and dependency .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VjDzCdTMG7VhY4yvgkR0yg.png" /><figcaption>🌐 2. API Service + Repository-Cursor AI</figcaption></figure><h3>🧠 3. ViewModel Logic</h3><p>Prompt:</p><blockquote><em>“Implement ViewModel using StateFlow and inject repository via Hilt.”</em></blockquote><p>The ViewModel correctly managed UI state transitions and exposed a UiState sealed class. Cursor also added error handling logic.</p><p><strong>Verdict:</strong> Near-perfect — production-ready after naming refinements.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Q85evTeaAbwL9MAWreSVmQ.png" /><figcaption>🧠 3. ViewModel Logic-Cursor AI</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BE2UhkvA9kBYJgnWqyGy6Q.png" /><figcaption>🧠 3. ViewModel Logic-Android Studio</figcaption></figure><h3>🧪 4. Unit Tests</h3><p>Prompt:</p><blockquote><em>“Write JUnit5 + MockK tests for WeatherRepository and WeatherViewModel.”</em></blockquote><p>Cursor wrote well-structured tests with realistic mocking and coroutine test scopes.</p><p><strong>Verdict:</strong> Saved ~60–70 % of boilerplate effort.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DzClDF9lt9mDvXaTsAKf8g.png" /><figcaption>🧪 4. Unit Tests-Cursor AI</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EelM_W-4ndMpylJnxehZDA.png" /><figcaption>🧪 4. Unit Tests-Android Studio</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KxFBHiLz2CU_t6ta0QNAqQ.png" /><figcaption>🧪 4. Unit Tests-Android Studio-Report</figcaption></figure><h3>📘 5. Auto-Documentation</h3><p>Prompt:</p><blockquote><em>“Add KDoc to all public functions and summarize the architecture.”</em></blockquote><p>The auto-generated documentation was coherent and ready for internal wiki publishing.</p><p><strong>Verdict:</strong> Good baseline documentation; ideal starting point for code reviews.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*W3jxV1A8pFJ-cDlaOzKkBw.png" /><figcaption>📘 5. Auto-Documentation-Cursor AI</figcaption></figure><h4>ARCHITECTURE.md</h4><pre># Weather App Architecture<br><br>## Overview<br><br>This Weather App follows the **MVVM (Model-View-ViewModel) + Repository** architecture pattern, designed for scalability, testability, and maintainability. The app fetches real-time weather data from the OpenWeatherMap API and displays it using Jetpack Compose.<br><br>## Architecture Layers<br><br>### 1. Presentation Layer<br>- **Technology**: Jetpack Compose<br>- **Components**:<br>  - `MainActivity`: Entry point, hosts Compose UI<br>  - `WeatherScreen`: Main UI composable that displays weather information<br>  - `WeatherViewModel`: Manages UI state and business logic<br>  - `WeatherUiState`: Data class representing UI state<br><br>**Responsibilities**:<br>- Display weather data to users<br>- Handle user interactions<br>- Observe ViewModel state changes reactively using StateFlow<br>- Manage UI states (loading, success, error)<br><br>### 2. Domain/Business Logic Layer<br>- **Components**:<br>  - `WeatherViewModel`: Contains business logic and state management<br>  - `WeatherRepository`: Abstracts data sources and provides data operations<br><br>**Responsibilities**:<br>- Execute business logic<br>- Transform API responses into UI-friendly data<br>- Manage application state<br>- Coordinate between UI and data layers<br><br>### 3. Data Layer<br>- **Technology**: Retrofit, OkHttp, Gson<br>- **Components**:<br>  - `WeatherRepository`: Single source of truth for weather data<br>  - `WeatherApiService`: Retrofit interface for API endpoints<br>  - `WeatherResponse`: Data models for API responses<br><br>**Responsibilities**:<br>- Fetch data from remote API (OpenWeatherMap)<br>- Handle network errors and HTTP exceptions<br>- Parse JSON responses into Kotlin data classes<br>- Provide error messages in user-friendly format<br><br>### 4. Dependency Injection Layer<br>- **Technology**: Hilt (Dagger)<br>- **Components**:<br>  - `AppModule`: Provides application-wide dependencies (API key)<br>  - `NetworkModule`: Provides network-related dependencies (Retrofit, OkHttp, Gson)<br><br>**Responsibilities**:<br>- Manage dependency injection<br>- Provide singleton instances<br>- Simplify testing with mock dependencies<br><br>## Data Flow<br><br>```<br>User Interaction<br>    ↓<br>WeatherScreen (Compose UI)<br>    ↓<br>WeatherViewModel.loadWeather()<br>    ↓<br>WeatherRepository.getCurrentWeather()<br>    ↓<br>WeatherApiService.getCurrentWeather() [Retrofit]<br>    ↓<br>OpenWeatherMap API<br>    ↓<br>WeatherResponse (Data Model)<br>    ↓<br>WeatherRepository (Error Handling &amp; Transformation)<br>    ↓<br>WeatherViewModel (State Update)<br>    ↓<br>StateFlow emits new state<br>    ↓<br>WeatherScreen (UI Updates Reactively)<br>```<br><br>## Key Technologies<br><br>### Core Android<br>- **Jetpack Compose**: Modern declarative UI toolkit<br>- **ViewModel**: Lifecycle-aware component for managing UI-related data<br>- **StateFlow**: Reactive state holder for UI<br>- **Kotlin Coroutines**: Asynchronous programming<br><br>### Dependency Injection<br>- **Hilt**: Simplified dependency injection built on Dagger<br>- **@HiltViewModel**: ViewModel injection<br>- **@AndroidEntryPoint**: Activity injection<br><br>### Networking<br>- **Retrofit**: Type-safe HTTP client for Android<br>- **OkHttp**: HTTP client with interceptors<br>- **Gson**: JSON parsing library<br>- **HttpLoggingInterceptor**: Debug logging for API calls<br><br>### Testing<br>- **JUnit 5**: Unit testing framework<br>- **MockK**: Mocking library for Kotlin<br>- **Compose UI Testing**: UI testing for Compose<br>- **Coroutines Test**: Testing coroutines<br>- **Hilt Testing**: Integration testing with Hilt<br><br>## Architecture Patterns<br><br>### MVVM (Model-View-ViewModel)<br>- **Model**: Data classes and API responses (`WeatherResponse`, data models)<br>- **View**: Jetpack Compose UI (`WeatherScreen`)<br>- **ViewModel**: `WeatherViewModel` - manages state and business logic<br><br>### Repository Pattern<br>- **Purpose**: Abstracts data sources from ViewModel<br>- **Benefits**:<br>  - Single source of truth<br>  - Easy to mock for testing<br>  - Centralized error handling<br>  - Can easily switch data sources (API, cache, database)<br><br>### Dependency Injection<br>- **Pattern**: Constructor injection via Hilt<br>- **Benefits**:<br>  - Loose coupling<br>  - Easy testing with test doubles<br>  - Centralized dependency management<br><br>## Error Handling<br><br>The app implements comprehensive error handling:<br><br>1. **HTTP Errors**: <br>   - 401: Invalid API key<br>   - 404: City not found<br>   - 429: Rate limiting<br>   - 5xx: Server errors<br><br>2. **Network Errors**: <br>   - IOException for connectivity issues<br><br>3. **API Response Errors**: <br>   - Validates `cod` field in response body<br><br>4. **User-Friendly Messages**: <br>   - All errors are translated to user-friendly messages<br>   - Displayed in UI with clear error state<br><br>## State Management<br><br>- **StateFlow**: Used for reactive UI updates<br>- **Immutable State**: UI state is immutable, updates create new instances<br>- **State Properties**:<br>  - `isLoading`: Indicates data fetching in progress<br>  - `cityName`, `temperature`, `description`: Weather data<br>  - `errorMessage`: Error information<br>  - `hasError`, `hasData`: Computed properties for state checking<br><br>## Testing Strategy<br><br>### Unit Tests<br>- **WeatherRepositoryTest**: Tests repository with mocked API service<br>- **WeatherViewModelTest**: Tests ViewModel with mocked repository<br>- **WeatherUiStateTest**: Tests state class properties<br><br>### Integration Tests<br>- **WeatherScreenHiltTest**: UI tests with Hilt dependency injection<br>- **WeatherScreenTest**: UI tests for Compose components<br><br>### Test Coverage<br>- Success scenarios<br>- Error scenarios (network, HTTP errors, API errors)<br>- Edge cases (null values, empty strings)<br>- State transitions<br><br>## Project Structure<br><br>```<br>app/src/main/java/com/example/weatherapp/<br>├── data/<br>│   ├── model/          # Data classes for API responses<br>│   ├── remote/         # Retrofit API service interface<br>│   └── repository/     # Repository implementation<br>├── di/                 # Hilt dependency injection modules<br>├── ui/<br>│   ├── screen/         # Compose UI screens<br>│   ├── state/          # UI state data classes<br>│   ├── theme/          # Material Design theme<br>│   └── viewmodel/      # ViewModels<br>├── BaseApplication.kt  # Base Application class<br>├── WeatherApplication.kt # Hilt Application class<br>└── MainActivity.kt      # Main activity<br><br>app/src/test/          # Unit tests<br>app/src/androidTest/    # Instrumented/UI tests<br>```<br><br>## Best Practices Implemented<br><br>1. **Separation of Concerns**: Clear separation between UI, business logic, and data layers<br>2. **Single Responsibility**: Each class has a single, well-defined purpose<br>3. **Dependency Injection**: All dependencies injected via Hilt<br>4. **Error Handling**: Comprehensive error handling with user-friendly messages<br>5. **Reactive UI**: StateFlow for reactive UI updates<br>6. **Testability**: Architecture designed for easy unit and integration testing<br>7. **Documentation**: KDoc comments on all public functions<br>8. **Type Safety**: Result type for error handling, null-safe code<br><br>## Future Enhancements<br><br>Potential improvements:<br>- Add caching layer for offline support<br>- Add local database (Room) for data persistence<br>- Add location-based weather using device GPS<br>- Add weather forecast (multi-day)<br>- Add search functionality for cities<br>- Add favorite cities feature<br>- Add pull-to-refresh<br>- Add Material Design 3 animations</pre><h3>⚖️ Observations</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/972/1*dG4CfY8ljMW1crNYTp4VqA.png" /></figure><h3>🧩 Challenges &amp; Tips</h3><ul><li>Occasionally duplicated Gradle dependencies — fix manually or ask Cursor to “clean Gradle setup.”</li><li>The Agent sometimes added redundant imports; use Git diff for validation.</li><li>Best results came when prompts explicitly mentioned the architecture or framework version.</li><li>Committing frequently avoided rollback issues during multi-file generation.</li></ul><h3>🔍 Summary of Findings</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/982/1*e8HxR2KLN41gc_-PdmtY7w.png" /></figure><p>Cursor AI’s multi-model flexibility (GPT-5-Codex, Claude 4.5, Grok Code Fast) and contextual file awareness made it more adaptable for enterprise-grade Android work than most IDE extensions I’ve tested.</p><h3>🏁 Conclusion</h3><p>The <strong>Weather App POC</strong> proved that Cursor AI can assist skilled Android developers — not by replacing craftsmanship, but by accelerating structured coding tasks while maintaining clean architecture standards.<br> Used responsibly, it has the potential to transform onboarding, prototyping, and documentation workflows across teams.</p><p><strong>Git Repo</strong>: <a href="https://github.com/shiraz990/WeatherApp.git">https://github.com/shiraz990/WeatherApp.git</a></p><h4>My Experience with Cursor AI in Android Studio</h4><p>Working with <strong>Cursor AI</strong> inside <strong>Android Studio</strong> was an interesting shift from traditional development workflows. While I’m used to crafting each layer manually — from composing the UI to structuring ViewModels — having AI assist in these areas changed how I approached coding.</p><ul><li><strong>UI Generation:</strong> Cursor did a solid job scaffolding Jetpack Compose screens with minimal prompts. It wasn’t always pixel-perfect, but it provided a strong starting point — especially for repetitive layouts or standard Material components.</li><li><strong>API &amp; Repository Setup:</strong> It handled boilerplate code generation efficiently, setting up Retrofit interfaces, repositories, and data models within seconds. However, I still needed to review and optimize the data flow to align with our architecture standards.</li><li><strong>ViewModel Logic:</strong> Cursor generated workable StateFlow logic, though I found refining state management logic manually gave better control.</li><li><strong>Unit Testing:</strong> The AI-generated tests were functional but generic — requiring contextual adjustments for real coverage.</li><li><strong>Documentation &amp; Review:</strong> The inline documentation suggestions were surprisingly consistent and helped maintain readability across files.</li></ul><p>Overall, using Cursor AI didn’t replace the developer’s role — it <em>accelerated</em> it. I found it most effective when treating it as a <strong>pair-programming assistant</strong> that speeds up routine work but still relies on developer judgment for architecture, design, and optimization decisions.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e43471109a66" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Harnessing AI in Gradle: Automating Code Documentation to Elevate Quality and Developer…]]></title>
            <link>https://medium.com/@shiraz990/harnessing-ai-in-gradle-automating-code-documentation-to-elevate-quality-and-developer-06aec61fb73f?source=rss-e44300520258------2</link>
            <guid isPermaLink="false">https://medium.com/p/06aec61fb73f</guid>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[code-comments]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Shiraz Muhammad]]></dc:creator>
            <pubDate>Thu, 16 Oct 2025 11:30:39 GMT</pubDate>
            <atom:updated>2025-10-16T12:22:28.868Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/875/0*6i6MWwRylfxoQPR8.jpeg" /></figure><h3>Harnessing AI in Gradle: Automating Code Documentation to Elevate Quality and Developer Productivity</h3><p>In fast-paced Android development environments, maintaining consistent and well-documented code across multiple client projects is an ongoing challenge. As codebases grow, the need for clear inline documentation becomes essential for quality assurance, maintainability, and smooth onboarding.</p><p>To address this, I engineered a <strong>production-ready Gradle task</strong> that leverages a <strong>Large Language Model (LLM)</strong> to automatically generate concise, context-aware inline comments for Kotlin and Java source files.</p><p>By integrating AI directly into the build process, I transformed repetitive code commenting into an <strong>automated, intelligent workflow</strong> — ensuring consistency, clarity, and faster delivery across all client projects.</p><h4>⚙️ Why This Matters</h4><p>In large, fast-moving client projects, <strong>maintaining consistent documentation</strong> is often the first casualty of tight deadlines.<br> Our approach changes that dynamic by letting AI handle the repetitive documentation work while developers focus on solving actual problems.</p><h4>Key Measurable Benefits</h4><ul><li>⏱ <strong>Reduce documentation effort</strong>: Cut 40–60% of time spent writing explanations during reviews and handovers.</li><li>🚀 <strong>Accelerated onboarding</strong>: New developers understand the codebase 30–50% faster.</li><li>💬 <strong>Consistency &amp; clarity</strong>: Uniform commenting style lowers misunderstanding-driven bugs.</li><li>🔁 <strong>Faster reviews</strong>: Clearer intent reduces back-and-forth between developers, QA, and clients.</li><li>🌍 <strong>Scalable solution</strong>: Works across dozens of repositories with identical setup and governance.</li></ul><h4>High-level architecture</h4><p>1. Gradle task scans source files (Kotlin/Java).</p><p>2. Files are chunked (safe size), each chunk sent to the LLM with a clear prompt.</p><p>3. Responses are cleaned (strip Markdown fences, unescape JSON), and reassembled.</p><p>4. Files are updated in-place (or written to an output folder for review).</p><p>5. Optional: changes committed automatically to a branch for human review.</p><h4>Step-by-step implementation</h4><h4>1 — Prerequisites</h4><p>· OpenAI API key (or equivalent LLM provider).</p><p>· Project using Gradle Kotlin DSL (build.gradle.kts) or Groovy (adjust accordingly).</p><p>· Java/Kotlin runtime available for Gradle.</p><h4>2 — Securely store your key</h4><p>Add to local.properties at repo root (never commit to VCS):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tJrcWL90_RUHIsC3pgdjww.png" /><figcaption>local.properties</figcaption></figure><h4>3 — Add the Gradle task</h4><p>Place the task in <strong>root</strong> build.gradle.kts (or module if preferred). The task:</p><ul><li>Loads local.properties securely.</li><li>Breaks files into safe chunks (e.g. 2.5–3k chars).</li><li>Calls the LLM with a deterministic prompt.</li><li>Cleans response (removes ``` fences and JSON artifacts).</li><li>Writes output (either overwrite or to build/ai_commented).</li><li>Optional: create .bak backup before overwrite.</li></ul><blockquote><strong><em>Design choices:</em></strong><em> chunking avoids token limits, cleaning prevents Markdown/JSON leakage, backups allow safe rollbacks.</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iDFMDMzQ-qlkB_mvnnwYnA.png" /><figcaption>build.gradle.kts</figcaption></figure><h4>4 — Prompt engineering</h4><p>Use a precise system/user prompt:</p><pre>You are an expert Kotlin/Java senior engineer and technical writer.<br>Add concise inline comments explaining purpose and logic. Preserve formatting.<br>Do NOT add code fences. Only return the full commented code chunk.</pre><p>This ensures consistent and non-intrusive comments.</p><h4>5 — Run &amp; review</h4><ul><li>Dry-run first: configure task to write to build/ai_commented so reviewers inspect changes.</li><li>After approval, switch to in-place overwrite and (optionally) auto-commit to a branch for QA review.</li></ul><p>Example run:</p><pre>./gradlew autoCommentSource     # writes to build/ai_commented by default (safe)<br># After review<br>./gradlew autoCommentSourceOverwrite  # or change flag to overwrite originals</pre><h3>🧠 Safety, Governance &amp; Quality Controls</h3><ul><li>🔒 <strong>Secret protection</strong>: Never commit API keys; always use local.properties.</li><li>💾 <strong>Backups</strong>: Automatically create .bak files before overwriting originals.</li><li>👀 <strong>Human-in-the-loop</strong>: Require PRs until full confidence is built.</li><li>🧾 <strong>Audit trail</strong>: Add metadata comments (author, timestamp, commit ID).</li><li>📉 <strong>Cost control</strong>: Limit runs to modified files via git diff.</li></ul><h3>💡 Real-World Impact</h3><p>This automation is already:</p><ul><li>Reducing review cycles by 20–30%.</li><li>Cutting average onboarding time by nearly half.</li><li>Increasing developer satisfaction scores internally.</li><li>Enhancing client perception of code quality during audits.</li></ul><h4>Example prompt + code snippet (short)</h4><p><strong>Prompt template</strong></p><pre>You are an expert Kotlin/Java engineer.<br>Add concise, helpful inline comments explaining the purpose and logic.<br>Do not change code or formatting. Do not use Markdown fences.<br>Respond with the full commented code only.<br>--- CODE START ---<br>&lt;file chunk here&gt;<br>--- CODE END ---</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/632/1*cvpzVMJ5u9tUQuzZYkk5OQ.png" /><figcaption>Gradle task</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JxIaJipfyZ0ZLcH-fmdH-A.png" /><figcaption>Before</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jrffVr8bdIUTtiwMUSvDkQ.png" /><figcaption>After</figcaption></figure><h3>🌍 Open Source Reference</h3><p>Full implementation is available here:<br> 🔗 <a href="https://github.com/shiraz990/AICodeComment.git">GitHub Repository — AICodeComment</a></p><h3>🚀 Conclusion</h3><p>This initiative shows how <strong>AI-driven automation can transform developer productivity</strong> — not by replacing engineers, but by amplifying their output quality and velocity.</p><p>Integrating LLMs into Gradle tasks bridges the gap between code and clarity, setting a new benchmark for scalable, maintainable, and audit-friendly enterprise software.</p><blockquote>“We’re not just writing code faster — we’re making every line of it smarter.”</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=06aec61fb73f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AIStudio: Redefining Digital Agencies with AI-Powered Innovation ]]></title>
            <link>https://medium.com/@shiraz990/aistudio-redefining-digital-agencies-with-ai-powered-innovation-de2697d7c28e?source=rss-e44300520258------2</link>
            <guid isPermaLink="false">https://medium.com/p/de2697d7c28e</guid>
            <category><![CDATA[openai]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[aistudio]]></category>
            <dc:creator><![CDATA[Shiraz Muhammad]]></dc:creator>
            <pubDate>Sat, 28 Dec 2024 14:24:50 GMT</pubDate>
            <atom:updated>2024-12-31T20:29:10.462Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZX7HH6ZPoACBwloWkEFbgg.gif" /><figcaption>OpenAi</figcaption></figure><h3>Introduction</h3><p>For years, I’ve envisioned creating an AI-powered digital agency application, and I’ve finally brought it to life. The result? Game-changing innovation! Meet <strong>AIStudio</strong> — a dynamic, AI-driven app that transforms project planning, strategy, and execution for digital agencies. 🤖✨</p><p>AIStudio leverages a <strong>multi-agent AI framework</strong> inspired by the <strong>Agency-Swarm</strong> model, where virtual agents collaborate in real-time to deliver tailored insights and solutions.</p><iframe src="https://cdn.embedly.com/widgets/media.html?url=https%3A%2F%2Fwww.youtube.com%2Fshorts%2FlbkngueeTF8%3Ffeature%3Dshare&amp;type=text%2Fhtml&amp;schema=youtube&amp;display_name=YouTube&amp;src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FlbkngueeTF8%3Ffeature%3Doembed" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/28f1c386b5c4fa9556ea2ae95d64ad64/href">https://medium.com/media/28f1c386b5c4fa9556ea2ae95d64ad64/href</a></iframe><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FlvMat5E3FIA%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DlvMat5E3FIA&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FlvMat5E3FIA%2Fhqdefault.jpg&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/7a337c279aeb4ea0d845ad9d10c32ddc/href">https://medium.com/media/7a337c279aeb4ea0d845ad9d10c32ddc/href</a></iframe><h3>🌀 <strong>The Framework: Agency-Swarm-Inspired AI Workflow</strong></h3><p>At the heart of AIStudio lies a <strong>team of AI agents</strong>, each specializing in a distinct role. These agents work collaboratively and asynchronously to simulate a real-world team environment.</p><h4>Roles in Action:</h4><ul><li>💡 <strong>Project Director AI</strong>:<br>Evaluates project feasibility, sets strategies, and suggests refinements to optimize outcomes.</li><li>🔧 <strong>Technical Architect AI</strong>:<br>Designs a scalable architecture tailored to the project’s unique requirements.</li><li>📋 <strong>Product Manager AI</strong>:<br>Defines clear scopes, timelines, and strategies to mitigate risks.</li><li>👩‍💻 <strong>Developer AI</strong>:<br>Tackles implementation details and provides debugging insights.</li><li>🎯 <strong>Client Success AI</strong>:<br>Tracks project delivery and ensures client satisfaction through feedback-driven refinements.</li></ul><h3>🚀 Key Features</h3><p>Here’s what makes AIStudio a powerhouse for digital project management:</p><h4>✅ <strong>Dynamic Form Validation</strong></h4><p>The app captures essential project details — like <strong>budget</strong>, <strong>timeline</strong>, and <strong>priority</strong> — ensuring that nothing falls through the cracks.</p><h4>✅ Personalized Analysis</h4><p>AIStudio provides tailored recommendations for key roles:</p><ul><li>CEOs get strategic insights.</li><li>CTOs receive technical specifications.</li><li>PMs gain detailed plans.</li><li>Developers have clear implementation strategies.</li><li>Clients enjoy actionable feedback for successful delivery.</li></ul><h4>✅ Composable UI Framework</h4><p>Built with <strong>Jetpack Compose</strong>, AIStudio offers a fluid and responsive UI that’s both modern and developer-friendly.</p><h4>✅ AI-Powered Suggestions</h4><p>Using the <strong>OpenAI API</strong>, AIStudio generates intelligent insights in real time, making project planning more efficient and effective.</p><h4>✅ Secure Key Management</h4><p>AIStudio ensures that API keys and sensitive user data remain private and secure, prioritizing user trust.</p><h3>🤔 What Sets AIStudio Apart?</h3><p>Here’s why AIStudio is a standout innovation:<br>➡️ <strong>Collaborative AI Agents</strong>: Agents work asynchronously while maintaining context, mimicking real-world teamwork.<br>➡️ <strong>Role-Specific Intelligence</strong>: Each agent specializes in a unique area, from strategy to client success.<br>➡️ <strong>AI-Driven Refinements</strong>: Agents don’t just follow instructions — they question inputs and refine them for better outcomes.</p><h3>🛠️ Built with Scalability in Mind</h3><p>AIStudio is built using <strong>Kotlin Multiplatform (KMP)</strong> for future scalability and <strong>Android-first</strong> development. This foundation ensures the app is adaptable for cross-platform deployment in the future.</p><h3>📈 Results So Far</h3><p>AIStudio has transformed the way I approach project management:</p><ul><li><strong>Automated insights</strong> that previously took hours of manual effort.</li><li>A <strong>seamless project-planning experience</strong> for diverse roles in the software lifecycle.</li><li><strong>Actionable recommendations</strong> that accelerate decision-making and execution.</li></ul><h3>🛤️ What’s Next?</h3><p>This is just the beginning for AIStudio. Future plans include:<br>🔄 Expanding the framework for <strong>cross-platform use</strong>.<br>📂 Sharing the <strong>source code on GitHub</strong> to enable open-source contributions.</p><h3>📂 Check It Out!</h3><p>I’m excited to share this journey and explore its potential with the developer community. <strong>Let’s collaborate and redefine the future of digital agencies together!</strong> 🚀</p><p>👉 GitHub Repository: <a href="https://github.com/shiraz990/AIStudio/blob/main/README.md">https://github.com/shiraz990/AIStudio/blob/main/README.md</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=de2697d7c28e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[“Effortlessly Check Your UI at Runtime with KMP Library for Text Rendering on TextViews — Using…]]></title>
            <link>https://medium.com/@shiraz990/effortlessly-check-your-ui-at-runtime-with-kmp-library-for-text-rendering-on-textviews-using-7182f3cf2a15?source=rss-e44300520258------2</link>
            <guid isPermaLink="false">https://medium.com/p/7182f3cf2a15</guid>
            <category><![CDATA[translation]]></category>
            <category><![CDATA[hugging-face]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Shiraz Muhammad]]></dc:creator>
            <pubDate>Sat, 21 Dec 2024 13:14:11 GMT</pubDate>
            <atom:updated>2024-12-21T19:41:48.749Z</atom:updated>
            <content:encoded><![CDATA[<h3>“Effortlessly Check Your UI at Runtime with KMP Library for Text Rendering on TextViews — Using HuggingFace Model”</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VICuHIqodthXwH8ZQX4p5w.jpeg" /></figure><p>As Android and iOS developers, we often face the challenge of displaying dynamic text in TextView elements, especially when the text length can vary. The problem intensifies when working with multilingual content, where translation and text rendering need to be handled efficiently at runtime. How do you ensure that text fits properly on a TextView while considering different languages, including right-to-left languages like Arabic?</p><p>To address this issue, I’ve developed a Kotlin Multiplatform (KMP) library that not only checks the rendering of text on TextViews but also translates text between English and Arabic in real-time. By leveraging the Helsinki-NLP/opus-mt-ar-en and Helsinki-NLP/opus-mt-en-ar models, this library provides seamless translation between Arabic and English, ensuring that text displays correctly and is contextually accurate.</p><h3>AI Model Used:</h3><p>The core of this library is built around an HuggingFace AI-powered model designed to predict text rendering behavior on TextViews. For this purpose, I’m using a lightweight machine learning HuggingFace model<strong><em> </em></strong>trained on large datasets.</p><p>The heart of this library combines two powerful AI models:</p><ol><li><strong>Helsinki-NLP/opus-mt-ar-en</strong>: A pre-trained translation model that translates Arabic text to English.</li><li><strong>Helsinki-NLP/opus-mt-en-ar</strong>: A pre-trained translation model that translates English text to Arabic.</li></ol><p>These models, provided by Helsinki-NLP, are designed for efficient translation and are integrated into the KMP library to handle text translation at runtime, making it easier to work with multilingual content. Additionally, the library uses a lightweight text prediction AI model to estimate how text will be rendered on TextViews, factoring in text length, styling, and screen size.</p><h3>Key Features:</h3><ol><li><strong>Dynamic Text Prediction</strong>: The library predicts how varying text lengths will render in TextViews, helping you catch overflow or truncation issues.</li><li><strong>Cross-Platform Support</strong>: Built on Kotlin Multiplatform, the library works seamlessly for both Android and iOS projects.</li><li><strong>AI-Powered Rendering Check</strong>: The AI model predicts UI issues such as truncation, text overflow, and line wrapping, providing real-time feedback.</li><li><strong>Real-Time Translation</strong>: Using Helsinki-NLP/opus-mt-ar-en and Helsinki-NLP/opus-mt-en-ar models, the library translates text between English and Arabic at runtime, making it easy to handle multilingual UIs.</li><li><strong>Real-Time UI Feedback</strong>: Get immediate feedback during development, without having to test your app on multiple devices.</li></ol><h3>How It Works:</h3><p>The KMP library integrates AI models to predict how text will be rendered and to translate text between languages. When you pass text to the library, it first checks whether the text will overflow or fit within the TextView. If the text is in English or Arabic, the library also translates it dynamically based on the target language.</p><ol><li><strong>Text Prediction</strong>: The AI model predicts whether the text will overflow or be truncated on different screen sizes and orientations.</li><li><strong>Translation</strong>: If the text is in Arabic, it will be translated to English using Helsinki-NLP/opus-mt-ar-en. Conversely, English text can be translated to Arabic using Helsinki-NLP/opus-mt-en-ar, ensuring that your UI displays the correct language content.</li></ol><h3>Sample Code:</h3><p>Here’s an example of how to use the library in an Android project:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6Bn58ddYZGcrffP-wpPLIg.png" /></figure><h3>How to Implement the Library:</h3><p>To integrate the KMP library into your Kotlin Multiplatform project, follow these steps:</p><ol><li><strong>Add the library to your dependencies</strong>: Add the following dependencies to your build.gradle.kts file:</li><li>Add the following versions to your libs.version.toml file:</li><li><strong>Ensure Maven Central is included</strong>: Make sure that your settings.gradle.kts file includes Maven Central in the repository management block. Add the following configuration:</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/634/1*3rzmG3OZaxH5RZz7MFNX_Q.png" /><figcaption>build.gradle.kts</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*N9V04TjvtalRuW3MCAyshA.png" /><figcaption>libs.version.toml</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/374/1*AfoOce6aJ8ySpxBis7hnHw.png" /><figcaption>libs.version.toml</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Oee97GnfU75JcS09-QsA9w.png" /><figcaption>settings.gradle.kts</figcaption></figure><h3>Conclusion:</h3><p>This Kotlin Multiplatform library provides a seamless solution for handling dynamic text in multilingual UIs. With its ability to predict text rendering and translate between English and Arabic in real-time, developers can build apps that are both visually appealing and culturally accurate. The integration of AI models makes it easy to ensure that your text fits perfectly on TextViews, regardless of the language or screen size.</p><p>Try integrating this library into your Kotlin Multiplatform projects today and simplify your development process with AI-powered text rendering and translation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/302/1*2TGYQ5Kl_R3gEkl-vdlhMg.gif" /></figure><h3>Sample Code and GitHub Repository:</h3><h4>Currently for Android Platform</h4><p>You can find the sample code</p><p><strong>Sample Code</strong> on <a href="https://github.com/shiraz990/SampleTranslization"><strong>https://github.com/shiraz990/SampleTranslization</strong></a></p><p><strong>Translization Library</strong> on <a href="https://github.com/shiraz990/Translization"><strong>https://github.com/shiraz990/Translization</strong></a>.</p><p>Make sure to check the repository for updates, improvements, and more detailed documentation.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7182f3cf2a15" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Flutter — Fetching Google Directions using ChangeNotifierProvider]]></title>
            <link>https://medium.com/@shiraz990/flutter-fetching-google-directions-using-changenotifierprovider-f642adbe6cf4?source=rss-e44300520258------2</link>
            <guid isPermaLink="false">https://medium.com/p/f642adbe6cf4</guid>
            <category><![CDATA[location]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[directionapi]]></category>
            <category><![CDATA[flutter-maps]]></category>
            <dc:creator><![CDATA[Shiraz Muhammad]]></dc:creator>
            <pubDate>Sun, 07 Nov 2021 18:57:41 GMT</pubDate>
            <atom:updated>2021-11-07T18:57:41.003Z</atom:updated>
            <content:encoded><![CDATA[<h3>Flutter — Fetching Google Directions using <strong>ChangeNotifierProvider</strong></h3><p>Google Maps Direction API is the best way way to achieve the directions from source to destination. Here is a simple way to create route between users location and destination.</p><p>First we add the necessary dependencies,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/528/1*eieWOm_j9p3j1wwnLBk0tQ.png" /></figure><p>Here we have to observe to location changes using ChangeNotifierProvider widget.</p><p><strong>ChangeNotifierProvider</strong></p><blockquote><em>ChangeNotifierProvider is the widget that provides an instance of a </em><em>ChangeNotifier to its descendants. It comes from the </em><em>provider package.</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uyZFB0Pyq8diB4fO531iew.png" /></figure><p>The provider is fetching the location changes at certain intervals and distance filters , once there is any location changes observed we may request the directions API to get the instructions of paths.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ItvTmx4HDDN2xoyyB_O3Xg.png" /></figure><h3>Directions API</h3><p>The Directions API is a <a href="https://developers.google.com/maps/documentation/directions/web-service-best-practices">web service</a> that uses an HTTP request to return JSON or XML-formatted directions between locations. You can receive directions for several modes of transportation, such as transit, driving, walking, or cycling.</p><p>Using <a href="https://maps.googleapis.com/maps/api/directions/json?">https://maps.googleapis.com/maps/api/directions/json?</a> while providing the origin and destination locations we receive the list of instructions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HNtXHl-VCbt61LFRkhUV4w.png" /></figure><p>Fetching the instructions from the response data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VXK7BVfiiT8I_nHgOAD7Rw.png" /></figure><p>While location is getting observed we receive all the instruction provided by the Directions API</p><blockquote><em>(Please note this requires Billing to be enabled from the console of the project)</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*g4rcXlqNGA7dg4lQpZ8O-A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RV-rVHyGzvwZ_PHvrpK91w.png" /></figure><p>Please find the source code of the sample project.<br><a href="https://github.com/shiraz990/FlutterDirectionAPI.git">https://github.com/shiraz990/FlutterDirectionAPI.git</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f642adbe6cf4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[CI CD — Android GitLab]]></title>
            <link>https://medium.com/@shiraz990/ci-cd-android-gitlab-8f5a7a13cd14?source=rss-e44300520258------2</link>
            <guid isPermaLink="false">https://medium.com/p/8f5a7a13cd14</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[ci-cd-pipeline]]></category>
            <category><![CDATA[gitlab-ci]]></category>
            <dc:creator><![CDATA[Shiraz Muhammad]]></dc:creator>
            <pubDate>Sun, 17 Oct 2021 18:09:18 GMT</pubDate>
            <atom:updated>2021-10-17T18:19:48.053Z</atom:updated>
            <content:encoded><![CDATA[<h3>CI CD — Android GitLab</h3><p>Continuous Integration and Delivery is one of the most important skills for any software engineer in general and for android developers in particular because it helps us to automate our build and delivery process to minimize the time consumed in tedious tasks and errors because of human mistakes.</p><p>What is Continuous Integration ?</p><p>Continuous Integration is a software development practice where members of a team can work on daily basis where each team member contributes daily and thus leading to multiple integrations where each integration is provided with automated build or test. It can help us to detect integration errors as quickly as possible.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*A3UPVvD8VXAAwZaOjf6Uig.png" /><figcaption><strong>Continuous Integration Process</strong></figcaption></figure><p>What is Continuous Delivery ?</p><p>Expanding process of continuous integration Continuous delivery adds a process to automatically deploy a build to an acceptance environment. Therefore the team can access and manually test the product. When the build is considered ready for general consumption, it can be promoted to the production environment. Continuous delivery is a development discipline where software is developed can be launched into production but with manual deployment.</p><p>What is Continuous Deployment ?</p><p>Continuous deployment is a software development discipline where software is developed in such a way that it can be launched into production following all process of continuous integration but with automated deployment. Only a failed test would break the automated process of production deployment</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3eMkL32CRQdGdgqetVNXPw.png" /><figcaption><strong>Continuous Delivery vs Continuous Deployment</strong></figcaption></figure><h3><strong>so Why CI/CD ?</strong></h3><p>CI/CD is important because of three reasons:</p><ul><li>Time</li><li>Efficiency</li><li>Money</li></ul><h3>Pipeline</h3><p>Pipeline is a group of tasks (job) that are executed in stages. The execution of all the tasks depends upon the stages created whether its automated or manual stage.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2p6LslPIZupNqlkeSG68-w.png" /><figcaption>Pipeline Stages</figcaption></figure><p>I have used GitLab as the CI server for this project.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/668/1*M0XukgClsONBKyU3nLsScA.png" /><figcaption>gitlab-ci.yml</figcaption></figure><p>Here this .yml file will handle all the CI scripts. The first step is to add <strong><em>Fastlane docker </em></strong>image and then start with creating stages.</p><blockquote>image: unitedclassifiedsapps/gitlab-ci-android-fastlane</blockquote><blockquote>Adding dependencies of cache to improve the build time</blockquote><pre>cache:<br>  paths:<br>    - .m2/<br>    - .gradle/</pre><blockquote>Adding required variable for CI which are as specific to project and version details according to <em>Android/sdk/platform-tools/adb</em></blockquote><pre>variables:<br>  ANDROID_COMPILE_SDK: &quot;31&quot;<br>  ANDROID_BUILD_TOOLS: &quot;31.0.3&quot;<br>  ANDROID_SDK_TOOLS: &quot;7562133&quot;</pre><blockquote>Adding before_script</blockquote><pre>before_script:<br>  - export GRADLE_USER_HOME=$(pwd)/.gradle<br>  - chmod +x ./gradlew<br>    <em># use yes to accept all licenses<br>  </em>- yes | sdkmanager --sdk_root=${ANDROID_HOME} --licenses || true</pre><blockquote>Adding build stage</blockquote><pre>stages:<br>  - build</pre><blockquote>Adding <strong>build</strong> Stage scripts</blockquote><pre>build:<br>  stage: build<br>  script:<br>    - ./gradlew assembleDebug<br>  artifacts:<br>    paths:<br>      - app/build/outputs/</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Hb1FpXvIGupxSZnCECfc7g.png" /></figure><p>GitLab provides the link of merge request where our pipeline stages are initiated.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_OTJ12tjUNcAehlt3H1Kbw.png" /><figcaption>Finally the Build Stage is Passed</figcaption></figure><blockquote>On Pipeline success we can merge the branch code</blockquote><blockquote><em>Now our second pipeline stage would be of test</em></blockquote><pre>stages:<br>  - build<br>  - test</pre><p>Adding <strong><em>test </em></strong>stage scripts</p><pre>unitTests:<br>  stage: test<br>  script:<br>    - ./gradlew test</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*k7p_X0rOG4tYmP8tDgK_Tw.png" /><figcaption><strong>Stages Queue</strong></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yG3KTxakRzpVDCP_3poaCw.png" /></figure><p>Once Stages are passed the branch can be Merged.</p><p>Here we can download the apk file from the Artifacts.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fhfqhXY2u_4VIJ4H4kYLHQ.png" /><figcaption><strong>build artifacts</strong></figcaption></figure><p>I hope you like the article where i had created a pipeline for a sample project , Continuous Integration and Delivery is one of the most important skills for any software engineer in general and for android developers in particular because it helps us to automate our builds and delivery process to minimize the time consumed in tedious tasks and errors because of human mistakes.</p><h3>If you enjoyed this story, please click the 👏 button and share to help others find it! Feel free to leave a comment below.</h3><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8f5a7a13cd14" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Sending Cookies through API Interceptors]]></title>
            <link>https://medium.com/@shiraz990/sending-cookies-through-api-interceptors-cae026fa2162?source=rss-e44300520258------2</link>
            <guid isPermaLink="false">https://medium.com/p/cae026fa2162</guid>
            <category><![CDATA[retrofit]]></category>
            <category><![CDATA[interceptors]]></category>
            <category><![CDATA[cookies]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Shiraz Muhammad]]></dc:creator>
            <pubDate>Mon, 10 Dec 2018 12:26:53 GMT</pubDate>
            <atom:updated>2018-12-10T12:26:53.211Z</atom:updated>
            <content:encoded><![CDATA[<p>I came around a task where it was supposed to send access token through the calling interceptors and then access all request call easily.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/425/0*8rVwhz7mcqesablO.gif" /></figure><p>But was not the case , Although the access token was also being sent but still request calls were not accessible.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/299/0*dh9-larJlTiY0Zgt" /></figure><p>So when i have found some mishappening with API calls and not getting responses as it was supposed to get using Retrofit then as to my surprise i came to know that there are some more things which are also meant to be sent through each API call . To access API services , we needed to send some <strong><em>JSESSIONID</em></strong> and <strong><em>LTAPID</em></strong> which were coming in request headers of the API calls.</p><p>It was found that cookies were not being sent. So i decided to create a Cookies Handler integrated with Retrofit.</p><p>To simplify this task we can get all the cookies and send then again through interceptors.</p><p>We will implement step by step procedures to do this task.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/0*T0WTuDBcfGiRp7J5" /></figure><p><strong>To Save all cookies in Preferences :</strong></p><p><strong><em>getCookies()</em></strong> &amp; <strong><em>setCookies()</em></strong> method</p><pre><strong>protected static final </strong>String <strong><em>KEY_COOKIES </em></strong>= <strong>&quot;KEY_COOKIES&quot;</strong>;<br><br><strong>public </strong>HashSet&lt;String&gt; getCookies() {<br>    <strong>return </strong>getStringSetPreference(<strong>context</strong>,  <strong><em>KEY_COOKIES</em></strong>);<br>}<br><br><strong>public void </strong>setCookies(HashSet&lt;String&gt;  cookies) {<br>    putStringSetPreference(<strong>context</strong>,   <strong><em>KEY_COOKIES</em></strong>, cookies);<br>}</pre><p><strong><em>putStringPreference()</em></strong> &amp; <strong><em>getStringPreference()</em></strong> methods</p><pre><strong>protected void </strong>putStringPreference(Context context, String prefsName, String key, String value) {<br><br>    SharedPreferences preferences = context.getSharedPreferences(prefsName, Activity.<strong><em>MODE_PRIVATE</em></strong>);<br>    SharedPreferences.Editor editor = preferences.edit();<br><br>    editor.putString(key, value);<br>    editor.commit();<br>}<br><br><strong>protected </strong>String getStringPreference(Context context, String prefsName,<br>                                     String key) {<br><br>    SharedPreferences preferences = context.getSharedPreferences(<br>            prefsName, Activity.<strong><em>MODE_PRIVATE</em></strong>);<br>    String value = preferences.getString(key, <strong>&quot;&quot;</strong>);<br>    <strong>return </strong>value;<br>}</pre><blockquote><strong>This SetCookies interceptor put all the Cookies in Preferences in the Request.</strong></blockquote><pre><strong>public class </strong>SetCookiesInterceptor <strong>implements </strong>Interceptor {<br><br><br>    <strong>public static final </strong>String <strong><em>PREF_COOKIES </em></strong>= <strong>&quot;PREF_COOKIES&quot;</strong>;<br>    <em>// We&#39;re storing our stuff in a preference made just for cookies called PREF_COOKIES. <br>    </em><strong>private </strong>Context <strong>context</strong>;<br><br>    <strong>public </strong>SetCookiesInterceptor(Context context) {<br>        <strong>this</strong>.<strong>context </strong>= context;<br>    }<br><br>    @Override<br>    <strong>public </strong>Response intercept(Interceptor.Chain chain) <strong>throws </strong>IOException {<br>        Request.Builder builder = chain.request().newBuilder();<br><br>          HashSet&lt;String&gt; preferences =  <strong>basePreferenceHelper</strong>.getCookies(); <br><br>        <strong>for </strong>(String cookie : preferences) {<br>            builder.addHeader(<strong>&quot;Cookie&quot;</strong>, cookie);<br>        }<br><br>        <strong>return </strong>chain.proceed(builder.build());<br>    }<br>}</pre><blockquote><strong>This RecievedCookies Interceptor add all received Cookies to the app DefaultPreferences.</strong></blockquote><pre><strong>public class </strong>ReceivedCookiesInterceptor <strong>implements </strong>Interceptor {<br><br>    <strong>private </strong>Context <strong>context</strong>;<br>    <strong>public </strong>ReceivedCookiesInterceptor(Context context) {<br>        <strong>this</strong>.<strong>context </strong>= context;<br>    }<br><br>    @Override<br>    <strong>public </strong>Response intercept(Chain chain) <strong>throws </strong>IOException {<br>        Response originalResponse = chain.proceed(chain.request());<br><br>        <strong>if </strong>(!originalResponse.headers(<strong>&quot;Set-Cookie&quot;</strong>).isEmpty()) {<br>            HashSet&lt;String&gt; cookies = <strong>basePreferenceHelper</strong>.getCookies();<br>            <strong>for </strong>(String header : originalResponse.headers(<strong>&quot;Set-Cookie&quot;</strong>)) {<br>                cookies.add(header);<br>            }<br>            <strong>basePreferenceHelper</strong>.setCookies(cookies);<br>        }<br><br>        <strong>return </strong>originalResponse;<br>    }<br>}</pre><blockquote><strong>While adding Interceptors in OkHttpClient , there is an important thing to be remembered while handling Cookies — First we have to store cookies returned within response from server call and when we are making another call we should have to add with request.</strong></blockquote><pre>OkHttpClient.Builder httpClient = <strong>new </strong>OkHttpClient.Builder();<br><br>httpClient.addInterceptor(<strong>new </strong>SetCookiesInterceptor(context));  <em><br></em>httpClient.addInterceptor(<strong>new </strong>ReceivedCookiesInterceptor(context));  <br>httpClient.addInterceptor(interceptor);</pre><p><strong>Hope this will help you a lot and thanks for reading this article.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cae026fa2162" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[MVVM Android Application — Architectural Component]]></title>
            <link>https://medium.com/@shiraz990/mvvm-android-application-architectural-component-d7be25e68000?source=rss-e44300520258------2</link>
            <guid isPermaLink="false">https://medium.com/p/d7be25e68000</guid>
            <category><![CDATA[android-components]]></category>
            <category><![CDATA[lifecycle]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Shiraz Muhammad]]></dc:creator>
            <pubDate>Wed, 17 Oct 2018 08:47:48 GMT</pubDate>
            <atom:updated>2018-10-17T09:11:39.971Z</atom:updated>
            <content:encoded><![CDATA[<h3>MVVM Android Application — Architectural Component</h3><p>Android Architecture Components facilitates the MVVM (Model-View-ViewModel) architecture and this is the first time the Android Framework team officially provides an official guidance on an Android app architecture.</p><p>The well-ordered and perhaps the most reusable way to organize your code is to use the ‘MVVM’ pattern. The Model, View, ViewModel (MVVM pattern) is all about guiding you in how to organize and structure your code to write maintainable, testable and extensible applications.</p><p><strong>Model</strong>: It simply holds the data and has nothing to do with any of the business logic.</p><p><strong>ViewModel</strong>: It acts as the link/connection between the Model and ViewModel and makes stuff look pretty.</p><p><strong>View</strong>: It simply holds the formatted date and essentially delegates everything to the Model.</p><p>This diagram only shows data persistence on device. Your app may also fetches data from the network.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aIjW3c8d9Q8sJvISoRj8qw.png" /><figcaption>Model-View-ViewModel with Android Architecture Components</figcaption></figure><h3>Implementation steps</h3><p>Follow these steps to implement MVVM with the new Android Architecture Components in your app:</p><ul><li>Add dependencies in app module build.gradle for architecture components</li><li>Create a entity class, a POJO which also defines database table schema</li><li>Create DAO (Data Access Object), an interface annotated with “@Dao”</li><li>Create a ViewModel class that contains LiveData, alternatively use RxJava, AsyncTask for the async operations on the SQLite database</li><li>Create UI (Activity &amp; Fragment) and get an instance of ViewModel with ViewModelProviders’ get() method</li><li>Observe the data changes with LiveData (or other async calls), and update UI upon data changes</li></ul><h3><strong>Gradle Dependencies</strong></h3><pre>implementation <strong>&#39;android.arch.lifecycle:extensions:&#39; </strong>+ project.archLifecycleVersion;<br>annotationProcessor <strong>&quot;android.arch.lifecycle:compiler:&quot; </strong>+ project.archLifecycleVersion;<br><br>implementation <strong>&#39;io.reactivex.rxjava2:rxandroid:&#39; </strong>+project.rxJavaVersion;<br>implementation <strong>&#39;io.reactivex.rxjava2:rxjava:&#39;</strong>+project.rxJavaVersion;<br><br>implementation <strong>&quot;android.arch.persistence.room:runtime:&quot; </strong>+ project.roomVersion;<br>annotationProcessor <strong>&quot;android.arch.persistence.room:compiler:&quot; </strong>+ project.roomVersion;<br><br>implementation <strong>&quot;android.arch.persistence.room:runtime:</strong>$archLifecycleVersion<strong>&quot;<br></strong>annotationProcessor <strong>&quot;android.arch.persistence.room:compiler:</strong>$archLifecycleVersion<strong>&quot;</strong></pre><h3>Model</h3><p>Represents the <em>Data + State + Business logic</em>. It is not tied to the view nor to the controller, which makes it reusable in many contexts.</p><pre><strong>public class </strong>Forecast {<br><br>    @SerializedName(<strong>&quot;forecastday&quot;</strong>)<br>    @Expose<br>    <strong>private </strong>List&lt;Forecastday&gt; <strong>forecastday </strong>= <strong>null</strong>;<br><br>    <strong>public </strong>List&lt;Forecastday&gt; getForecastday() {<br>        <strong>return forecastday</strong>;<br>    }<br><br>    <strong>public void </strong>setForecastday(List&lt;Forecastday&gt; forecastday) {<br>        <strong>this</strong>.<strong>forecastday </strong>= forecastday;<br>    }<br><br>}</pre><h3>ViewModel</h3><p>Create a ViewModel class that extends from ViewModel. Extend from AndroidViewModel if you need the Application Context to be available.</p><pre><strong>public class </strong>ForecastViewModel <strong>extends </strong>AndroidViewModel {<br><br>    @Inject<br>    ForecastNetworkCallInterface <strong>forecastNetworkCallInterface</strong>;<br><br>    <strong>private </strong>MediatorLiveData&lt;ForecastResponse&gt; <strong>forecastNetworkLiveData </strong>= <strong>new </strong>MediatorLiveData&lt;&gt;();<br><br><br>    <strong>public </strong>ForecastViewModel(@NonNull Application application) {<br>        <strong>super</strong>(application);<br>        ((BaseApplication) application).getAppComponent().inject(<strong>this</strong>);<br>    }<br><br>    <strong>public void </strong>loadForecast(ApiInput forecast_input_details) {<br><br>        String latLong= forecast_input_details.<strong>latitude</strong>+<strong>&quot;,&quot;</strong>+forecast_input_details.<strong>longitude</strong>;<br>        <strong>final </strong>LiveData&lt;ForecastResponse&gt; forecastLiveData = <strong>forecastNetworkCallInterface</strong>.getForecast(forecast_input_details.<strong>key</strong>, latLong,forecast_input_details.<strong>days</strong>);<br>        <strong>forecastNetworkLiveData</strong>.addSource(forecastLiveData, <strong>new </strong>Observer&lt;ForecastResponse&gt;() {<br><br>            @Override<br>            <strong>public void </strong>onChanged(@Nullable ForecastResponse forecastResponse) {<br><br>                <strong>forecastNetworkLiveData</strong>.setValue(forecastResponse);<br>                <strong>forecastNetworkLiveData</strong>.removeSource(forecastLiveData);<br>            }<br>        });<br>    }<br>    <strong>public </strong>LiveData&lt;ForecastResponse&gt; getForecastLiveData() {<br>        <strong>return forecastNetworkLiveData</strong>;<br>    }<br>}</pre><h3>View</h3><p>Your Activity and Fragments are the Views .Here the word “View” means UI.</p><p><em>Binds</em> to observable variables and actions exposed by the View Model. It is possible for multiple views to bind to a single View Model.</p><pre><em>// Create a ForecastViewModel instance</em><strong><br>forecastViewModel </strong>= ViewModelProviders.<em>of</em>(<strong>this</strong>).get(ForecastViewModel.<strong>class</strong>);</pre><pre><em>// Get the forecast list and set the forecast list for the adapter<br></em><strong>forecastViewModel</strong>.loadForecast(<strong>new </strong>ApiInput(ApiUrls.<strong><em>API_KEY </em></strong>, <strong>latitude</strong>,<strong>longitude</strong>,4));<br><strong>forecastViewModel</strong>.getForecastLiveData().observe(<strong>this</strong>, (ForecastResponse response) -&gt; {<br>    dissmissProgressbar();<br>    <strong>if</strong>(response != <strong>null</strong>) {<br><br>        <strong>ll_placeholder</strong>.setVisibility(View.<strong><em>GONE</em></strong>);<br><br>        renderData(response);<br><br>    }<br>    <strong>else</strong>{<br>        <strong>ll_placeholder</strong>.setVisibility(View.<strong><em>VISIBLE</em></strong>);<br>    }<br>});</pre><p>Overall I find the architecture components library does a good job in solving the major challenges on Android:</p><ul><li>MVVM architecture provides clear separation of UI from Data which also makes testing much easier.</li><li>Many more options in asynchronous operations in querying data from SQlite Database. You can use LiveData, RxJava, or AsyncTask.</li></ul><p>There are quite a lot of new architectural designs and new objects introduced in the Android Architecture Components. Just choose the ones that make sense.</p><p><em>For brainstorming i have created a sample project using architectural components using the free version of </em><a href="https://www.apixu.com/doc/history.aspx"><em>apixu weather API</em></a><em>.</em></p><h3>Sample Application details</h3><p>Its a simple weather app that shows current temperature along with the temperature forecast for the next days (average temperature for each day should be shown for the forecast). All temperatures are in Celsius. The temperature shown for the current location of the user.</p><p><a href="https://gitlab.com/Shiraz990/Weather_App">Muhammad Shiraz / Weather_App</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d7be25e68000" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>