<?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 Furkan Paşaoğlu on Medium]]></title>
        <description><![CDATA[Stories by Furkan Paşaoğlu on Medium]]></description>
        <link>https://medium.com/@furkan-pasaoglu?source=rss-b505f71caeba------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*VpjPdyDgMgMfqlpdcFAa5Q.jpeg</url>
            <title>Stories by Furkan Paşaoğlu on Medium</title>
            <link>https://medium.com/@furkan-pasaoglu?source=rss-b505f71caeba------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 14:26:32 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@furkan-pasaoglu/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[Game of Mobile Thrones]]></title>
            <link>https://medium.com/digigeek/game-of-the-mobile-thrones-d9c43f65bc7a?source=rss-b505f71caeba------2</link>
            <guid isPermaLink="false">https://medium.com/p/d9c43f65bc7a</guid>
            <category><![CDATA[flutter-vs-react-native]]></category>
            <category><![CDATA[kmm]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[multiplatform]]></category>
            <category><![CDATA[react-native]]></category>
            <dc:creator><![CDATA[Furkan Paşaoğlu]]></dc:creator>
            <pubDate>Sat, 16 Sep 2023 13:35:59 GMT</pubDate>
            <atom:updated>2023-09-21T07:15:51.853Z</atom:updated>
            <content:encoded><![CDATA[<h3>Flutter vs KMM vs React Native</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9phPPbLNPcYLcPa1-gEfLQ.jpeg" /></figure><p>In the world of mobile app development, it seems like there’s an ongoing battle among different technologies. The starring roles in this battle feature powerful contenders like Flutter, Kotlin Multiplatform Mobile (KMM), and React Native. Each has its own followers and advocates. But how can you determine which technology is the best, and which one is the right choice for you? Here’s an analysis of this battle!</p><h3>Round 1: Programming Language Clash</h3><ul><li>Flutter: Utilizes the Dart programming language. Designed for creating visually appealing and high-performance applications.</li><li>KMM: Kotlin Multiplatform Mobile employs the Kotlin programming language, enabling you to use the same code for Android and iOS apps.</li><li>React Native: Uses JavaScript and React. May be more accessible to web developers.</li></ul><h3>Round 2: Performance Showdown</h3><ul><li>Flutter: Offers high performance due to Dart’s speed and compile-time optimizations.</li><li>KMM: Strong in terms of performance thanks to Kotlin’s direct JVM integration but may require some platform customizations.</li><li>React Native: JavaScript-based, so it might have slightly lower performance compared to native performance.</li></ul><h3>Round 3: Developer Experience Battle</h3><ul><li>Flutter: Enhances developer experience with a fast development cycle and a rich widget library.</li><li>KMM: Offers a smooth transition for Kotlin users but may require platform-specific customizations.</li><li>React Native: Designed with web developers in mind, making it accessible for those who know JavaScript.</li></ul><h3>Round 4: Community and Ecosystem Clash</h3><ul><li>Flutter: Boasts a rapidly growing community and a rich package ecosystem.</li><li>KMM: Built on the Kotlin community but has not yet fully matured in terms of the ecosystem.</li><li>React Native: Has a large community and a broad ecosystem but may lack some packages.</li></ul><h3>Conclusion:</h3><p>As the final round comes to an end, it’s evident that each technology has its unique advantages and disadvantages. Flutter provides rapid development and performance, KMM is a convenient choice for Kotlin users, and React Native offers an easy transition for web developers.</p><p>Ultimately, the technology you choose will depend on the needs of your project and your existing skills. Regardless of which arena you decide to battle in, each technology has its distinct features, and the victor of this battle will be determined by your requirements and preferences. Enjoy the battle and keep coding!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d9c43f65bc7a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/digigeek/game-of-the-mobile-thrones-d9c43f65bc7a">Game of Mobile Thrones</a> was originally published in <a href="https://medium.com/digigeek">DigiGeek</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Stay away BaseClasses for your Health]]></title>
            <link>https://medium.com/digigeek/stay-away-baseclasses-for-your-health-e2be456763f1?source=rss-b505f71caeba------2</link>
            <guid isPermaLink="false">https://medium.com/p/e2be456763f1</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[antipattern]]></category>
            <category><![CDATA[clean-code]]></category>
            <dc:creator><![CDATA[Furkan Paşaoğlu]]></dc:creator>
            <pubDate>Fri, 17 Sep 2021 06:05:06 GMT</pubDate>
            <atom:updated>2021-09-22T06:03:49.937Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iTAB0AqzjFAkUxIMq2c5MA.jpeg" /></figure><p>Hello everyone, today I am gonna write why we should avoid from BaseActivity, BaseClasses, and BaseFragment. Why they are anti-pattern, what we can use instead of BaseClasses. I know “Base” is appealing but causes bugs, defects, conflicts, complexity (unhealthy) in the future.</p><blockquote>Pleeeaasee. Stay away and hide it where children can’t see it !!!</blockquote><p>Let’s assume Sakir is supporting BaseClasses, Abbas is not. See what are the dialogs between them</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Wpr6EikxRIUIF15IqramiQ.jpeg" /><figcaption>Ref [<a href="https://kulturveyasam.com/">https://kulturveyasam.com/</a>]</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hl9CrSWl-G2UuwVWr-N2tg.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Vja4s1_IT7yeI53WlWnVfA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9NFh4MMOQ7sZagBHT4NNhA.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DQ7JPUVlwlY7QijeK1aV6A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Jt-DYvfX8dqI0dRxfvO5Sw.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*W8pdhej7dl9_h5nWLk5bOg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1_YakbwL4ewjkslaKhi0Ag.jpeg" /></figure><p>Yeaah you witnessed a Turkish Quarrel. Actually, we don’t talk about software like this but this is imaginary so there is no problem 😉</p><p>As you understand, Abbas won the quarrel. BaseClasses is anti-pattern.</p><ul><li>Naming is meaningless</li><li>Block to extend others classes</li><li>BaseClasses update takes a lot of effort and impacts almost all classes</li><li>Hard to write a test because dependencies are tightly coupled</li><li>Maybe you want to use one method of BaseClass and when you extend it, you get all methods. One method&#39;s changes may cause RunTimeException and crashes.</li></ul><blockquote>⚠️ If that isn’t enough to prevent you from BaseClasses. You can try it and see how bugs, conflicts and complexity feels like ⚠️</blockquote><p>Don’t forget to clap, stay well 👋</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e2be456763f1" width="1" height="1" alt=""><hr><p><a href="https://medium.com/digigeek/stay-away-baseclasses-for-your-health-e2be456763f1">Stay away BaseClasses for your Health</a> was originally published in <a href="https://medium.com/digigeek">DigiGeek</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Android Work Manager with an Example ‍♂️]]></title>
            <link>https://medium.com/digigeek/android-work-manager-with-an-example-%EF%B8%8F-63d1b29955d4?source=rss-b505f71caeba------2</link>
            <guid isPermaLink="false">https://medium.com/p/63d1b29955d4</guid>
            <category><![CDATA[jetpack]]></category>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[workmanager]]></category>
            <dc:creator><![CDATA[Furkan Paşaoğlu]]></dc:creator>
            <pubDate>Fri, 04 Jun 2021 12:26:57 GMT</pubDate>
            <atom:updated>2021-06-07T06:43:20.654Z</atom:updated>
            <content:encoded><![CDATA[<h3>Android WorkManager with an Example 👷‍♂️</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*677KXyRwpAq6ohbLQHNbwA.png" /><figcaption>Work Work Work Work — image ref[<a href="https://www.raywenderlich.com/">https://www.raywenderlich.com/</a>]</figcaption></figure><p>Hello everyone👋 in this section, we’ll talk about what exactly <em>Work Manager</em> is? Where we can use it? Is there any example ?🤔 and blah blah blah…</p><p>I do not deep into it, our main purpose is to explain the work manager with an example. You can reach the source code link below the story if you do not have much time</p><h3>What is Work Manager?</h3><p>We met Work Manager at the Google IO-18 event. it is an API that part of the Jetpack makes it easy to schedule deferrable, asynchronous tasks</p><p>we’ll use Work Manager when background task needs to the combination of opportunistic and guaranteed execution</p><ul><li><strong>Opportunistic:</strong> It will live as long as possible. Work Manager has a database and it saves all request information into DB. So Background request will able to run even if the app exits or device restart</li><li><strong>Guaranteed:</strong> It fulfills its mission no matter what. Work manager has flexible retry policies and if request get fails, these policies provide to retry the requests with interval you define</li></ul><p>Some usage of Work Manager</p><ol><li>Uploading logs 🗳 -&gt; Maybe you want to get some user’s log every day at 12.00 am. Work manager is suitable for that</li><li>Applying filters to images and saving the image 🗂 -&gt; Suppose that you work at an AI Company and you want to filter the image but request-response get fails, work manager is retry it at later time</li><li>Periodically syncing local data with the network 🤝 -&gt; Suppose that You developed COVID App that can work offline and you want to sync data periodically. What Should I use for sync data 😩 <strong>Work Manager: Hi. I am here for you 💪</strong></li></ol><p>You could say that Google already has APIs which is schedule deferrable, asynchronous tasks. JobScheduler, GcmNetworkManager, FirebaseJobDispatcher …… why we need to use of work manager hah!🤬</p><p>Hey, Calm Down 💆‍♂️</p><blockquote>The WorkManager API is a suitable and recommended replacement for all previous Android background scheduling APIs, including <a href="https://developer.android.com/topic/libraries/architecture/workmanager/migrating-fb">FirebaseJobDispatcher</a>, <a href="https://developer.android.com/topic/libraries/architecture/workmanager/migrating-gcm">GcmNetworkManager</a>, and <a href="https://developer.android.com/reference/android/app/job/JobScheduler">Job Scheduler</a>. WorkManager incorporates the features of its predecessors in a modern, consistent API that works back to API level 14 while also being conscious of battery life.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NeyRYZFErHogkJPVHgw-eQ.png" /></figure><ul><li>if API level &gt; 23, Work Manager executes the Job Scheduler</li><li>if API level &lt; 23, Work Manager checks the availability of Google Play Services <em>(because some Chinese devices cannot access Google Play Services</em>😬<em>) </em>if NO, it executes Custom Class that is a mix of Alarm Manager and BroadcastReceiver</li></ul><h4>Let’s do some example 👊</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*LANYk5XT8D_IV7EdjHzydw.jpeg" /></figure><p>For this demo app I thought of 3 different scenarios🤔</p><p>In first scenario, let’s assume that we analyze the user’s emotions with AI with the text we receive from the user. The user enters the text, sends a request to the server. Server analyzes the text and the output displays on the screen. The only constraint to this scenario works correctly is that the Internet is accesible. Let’s take a look to the Classes 🤓</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a03c4ceefd5babb1294b13ec2389879c/href">https://medium.com/media/a03c4ceefd5babb1294b13ec2389879c/href</a></iframe><ol><li>Get Work Manager’s instance</li><li>with Data Builder, you can convey the data to the doWork() function where work manager’s work area. (<em>Note: In the next example, we will use </em><strong><em>workDataOf</em></strong><em> inline function for data conveying. You may realise how data transfer becomes easier</em>)</li><li>Build the constraints. The only constraint is that Internet is accesible</li><li>Run doWork() function in EmotionAnalysisWorker once with OneTimeRequestBuilder. Set the inputData and constraints.</li><li>We are getting close to the final stage. We queued emotionAnalysisWorker to run. 🛫</li><li>Work Manager is a member of Jetpack Libraries and supports Live data allowing you to observe the workManager’s unique id. If the Result returns succeeded, Toast message displays workManager.outputData</li></ol><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3e716b17f8fdb6dbb1a82b94106be8d7/href">https://medium.com/media/3e716b17f8fdb6dbb1a82b94106be8d7/href</a></iframe><ol><li>Request sent in MainActivity runs on EmotionAnalysisWorker which inheriting Worker Abstract class ⚠️ <em>Note : In this function, all processing works on the background thread. If you use kotlin and don’t want to occupy Background thread, you can use kotlin coroutine. All you must do is inherit the class from </em><a href="https://developer.android.com/topic/libraries/architecture/workmanager/advanced/coroutineworker"><em>CoroutineWorker</em></a></li><li>Get the input key sent in MainActivity. This key represents the user’s text.</li><li>Let’s assume you are processing the text and finding emotion. I wrote For-loop, it represents the analyzing stage 😄</li><li>After all the processing, we get emotion output from the getUserEmotion function. There is absolutely no random action. This is the real AI 😝</li><li>Returned Result value</li><li>AI representative, emotion output function</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/298/1*QMJo_NIJ71iu9q_GBMqj_Q.gif" /></figure><p>Finally, someone understood my true feelings 😬</p><blockquote>As you can see from the above gif. The second example is about the Golden Ratio Filter. Let’s say you took a photo, the phone compressed and filtered it. Then you uploaded it to the server for processing, finally, you can download your golden ratio filtered image.</blockquote><p>For this scenario we’ll use one of Work Manager feature Work Chaining. Work Chaining allows to execution parallel and sequential works. Compress and Filter Worker should be parallel, then Upload and Download Worker should be run respectively.</p><p>Let’s start to examine code 🐍</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d8b3d544a6766d4f5c2dd459598823be/href">https://medium.com/media/d8b3d544a6766d4f5c2dd459598823be/href</a></iframe><ol><li>After the get instance, we transfer data to Work Manager using workDataOf inline function. If you remember we used Data.Builder for Emotion Anaylsis. Kotlin makes it easy to write code 🤲</li><li>Set the key for Upload Worker</li><li>We have set the constraint that is Internet is accesible and requires charging for Upload Worker. — Internet must be Unmetered(require Wifi), requires battery not low and storage not low for Download Worker. Upload and Download won’t work until constraints are not satisfy.</li><li>Build the CompressWorker request</li><li>Build the FilterWorker request</li><li>Build UploadWorker request with set the constraint and input data.</li><li>Build DownloadWorker request with set the constraint and input data.</li><li>Create parallel work list that include Compress ve Filter Worker</li><li>We use Work Manager Chaining feature. Begin with Compress and Filter parallel works, then runs Upload worker. Then if upload is complete,runs Download Worker.</li></ol><p>I added a notification to make it clear that it runs in the background even if the application is exited. Notify when worker is finished</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/762/1*ur-BKhFQuZdDRxOS0xgHUQ.gif" /></figure><p>We have 2 constraint for Upload worker. When Internet is connected, it stay in blocked state because it not charging. As soon as we charge the emulator, UploadWorker works even though the application is killed.</p><p>We have 3 constraints for Download Worker. The Battery condition is good, storage is sufficient. But Internet must be on Unmetered(Wifi). Download Worker works as soon as WiFi is turned on.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/281/1*uhv0D5LVDkXifSkVVIk0aA.gif" /></figure><p>Yeah. it works 🥳</p><p>The last example, let’s assume we want to get the user’s log with periodical interval with activated switch. We can cancel this request with deactivated switch. and and and let’s look at the code 👀</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/54ba53757a0e6b77031bcedacfdda83d/href">https://medium.com/media/54ba53757a0e6b77031bcedacfdda83d/href</a></iframe><ol><li>If switch is checked then send periodical request, else cancel it</li><li>Send periodic request with 15 minutes interval</li><li>Cancelling work by tag</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/281/1*M5qVqDgAQipz9i6bnTVlrg.gif" /></figure><p>We’ve come to the end of the blog about Work Manager API that makes it easy to schedule <a href="https://developer.android.com/topic/libraries/architecture/workmanager?gclid=Cj0KCQjw--GFBhDeARIsACH_kdbnH_I75_QpYncTtMIby1pG57hTHxAIQlZ1mYeJKgduyYRvz_XYAC4aAsWuEALw_wcB&amp;gclsrc=aw.ds#deferrable">deferrable, asynchronous tasks</a></p><h4>Don’t forget : The WorkManager API is a suitable and recommended replacement for all previous Android background scheduling APIs</h4><blockquote>source code link : <a href="https://github.com/FPasaoglu/Work-Manager-Example">https://github.com/FPasaoglu/Work-Manager-Example</a></blockquote><p>I hope you enjoy,</p><p>Stay Well :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=63d1b29955d4" width="1" height="1" alt=""><hr><p><a href="https://medium.com/digigeek/android-work-manager-with-an-example-%EF%B8%8F-63d1b29955d4">Android Work Manager with an Example 👷‍♂️</a> was originally published in <a href="https://medium.com/digigeek">DigiGeek</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[CoordinatorLayout’u MotionLayout ile harmanlamak ‍]]></title>
            <link>https://medium.com/digigeek/coordinatorlayoutu-motionlayout-ile-harmanlamak-67c48c7ef9a7?source=rss-b505f71caeba------2</link>
            <guid isPermaLink="false">https://medium.com/p/67c48c7ef9a7</guid>
            <category><![CDATA[animation]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[coordinatorlayout]]></category>
            <category><![CDATA[coordinator]]></category>
            <dc:creator><![CDATA[Furkan Paşaoğlu]]></dc:creator>
            <pubDate>Thu, 18 Feb 2021 10:11:20 GMT</pubDate>
            <atom:updated>2021-11-11T09:04:06.251Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hiXliz1dGpb_NhqF78JHJw.png" /><figcaption>Biraz CoordinatorLayout, biraz MotionLayout ve iyi olan her şey…</figcaption></figure><p>Merhabalar, bugünki yazımızda Android geliştiriciler olarak çoğu kez tek başına kullandığımız iki layout’u aynı tasarımda kullanmayı öğreneceğiz. CoordinatorLayout’un scrollFlag özelliğinden yararlanacak, MotionLayout’un animasyon geçişleri ile uygulamaya ayrı bir hava katacağız. Sonucunda aşağıdaki gibi bir sonuç elde edeceğiz 👇</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/320/1*xace_WUGVME7kM3BFbo82w.gif" /></figure><blockquote>Bu yazımda iki layout sınıfının ne olduğundan bahsetmeyeceğim. Yazının başlığında belirtildiği üzere burada işimiz bu layoutları harmanlamak 👨‍🍳</blockquote><blockquote>Bkz: <a href="https://developer.android.com/reference/androidx/coordinatorlayout/widget/CoordinatorLayout">CoordinatorLayout</a> 👈 👉 <a href="https://medium.com/digigeek/learn-motionlayout-step-by-step-example-1-layoutdescription-keyframeset-keyattribute-e1353d764836">MotionLayout</a></blockquote><h3>Haydi Kod Zamanı 🕺</h3><p>Component Tree inceleyerek başlayalım.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/506/1*7L1D7DDC0f6BNI5nvOFIDQ.png" /></figure><p>CoordinatorLayout’un parent view olduğu, AppBarLayout ve NestedScrollView ‘in ise child view olduğu bir yapı oluşturuldu.</p><p>CoordinatorLayout, NestedScrollView içerisinde yapılan scroll işleminin haberini AppBarLayout’a iletir. AppBarLayout da scrollFlagler aracılığıyla layout tasarımına ayar çeker.</p><p>Activity_main.xml kodlarının tamamını paylaşıyorum ⬇️ ama kodumuzu bölerek inceleyecek ve nasıl bir yapı oluşturduk birlikte anlayacağız 💪</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2039a7837956599dc017c78780ebe5ec/href">https://medium.com/media/2039a7837956599dc017c78780ebe5ec/href</a></iframe><pre>&lt;com.google.android.material.appbar.AppBarLayout<br>    android:id=&quot;@+id/appbar_layout&quot;<br>    android:layout_width=&quot;match_parent&quot;<br>    <strong>android:layout_height=&quot;@dimen/app_bar_height&quot;</strong><br>    android:theme=&quot;@style/AppTheme.AppBarOverlay&quot;&gt;</pre><p>CoordinatorLayout altındaki AppBarLayout’u inceleyerek başlayalım. app_bar_height = 200 dp olarak belirledim. Bu bilgi dimen.xml içerisinde yer alıyor. Bu layout, uygulama açılış ekranında 200 dp yüksekliğinde bir appBarLayout çizdirilmesini ve scroll işlemi sırasında bu layout’un yukarı doğru küçülmesini sağlayacaktır.</p><pre>&lt;androidx.constraintlayout.motion.widget.MotionLayout<br>    android:id=&quot;@+id/motion_layout&quot;<br>    android:layout_width=&quot;match_parent&quot;<br>    android:layout_height=&quot;match_parent&quot;<br>    <strong>android:minHeight=&quot;@dimen/layout_min_height&quot;</strong><br>  <strong>  app:layoutDescription=&quot;@xml/activity_main_scene&quot;</strong><br>    <strong>app:layout_scrollFlags=&quot;scroll|exitUntilCollapsed&quot;&gt;</strong><br><br>    &lt;ImageView<br>        android:id=&quot;@+id/background&quot;<br>        android:layout_width=&quot;match_parent&quot;<br>        android:layout_height=&quot;match_parent&quot;<br>        android:scaleType=&quot;centerCrop&quot;<br>        android:contentDescription=&quot;@string/background_desc&quot;<br>        app:srcCompat=&quot;@drawable/digital&quot; /&gt;<br><br>    &lt;ImageView<br>        android:id=&quot;@+id/icon_digigeek&quot;<br>        android:contentDescription=&quot;@string/icon_digigeek_desc&quot;<br>        android:layout_width=&quot;wrap_content&quot;<br>        android:layout_height=&quot;wrap_content&quot;<br>        android:src=&quot;@drawable/ic_digigeek&quot; /&gt;<br><br>    &lt;TextView<br>        android:id=&quot;@+id/textview_digigeek&quot;<br>        android:layout_width=&quot;wrap_content&quot;<br>        android:layout_height=&quot;wrap_content&quot;<br>        android:alpha=&quot;0.0&quot;<br>        android:contentDescription=&quot;@string/digigeek&quot;<br>        android:text=&quot;@string/digigeek&quot;<br>        android:textSize=&quot;@dimen/text_size_medium&quot; /&gt;<br><br>&lt;/androidx.constraintlayout.motion.widget.MotionLayout&gt;</pre><p>Sırada MotionLayout var. Burada <strong>minHeight attribute </strong>önemli, minimum height’ı belirliyoruz. AppBarLayout’u sınırlıyoruz ve belirlediğimiz minHeight’a kadar collapse etmesini(yukarı doğru küçülmesini) ve daha fazla küçülememesini sağlıyoruz. layout_min_height = 80dp olarak belirledim. AppBarLayout height’ı 200 dp idi. Bu da demek oluyor ki 200dp ile çizdirilen tasarım, scroll edildikçe 80 dp’e kadar collapse edilebilecek.</p><p><strong>layoutDescription</strong> alanı bir diğer önemli attribute. Bu da MotionLayout için MotionScene tanımladığımız alan. Bu dosyaya <em>activity_main_scene</em> içerisinde erişebileceğini ve bu dosyada yazan kod parçacıklarına göre animasyon hünerlerini gösterebileceğini belirtiriz.</p><p><strong>ScrollFlags</strong> , CoordinatorLayout tarafından bize sağlanan attribute, scroll sonrası MotionLayout’un nasıl davranması gerektiğini belirtiyor.</p><p><em>Scroll</em> : Text içerisinde kaydırma yapılması durumunda MotionLayout’un da aynı yönde kaydırılmasını sağlar. Bu flag ile ekran kaydırma özelliği aktif oluyor diyebiliriz.</p><p><em>ExitUntilCollapsed</em> : NestedScrollView aşağı doğru kaydırıldığında MotionLayout ne kadar collapse edilebiliyorsa o kadar et. MotionLayout içerisinde minHeight vermemizdeki amaç da bu. minHeight’tan sonrasını collapse edemiyor yani yukarı doğru küçülemiyor. Ekranda DigiGeek yazan toolbar sabit kalıyor.</p><p>ScrollFlags özellikleri aralarındaki farkı detaylı incelemek için 👉 <a href="https://blog.mindorks.com/using-coordinator-layout-in-android"><strong>tıkla</strong></a><strong> 👈</strong></p><pre>&lt;androidx.core.widget.NestedScrollView<br>    android:id=&quot;@+id/nested_scroll_view&quot;<br>    android:layout_width=&quot;match_parent&quot;<br>    android:layout_height=&quot;match_parent&quot;<br> <strong>app:layout_behavior=&quot;com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior&quot;&gt;</strong><br><br>    &lt;TextView<br>        android:id=&quot;@+id/textview_desc&quot;<br>        android:layout_width=&quot;wrap_content&quot;<br>        android:layout_height=&quot;wrap_content&quot;<br>        android:text=&quot;@string/long_text&quot; /&gt;<br><br><br>&lt;/androidx.core.widget.NestedScrollView&gt;</pre><p>NestedScrollView bildiğiniz gibi ama çok önemli bir fark var burada. Scroll edildiğinde AppBarLayout’un haberdar olmasını sağlamak için layout_behaviour ekliyoruz ve parametre olarak “com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior” veriyoruz.</p><p>Evet, activity_main.xml içerisindeki tanımları birlikte inceledik. Şimdi MotionLayout içerisinde app:layoutDescription alanına tanımladığımız ve ekranda animasyon geçişlerini yönettiğimiz activity_main_scene.xml kodlarını inceleyelim</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*mMMb2HLOU783cOI9jRIjZg.gif" /></figure><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9fadb18d48def1c158135bcbbba21f87/href">https://medium.com/media/9fadb18d48def1c158135bcbbba21f87/href</a></iframe><p>2 adet ConstraintSet’imiz var , @id/<strong>start</strong> uygulamanın açılışını , @id/<strong>end</strong> ise kaydırma yapıldıkça nasıl bir kapanış olacağını belirtiyor.</p><p>&lt;Transitions&gt; içerisinde &lt;KeyAttribute&gt; ve &lt;KeyPosition&gt; larımız var. Burada framePosition vererek ek birkaç özellik ekledim. Örneğin</p><ul><li>DigiGeek Icon’un Y eksenini %60 oranında arttırmak, böylece havaya yükseliyormuş izlenimi vermek.</li><li>Arkaplanda yer alan resmin alpha değerini 0.0 vererek, animasyonun 100.Frame’i esnasında arkaplan resmini invisible yapmak.</li><li>DigiGeek Text’ini 85.frame’den sonra visible olmasını ve X ekseni etrafında 2 defa dönmesini sağlamak…..</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/784/1*Q820OnKPqCzUBZ7YQX1_FA.png" /></figure><p>Tamam, süper. CoordinatorLayout ve MotionLayout’u harmanlayarak hayalimizdeki tasarımı kodlayabildik. Şimdi kodumuzu çalıştırıp test etme vakti...</p><p>Evet, uygulama build oldu. Test ediyoruz ve görüyoruz ki text scroll edilmesi AppBarLayout’un collapse edilmesini sağladı ama yazmış olduğumuz animasyonların hiçbiri çalışmadı 🤔</p><p>Kodlarımızı tekrardan inceliyor ve fark ediyoruz ki çalışmaması çok normal. Çünkü Scroll işleminin bilgisi NestedScrollView ve AppBarLayout arasında kalmakta. MotionLayout’un bu işlemden haberi olmamakta. MainActivity içerisinde yazacağımız fonksiyon ile motionlayout’u bu bilgiden mahrum bırakmayacağız.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b4edd3a948bb72a9b46c3f867350d581/href">https://medium.com/media/b4edd3a948bb72a9b46c3f867350d581/href</a></iframe><p>AppBarLayout için yazmış olduğumuz listener, scroll anında position bilgisini motinLayout.progress’e eşitlemektedir. Böylece MotionLayout, scroll bilgisini elde edecek ve animasyon başarılı bir şekilde çalışacaktır.</p><p>Tekrardan çalıştırıyor, test ediyor ve başarılı şekilde çalıştığını görüyoruz 🎉</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*BTZ8ed7zlqbPqH-Wm5uUoQ.gif" /></figure><blockquote>Umarım bu tasarım sizin için faydalı olmuştur. Bu yazıda MotionLayout’u CoordinatorLayout ile harmanladık. Siz ihtiyacınıza göre farklı tarifler uygulayabilirsiniz. MotionLayout ile yapabilecekleriniz sınırı yok, asıl olay hayal gücünüzde ⚡️</blockquote><blockquote>Sağlıcakla kalın…</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=67c48c7ef9a7" width="1" height="1" alt=""><hr><p><a href="https://medium.com/digigeek/coordinatorlayoutu-motionlayout-ile-harmanlamak-67c48c7ef9a7">CoordinatorLayout’u MotionLayout ile harmanlamak 👨‍🍳</a> was originally published in <a href="https://medium.com/digigeek">DigiGeek</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Kotlin Synthetic: Ben giderim adım kalır, dostlar beni hatırlasın]]></title>
            <link>https://medium.com/digigeek/kotlin-synthetic-ben-giderim-ad%C4%B1m-kal%C4%B1r-dostlar-beni-hat%C4%B1rlas%C4%B1n-3df5f67f92c1?source=rss-b505f71caeba------2</link>
            <guid isPermaLink="false">https://medium.com/p/3df5f67f92c1</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[mvvm-databinding]]></category>
            <category><![CDATA[kotlin-synthetic]]></category>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[view-binding]]></category>
            <dc:creator><![CDATA[Furkan Paşaoğlu]]></dc:creator>
            <pubDate>Fri, 25 Dec 2020 08:17:26 GMT</pubDate>
            <atom:updated>2021-01-26T11:08:52.267Z</atom:updated>
            <content:encoded><![CDATA[<p>Kotlin, 1.4.20.M2 sürümü ile birlikte Kotlin Synthetic’ i tedavülden kaldırdı.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EVTmMRIpw2HcFTwCHrmCXA.jpeg" /><figcaption>ref [<a href="https://www.techyourchance.com/asynctask-deprecated/">https://www.techyourchance.com</a>]</figcaption></figure><p>Kolay kullanımı ve kod okunabilirliğini arttırması ile gönüllerde taht kuran kotlin Synthetic deprecated olmasının ardında birkaç neden yatmakta. Bu yazımda Kotlin Synthetic avantaj ve dezavantajlarından bahsedeceğiz ve ve ve alternatifleri FindViewById, DataBinding ve ViewBinding arasında karşılaştırma ve örnekleme yapacağız. Hiç vakit kaybetmeden hemen başlayalım 👊</p><h3>Kotlin Synthetics — Rahmetli 👼</h3><p>Biz onu type-safety özelliği ve kolay kullanımı ile sevdik ama Kotlin Synhetic ne yaptı ne etti kendini bir türlü Android’e sevdiremedi. Tabi Google’ın Synthetic’i desteklememesinin ve sonunda Kotlin tarafından kaldırmasının nedenleri var. Hemen inceleyelim.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Cd2DflY1SXkwCq9cVvwiUg.png" /></figure><ul><li><strong>ID’e direkt erişim </strong>— Yazmış olduğun xml id’sine sınıfında erişim sağlayabiliyorken, farklı sınıflara ait xml id’lerine de erişebilirsin, bu da nullPointerException 😧</li><li>Sadece <strong>Kotlin</strong> programlama dilini destekliyor olması 👀</li><li><strong>Null-Safe değil </strong>⚠️ xml oluşmadığında veya destroy olduğunda veya farklı bir xml’den erişmeye çalışırsan, booomm💥 💥</li></ul><p>.</p><p>Kotlin Synthetic, deprecate oldu dememe bakmayın. Aslında Android Kotlin Extensions Gradle plugin tedavülden kalkıyor ve bu da Synthetic ve Parcelize özelliğini kullanamayacak olmamız demek.</p><blockquote>Merak etmeyin, size kötü bir haber daha vermeyeceğim. Parcelize özelliğini standalone plugin: kotlin-parcelize ile kullanabiliyor olacağız.</blockquote><p>Örnek bir uygulama ile bilgilerimizi pekiştirek. Çok basit bir uygulama üzerinde farkları görelim. Bir zikirmatik uygulaması düşünelim. Count tuşuna basınca sayı artan, Reset tuşuna basınca sayıyı sıfırlanan.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*cs5UgiYDwhhj03YsaO-jSg.gif" /></figure><p>Biz bu uygulamayı Synthetic kullanarak yapsaydık nasıl yapardık ? Tasarım, zikirmatik fotosu üzerine bağlanan buttonCount, buttonReset, textViewZikir layoutlarına dayanır 👇</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b175479525538cff77c805bb82666b3c/href">https://medium.com/media/b175479525538cff77c805bb82666b3c/href</a></iframe><p>Activity_main’imizde id’sini vermiş olduğumuz bilgilere nasıl erişiyoruz peki ?</p><p>Çok kolay efenimm 👇</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a4e33fd5931652af0712d8300709213a/href">https://medium.com/media/a4e33fd5931652af0712d8300709213a/href</a></iframe><p>kotlinx.android.synthetic.main.activity_main.* kütüphanesini import ettikten sonra id’lere direkt erişim sağlar. buttonCount ve buttonReset clickListener’ların ne kadar temiz durduğuna bakın. Bu bir yazılımcı için kolaylık sağlarken, aynı isimli bir farklı id’e erişim olabileceğinden Null Safety özelliğini yitiriyor 😲</p><p>Uygulamada ViewModel-Live Data kullanarak fonksiyonlarımı yazdım. Konu hakkında bilginiz yoksa 👉 <a href="https://developer.android.com/topic/libraries/architecture/viewmodel?gclid=Cj0KCQiAlZH_BRCgARIsAAZHSBlqbcb_nbLT-Wkmt6R47onvGhZvJ_bmQqU903z-kNqysPP88ktgCDYaAsSlEALw_wcB&amp;gclsrc=aw.ds"><strong>Tutorial</strong></a></p><p>observe fonksiyonum ile viewModel.startCount değişikliğinde textViewZikir.text güncel değeri alır. textViewZikir’in id’sine direkt erişebildiğimize dikkat 🗽</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/05dbee9c037514dadb5963cc5aa17c9b/href">https://medium.com/media/05dbee9c037514dadb5963cc5aa17c9b/href</a></iframe><p>Kotlin’in en büyük avantajlarından biriydi Synthetic… Bu sana veda ederken son bakış 👽 , son gülücük ….😄</p><h4>Peki Kotlin Synthetic kullanmayacaksam ne kullanmalıyım ??</h4><ul><li>findViewById</li><li>Data Binding</li><li>View Binding</li></ul><h3>FindViewById — Geçmişe yolculuk 🔙</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/460/1*MpYt5KJ0pdpdWG5Re1v_bA.gif" /></figure><blockquote>En eski ve geleneksel yöntem , bu yazıyı okuyan herkes tarafından View tarafına nasıl erişildiği biliniyor diye düşünüyorum. Bu karşılaştırmayı daha çok findViewById’nin ne yapamadığından bahsedeceğim.</blockquote><ul><li>Kod okunabilirliği düşük , her View için Id atanması gerek.</li></ul><pre>var buttonCount: Button = findViewById&lt;Button&gt;(R.id.<em>buttonCount</em>)<br>var buttonReset: Button = findViewById&lt;Button&gt;(R.id.<em>buttonReset</em>)</pre><ul><li>Type Safety değil bu da demek oluyor ki yukarıdaki kodu aşağıdaki gibi yazarsam bana herhangi bir uyarı vermeyecek ve uygulamam crash olacak.</li></ul><pre>var buttonCount = findViewById&lt;TextView&gt;(R.id.<em>buttonCount</em>)</pre><ul><li>findViewById, her çağırıldığında <a href="https://developer.android.com/topic/performance/rendering/optimizing-view-hierarchies"><em>View Hiyerarşisi</em></a><em>’</em>nde işlem görür bu da performans için maliyettir.</li></ul><p>findViewById kolaylaştımak için ButterKnife gibi kütüphaneler var…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/513/1*_gSaiW1mJpjb7r5ojAYw1g.png" /></figure><p><strong><em>VARDI…</em></strong></p><p>Ölenle ölünmez diyor ve ben ana odağı kaybetmemek adına buraları hızlı geçiyorum.</p><h3>Data Binding vs View Binding</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/937/1*x-UxhyCpctOG0Fqu8s4ZMg.jpeg" /></figure><ul><li>.</li></ul><p><strong>-Sen daha Binding’in iyisi nasıl olur onu bilmiyorsun !!!</strong></p><p><strong>+ Data ile olurrrrrr !!!!</strong></p><p><strong>-Nahhh sanaa View ile olur !!!!</strong></p><p><strong>+Dataaaaaaaaaaa</strong></p><p><strong>-Viewwwwwwwww</strong></p><p>👊 👊 👊</p><p>😡 😡 😡 😡</p><p>Gelin bu Binding işini tatlıya bağlayalım. Ben size iki yöntemin de artı ve eksiklerini yazayım, seçimi siz yapın ⏬</p><h3>Data Binding</h3><p>Verilerin xml ile direkt olarak haberleşmesine dayanır. Kısaca nasıl kullanıldığına bakalım. Kullanabilmek için build.gradle(module) içerisinde dataBinding enable ediyoruz.</p><pre>android { <br>  buildFeatures {     <br>     dataBinding true<br>  }<br>}</pre><blockquote>⚠️ Ardından DataBinding tarafından generate edilmesini istediğin her layout’u &lt;layout&gt; tag’i arasına alıyorsun. Burada xmlnamespace’lerin &lt;layout&gt; tag’i içerisine alındığına dikkat et.</blockquote><p>Dilersen xml’e &lt;data&gt; tagleri arasında veri ekleyebilirsin. Ben viewModel’imi variable olarak tanımladım.</p><pre>&lt;layout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;<br>    xmlns:app=&quot;http://schemas.android.com/apk/res-auto&quot;<br>    xmlns:tools=&quot;http://schemas.android.com/tools&quot;&gt;</pre><pre>    &lt;data&gt;<br>        &lt;variable<br>            name=&quot;mViewModel&quot;<br>            type=&quot;com.example.databindingvsviewbinding.MyViewModel&quot;         /&gt;<br>    &lt;/data&gt;<br></pre><pre>    &lt;androidx.constraintlayout.widget.ConstraintLayout<br>        android:layout_width=&quot;match_parent&quot;<br>        android:layout_height=&quot;match_parent&quot;</pre><pre>.<br>                         .<br>                         .<br>                         .<br>&lt;/layout&gt;</pre><p>Tüm işlemlerimi viewModel sınıfımda yapacağım. ViewModel sınıfım 👇</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f9a93e6887c05f8853fb5ce26f381899/href">https://medium.com/media/f9a93e6887c05f8853fb5ce26f381899/href</a></iframe><p>zikirCount ve zikirReset’i MyViewModel sınıfıma yazarak, Xml’de variable olarak verdiğim viewModel’de erişim sağlayabileceğim. onClick metodunu xml içerisinde yapacağım anlayacağın.</p><pre>&lt;Button<br>    android:id=&quot;@+id/buttonCount&quot;<br>    .<br>    .<br>    .<br>    <strong>android:onClick=&quot;@{ _ -&gt; mViewModel.zikirCount()}&quot;</strong><br>    .<br>    .<br>    .<br>/&gt;</pre><blockquote>buttonCount’a tıklandığı vakit viewModel içerisinde zikirCount() fonksiyonu işlem görür</blockquote><p>buttonReset için de mViewModel.zikirReset() fonksiyonu çağırıldı. TextView nasıl oluyor onu inceleyeyim</p><pre>&lt;TextView<br>    android:id=&quot;@+id/textViewZikir&quot;<br>    .<br>    .<br>    .<br>    <strong>android:text=&quot;@{mViewModel.startCount.toString()}&quot;</strong><br>    .<br>    .<br>    .<br>/&gt;</pre><p>android:text — &gt; viewModel’imizden startCount değerini verdik String tipine dönüştürerek tabiki 📄</p><p>MainActivity’imizde nasıl bir işlem yapacağız ??</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4fc9aa0fd416d71f715826eac2e4e6a5/href">https://medium.com/media/4fc9aa0fd416d71f715826eac2e4e6a5/href</a></iframe><p>DataBindingUtil kullanarak xml’i bağlıyoruz. binding’in &lt;data&gt; ‘sında variable olarak tanımladığımız mViewModel’i set ediyoruz.</p><p>viewModel ve LiveData ile işlem yaptığımızdan binding.lifeCycleOwner’ı tanımlamayı unutmuyoruz 👌</p><p>Gördüğünüz gibi 2 satır kodla işlemlerimizi gerçekleştirdik. Çokk temizzzz</p><p><strong>Uzun lafın kısası</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/645/1*DOto0zyrq4O5_MpXNGRgpw.png" /></figure><ul><li>DataBinding tarafından otomatik generate edilen ActivityMainBinding sınıfı sayesinde hem <strong>Null Safe </strong>hem de <strong>Type Safe</strong></li><li><strong>Xml’e direkt erişim</strong></li><li><strong>Annotation </strong>kullanımı<strong> </strong>ve <strong>&lt;layout&gt;</strong> tag’i zorunluluğu, yeni sınıf generate edileceği zaman build süresini uzatabiliyor 😭</li><li>Temiz kodlama prensibine pozitif yönde ciddi bir etki</li></ul><h3>View Binding</h3><blockquote>&lt;layout&gt; tag’i koymak istemiyor musunuz ? 😮</blockquote><blockquote>Build time süresi sizin için daha mı önemli ? 😋</blockquote><blockquote>Binding referansı ile veriye erişsem yeter mi diyorsunuz ? 🙋‍♂</blockquote><p>Tam yerindesiniz. Data Binding üzerine +1 tl farkla View Binding ister misiniz ??</p><blockquote>View Binding, Data Binding’in build etki süresini azaltmak amacıyla tasarlanmıştır.</blockquote><p>Gradle’da enable et</p><pre>android { <br>  buildFeatures {     <br>     viewBinding true<br>  }<br>}</pre><p>DataBindingUtil kullanmadan, veri ActivityMainBinding ile inflate edilebilir. setContentView’e binding.root’tan view veriyoruz. Daha sonradan verilere binding referans’ı vererek erişiyoruz 👇</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/00a03b523284c29ea67d1a5065d275eb/href">https://medium.com/media/00a03b523284c29ea67d1a5065d275eb/href</a></iframe><p><strong>⚠️ ÇOOK ÖNEMLİİ BİR UYARI ⚠️</strong></p><p>ViewBinding, Fragment ile kullanımı Activity’den farklıdır ve onDestroy() esnasında binding=null eşitlenmelidir. Aksi takdirde <strong>MEMORY LEAK</strong></p><p>Yukarıdaki örnekte Activit’de binding kullandın kardeşş, onu neden null’a eşitlemedin ???</p><p>Şöyle düşünelim -&gt; Fragment A ve B , aynı FragmentManager’ı kullanan iki Fragment olsun. Fragment A’dan B’e geçiş yaptığında onDestroy çalışır iyi hoş ama BackStack’de Fragment A instance’ı canlı kalır yani bizim binding de canlı kalacaktır.</p><p>Memory Leak’e sebep olmaması için <strong>Google Reis</strong> ; “Yav kardeş çok bir şey istemiyoz, bi null’a eşitlicen nolur nolmaz” önerisinde bulunuyor.</p><blockquote>Her fragment için binding objesini null’a eşitlemekle uğraşmak istemiyorsan, BaseFragment oluşturabilirsin ve onDestroy içerisinde binding=null işlemini gerçekleştirebilirsin 👉 <a href="https://stackoverflow.com/questions/64819181/how-to-make-basefragment-with-view-binding"><strong>ViewBinding için Base Fragment nasıl oluşturulur ?</strong></a></blockquote><h4><strong>Uzun lafın kısası</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*1fqvXIjpSyxboZQrm_WV_A.gif" /><figcaption>Çek tulumbayı, çek çek çek….</figcaption></figure><ul><li>Hem<strong> Type Safe</strong></li><li>Hem <strong>Null Safe</strong></li><li><strong>Build Time</strong>’ı etkilemiyor</li><li>Hem <strong>Java</strong> hem <strong>Kotlin </strong>destekliyor</li><li><strong>Temiz kod</strong> prensibine uyuyor.</li><li>Fakat <strong>XML’e</strong> direkt erişimi yok.</li></ul><h3>Özet</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IiDcuw8lBu9oX7qRInxRdQ.png" /><figcaption>ref [<a href="https://wajahatkarim.com/">https://wajahatkarim.com/</a>]</figcaption></figure><p>Anlattığım her şeyi özetleyen fotoğraf , daha ben konuşmuyorum. Kendimi veda konuşmamı yapmak üzere sahneye davet ediyorum 👏</p><h3>Veda Konuşması</h3><p>Evetttttt…..</p><p>Kotlin Synthetic , FindViewById , Data Binding ve View Binding karşılaştırması yaptığım yazımın sonuna gelmiş bulunmaktasınız.</p><p>Vaktinizi ayırıp okuduğunuz için teşekkür ederim, umarım faydalı olmuştur. Sağlıcakla kalın</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3df5f67f92c1" width="1" height="1" alt=""><hr><p><a href="https://medium.com/digigeek/kotlin-synthetic-ben-giderim-ad%C4%B1m-kal%C4%B1r-dostlar-beni-hat%C4%B1rlas%C4%B1n-3df5f67f92c1">Kotlin Synthetic: Ben giderim adım kalır, dostlar beni hatırlasın</a> was originally published in <a href="https://medium.com/digigeek">DigiGeek</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[GOOGLE COLAB VE TENSORFLOW KULLANARAK KENDİ NESNENİ TASARLA]]></title>
            <link>https://medium.com/deep-learning-turkiye/google-colab-ve-tensorflow-kullanarak-kendi%CC%87-nesneni%CC%87-tasarla-b089fc3ae5bb?source=rss-b505f71caeba------2</link>
            <guid isPermaLink="false">https://medium.com/p/b089fc3ae5bb</guid>
            <category><![CDATA[object-detection-api]]></category>
            <category><![CDATA[tensorflow]]></category>
            <category><![CDATA[object-detection]]></category>
            <category><![CDATA[computer-vision]]></category>
            <category><![CDATA[google-colab]]></category>
            <dc:creator><![CDATA[Furkan Paşaoğlu]]></dc:creator>
            <pubDate>Sun, 17 May 2020 12:03:47 GMT</pubDate>
            <atom:updated>2021-03-24T09:25:34.100Z</atom:updated>
            <content:encoded><![CDATA[<p><a href="https://colab.research.google.com/"><strong>Google Colaboratory</strong></a><strong> </strong>üzerinde <a href="https://github.com/tensorflow/models/tree/master/research/object_detection"><strong>Tensorflow Object Detection API</strong></a> kullanarak kendi nesnemizi tasarlayacak ve kullanacağız. Örnek bir nesne olarak ben <strong>lahmacun</strong>u seçtim.Siz istediğiniz nesneyi aynı şekilde eğitebilirsiniz. Haydi biraz lahmacun eğitelim 🔫</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*50Lz9ZKr8IAN9YIIzkmiKg.jpeg" /></figure><p>Derin Öğrenme teknolojileri ve nesne tanıma ile ilgilenmiş olanlar bilir , en zahmetli iş nesnelerin etiketlenmesi ve nesnelerin eğitim sürecidir. Henüz etiket işinin bir çözümü yok ama yüksek hızlı ekran kartlarını kullanarak eğitim süresini oldukça azaltabiliriz.</p><p>Tabi elimizde yüksek hızlı bir ekran kartı yok (En azından benim için). Bu konuda bizim imdadımıza <strong>Google Colab</strong> yetişiyor. Colab, yüksek hızlı ekran kartı olan <a href="https://www.nvidia.com/en-gb/data-center/tesla-k80/">Nvidia Tesla K80</a> i ücretsiz olarak kullanımımıza sunuyor.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*c33tQqN3R5QEV6PwitCmqg.jpeg" /></figure><p>Anlaşılacağı üzere eğitimimizi COLAB üzerinde yapacağız .</p><p>Sıfırdan veri modeli oluşturmak oldukça maliyetli bir işlemdir. Sıfırdan veri modeli oluşturmak yerine önceden eğitilmiş modelleri kendi verisetimizde kullanabiliriz. Bu modelleri kullanarak kendi datasetimizde veri eğitimi gerçekleştirebiliriz. Bu sayede hem daha kısa sürede hem de daha az veriyle kişisel bilgisayarlarda eğitim gerçekleştirebiliriz.</p><p>Google Reis bu konuda tekrardan devreye giriyor ve karşınızda <strong>Tensorflow Object Detection API</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uhDysFHBEgnGI78IcSrmkA.gif" /></figure><p>TensorFlow’un üzerine inşa edilmiş ve nesne algılama modellerinin oluşturulmasını, eğitilmesini ve dağıtılmasını kolaylaştıran açık kaynaklı bir framework olan bu API, COCO datasetini ki bu dataset 330.000 resim ile eğitilmiş ve 80 adet nesneyi tanıyabilen bir veri kümesidir.Bu API ile COCO dataseti üzerinde eğitilen modeli kendi veri setimiz için kullacağız.Bu teknolojiye 👉 <a href="https://en.wikipedia.org/wiki/Transfer_learning"><strong>transfer learning</strong></a><strong> </strong>👈 denir.</p><p>Artık kodlama aşamasına geçebiliriz.</p><p><strong>Güzergahımız 🚂</strong></p><ol><li>Gerekli kurulumlar</li><li>Veri Toplama</li><li>Verileri Etiketleme</li><li>Eğitim için TFRecords Dosyaları Oluşturma</li><li>Eğitim Yapılandırma</li><li>Model Eğitimi</li><li>Inference Graph Dosyası Elde Etme</li><li>Model Testi</li></ol><p>⚠️ Güzergahımızdaki ilk 4 adım TENSORFLOW ile kişisel bilgisayarda olacaktır. Sonraki adımlar COLAB üzerinde gerçekleştirilecektir.⚠️</p><h4>GEREKLİ KURULUMLAR</h4><p>Bu kurulumları yapmadan önce ANACONDA kurmanız gerekmektedir. Kurulum için <a href="https://medium.com/@kamilkaplnn/python-ve-anaconda-kurulumu-b8931bd80e64">makaleyi</a> 📗 inceleyebilirsin.</p><p>ANACONDA kurulumu tamamlandıktan sonra <em>Virtual Environment</em> oluşturuyoruz. Sürümlerin benim yazdığım gibi olmasına dikkat edin. Yoksa sürüm hatası alabilirsiniz ⚠️</p><pre>conda create -n virtualTf python=3.7</pre><p>virtualTf adında oluşturduğumuz Virtual Environment aktif ediyoruz.</p><pre>conda activate virtualTf</pre><h4><strong>1.2 Kütüphanelerin kurulumu</strong></h4><pre>pip install tensorflow==1.15.0<br>conda install -c anaconda protobuf<br>pip install pillow<br>pip install lxml<br>pip install jupyter<br>pip install matplotlib<br>pip install pandas<br>pip install opencv-python</pre><h4><strong>1.3 Tensorflow Modelleri Deposunu Klonla</strong></h4><pre>git clone <a href="https://github.com/tensorflow/models.git">https://github.com/tensorflow/models.git</a></pre><h4><strong>1.4 Ortam Ayarları</strong></h4><p>İndirilen Tensorflow model dosyamızda research dosyası içerisine giriyoruz.</p><pre>cd models/research</pre><p><strong>Protobuf Derlenmesi</strong></p><p>Tensorflow Object Detection API’si model ve eğitim parametrelerini yapılandırmak için Protobuf’ları kullanır. Protobuf, gerçek ismi Protocol Buffers olan, Google’ın kendi içindeki veri iletişiminde de bolca kullandığı bir veri transfer protokolüdür.Protobuf Çerçeve kullanılmadan önce, Protobuf kütüphaneleri derlenmelidir.</p><pre># models/research/ klasöründe <br>protoc object_detection/protos/*.proto --python_out=.</pre><p><strong>PYTHONPATH</strong></p><p>PYTHONPATH, Python’un modülleri ve paketleri arayacağı ek dizinler eklemek için ayarlayabileceğiniz bir ortam değişkenidir.</p><pre># models/research/ klasöründe<br>export PYTHONPATH=$PYTHONPATH:`pwd`:`pwd`/slim</pre><blockquote>NOT : Terminali her yeniden başlatmanızda PYTHONPATH vermeniz gerekmektedir. Terminal her açıldığında otomatik olarak PYTHONPATH verilmesini istiyorsanız ~/.bashrc dosyasına yukarıdaki kod parçasında ‘pwd’ yazan yerlere model/research dosya yolunu vererek ekleyebilirsiniz.</blockquote><p><strong>Object Detection Kurulumu</strong></p><pre># models/research/ klasöründe<br>sudo python setup.py build<br>sudo python setup.py install</pre><p><strong>Test</strong></p><p>Tensorflow Object Detection API kurulumunun doğru bir şekilde gerçekleştiğini test etmek için kodu çalıştırın.</p><pre># models/research/ klasöründe<br>python object_detection/builders/model_builder_test.py</pre><p>Eğer çıktı şu şekilde ise bir sonraki adıma geçebiliriz.</p><pre>----------------------------------------------------------------------<br>Ran 17 tests in 0.278s</pre><pre>OK (skipped=1)</pre><h4>VERİ TOPLAMA</h4><p><strong>2.1 </strong>Google Chrome Tarayıcı içerisinde Download All Image adlı uzantıyı kuralım. Bu uzantı sayesinde Google Görseller içerisinde bulunan görselleri indirebileceğiz.</p><p><strong>2.2</strong> Google ‘da Lahmacun resimlerini arattım , sağ üstte ZIP adında gelen bir eklentiye basıldığında ekranda gözüken tüm resimleri indiriyor olacaktır.</p><p>⚠️Daha fazla resim elde etmek için Google Görseller sonunda daha fazla gönderi yükle butonuna basmayı unutmayın ⚠️</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jDwzT8vM86XJa18CaSpwQw.png" /></figure><blockquote>En az 300 fotoğraf indirmeniz veri modelinin doğru şekilde çalışması için yeterli olacaktır.</blockquote><blockquote>Resimlerde tekrar eden ve aradığımız nesneyle alakalı olmayan resimleri silmeyi unutmayın</blockquote><h4>VERİ ETİKETLEME</h4><p>Şimdi modelimizde bazı işlemler yapabilmek adına github hesabımda bulunan dosyaları indirin.</p><pre>git clone <a href="https://github.com/FPasaoglu/CustomObjectDetector.git">https://github.com/FPasaoglu/CustomObjectDetector.git</a></pre><p>Klonladığınız klasörün içindeki dosyaları models/research/object_detection klasörüne atınız.</p><p>object_detection klasöründe şu şekilde gözükmelidir.</p><pre>├── ...<br>    ├── data                 <br>    ├── images<br>    │   ├── train<br>    │   ├── test<br>    ├── utils<br>    │ ├── label_map_util.py<br>    │ ├── visualization_utils.py<br>    ├── generate_tfrecord.py<br>    └── object-detection.pbtxt<br>    └── resizer.py<br>    └── xml_to_csv.py<br>    └── Object_detection_image.py<br>    └── train.py</pre><blockquote>İndirdiğiniz resimlerin %80 ‘ini models/research/object_detection/images/train klasörüne ,</blockquote><blockquote>%20’sini models/research/object_detection/images/test klasörüne atınız.</blockquote><p>Etiketlenecek resimleri train ve test klasörüne attığına göre , şimdi geldik nesne tanımanın en zahmetli aşamasına . Burada her bir resmin etiketleme işlemi yapılacaktır. Bu işlem ile resimleri XML formatını dönüştürüyoruz.</p><p>Bu etiketleme işlemi için <a href="https://github.com/tzutalin/labelImg"><strong>LabelImg</strong></a><strong> </strong>programını indirin ve videoda görüldüğü üzere etiketlemeye başlayın.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*21LHamQ9KHsbGbsWYEaAGA.gif" /></figure><p>Etiketleme işlemi bittikten sonra object_detection klasörü şu şekilde gözükmelidir.</p><pre>├── ...<br>    ├── data                 <br>    ├── images<br>    │       ├── train<br>    │            ├── image1.jpg<br>    │            ├── image1.xml ..<br>    │       ├── test<br>    │            ├── image5.jpg<br>    │            ├── image5.xml ..<br>    ├── generate_tfrecord.py<br>    └── object-detection.pbtxt<br>    └── resizer.py<br>    └── xml_to_csv.py<br>    └── Object_detection_image.py<br>    └── train.py</pre><h4>Eğitim için TFRecords Dosyaları Oluşturma</h4><p>TFRecords , bir modelin eğitimi / testi sırasında gerekli olan tüm verileri toplayan, bireysel birleştirilmiş kompakt bir dosyadır.</p><p>TFRecords oluşturulabilmesi için resimlerin csv dosyasında birleştirilmiş olması lazım.</p><p>Bunun için hesabımdan klonlamış olduğunuz ve içerisinde xml_to_csv.py dosyasını kullanarak resimleri csv’e dönüştürme işlemi yapacağız.</p><blockquote>⚠️Eğer terminali kapatıp açtıysanız tekrardan PYTHONPATH vermeyi unutmayınız. Yoksa hata alırsınız. PYTHONPATH vermek için 1. adıma bakınız.</blockquote><pre>#models/research/object_detection<br>python xml_to_csv.py</pre><p>Bu komut sonucunda iki adet csv dosyamız oluşacaktır. object_detection/images klasörü altında <em>train_labels.csv</em> ve <em>test_labels.csv</em></p><p>TFRecords oluşturmadan önce generate_tfrecord.py dosyasında değişiklik yapmamız gerekmektedir.</p><pre># TO-DO replace this with label map<br>def class_text_to_int(row_label):<br>    if row_label == &#39;lahmacun&#39;:<br>        return 1<br>    else:<br>        None</pre><p>generate_tfrecord.py dosyasında yukarıda yazılan fonksiyonu kendi nesnenize göre adapte edin. Birden fazla nesneniz olması durumunda</p><pre># TO-DO replace this with label map<br>def class_text_to_int(row_label):<br>    if row_label == &#39;lahmacun&#39;:<br>        return 1<br>    if row_label == &#39;cigkofte&#39;:<br>        return 2<br>    if row_label == &#39;manti&#39;:<br>        return 3<br>    if row_label == &#39;dolma&#39;:<br>        return 4<br>    else:<br>        None</pre><p>şeklinde fonksiyonu düzenleyebilirsiniz.</p><p>Şimdi her şey hazırsa TFRecords dosyasımızı komut ile üretebiliriz.</p><pre>python generate_tfrecord.py --csv_input=images/train_labels.csv --image_dir=images/train --output_path=train.record</pre><pre>python generate_tfrecord.py --csv_input=images/test_labels.csv  --image_dir=images/test --output_path=test.record</pre><p>Csv dosyalarını images/train ve images/test klasörlerinden alıyor ve çıktı olarak train.record ve test.record adlı TFRecord dosyası oluşturuyor.</p><h4>Eğitim Yapılandırma</h4><p>Eğitime geçmeden önceki son aşamamız label-map oluşturma</p><p>İlk olarak <strong><em>object-detection.pbtx </em></strong>formatında yeni bir dosya oluşturuyoruz.</p><p>Ve içerisine nesnemizi ve ya nesnelerimizi <em>id </em>ve <em>name</em> vererek ekliyoruz</p><pre>item{<br>  id:1<br>  name:&quot;lahmacun&quot;<br>}</pre><p>Birden çok sınıfınız var ise</p><pre>item {<br>    id: 1<br>    name: &#39;lahmacun&#39;<br>}<br>item {<br>    id: 2<br>    name: &#39;cigkofte&#39;<br>}<br>item {<br>    id: 3<br>    name: &#39;manti&#39;<br>}<br>item {<br>    id: 4<br>    name: &#39;dolma&#39;<br>}</pre><blockquote>id ‘ sini vermiş olduğunuz nesnelerin, generate_record.py dosyasında atamış olduğunuz sırada olmasına dikkat ediniz.</blockquote><h4>Model Eğitimi</h4><p>Evet tüm dosyalarımız hazır olduğuna göre eğitime geçebiliriz.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/320/1*NyLBQyQWWrHs-pYi3p6O6A.gif" /></figure><p>Eğitim için bilgisayarımızda bulunan</p><ul><li>-&gt; train.record</li><li>-&gt; test.record</li><li>-&gt; object-detection.pbtx</li></ul><p>dosyalarını Colab platformuna yüklememiz gerekmektedir. Bunun için 3 dosyasımı <a href="https://www.dropbox.com/s/5xjr8nm0xpwf8m9/record.zip">Dropbox</a> platformuna ekledim ve Colab üzerinde indirme yapacağım.</p><p>Aynı şekilde Drive ile veya kişisel olarak bilgisayardan yükleme yapabilirsiniz.</p><p>Colab defterimde adımları çalıştırarak eğitimi gerçekleştirebilirsiniz.</p><p>📘<a href="https://colab.research.google.com/drive/1y8_SwpkfWoPPDrtT0Rl8iMoG4SnnaSUA?usp=sharing">COLAB AÇ </a>📘</p><p>Eğitim verisi için “SSD_MOBILENET_V2” eğitilmiş modelini kullandım.</p><p>Sizde programınıza uygun şekilde 👊<a href="https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/detection_model_zoo.md">model</a> 👊 seçebilir, adım sayılarını ve boyutu(batch_size) ayarlayabilirsiniz.</p><h4>Model Testi</h4><p>Colab üzerinde eğitimi gerçekleştirmiş ve modelimizi indirmiş bulunmaktayız.</p><p>İndirmiş olduğumuz frozen_inference_graph.pb dosyasını models/research/objectdetection klasörüne atınız.</p><p>Veri Etiketleme işleminde klonlamış olduğunuz <a href="https://github.com/FPasaoglu/CustomObjectDetector">Github</a> dosyalarımızdan <a href="https://github.com/FPasaoglu/CustomObjectDetector/blob/master/Object_detection_image.py">Object_detection_image.py</a> uzantılı python kodunu kullanacağız.</p><p>Kodu not defteri ile açın ve test edeceğiniz resmin dosya yolunu image_path = …. vererek kodu düzenleyin.</p><pre>python Object_detection_image.py</pre><p>kodu ile modeliniz resim üzerinde tanıma yapacaktır.</p><h4>Sonuç</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/225/1*01U6VLuUhy1je29uxAWlNA.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*QQBL4Bp6Z6eOMiJr50L5Pg.jpeg" /></figure><p>Görüldüğü üzere modelimiz tanıma işlemini başarıyla tamamlamıştır.</p><p>Yandaki fotoğrafta İbrahim Tatlıses’in elinin lahmacun üzerinde olması modelin kafasını karıştırmış olmalı 😃</p><p>Umarım iyi anlatabilmişimdir ve modelinizi hatasız eğitebilmişsinizdir.</p><p>Sorularınızı , önerilerinizi , yorumlarınızı mail üzerinden yazabilirsiniz.</p><p><em>furkan_pasaoglu@hotmail.com</em></p><p>Teşekkürler…</p><h4>Referans :</h4><ol><li><a href="https://medium.com/analytics-vidhya/custom-object-detection-with-tensorflow-using-google-colab-7cbc484f83d7">https://medium.com/analytics-vidhya/custom-object-detection-with-tensorflow-using-google-colab-7cbc484f83d7</a></li><li><a href="https://www.tutorialspoint.com/What-is-PYTHONPATH-environment-variable-in-Python">https://www.tutorialspoint.com/What-is-PYTHONPATH-environment-variable-in-Python</a></li><li><a href="https://www.tutorialspoint.com/What-is-PYTHONPATH-environment-variable-in-Python">https://www.tutorialspoint.com/What-is-PYTHONPATH-environment-variable-in-Python</a></li><li><a href="https://medium.com/deep-learning-turkiye/derin-ogrenme-uygulamalarinda-en-sik-kullanilan-hiper-parametreler-ece8e9125c4">https://medium.com/deep-learning-turkiye/derin-ogrenme-uygulamalarinda-en-sik-kullanilan-hiper-parametreler-ece8e9125c4</a></li><li><a href="https://medium.com/deep-learning-turkiye/google-colab-ile-%C3%BCcretsiz-gpu-kullan%C4%B1m%C4%B1-30fdb7dd822e">https://medium.com/deep-learning-turkiye/google-colab-ile-%C3%BCcretsiz-gpu-kullan%C4%B1m%C4%B1-30fdb7dd822e</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b089fc3ae5bb" width="1" height="1" alt=""><hr><p><a href="https://medium.com/deep-learning-turkiye/google-colab-ve-tensorflow-kullanarak-kendi%CC%87-nesneni%CC%87-tasarla-b089fc3ae5bb">GOOGLE COLAB VE TENSORFLOW KULLANARAK KENDİ NESNENİ TASARLA</a> was originally published in <a href="https://medium.com/deep-learning-turkiye">Deep Learning Türkiye</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>