<?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 Palash Kosta on Medium]]></title>
        <description><![CDATA[Stories by Palash Kosta on Medium]]></description>
        <link>https://medium.com/@kosta.palash?source=rss-830fb0ccb7ef------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*OS9vDO4Zkf71-ih-8UQUVA.jpeg</url>
            <title>Stories by Palash Kosta on Medium</title>
            <link>https://medium.com/@kosta.palash?source=rss-830fb0ccb7ef------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 22 Nov 2026 16:03:11 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@kosta.palash/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[Back-end - why Serverless Computing for this course]]></title>
            <link>https://medium.com/@kosta.palash/back-end-why-serverless-computing-for-this-course-6c0cce0020ae?source=rss-830fb0ccb7ef------2</link>
            <guid isPermaLink="false">https://medium.com/p/6c0cce0020ae</guid>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[serverless-computing]]></category>
            <category><![CDATA[lambda]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[serverless]]></category>
            <dc:creator><![CDATA[Palash Kosta]]></dc:creator>
            <pubDate>Mon, 25 Nov 2019 10:41:43 GMT</pubDate>
            <atom:updated>2019-11-29T12:19:15.914Z</atom:updated>
            <content:encoded><![CDATA[<p>#This is the part-2 of the course — <a href="https://medium.com/@kosta.palash/welcome-to-the-android-aws-course-1-7380ddaa8234"><strong>Android + AWS Course 1</strong></a><strong>.</strong></p><p><strong>#Learning — </strong>In this part, we will understand the reason for using the Serverless computing as the back-end in this course/ project.</p><blockquote><strong>Serverless Computing </strong>— <strong>Serverless computing is a cloud-computing execution model</strong> in which the cloud provider runs the server, and dynamically manages the allocation of machine resources. Pricing is based on the actual amount of resources consumed by an application, rather than on pre-purchased units of capacity. [<a href="https://en.wikipedia.org/wiki/Serverless_computing">Wikipedia</a>]</blockquote><p>To understand the serverless computing, consider the scenario where you have an idea for which you want to create a mobile app (Just like in this course, we have an idea of creating movie mobile application). To create fully functional mobile/web application, you need to have the <strong>server/back-end</strong> to back your data.</p><p>In the above scenario, your back-end should be able to do the following things —</p><ol><li>Executing the server side code</li><li>Storing the data permanently</li><li>Providing &quot;doors&quot; (API Endpoints) to mobile/web applications to create/read/update/delete the data stored on the server.</li></ol><blockquote>Storing data on the server will give you centralized and secured location for your data. Also, it provides consistent and real time experience to all of your users</blockquote><p>First we will look at the steps <strong>if we don&#39;t use serverless computing</strong> and use the normal cloud computing tools to setup the back-end —</p><ol><li>Leverage the machine instance on cloud e.g. Amazon EC2 or Lightsail on AWS cloud</li><li>Install the required applications/environments to run the back-end programming language. For e.g. if you want to use Java, you need to setup the JVM/JRE on your server instance <strong>OR</strong> if you want to use JavaScript, you need to setup the NodeJs environment to execute the code</li><li>Install the DB instance on your server instance e.g. installing MongoDB on server instance locally <strong>OR</strong> leveraging the cloud DB instance separately e.g. DynamoDB on the AWS cloud</li><li>Creating and managing API end points by configuring the API gateway on your server instance e.g. express-gateway <strong>OR </strong>leverage the cloud provided API gateway e.g. Amazon API Gateway on AWS, Cloud Endpoints on Google Cloud</li></ol><p><strong>Disadvantages of using the above approach —</strong></p><ol><li>Cloud server instance is not cheap — If we have just started your business or you want to launch your first mobile/web application, it will not be feasible for usto buy/leverage the server instance with the money. Because our business will take time to create traffic on our application and during that time, we don&#39;t want to pay extra money for the idle resources.</li></ol><p>For example, if you opt for Amazon Lightsail as the cloud instance with configuration — <strong>Linux/Unix platform + Ubuntu 16.04 LTS (OS only)</strong> — it will cost you <strong>$3.50 per month. </strong>Please use the link with different options to get more information regarding pricing — <a href="https://lightsail.aws.amazon.com/ls/webapp/create/instance?region=us-east-1">https://lightsail.aws.amazon.com/ls/webapp/create/instance?region=us-east-1</a></p><p>2. In addition to that, <strong>if you opt for installing required applications, DB instances and API gateway locally on the server instances </strong>(not opting separate cloud db instance and cloud API gateway), it will need more memory on the server instance and consequently it will increase the price for the cloud server instance.</p><p>So what should be the ideal scenario for startup and small businesses? — you don&#39;t want to buy server, you don&#39;t want to spend money for idle resources — you will be happy if you spend money only for the time when the actual user is using your application. That&#39;s exactly is <strong>serverless computing </strong>would do<strong>. THERE IS NO SERVER TO MANAGE IN SERVERLESS COMPUTING.</strong></p><p><strong>With Serverless, the steps will be very easy —</strong></p><ol><li>Select serverless cloud provider e.g. Lambda on AWS, Azure Function on Microsoft Azure, and write functions on cloud that you want to execute on the server.</li><li>Leveraging the cloud DB instance separately e.g. DynamoDB on the AWS cloud</li><li>Leverage the cloud provided API gateway e.g. Amazon API Gateway on AWS, Cloud Endpoints on Google Cloud</li></ol><p>THAT&#39;S it…you are done.</p><blockquote>Reference — <a href="https://aws.amazon.com/lambda/">https://aws.amazon.com/lambda/</a></blockquote><p>The main benefit of using serverless lambda functions —</p><ol><li>No server to manage</li><li>Continuous scaling</li><li>Sub-second metering</li></ol><p><strong>Due to sub-second metering feature — it is very very cheap to use for startup and small businesses. It will be charged for every 100ms your code executes and the number of times your code is triggered. You don’t need to pay anything when your code isn’t running.</strong></p><p>If you check the pricing for lambda — <a href="https://aws.amazon.com/lambda/pricing/">https://aws.amazon.com/lambda/pricing/</a></p><blockquote><em># Request — First 1Million requests per month are free. </em><strong><em>$0.20 PER 1M REQUESTS THEREAFTER</em>. </strong><em>$0.0000002 per request.</em></blockquote><blockquote># <em>Duration — First 400,000 GB-seconds per month, up to 3.2M seconds of compute time, are free. </em><strong><em>$0.0000166667 FOR EVERY GB-SECOND USED THEREAFTER. </em></strong><em>The price depends on the amount of memory you allocate to your function.</em></blockquote><blockquote><em>The </em><strong><em>Gigabyte</em></strong><em>-</em><strong><em>second</em></strong><em> unit specifies the amount of memory allocated to a function per </em><strong><em>second</em></strong><em> that that function executes. Function-1 of 1 GB executes for 1 minute ~</em><strong><em>1 GB*60Seconds = 60GB-Sec</em></strong><em>. Function-2 of 128MB executes for 1 minute ~</em><strong><em>0.128 GB*60Seconds = 7.68GB-Sec.</em></strong></blockquote><p>So these two advantages of serverless technology (Lambda on AWS) — 1. no need to buy instance and to install operating system/applications — 2. paying only for what we are using with free requests and execution time per month — convinced us to use <strong>Lambda as compute service for this course/project. </strong>And it is perfect for startup and small businesses.</p><p>To understand the cloud vs serverless computing with video content (this has shown the pricing and other details on AWS console), please follow the below video —</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FAYhRyCUrLs0%3Ffeature%3Doembed&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DAYhRyCUrLs0&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FAYhRyCUrLs0%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="640" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/91cc4e554920061f9f47e863bd4963f3/href">https://medium.com/media/91cc4e554920061f9f47e863bd4963f3/href</a></iframe><p>Let&#39;s summarise — for this course — we will be using the following technologies for this course/project—</p><ol><li>Lambda — to execute server code</li><li>DynamoDB — to store the data permanently</li><li>API Gateway — to make API end points</li><li>Swagger — To create API definition (contract)</li></ol><p>I hope you have understood the concept of serverless computing. In the next article, we will start creating back-end starting with API definition using Swagger.</p><p>Thanks for reading this article!</p><p>Part-1 — <a href="https://medium.com/@kosta.palash/introduction-to-course-android-aws-course-1-demo-flows-architecture-technologies-561d147408a9">https://medium.com/@kosta.palash/introduction-to-course-android-aws-course-1-demo-flows-architecture-technologies-561d147408a9</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6c0cce0020ae" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Introduction to course — Android + AWS Course 1 — Demo, Flows, Architecture, Technologies]]></title>
            <link>https://medium.com/@kosta.palash/introduction-to-course-android-aws-course-1-demo-flows-architecture-technologies-561d147408a9?source=rss-830fb0ccb7ef------2</link>
            <guid isPermaLink="false">https://medium.com/p/561d147408a9</guid>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[aws-lambda]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Palash Kosta]]></dc:creator>
            <pubDate>Tue, 19 Nov 2019 20:10:19 GMT</pubDate>
            <atom:updated>2019-11-25T10:53:09.110Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction to course — Android + AWS Course 1 — Demo, Flows, Architecture, Technologies</h3><p>#This is the part-1 of the course — <a href="https://medium.com/@kosta.palash/welcome-to-the-android-aws-course-1-7380ddaa8234"><strong>Android + AWS Course 1</strong></a><strong>.</strong></p><p><strong>#Learning— </strong>This part will provide you the details on the <strong>use cases, demo, architecture and tools/technologies</strong> that we are going to use through out this course to implement the final project.</p><blockquote>The video of complete demo for the project/course (mobile application and AWS console changes) is mentioned at the bottom of this article.</blockquote><p><strong>#Use Case for this course</strong> — We are going to build a <strong>Movie Android Mobile Application</strong> with real time data stored in <strong>AWS cloud using server-less technologies</strong>. We will implement both front-end and back-end of the project. First, we will be acting as back-end developer and develop the APIs (end-points) which will be provided to front-end developers. And then we will be acting as a front-end developer to create the mobile application (UI) and consume the APIs to handle the real time data.</p><p><strong>#Feature of the mobile application</strong> —</p><ol><li>User can <strong>view</strong> all the movies on the main screen</li><li>User can <strong>view details</strong> of the particular movie</li><li>User can <strong>create</strong> a movie from the mobile application</li><li>User can <strong>delete</strong> the particular movie</li><li>User can <strong>update</strong> the rating of the particular movie</li></ol><p><strong>#Demo (Mobile Application — UI) —</strong></p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FhJfhyB0I4Wo%3Ffeature%3Doembed&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DhJfhyB0I4Wo&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FhJfhyB0I4Wo%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="640" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/eec609db085bf73387d30a1a69505540/href">https://medium.com/media/eec609db085bf73387d30a1a69505540/href</a></iframe><p><strong>#Architecture —</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-kvVdtnW2ZYeAbAiy7M-5Q.png" /></figure><p><strong>#Tools and Technologies (Back-End) —</strong></p><ol><li>API Gateway — To manage the APIs. It maps the end-point to lambda function to execute.</li><li>Lambda Function — To execute the code at back-end (back-end coding). We are going to use NodeJs language to write back-end code.</li><li>DynamoDB — To store the data permanently (NoSql DB).</li><li>Swagger — To define the service end-point, request parameters and expected response. We will use YAML language in swagger tool to create the swagger file. Swagger file can be imported directly to create end-points in API Gateway. Swagger file is also considered as the contract between front-end development team and back-end development team.</li></ol><p><strong>#Tools and Technologies (Front-End) —</strong></p><ol><li>Android Studio — IDE to develop android mobile applications.</li><li>Android Architecture Components — ViewModel and LiveData — To architecture the mobile application better (on the UI side).</li><li>Retrofit library — A networking library to call the APIs end-points to get and manipulate the data stored in the server.</li><li>Picasso — A image loading library which can load the images asynchronously displayed on the list view.</li></ol><blockquote>I would recommend to watch the video to get the better understanding of the course/project:</blockquote><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FZSVJppWBtH0%3Ffeature%3Doembed&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DZSVJppWBtH0&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FZSVJppWBtH0%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="640" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/23b339748a4963a0194ea0dabaa4af56/href">https://medium.com/media/23b339748a4963a0194ea0dabaa4af56/href</a></iframe><p>In the next article/video, we will discuss “Introduction to back-end technologies and why serverless computing for this course”.</p><p>Thanks for reading this article!</p><p>Part-0 — <a href="https://medium.com/@kosta.palash/welcome-to-the-android-aws-course-1-7380ddaa8234">https://medium.com/@kosta.palash/welcome-to-the-android-aws-course-1-7380ddaa8234</a></p><p>Part-2 — <a href="https://medium.com/@kosta.palash/back-end-why-serverless-computing-for-this-course-6c0cce0020ae">https://medium.com/@kosta.palash/back-end-why-serverless-computing-for-this-course-6c0cce0020ae</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=561d147408a9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Welcome to the Android + AWS Course 1!]]></title>
            <link>https://medium.com/@kosta.palash/welcome-to-the-android-aws-course-1-7380ddaa8234?source=rss-830fb0ccb7ef------2</link>
            <guid isPermaLink="false">https://medium.com/p/7380ddaa8234</guid>
            <category><![CDATA[swagger]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[serverless]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Palash Kosta]]></dc:creator>
            <pubDate>Sun, 17 Nov 2019 10:03:57 GMT</pubDate>
            <atom:updated>2019-11-25T10:49:09.037Z</atom:updated>
            <content:encoded><![CDATA[<p>It’s good to have you here! This is the starting point of the course of creating<strong> android mobile application with AWS services as backend</strong>. In this course, we will learn all the concepts in a very practical way through video (Youtube) tutorials. And I will provide all the notes through medium blogs.</p><p>This course will include the following concepts:</p><ol><li>API designing — <strong>Swagger</strong></li><li>API creation — AWS server-less technologies — <strong>API Gateway</strong>, <strong>Lambda</strong>, <strong>DynamoDB</strong></li><li>Android development — Networking library — <strong>Retrofit</strong></li><li>Android development —Architecture component — <strong>ViewModel, LiveData</strong></li><li>Android development — Showing list and details — <strong>RecyclerView/CardView</strong></li><li>Android development — Creating user interface — <strong>Constraint layout</strong></li><li>Android development — Image loading library — <strong>Picasso</strong></li><li>Android development — Uploading project to Github</li></ol><p>The complete course content and videos will be completely <strong>FREE</strong></p><p>If you are excited to learn all these technologies step by step to create a final mobile application backed by AWS server-less services, then you are on the right place!!!</p><blockquote>Pre-requisites — Very basic knowledge of android app development is needed.</blockquote><h4>Course Content -</h4><ol><li><a href="https://medium.com/@kosta.palash/introduction-to-course-android-aws-course-1-demo-flows-architecture-technologies-561d147408a9">Introduction to course — Android + AWS Course 1 — Demo, Flows, Architecture, Technologies</a></li><li><a href="https://medium.com/@kosta.palash/back-end-why-serverless-computing-for-this-course-6c0cce0020ae">Introduction to back-end technologies and why serverless computing for this course</a></li><li>Getting started with Swagger and why Swagger</li><li>Introduction to AWS server-less technologies — API Gateway, Lambda and Dynamo DB</li><li>Designing API for Course Project/Application using Swagger</li><li>Creating API using API Gateway, Lambda and Dynamo DB</li><li>Testing newly created API using Postman</li><li>Congratulations!!! Our APIs for the project are ready.</li><li>Basic Android/Mobile Application Architecture</li><li>Creating application in Android Studio and creating necessary packages and files</li><li>Integrating Android app with our APIs — Retrofit</li><li>Creating UI and attaching the data to display to the user</li><li>Loading images asynchronously for the list</li><li>Uploading the project to Github</li><li>Congratulation!!! Our course is complete.</li></ol><p>I will start posting articles and videos for the course (as soon as it is ready) in the sequence as mentioned above and link them with the bullet points. Please keep in touch…</p><p>Thanks for reading this article.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7380ddaa8234" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to code pyramid problems in any language : Concepts and Tips — Part 1]]></title>
            <link>https://medium.com/@kosta.palash/how-to-code-pyramid-problems-in-any-language-concepts-and-tips-part-1-6ac4aa725c88?source=rss-830fb0ccb7ef------2</link>
            <guid isPermaLink="false">https://medium.com/p/6ac4aa725c88</guid>
            <category><![CDATA[pyramid-problem]]></category>
            <category><![CDATA[star-problem]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[pyramid]]></category>
            <dc:creator><![CDATA[Palash Kosta]]></dc:creator>
            <pubDate>Sat, 09 Nov 2019 14:51:05 GMT</pubDate>
            <atom:updated>2019-11-09T14:51:05.535Z</atom:updated>
            <content:encoded><![CDATA[<h3>How to code pyramid problems in any language : Concepts and Tips — Part 1</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/825/1*_M9ISImizuRxcZB009LVlQ.png" /><figcaption>Easy Pyramid Patterns</figcaption></figure><p>Below video is to demonstrate the simple concepts that freshers or initial level programmers can use to make/code the pyramid problems. Pyramid problems are very common topics in the college level interview. Every student must be prepared with these programs to crack the interviews.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2Fosq6M3AoL_c%3Ffeature%3Doembed&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3Dosq6M3AoL_c&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2Fosq6M3AoL_c%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="640" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/fc9721f80253a8cc295d55c8b3b88697/href">https://medium.com/media/fc9721f80253a8cc295d55c8b3b88697/href</a></iframe><p>In the next video (part-2), I will be sharing the logic for some difficult patterns.</p><p>Thank you for reading this concept. Keep Learning :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6ac4aa725c88" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Converting Date/Time Considering Time Zone — Android]]></title>
            <link>https://medium.com/@kosta.palash/converting-date-time-considering-time-zone-android-b389ff9d5c49?source=rss-830fb0ccb7ef------2</link>
            <guid isPermaLink="false">https://medium.com/p/b389ff9d5c49</guid>
            <category><![CDATA[parse]]></category>
            <category><![CDATA[simple-date-format]]></category>
            <category><![CDATA[timezone]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[format]]></category>
            <dc:creator><![CDATA[Palash Kosta]]></dc:creator>
            <pubDate>Wed, 10 Jan 2018 05:17:27 GMT</pubDate>
            <atom:updated>2019-09-22T09:21:06.809Z</atom:updated>
            <content:encoded><![CDATA[<p>This article will explain the concept of converting date/time from one time zone to another time zone in android application.</p><p>In normal scenario, you get the time stamp in GMT time zone from the server and you need to convert it in the local time zone to display it to the UI. If you feel uncomfortable or have some doubts in converting the date/time from one timezone to another timezone…you can refer this article. This article is for you. :)</p><p>To understand the concept, let us consider the below scenarios where we get the time stamp from the server in GMT format (assuming), then we need to convert it to some model which store the date as Date object in Local format, then we store the date as time stamp (string) into the DB in GMT format and then to show to the UI, we get the date object in some UI Model in Local Format and then showing the date as string on the UI in Local Format. Please refer the below diagram.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/344/1*qrGcZJdUHJkSrYuCcIJstQ.png" /></figure><p>In the whole process, we need to either convert the date/time from <strong>string to Date object</strong> or from <strong>Date object to String</strong>. To convert this, we use the <strong>SimpleDateFormat</strong> class in Android like below:</p><pre>/** Converting from String to Date **/</pre><pre><strong>fun </strong>String.getDateWithServerTimeStamp(): Date? {<br> val dateFormat = SimpleDateFormat(&quot;<strong>yyyy-MM-dd&#39;T&#39;HH:mm:ss.SSS&#39;Z&#39;&quot;,<br>     </strong>Locale.getDefault())<br> dateFormat.timeZone = TimeZone.getTimeZone(&quot;GMT&quot;)  // IMP !!!<br> try {<br>  return dateFormat.parse(this)<br> } catch (e: ParseException) {<br>  return null<br>}</pre><pre>/** Converting from Date to String**/</pre><pre>fun Date.getStringTimeStampWithDate(): String {<br> val dateFormat = SimpleDateFormat(&quot;<strong>yyyy-MM-dd&#39;T&#39;HH:mm:ss.SSS&#39;Z&#39;&quot;,<br>     </strong>Locale.getDefault())<br> dateFormat.timeZone = TimeZone.getTimeZone(&quot;GMT&quot;)<br> return dateFormat.format(this)<br>}</pre><pre>/** TESTING **/</pre><pre><strong>val </strong>dateString = <strong>&quot;2018-01-09T07:06:41.747Z&quot;<br>val </strong>date = dateString.<em>getDateWithServerTimeStamp</em>()<br>Log.d(<strong>&quot;LOG&quot;</strong>, <strong>&quot;String To Date Conversion &quot; </strong>+date.<em>toString</em>())<br><strong>val </strong>dateBackToString = date?.<em>getStringTimeStampWithDate</em>()<br>Log.d(<strong>&quot;LOG&quot;</strong>, <strong>&quot;Date To String Conversion &quot; </strong>+dateBackToString)</pre><pre>/** OUTPUT **/<br><strong>String To Date Conversion Tue Jan 09 15:06:41 GMT+08:00 2018<br>Date To String Conversion 2018-01-09T07:06:41.747Z</strong></pre><pre>/** NOTE: I am currently at GMT+08:00 **/</pre><p>If you are not sure how the date format is generating this output then don’t worry, I will explain you each and every bit of it. By the end of this article, you will be able to understand how this works and how we can play with date objects and strings with different timezone.</p><p>OK it’s time to understand the concept…<strong>three concepts will explain you all the logics behind this.</strong></p><p>Consider the very first case…<strong>converting GMT string (from server) to Local Date Object</strong>…</p><p><strong>Concept-1</strong> If we want the date/time to be adjusted based on the timezone, <strong>we need to think the time zone that need to be associated with the string (representing date).</strong></p><p>So if we are getting the date — <strong>“2018–01–09T07:06:41.747Z” </strong>from the server then we need to think / decide it’s time zone…let us say, it is representing in the GMT format. <strong>Whatever format we decide for string (representing date), that has to be associated with “SimpleDateFormat” class of Android.</strong></p><pre>/** Converting from String to Date **/</pre><pre><strong>fun </strong>String.getDateWithServerTimeStamp(): Date? {<br> val dateFormat = SimpleDateFormat(&quot;<strong>yyyy-MM-dd&#39;T&#39;HH:mm:ss.SSS&#39;Z&#39;&quot;,<br>     </strong>Locale.getDefault())<br> <strong>dateFormat.timeZone = TimeZone.getTimeZone(&quot;GMT&quot;)  // IMP !!!</strong><br> try {<br>  return dateFormat.parse(this)<br> } catch (e: ParseException) {<br>  return null<br>}</pre><p><strong>Concept-2</strong> By default, the <strong>Date </strong>class works with Local time zone, in my case…GMT+8</p><p><strong>Concept-3 </strong>Now during conversion, <strong>If there is a difference in time zone of source (String — GMT) and destination (Date — Local), then automatic date/time adjustment happens based on the time zone.</strong> And therefore, the conversion happened in the above case…</p><pre><strong>val </strong>dateString = <strong>&quot;2018-01-09T07:06:41.747Z&quot;   // considered GMT<br>val </strong>date = dateString.<em>getDateWithServerTimeStamp</em>()<br>Log.d(<strong>&quot;LOG&quot;</strong>, <strong>&quot;String To Date Conversion &quot; </strong>+date.<em>toString</em>())</pre><pre>/** OUTPUT **/<br><strong>String To Date Conversion Tue Jan 09 15:06:41 GMT+08:00 2018</strong></pre><pre>/** NOTE: I am currently at GMT+08:00 (Local)**/</pre><p><strong>Also, if the time zone is same of source and destination, no automatic date/time adjustment will happen while conversion. For illustration,</strong></p><pre>/** Converting from String to Date **/</pre><pre><strong>fun </strong>String.getDateWithServerTimeStamp(): Date? {<br> val dateFormat = SimpleDateFormat(&quot;<strong>yyyy-MM-dd&#39;T&#39;HH:mm:ss.SSS&#39;Z&#39;&quot;,<br>     </strong>Locale.getDefault())<br> <strong>dateFormat.timeZone = TimeZone.getDefault()  // IMP !!!</strong><br> try {<br>  return dateFormat.parse(this)<br> } catch (e: ParseException) {<br>  return null<br>}</pre><pre><strong>val </strong>dateString = <strong>&quot;2018-01-09T07:06:41.747Z&quot;   // considered LOCAL<br>val </strong>date = dateString.<em>getDateWithServerTimeStamp</em>()<br>Log.d(<strong>&quot;LOG&quot;</strong>, <strong>&quot;String To Date Conversion &quot; </strong>+date.<em>toString</em>())</pre><pre>/** OUTPUT **/<br><strong>String To Date Conversion Tue Jan 09 07:06:41 GMT+08:00 2018</strong></pre><pre>/** NOTE: I am currently at GMT+08:00 (Local)**/<br>It has considered the server time to be local time (not real time scenario, I have shown it just to explain the scenario)</pre><p>That’s it…we can use these three concepts to work with remaining cases…let us take one by one.</p><p>Second Case, <strong>converting the Date Local Object to GMT String format…</strong></p><p>Now ask yourself, — string timezone?? ==&gt; GMT, ok that means SimpleDateFormat will have GMT format associated with it. Also, the Date Object is in Local Format (Source) and String we want to be in GMT (Destination)…<strong>conversion will happen.</strong></p><pre>/** Converting from Date to String**/</pre><pre>fun Date.getStringTimeStampWithDate(): String {<br> val dateFormat = SimpleDateFormat(&quot;<strong>yyyy-MM-dd&#39;T&#39;HH:mm:ss.SSS&#39;Z&#39;&quot;,<br>     </strong>Locale.getDefault())<br> dateFormat.timeZone = TimeZone.getTimeZone(&quot;GMT&quot;)<br> return dateFormat.format(this)<br>}</pre><pre>/** TESTING **/</pre><pre><strong>val </strong>dateString = <strong>&quot;2018-01-09T07:06:41.747Z&quot;<br>val </strong>date = dateString.<em>getDateWithServerTimeStamp</em>()<br>Log.d(<strong>&quot;LOG&quot;</strong>, <strong>&quot;String To Date Conversion &quot; </strong>+date.<em>toString</em>())<br><strong>val </strong>dateBackToString = date?.<em>getStringTimeStampWithDate</em>()<br>Log.d(<strong>&quot;LOG&quot;</strong>, <strong>&quot;Date To String Conversion &quot; </strong>+dateBackToString)</pre><pre>/** OUTPUT **/<br><strong>String To Date Conversion Tue Jan 09 15:06:41 GMT+08:00 2018<br>Date To String Conversion 2018-01-09T07:06:41.747Z</strong></pre><pre>/** NOTE: I am currently at GMT+08:00 (Local)**/</pre><p>I hope, by now you have understood the concept. Let us take remaining cases for the practice…</p><p>Third Case, It is almost the same case as the first case where we have converted the GMT string to Local Date Object. Same method can be used to do it. Nothing new in this case. :)</p><p>Last case, this one will help you to practice the concepts…<strong>converting the Local Date to Local String to display it to the UI</strong>.</p><p>string time zone to consider??? → Local → SimpleDateFormat timezone →local</p><p>Conversion needed? NO → it will not happen as the time zone of source and destination is same. The function will be look like —</p><pre>/** Converting from Date to String**/</pre><pre>fun Date.getUIStringTimeStampWithDate(): String {<br> val dateFormat = SimpleDateFormat(<strong>&quot;dd-MMM-yyyy HH:mm:ss&quot;,<br>     </strong>Locale.getDefault())<br> dateFormat.timeZone = TimeZone.getDefault()<br> return dateFormat.format(this)<br>}</pre><pre><strong>val </strong>uiString = date?.<em>getStringTimeStampWithDate</em>()<br>Log.d(<strong>&quot;BUGS&quot;</strong>, <strong>&quot;Date To String Conversion &quot; </strong>+uiString)</pre><pre><strong>Date To String Conversion 09-Jan-2018 15:06:41</strong></pre><p>That’s it…for date/time conversion with timezone. I hope you enjoyed the article.</p><p>Thank you for reading this article. Keep Learning :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b389ff9d5c49" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Thinking MVP with Android]]></title>
            <link>https://medium.com/@kosta.palash/thinking-mvp-with-android-e0df1772dd11?source=rss-830fb0ccb7ef------2</link>
            <guid isPermaLink="false">https://medium.com/p/e0df1772dd11</guid>
            <category><![CDATA[mvp]]></category>
            <category><![CDATA[architecture-pattern]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[android-mvp]]></category>
            <dc:creator><![CDATA[Palash Kosta]]></dc:creator>
            <pubDate>Sun, 07 Jan 2018 04:35:09 GMT</pubDate>
            <atom:updated>2018-01-07T04:35:09.813Z</atom:updated>
            <content:encoded><![CDATA[<p>Are you thinking about architecture design (MVP or MVVM) to follow for your next Android application? Great…you are on the right track. :)</p><p>But you may be wondering how to start or think in a way these architecture demand us to design our application. Yes, I have also struggled a lot to understand the different way of thinking needed to work on any of the architecture design patterns.</p><p>In this article, I will try to explain how I get started implementing<strong> MVP with Android application.</strong></p><blockquote>NOTE:<em> This article will not explain how to implement the MVP with Android step by step through code but it will explain how you should think or analyze the requirement to convert them to MVP design pattern.</em></blockquote><p>In the MVP pattern, for each screen of the application, we need to make set of classes :</p><ol><li>One View — Activity or Fragment (One screen can be associated with multiple Fragment). For simplicity, we are taking one fragment for one screen here.</li><li>One Presenter — Behaves as the <strong>“brain”</strong> for the screen. And it has the one to one mapping with the View as per MVP pattern.<em> I will explain why Presenter is called as brain, in a while.</em></li><li>The Contract — Very very useful class that defines the capability of the View and Presenter. It comes between the Presenter and View. View and Presenter need to define their capabilities in this class. <em>I will explain how we decide the capability of View and Presenter for the particular screen.</em></li></ol><p>In short, to implement MVP with Android, we need to understand two things for every screen,</p><p>1. Why and How Presenter behaves as the brain for the particular screen?</p><p>2. How to think or how to define the capabilities of View and Presenter inside the contract beforehand.</p><p>So, <strong>first thing first, why the Presenter is the brain for the screen…</strong><em>you will say, yes we all know that Presenter is going to handle all the business logic for the screen and that is why it is called as “The Brain” for the screen. … </em>You are correct and fair enough to explain the concept. But let me put it in a more implementation way…</p><p>Consider the scenario when <strong>User</strong> click on the <strong>FAB Button </strong>to open the “New Notes” Activity.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/270/1*heZ12AvjOQdZH5b6W2n0Zw.png" /></figure><p>Now as the user presses the button, activity get the input event…but it cannot take any action…because it does not know what to do (it is not the brain .:D), it will ask the brain (Presenter) for further action, something like this — “<em>hey presenter, user clicked on FAB button, please tell me what functionality I need to perform for this</em>”. Then, Presenter will check the capabilities of View (from the Contract) and tell him to perform any one of them. <strong>And this goes in the same way for every user action for every screen in MVP</strong>.</p><p>Now the second thing, how to think the capabilities for View and Presenter to define in the Contract. A sample contract class looks something like this:</p><pre><strong>public interface ScreenContract {</strong><br><br>    <strong>interface View {</strong> <em>// defines the View Capability. This interface will be implemented by the View class. Presenter (Brain) can only call any of the method defined here.</em><br>    <strong>}<br><br>    interface UserActionsListener {</strong> <em>// defines the Presenter trigger points from the View. This class will be implemented by the Presenter</em><br>    <strong>}<br>}</strong></pre><p>So for every screen of the application we need to think — <strong>1. what all are the user actions possible in the particular screen</strong>, that will go into the <strong>UserActionsListener </strong>interface and that need to be implemented by the Presenter. View will call these Presenter methods when any user action happens.</p><p>2. <strong>What all are the behaviors or functionalities of the screen</strong>, that will go into the <strong>View </strong>interface and will be implemented by the View (Activity or Fragment).</p><p>Now we are taking an example to show, how can we think to evaluate these <strong>user actions</strong> and <strong>functionalities</strong> of the screen. Consider the same screen again…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/270/1*heZ12AvjOQdZH5b6W2n0Zw.png" /></figure><p><em>Please ignore the hamburger/navigation menu input for now. Actually we are taking the Fragment as the View, which show the notes and provide the FAB button to add new note. Also this fragment provides the “pull to refresh” functionality.</em></p><p>OK, so now first think about the inputs that a user can provide to this screen…be relax…and think…the very straight forward is the “FAB Button” input which is used to add the new note. Next, to refresh the notes list using pull to refresh. And next could be to click on the note item to see the details. So to summarize:</p><ol><li>Add Button Click</li><li>Refresh Notes List</li><li>View Details</li></ol><p>OK, now we need to think how this screen can behave…what functionalities it can offer to the user…like</p><ol><li>Showing Notes</li><li>Showing Progress Indicator</li><li>Hiding Progress Indicator</li><li>Redirecting user to add new note</li><li>Redirecting user to view details</li></ol><p>That’s it…after defining these user actions and functionalities…we are done. Now just create the contract class and declare these methods…and let View and Presenter to implement these. A final contract class could be look like this:</p><pre><strong>public interface </strong>NotesContract {<br><br>    <strong>interface </strong>View {<br><br>        <strong>void </strong>setProgressIndicator(<strong>boolean </strong>active);<br><br>        <strong>void </strong>showNotes(List&lt;Note&gt; notes);<br><br>        <strong>void </strong>navigateAddNoteView();<br><br>        <strong>void </strong>navigateNoteDetailView(String Id);<br>    }<br><br>    <strong>interface </strong>UserActionsListener {<br><br>        <strong>void </strong>loadorRefreshNotes();<br><br>        <strong>void </strong>addNewNoteClicked();<br><br>        <strong>void </strong>openNoteDetailsClicked(@NonNull Note requestedNote);<br>    }<br>}</pre><p><strong>Take away</strong> —If you want to use MVP in your application…first step is to think all the user actions and functionalities for all the screens of the application and define the <strong>Contract</strong> classes. Once contract classes are defined, do not change/modify the <strong>Contract </strong>classes too frequently, think about the change and evaluate if it make perfect sense to change it (based on the concept we have learned) then proceed with the confidence.</p><p>View and Presenter need to act according to the <strong>Contract </strong>classes. This process will also help you in working with TDD (Test Driven Development) approach with Android application.</p><p>Thanks for reading the article. I hope this will help to understand the basics of how to construct the contract between View and Presenter in MVP.</p><p>If you like the article…please clap for it…:) :D</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e0df1772dd11" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Using BottomSheetDialogFragment with Material Design Guideline]]></title>
            <link>https://medium.com/@kosta.palash/using-bottomsheetdialogfragment-with-material-design-guideline-f9814c39b9fc?source=rss-830fb0ccb7ef------2</link>
            <guid isPermaLink="false">https://medium.com/p/f9814c39b9fc</guid>
            <category><![CDATA[bottomsheetdialogfragment]]></category>
            <category><![CDATA[bottomsheet]]></category>
            <category><![CDATA[bottomsheet-example]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[material-de]]></category>
            <dc:creator><![CDATA[Palash Kosta]]></dc:creator>
            <pubDate>Fri, 20 Oct 2017 03:49:34 GMT</pubDate>
            <atom:updated>2017-10-20T03:49:34.784Z</atom:updated>
            <content:encoded><![CDATA[<p>As per the material design guideline for BottomSheet, there are two types of BottomSheets:</p><ol><li><strong>Modal bottom sheets</strong>: It Can be implemented using BottomSheetDialog or BottomSheetDialogFragment. Elevation is higher than the app. It is fundamentally acting as the dialog.</li><li><strong>Persistent bottom sheets</strong>: It can be implemented using <a href="https://material.io/components/android/catalog/bottom-sheet-behavior/">BottomSheetBehavior</a> in conjunction with a <a href="https://material.io/components/android/catalog/coordinator-layout/">CoordinatorLayout</a>.</li></ol><p>Links: <a href="https://material.io/guidelines/components/bottom-sheets.html#bottom-sheets-modal-bottom-sheets">https://material.io/guidelines/components/bottom-sheets.html#bottom-sheets-modal-bottom-sheets</a></p><p><a href="https://material.io/components/android/catalog/bottom-sheet-dialog-fragment/">https://material.io/components/android/catalog/bottom-sheet-dialog-fragment/</a></p><p>In this article, we are going to learn how to implement the BottomSheetDialogFragment to use the bottom sheet as a modal dialog.</p><p>Final Outcome:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/268/1*FQWuc0H4a7iQSfgvvoSUaA.png" /></figure><p>So lets get started…</p><p>Step 1: Create the layout file for bottom sheet (consider the material design guideline while building the guideline):</p><pre>&lt;<strong>LinearLayout<br>    xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;<br>    android:layout_width=&quot;match_parent&quot;<br>    android:layout_height=&quot;wrap_content&quot;<br>    android:layout_marginBottom=&quot;@dimen/dp_8&quot;<br>    android:layout_marginTop=&quot;@dimen/dp_8&quot;<br>    android:orientation=&quot;vertical&quot;</strong>&gt;<br><br>    &lt;<strong>TextView<br>        android:id=&quot;@+id/tv_bottom_sheet_heading&quot;<br>        android:layout_width=&quot;wrap_content&quot;<br>        android:layout_height=&quot;@dimen/dp_56&quot;<br>        android:layout_marginEnd=&quot;@dimen/dp_16&quot;<br>        android:layout_marginStart=&quot;@dimen/dp_16&quot;<br>        android:gravity=&quot;center&quot;<br>        android:text=&quot;@string/bottom_sheet_option_heading&quot;<br>        android:textColor=&quot;@color/md_bottom_sheet_title_color&quot;<br>        android:textSize=&quot;16sp&quot; </strong>/&gt;<br><br>    &lt;<strong>TextView<br>        android:id=&quot;@+id/tv_btn_add_photo_camera&quot;<br>        android:layout_width=&quot;match_parent&quot;<br>        android:layout_height=&quot;@dimen/dp_48&quot;<br>        android:layout_marginEnd=&quot;@dimen/dp_16&quot;<br>        android:layout_marginStart=&quot;@dimen/dp_16&quot;<br>        android:backgroundTint=&quot;@android:color/white&quot;<br>        android:drawablePadding=&quot;@dimen/dp_32&quot;<br>        android:drawableStart=&quot;@drawable/ic_add_a_photo&quot;<br>        android:drawableTint=&quot;@color/md_bottom_sheet_text_color&quot;<br>        android:gravity=&quot;start|center_vertical&quot;<br>        android:text=&quot;@string/bottom_sheet_option_camera&quot;<br>        android:textColor=&quot;@color/md_bottom_sheet_text_color&quot;<br>        android:textSize=&quot;16sp&quot; </strong>/&gt;<br><br>    &lt;<strong>TextView<br>        android:id=&quot;@+id/tv_btn_add_photo_gallery&quot;<br>        android:layout_width=&quot;match_parent&quot;<br>        android:layout_height=&quot;48dp&quot;<br>        android:layout_marginEnd=&quot;@dimen/dp_16&quot;<br>        android:layout_marginStart=&quot;@dimen/dp_16&quot;<br>        android:backgroundTint=&quot;@android:color/white&quot;<br>        android:drawablePadding=&quot;@dimen/dp_32&quot;<br>        android:drawableStart=&quot;@drawable/ic_gallery_photo&quot;<br>        android:drawableTint=&quot;@color/md_bottom_sheet_text_color&quot;<br>        android:gravity=&quot;start|center_vertical&quot;<br>        android:text=&quot;@string/bottom_sheet_option_gallery&quot;<br>        android:textColor=&quot;@color/md_bottom_sheet_text_color&quot;<br>        android:textSize=&quot;16sp&quot; </strong>/&gt;<br><br>    &lt;<strong>View<br>        android:layout_width=&quot;match_parent&quot;<br>        android:layout_height=&quot;1dp&quot;<br>        android:layout_marginBottom=&quot;@dimen/dp_8&quot;<br>   <br>android:layout_marginTop=&quot;@dimen/md_bottom_sheet_separator_top_margin&quot;<br>        android:background=&quot;@color/grayTextColor&quot; </strong>/&gt;<br><br>    &lt;<strong>TextView<br>        android:id=&quot;@+id/tv_btn_remove_photo&quot;<br>        android:layout_width=&quot;match_parent&quot;<br>        android:layout_height=&quot;@dimen/dp_48&quot;<br>        android:layout_marginEnd=&quot;@dimen/dp_16&quot;<br>        android:layout_marginStart=&quot;@dimen/dp_16&quot;<br>        android:backgroundTint=&quot;@android:color/white&quot;<br>        android:drawablePadding=&quot;@dimen/dp_32&quot;<br>        android:drawableStart=&quot;@drawable/ic_delete_photo&quot;<br>        android:drawableTint=&quot;@color/md_bottom_sheet_text_color&quot;<br>        android:gravity=&quot;start|center_vertical&quot;<br>        android:text=&quot;@string/bottom_sheet_option_remove_photo&quot;<br>        android:textColor=&quot;@color/md_bottom_sheet_text_color&quot;<br>        android:textSize=&quot;16sp&quot; </strong>/&gt;<br><br>&lt;/<strong>LinearLayout</strong>&gt;</pre><p>Step 2: Create the dimen.xml file:</p><pre><em>&lt;?</em><strong>xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;</strong><em>?&gt;<br></em>&lt;<strong>resources</strong>&gt;<br>    &lt;<strong>dimen name=&quot;dp_8&quot;</strong>&gt;8dp&lt;/<strong>dimen</strong>&gt;<br>    &lt;<strong>dimen name=&quot;dp_16&quot;</strong>&gt;16dp&lt;/<strong>dimen</strong>&gt;<br>    &lt;<strong>dimen name=&quot;dp_24&quot;</strong>&gt;24dp&lt;/<strong>dimen</strong>&gt;<br>    &lt;<strong>dimen name=&quot;dp_32&quot;</strong>&gt;32dp&lt;/<strong>dimen</strong>&gt;<br>    &lt;<strong>dimen name=&quot;dp_40&quot;</strong>&gt;40dp&lt;/<strong>dimen</strong>&gt;<br>    &lt;<strong>dimen name=&quot;dp_48&quot;</strong>&gt;48dp&lt;/<strong>dimen</strong>&gt;<br>    &lt;<strong>dimen name=&quot;dp_56&quot;</strong>&gt;56dp&lt;/<strong>dimen</strong>&gt;<br>    &lt;<strong>dimen name=&quot;dp_64&quot;</strong>&gt;64dp&lt;/<strong>dimen</strong>&gt;<br>    &lt;<strong>dimen name=&quot;dp_72&quot;</strong>&gt;72dp&lt;/<strong>dimen</strong>&gt;<br>    &lt;<strong>dimen name=&quot;dp_80&quot;</strong>&gt;80dp&lt;/<strong>dimen</strong>&gt;<br>    &lt;<strong>dimen name=&quot;dp_160&quot;</strong>&gt;160dp&lt;/<strong>dimen</strong>&gt;<br><br>    &lt;<strong>dimen name=&quot;md_bottom_sheet_separator_top_margin&quot;</strong>&gt;7dp&lt;/<strong>dimen</strong>&gt;<br>&lt;/<strong>resources</strong>&gt;</pre><p><strong>The dp used while creating the bottom sheet layout are adhere to the </strong><a href="https://material.io/guidelines/components/bottom-sheets.html#bottom-sheets-modal-bottom-sheets"><strong>Material Design Guidelines</strong></a><strong>.</strong></p><p>Step 3: The string.xml file:</p><pre>&lt;<strong>string name=&quot;bottom_sheet_option_camera&quot;</strong>&gt;Use Camera&lt;/<strong>string</strong>&gt;<br>&lt;<strong>string name=&quot;bottom_sheet_option_gallery&quot;</strong>&gt;Upload from Gallery&lt;/<strong>string</strong>&gt;<br>&lt;<strong>string name=&quot;bottom_sheet_option_heading&quot;</strong>&gt;Add Photo&lt;/<strong>string</strong>&gt;<br>&lt;<strong>string name=&quot;bottom_sheet_option_remove_photo&quot;</strong>&gt;Remove Photo&lt;/<strong>string</strong>&gt;</pre><p>Step 4: Create the custom BottomSheetDialogFragment</p><pre><strong>public class </strong>AddPhotoBottomDialogFragment <strong>extends </strong>BottomSheetDialogFragment{<br><br>    <strong>public static </strong>AddPhotoBottomDialogFragment newInstance() {<br>        <strong>return new </strong>AddPhotoBottomDialogFragment();<br>    }<br><br>    @Nullable<br>    @Override<br>    <strong>public </strong>View onCreateView(LayoutInflater inflater,<br>                             @Nullable ViewGroup container,<br>                             @Nullable Bundle savedInstanceState) {<br><br>        View view = inflater.inflate(R.layout.<strong><em>layout_photo_bottom_sheet</em></strong>, container,<br>                <strong>false</strong>);<br><br>        <em>// get the views and attach the listener<br><br>        </em><strong>return </strong>view;<br><br>    }<br>}</pre><p>Step 5: To show the dialog fragment in the activity:</p><pre>AddPhotoBottomDialogFragment addPhotoBottomDialogFragment =<br>        AddPhotoBottomDialogFragment.<em>newInstance</em>();<br>addPhotoBottomDialogFragment.show(getSupportFragmentManager(),<br>        <strong>&quot;add_photo_dialog_fragment&quot;</strong>);</pre><p>That’s it... Now you can run the application and check the BottomSheet in your application.</p><p>You can create the custom callback (interfaces) in the custom bottom sheet dialog fragment to notify the activity when one of the button is tapped on the Bottom Sheet (dialog fragment).</p><p>Thank you for reading the article... :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f9814c39b9fc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Good Coding Points]]></title>
            <link>https://medium.com/@kosta.palash/good-coding-points-22d37dbbd652?source=rss-830fb0ccb7ef------2</link>
            <guid isPermaLink="false">https://medium.com/p/22d37dbbd652</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[coding-points]]></category>
            <dc:creator><![CDATA[Palash Kosta]]></dc:creator>
            <pubDate>Wed, 07 Jun 2017 17:35:43 GMT</pubDate>
            <atom:updated>2017-06-07T17:42:07.105Z</atom:updated>
            <content:encoded><![CDATA[<p>Hello friends, I am Palash Kosta, an Android Developer. I wanted to have a list of good points that I should keep in mind during development of any Android application. So here I started. This list will help me as well as others who have started the Android Development recently and want to have such list at their hand. I will update the list…as soon as I get the new good point :)</p><p>Good Coding Points:</p><ul><li>When creating static helper functions, you can extract the application context from the context you are given (Calling getApplicationContext() on the application context returns the application context).</li><li>If the application context is not appropriate for your use case, you can include a Context parameter in each utility function, you should avoid keeping references to these context parameters at the class level.</li><li>Avoid using anonymous inner classes. It can never be any type of solution for memory leak. But it does apposite. Because the anonymous inner class has an implicit reference to the outer class (in this case the activity).</li><li>The only type of inner classes that do not have a reference to the outer class are <strong>static</strong> inner classes.</li><li>Use AsyncTaskLoader (instead of AsyncTask) to better manage the activity life cycle or configuration changes. Loader is a life cycle aware component. “<strong><em>It is incredibly important that your </em>Loader<em> does not contain any reference to any containing </em>Activity<em> or </em>Fragment<em> </em></strong><em>and that includes the implicit reference created by non-static inner classes. Obviously, if you’re not declaring your </em>Loader<em> as an inner class, you won’t need the static keyword.” from below link.</em></li></ul><p><a href="https://medium.com/google-developers/making-loading-data-on-android-lifecycle-aware-897e12760832">Making loading data on Android lifecycle aware</a></p><ul><li>Always remember, RelativeLayout viewgroup ‘measures the child position twice’, which is not very much performance efficient. Also, the linear layout with weight_sum attribute does the same. For simple layout, where RelativeLayout can be avoided, you should avoid it.</li><li>Don’t use enums in the code…memory insufficient. Use ‘@intdef’ annotation with retention policy.</li></ul><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FHzs6OBcvNQE%3Ffeature%3Doembed&amp;url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DHzs6OBcvNQE&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FHzs6OBcvNQE%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/554d2e7f0c488754a59fad710a06d84f/href">https://medium.com/media/554d2e7f0c488754a59fad710a06d84f/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=22d37dbbd652" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>