<?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 Fatih Kurçenli on Medium]]></title>
        <description><![CDATA[Stories by Fatih Kurçenli on Medium]]></description>
        <link>https://medium.com/@fatihkurcenli?source=rss-350d6c9c2df8------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*Ej_-pCNpOyypAVCQZm-Ntg.jpeg</url>
            <title>Stories by Fatih Kurçenli on Medium</title>
            <link>https://medium.com/@fatihkurcenli?source=rss-350d6c9c2df8------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 17 Nov 2026 17:51:59 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@fatihkurcenli/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[Video Quality on Android]]></title>
            <link>https://fatihkurcenli.medium.com/video-quality-on-android-be40d7ed62ad?source=rss-350d6c9c2df8------2</link>
            <guid isPermaLink="false">https://medium.com/p/be40d7ed62ad</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[android-development]]></category>
            <category><![CDATA[androiddev]]></category>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[android-app-development]]></category>
            <dc:creator><![CDATA[Fatih Kurçenli]]></dc:creator>
            <pubDate>Thu, 24 Feb 2022 13:19:33 GMT</pubDate>
            <atom:updated>2022-02-24T13:20:35.125Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IKSAsv4DM6rCJ6VC-NEICw.png" /><figcaption><a href="https://www.youtube.com/watch?v=AxgE5ojwKto"><strong>Dr. Oetker</strong></a></figcaption></figure><p>Herkese merhabalar bugün sizlere youtube videolarda gördüğümüz ve kullandığımız görüntü kalitesi ayarını otamatik nasıl yapar ve bunu nasıl yapmayı öğrendiği, yazılım ve teknolojiyle ilgili her sorunun iyi bir cevabı var olduğunu biliyoruz, çünkü yazılımı seviyoruz <a href="https://emojipedia.org/man-technologist/">👨‍💻</a><a href="https://emojipedia.org/woman-technologist/">👩‍💻</a> Tarifimize başlamadan önce gerekenler listemiz;</p><ul><li>Backend (Spring)</li><li>Mobil (Android)</li><li>FFmpeg (Video Coding)</li><li>Local Server (XAMPP HTTP-Server)</li></ul><p>Gerekenler listemizi hazırladıysak video görüntü ayarları bizim için neden önemli olduğunu anlatalım. Bildiğiniz üzere kullanıcılar mobil uygulamalarımızda her zaman Wi-Fi kullanamamakta bundan dolayı da mobil veri bağlantısına ihtiyaç duymaktadır. Bildiğiniz üzere mobil veri bağlantıları 5G gelmesiyle artık çok gelişti ancak benim gibi köy yerlerinde dağlarda bazen çok iyi çekmeyebiliyor ancak mobil internet ile video izlemek isteyebiliyoruz. Eğer video çok yüksek boyutlarda ise donarak video izlemek kullanıcılar için olumsuz etki bırakmakta. Bunun yerine kullanıcıları internet bant genişliğindeki video ile kullanıcıları donmadan da olsa video izlemesini sağlamalıyız. Bu yapıyı Youtube, Facebook, Instagram, Twitch… Birçok şirket hali hazırda kullanmaktadır. Amaçları kullanıcıları aktif tutarak uygulama içerisinde Smooth bir akış sağalamaktır.</p><p>Evet, artık neden olduğunu öğrendikten sonra gelelim tarifimize. Öncelikle Backendimizi bir spring boot ile ayağa kaldıralım. Spring’de Java ve Kotlin kullanabilmekteyiz. Ben Kotlin tercih ediyorum, Kotlin ve Java karşılaştırmaları için <a href="https://www.google.com/search?q=kotlin+vs+java&amp;oq=kotlin+vs+java"><em>bakınız</em></a>. Kotlini dependency modülüne ekleyerek kolayca kurulumunu yapabilirsiniz.</p><pre>&lt;dependency&gt;<br>   &lt;groupId&gt;org.jetbrains.kotlin&lt;/groupId&gt;<br>   &lt;artifactId&gt;kotlin-stdlib-jdk8&lt;/artifactId&gt;<br>   &lt;version&gt;${kotlin.version}&lt;/version&gt;<br>&lt;/dependency&gt;<br>&lt;dependency&gt;<br>   &lt;groupId&gt;org.jetbrains.kotlin&lt;/groupId&gt;<br>   &lt;artifactId&gt;kotlin-test&lt;/artifactId&gt;<br>   &lt;version&gt;${kotlin.version}&lt;/version&gt;<br>   &lt;scope&gt;test&lt;/scope&gt;<br>&lt;/dependency&gt;</pre><p>Kotlin kurulumunu yaptıktan sonra, Backend’imizde öncelikle video yükleyeceğimiz bir end pointimizi belirliyoruz. “/api/v1/videos” POST işlemiyle bir video yükleyeceğiz. FileUploadService classımızı ”@AutoWired” Anotions ile inject ederek lateinit var şeklinde oluşturduğumuz service Spring senin için bir nesne üretecek ve sen bu nesneyi sonradan atanacaksın bundan dolayı “lateinit var” ile üretiyoruz. “Lateinit” için <a href="https://www.google.com/search?q=lateinit+nedir">bakınız</a>. FileUploadService class’ımızdaki uploadFileLocal fonksiyonumuza dosyamızı gönderiyor ve FileUploadService kısmından dönen Boolean cevabına göre kullanıcıya SuccessOrErrorModel olarak oluşturdumuz nesnemizi response olarak dönüyoruz.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/99d26c44810db524d15ce52af979078f/href">https://medium.com/media/99d26c44810db524d15ce52af979078f/href</a></iframe><p>Şimdi aldığımız dosyayı FileUploadService class’ımızdaki uploadFileLocal fonksiyonumuzu inceleyelim.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/202f57f7c43c4ecb655bc6ed6949a11d/href">https://medium.com/media/202f57f7c43c4ecb655bc6ed6949a11d/href</a></iframe><p>uploadFileLocal fonksiyonumuzda aldığımız file öncelikle mp4 olup olmadığını kontrol ediyoruz. Burada örneğimizde mp4 olarak ilerlemekteyiz. Tabi diğer video modelleri için ayrı Class ve fonksiyonlar kullanmamız gerekecektir FFmpeg için kodlar ayrı olacaktır. Biz dedim gibi en çok kullanılan yapı olan mp4 üzerinden ilerliyor olacağız. Burada gelen file dosyamızı geçici olarak bilgisayarımızda bir klasör açarak kaydediyoruz. Kaydettikten sonra kullanıcımızı bekletmemek için response zamanı uzamaması için Thread Sınıfından miras alan RefactorVideoClass’a file dosyamızın adını gönderiyoruz. Çünkü üst kısımda yaptığımız gibi temp’ olarak açtığımız yer RefactorVideoClass yapımız bilmektedir. Sadece aldığımız video adını göndermemiz ve Thread açarak bu işlemi başlatıyoruz. Kullanıcıya ise “True” olarak dönerek videonun başarılı bir şekilde elimize ulaştığını bildiriyoruz.</p><blockquote>Bir process’in birden fazla işi aynı anda yapmasını sağlayan yapılara T<strong>hread</strong> denir.</blockquote><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/62d55cd36868f368e2798fa6afc10ca8/href">https://medium.com/media/62d55cd36868f368e2798fa6afc10ca8/href</a></iframe><p>Aslında tüm video işlememiz bu kısımda gerçekleşiyor. Burada gördüğümüz gibi 3 değişkenimiz yer almakta. Video adı, segmentlere ayırdığımızda videoların adı, ve son olarak bu segmentleri kaçar saniye olarak video ayıracağımızın default değeri olarak atanmış ve constructor sayesinde bunları değiştirme olanağı sunabilmekteyiz. Gelelim FFmpeg nedir ne işimize yarar ?</p><blockquote>FFmpeg, herhangi bir video formatını başka bir video formatına kodeklerini de değiştirerek çevirebilen açık kaynak kodlu ücretsiz bir yazılımdır. FFmpeg, neredeyse tüm <a href="https://www.ffmpeg.org/ffmpeg-codecs.html">ses/görüntü kodeklerini</a>(h264, h265, vp8, vp9, aac, opus, etc.), <a href="https://www.ffmpeg.org/ffmpeg-formats.html">dosya formatlarını</a>(mp4, flv, mkv, ts, webm, mp3 etc.) hatta tüm <a href="https://www.ffmpeg.org/ffmpeg-protocols.html">streaming protokollerini</a>(http, rtmp, rtsp, hls, etc.) destekler.</blockquote><p>FFmpeg ile videolarla neler yapabileceğimizi bu linkten <a href="https://ceaksan.com/tr/ffmpeg-nedir-nasil-kullanilir"><em>bakabilir </em></a>deneyebilirsiniz. Örnek olarak bir videoyu gif’e dönüştürebilir, bir videoyu fotoğraflara dönüştürebilir, bir videoyu sadece video ve sese dönüşterebilirsiniz. Bizim örneğimizde videoyu 6 kategoriye bölerek video kalitesini düzenleyeceğiz. FFmpeg <a href="https://ffmpeg.org/download.html">buradan </a>indirebilir kendi bilgisyarınıza veya serverınıza yüklemeniz gerekmektedir. Windows için ffmpeg kurduğunuz dosyanın bin yolunu Windows’da Environment variable olarak setlemeniz gerekmektedir. Aksi takdirde backend’te koşacağımız Cmd komutu çalıştırmayacaktır.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/616/1*eQcG3n58kER-Xl9xIAt3qw.png" /></figure><p>Kodumuzu incelemeye devam ettiğimizde Bir ProcessBuilder objesi oluşturuyoruz bu objemizin yaptığı açıklamayı bakalım;</p><pre><em>/**<br> * Constructs a process builder with the specified operating<br> * system program and arguments.  This is a convenience<br> * constructor that sets the process builder&#39;s command to a string<br> * list containing the same strings as the {</em><strong><em>@code </em></strong><em>command}<br> * array, in the same order.  It is not checked whether<br> * {</em><strong><em>@code </em></strong><em>command} corresponds to a valid operating system<br> * command.<br> *<br> * </em><strong><em>@param </em></strong><em>command a string array containing the program and its arguments<br> */<br></em>public ProcessBuilder(String... command) {<br>    this.command = new ArrayList&lt;&gt;(command.length);<br>    for (String arg : command)<br>        this.command.add(arg);<br>}</pre><p>İşletim sistemi command’lerden oluşan string bir ArrayList almakta ve bunları koşmaktadır. Koşması için builder.start() fonksiyonumuzu başlatmamız gerekmektedir. Start fonksiyonumuzu başlattıktan sonra hata almamız durumunda normalde Start fonksiyonu IOException atmakta ancak biz while döngüsünü sonsuz yaptığımızdan dolayı redirectErrorStream(true) yaptık bu bize aslında herhangi bir hata olursa bunu command satırında yazmamızı sağlıyor bu sayede döngünün break yapıldığından emin olabilmekteyiz. Default value değeri false’dur. Eğer Command sırasıyla cmd.exe ile command satırımızı açıyoruz. Sonrasında geçici olarak yer alan dosyamızın komutuna giderek Windows Env. dosyamızdaki FFmpeg kullanarak komutumuzu koşuyoruz. FFmpeg Komutumuzu inceleyelim.</p><blockquote>&quot;ffmpeg -y -i $videoName -preset slow -g 48 -sc_threshold 0 -map 0:0 -map 0:1 -map 0:0 -map 0:1 -map 0:0 -map 0:1 -map 0:0 -map 0:1 -map 0:0 -map 0:1 -map 0:0 -map 0:1 -s:v:0 1920*1080 -b:v:0 1800k -s:v:1 1280*720 -b:v:1 1200k -s:v:2 858*480 -b:v:2 750k -s:v:3 630*360 -b:v:3 550k -s:v:4 426*240 -b:v:4 400k -s:v:5 256*144 -b:v:5 200k -c:a copy -var_stream_map \&quot;v:0,a:0,name:1080p v:1,a:1,name:720p v:2,a:2,name:480p v:3,a:3,name:360p v:4,a:4,name:240p v:5,a:5,name:144p\&quot; -master_pl_name master.m3u8 -f hls -hls_time $parseDynamicVideoRange -hls_playlist_type vod -hls_list_size 0 -hls_segment_filename \&quot;v%v/$segmentedName%d.ts\&quot; v%v/index.m3u8&quot;</blockquote><p>ffmpeg komutu ile başlatıyoruz -y (<em>global</em>) bir komut olup ovveride yapmakta dosya var ise üzerine yazmaktadır. -i ile video url vereceğimizi belirtmekteyiz. -present slow bizim video işleme sürecimizi dile getirmekte yani eğer hızlı işlersek video’da daha düşük boyut ancak görüntü kaybı yaşayabiliriz ancak yavaş yaparsak bu sefer daha iyi kalite daha uzun sürede işleyeceğini söylemekteyiz. Map ile video ve sesleri birleştirmeye sağlıyoruz. Map ile detaylı bilgi <a href="https://trac.ffmpeg.org/wiki/Map">bakınız</a>. Diğer önemli yapımız master.m3u8 Aslında kullanıcımıza bu text dosyasını vereceğiz. İleride geleceğiz. hls_time olarak dynamic olarak aldığımız değerdir. Segment File adını yine dynamic olarak değiştirebileceğimiz değeri almaktadır default değeri video dosyasının adıdır. Builder.start() bize geriye bir Process dönmekte bu process inputStream olarak dinleyip her bir koşulan komut satırını ekrana göstermekteyiz bu sırada youtube bir video yüklediğimizde işleniyor gözükmesini bir boolean değişikliği kurarak kullanıcılara video işleniyor yapısı gösterebiliriz. Eğer null değerine ulaşmış ise dosyamız artık işlenmiş olup template olarak yüklediğimiz videoyu silebiliriz ve asıl dosyalarımızı cloud’da veya kendi server üzerinde yükleme işlemini yapabilirsiniz.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cdqCJtQb7f_Aff-WH8ShHQ.png" /></figure><p>Burada aşağıdaki görüntü kalitelerini üretmekteyiz.</p><ul><li>v1080p</li><li>v720p</li><li>v480p</li><li>v360p</li><li>v240p</li><li>v144p</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/917/1*UtN4Z8bxSir7fqw7QEeCIA.png" /></figure><p>Artık videolarımız işlenmiş şekilde görüntü kalitesine göre ayarladık ve master.m3u8 dosyamızı aldık. Peki şimdi ne olcak bu oluşturduğumuz dosyaları Amazon S3 Bucket servisine veya Google, Azure Storage servislerine ya da kendi backend Storage servisimize yüklüyoruz master.m3u8 url değerini alıp bunu artık video url olarak kullanıcıya dönüyor yada database’e kaydediyoruz. Peki bu master.m3u8&#39;de ne mi var ?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/755/1*KCoJ6so3chbXGrhtUTCy4w.png" /></figure><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Ftenor.com%2Fembed%2F11411674&amp;display_name=Tenor&amp;url=https%3A%2F%2Ftenor.com%2Fview%2Fomg-oh-my-god-wow-gif-11411674&amp;image=https%3A%2F%2Fmedia.tenor.com%2FBmCbsCskdA4AAAAF%2Fomg-oh-my-god.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=tenor" width="600" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/e8a73c1227869f7754a4f806cf4fd858/href">https://medium.com/media/e8a73c1227869f7754a4f806cf4fd858/href</a></iframe><p>M3u8 file formatı bir HLS(HTTP Live Streaming) olmakla birlikte kullanıcılara canlı bir yayın akışı sağlamasını amaçlamaktadır. Bu dosyamızın içerisinde baktığımızda “Bandwidth” ile karşılaşmaktayız aslında tüm mesele burada yatıyor görüntü ayarını internet bant genişliğinize göre hangi çözünürlüğü vereceğini bu master.m3u8 dosyasına göre url kısmını değiştirmemizi sağlıyor. Burada kullanıcının internet değerine göre hangi video url setlenmesini sağlıyor ayrıca mpd dosyasını da i</p><blockquote><strong>HTTP Live Streaming</strong> veya HLS , <a href="https://tr.wikipedia.org/wiki/Apple">Apple</a> tarafından <a href="https://tr.wikipedia.org/wiki/QuickTime">QuickTime</a>, Safari, <a href="https://tr.wikipedia.org/wiki/OS_X">OS X</a> ve <a href="https://tr.wikipedia.org/wiki/%C4%B0OS">iOS</a> yazılımının bir parçası olarak uygulanan <a href="https://tr.wikipedia.org/wiki/HTTP">HTTP</a> tabanlı bir medya akış iletişim protokolüdür. <a href="https://tr.wikipedia.org/wiki/HTTP_Live_Streaming#cite_note-1">MPEG-DASH</a>’ı andırıyor. Genel akışın küçük HTTP tabanlı dosya indirmelerinin dizisine bölünmesi ile çalışır; her yükleme, genel olarak potansiyel olarak sınırsız aktarım akışının kısa bir bölümünü yükler.</blockquote><p>Dosyalarımızın içerisine baktığımızda tam olarak bunu görmekteyiz. Belli bir aktarım kesitlerini zaten üst taraftaki kodlarımızda aktarım akışını kaç saniyelere böleceğimizi yazmıştık. Videomuzun toplam süresi 43 saniye bu da 10&#39;a bölerek yaptık ve karşımızda 5 adet bölünmüş .ts dosyaları karşımıza çıkarmakta.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/885/1*h1d0ghPnaW4ReMAntiUREw.png" /><figcaption>Segmentlere bölümüş video parçacıkları.</figcaption></figure><p>Peki url istek attığımızda ne olcak aslında bir mp4 dosyası gibi çalışmasını bekliyoruz. Ben localserver olarak <a href="https://www.apachefriends.org/tr/index.html">XAMPP</a> kullanacağım videolarımın local bir server çalışması için. Burasının aynı bir server’da tuttuğumuz gibi düşünebilirsiniz. Localhost xampp’da localhost:80 portunda çalışmakta. Buradaki master.m3u8 isteğimiz localhost/hls-server/input olmakta. Eğer chroma’da bu url istek attığımızda download yapmakta ancak videomuz yüklenmemekte bunun için HLS koşabilen bir video-player bulmamız gerekiyor chrome üzerinde <a href="https://chrome.google.com/webstore/detail/native-hls-playback/emnphkkblegpebimobpbekeedfgemhof"><em>Native HLS Playback</em></a> gibi bir extension bulunmakta bunu chorme yükleyerek videomuzu başlatabiliriz.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/734/1*4V7481CXh43Om_m8DAWG4Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*246n85MrFuOg2xe3f_4uqA.png" /></figure><p>Artık videomuz yayında :) Şimdi artık bu video url Android Tarafında Exoplayer kullanarak görelim :) O zaman Android tarafına başlayalım.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Ftenor.com%2Fembed%2F5344094&amp;display_name=Tenor&amp;url=https%3A%2F%2Ftenor.com%2Fview%2Fgravity-falls-dipper-start-player-gif-5344094&amp;image=https%3A%2F%2Fmedia.tenor.com%2FMT4hklANlEsAAAAN%2Fgravity-falls.png&amp;type=text%2Fhtml&amp;schema=tenor" width="600" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/7a701331fc6eb606b78d262d9f556157/href">https://medium.com/media/7a701331fc6eb606b78d262d9f556157/href</a></iframe><p>Öncelikle Exoplayer dependency gradle’mıza ekliyoruz. <a href="https://exoplayer.dev/"><strong><em>Exoplayer</em></strong></a> kütüphanesi Google tarafından geliştirilen açık kaynaklı bir Video-player oynatıcısıdır.</p><pre>implementation &quot;com.google.android.exoplayer:exoplayer:2.14.0&quot;<br>implementation &quot;com.google.android.exoplayer:exoplayer-core:2.14.0&quot;<br>implementation &quot;com.google.android.exoplayer:exoplayer-ui:2.14.0&quot;<br>implementation &quot;com.google.android.exoplayer:exoplayer-hls:2.14.0&quot;</pre><ul><li>exoplayer-core: Core functionality (required).</li><li>exoplayer-dash: Support for DASH content.</li><li>exoplayer-hls: Support for HLS content.</li><li>exoplayer-rtsp: Support for RTSP content.</li><li>exoplayer-smoothstreaming: Support for SmoothStreaming content.</li><li>exoplayer-transformer: Media transformation functionality.</li><li>exoplayer-ui: UI components and resources for use with ExoPlayer.</li></ul><p>Bizim uygulamamız bildiğiniz üzere HLS üzerinde olacağından core, ui, hls kütüphanelerini de ekliyoruz. MainActivity’mizdeki ui kısmını çizdirelim.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f17d251521b03991f33aa6a3392ad324/href">https://medium.com/media/f17d251521b03991f33aa6a3392ad324/href</a></iframe><p>Burada custom bir exo_player_control_view veriyoruz ve butonlarımızı setliyoruz. Burada UI kısmındaki tüm özelleştirmeleriniz uygulamanızın ana temel renklerine ve özelliklerine göre değişmektedir.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9ea92be4ab20825b9a3ececb5bf604d5/href">https://medium.com/media/9ea92be4ab20825b9a3ececb5bf604d5/href</a></iframe><p>MainActivity’mize gelelim. Öncelikle exoPlayer, dataSourceFactory, trackSelector objelerimizi lateinit var ile oluşturulacağını belirtriyoruz. Burada mediaItem değeri şuanlık Compain Object’de static olarak tutuğumuz HLS_STATIC_URL ile MimeType’ı m3u8 formatında yapiyoruz. Ayrıca trackDialog yapısında Dialog göstererek kullanıcıların hangi kalite seçmek istediğini belirtmesini sağlayacak yapımızı göstereceğiz. OnCreate fonksiyonumuzda dataSourceFactory’i ve eğer trackDialog boş ise initPoupQuality ile dialog’umuzu yüklenimini yapmaktayız.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f0de9e44bf5e71832cb6b9b744d8972d/href">https://medium.com/media/f0de9e44bf5e71832cb6b9b744d8972d/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*S6gGRII1U--upj-sinvtLA.jpeg" /></figure><p>initPopupQuality fonksiyonumuzda trackSelector currentMappedTrackInfo değerini alıyoruz. Burada alınan video değerinin birden fazla Quality’si olduğunu anlamamızı sağlıyor eğer yok ise fonksiyonumuz return etmekde değilse ayarlar görüntüsünü aktif etmekte. MappedTrakInfo.renderCount kadar fonksiyonumuz koşcak. Bu da kaç tane görüntü kalitemiz var ise o kadar bizim 144, 240, 360, 480, 720, 1080 vardı, ayrıca 1 tane de otomatik seçeneğimiz olmakla beraber 6 tane değerimiz olmakta.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*UDocYG4rI5P736H2bjEq5g.jpeg" /></figure><p>mapped.getTrackGroups dediğimizde eğer bir uzunluğumuz yok ise 0 ise bizim aslında bir render değerimiz olmadığını anlamaktayız. Eğer 0&#39;dan farklı ise evaluate ettiğimiz gibi birden fazla değer gelmekte.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QqY4ayECem65MRZ4YaX4Qw.png" /></figure><p>Görülüğü gibi bizim format değerlerimiz gelmiş bulunmakta. Hangi’si ile render ettiği değeri getRenderType() fonksiyonu kullanarak C.TRACK_TYPE_VIDEO ile kıyaslıyoruz ve videomuz hangi value değeriyle renderlandığını alıyoruz. For döngümüzden çıktığımızda value değerimiz 0 olmakta görüyoruz. TrackSelectionDialogBuilder oluşturuyoruz contructor yapısında context,title, oluşturduğumuz trackSelector (trackSelector=DefaultTrackSelector(this) atamıştık) ve son olarak da rendererIndex’imizi gönderiyoruz.</p><pre>TrackSelectionDialogBuilder(<br>    Context context, CharSequence title, DefaultTrackSelector trackSelector, int rendererIndex)</pre><p>Ve son olarak TrackSelectionDialog’muzun adlarını düzeltmek için string dosyamızdaki gelen height değerine göre değiştiriyoruz.</p><pre>&lt;string name=&quot;exo_track_resolution_pixel&quot;&gt;&lt;xliff:g example=&quot;768&quot; id=&quot;height&quot;&gt;%1$dp&lt;/xliff:g&gt;&lt;/string&gt;</pre><p>Sonrasında oluşturduğumuz dialog’a atamasını yapıyoruz bu sayede her tıklanmada sürekli aynı işlemlerin yapılmasını engelleyip performans kazanıyoruz.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*foaTBvaCIE60uOygicF-tQ.png" /></figure><p>Bu sayede artık kullanıcın artık video kalitesini seçerek videosun kalitesini ayarlamasını sağladık. Default olarak video kalitesi otomatik olmaktadır. Ancak kullanıcı daha kaliteyi yükseltebilir veya kaliteyi düşürerek takılmadan videoyu izlemesini sağlatabilir ve kullanıcıları uygulamada aktif olarak tutabiliriz. Demo bir video çektim tam mantığını anlatmak için iyi seyiler dilerim umarım tıkanmaz youtube video tıkanmaz alttaki gibi olmak istemeyiz :)</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2Fu2wg2uXJbHzkXkPphr%2Fvideo&amp;display_name=GIPHY&amp;url=https%3A%2F%2Fgiphy.com%2Fclips%2Fstudiosoriginals-sleep-tired-sleepy-u2wg2uXJbHzkXkPphr&amp;image=https%3A%2F%2Fmedia1.giphy.com%2Fmedia%2Fu2wg2uXJbHzkXkPphr%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="480" height="320" frameborder="0" scrolling="no"><a href="https://medium.com/media/6906eb0a92f9aad67322060f1dff16bb/href">https://medium.com/media/6906eb0a92f9aad67322060f1dff16bb/href</a></iframe><p>Türkçe anlatım videosu youtube’da yayınladım izlemek isteyenler için linki aşağıya bıraktım.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2F88X1b8c47jA%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D88X1b8c47jA&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2F88X1b8c47jA%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/cff4a27bc9496aec15ea1a57fc61f171/href">https://medium.com/media/cff4a27bc9496aec15ea1a57fc61f171/href</a></iframe><ul><li><a href="https://github.com/fatihkurcenli/AndroidQuality">GitHub - fatihkurcenli/AndroidQuality: Android Quality with Spring Backend Server, FFMPEG</a></li><li><a href="https://exoplayer.dev/">ExoPlayer</a></li><li><a href="https://www.ffmpeg.org/">FFmpeg</a></li><li><a href="https://spring.io/">Home</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=be40d7ed62ad" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Ktor-Android(Kotlin) WebSocket ile Chat Uygulaması ]]></title>
            <link>https://fatihkurcenli.medium.com/ktor-android-kotlin-websocket-ile-chat-uygulamas%C4%B1-a757d445fd04?source=rss-350d6c9c2df8------2</link>
            <guid isPermaLink="false">https://medium.com/p/a757d445fd04</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[websocket]]></category>
            <category><![CDATA[ktor]]></category>
            <category><![CDATA[kotlin]]></category>
            <dc:creator><![CDATA[Fatih Kurçenli]]></dc:creator>
            <pubDate>Thu, 11 Nov 2021 14:49:10 GMT</pubDate>
            <atom:updated>2021-11-11T14:49:10.840Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*M6OzGNBzgb7kfEsXv-r33A.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@ademay?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Adem AY</a> on <a href="https://unsplash.com/?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>Günümüz pandemi döneminde anlık olarak mesajlaşma ve konuşma ihtiyacımız arttı.Birçok şirket ve kullanıcılar bu durumdan etkilendi. İnsanlar alternatif uygulamaları edinmeye ve indirmeye, hatta şirketler kendi uygulamalarını geliştirip kullanmaya başladı. Peki bu verileri nasıl gönderiliyor ve anlık olarak alıyorlar ? İşte bu kısımda WebSocket ve anlık haberleşme yapıları karşımıza çıkıyor. Şuan bir sürü chat uygulaması bu yapıyı günümüzde kullanıyor. Bu uygulamalar anlık olarak konuşmamızı sağlıyor ve veri iletimi sağlayarak mesajlaşma ve konuşma yapısını internet servisleri üzerinden sağlanıyor. Ayrıca bu sırada uygulama içerisinde pek çok özellikler de barındırıyorlar. Peki ya bu uygulamaları kendimiz yapmak istersek ?</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Ftenor.com%2Fembed%2F20876342&amp;display_name=Tenor&amp;url=https%3A%2F%2Ftenor.com%2Fview%2Fleyla-ile-mecnun-gif-20876342&amp;image=https%3A%2F%2Fc.tenor.com%2FMk2cYQJEXQAAAAAC%2Fleyla-ile-mecnun.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=tenor" width="600" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/dc8d9d9c70e7d22f214409f5b9221ae8/href">https://medium.com/media/dc8d9d9c70e7d22f214409f5b9221ae8/href</a></iframe><p>Gelelim önce bir backendimizi ayağa kaldıralım. Ktor uygulaması nasıl kurulur hemen bir bakalım. Öncelikle ide olarak ben intelij idea community’sini kullandım. Burada marketplace’den ktor’u pluginini ekliyoruz.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/785/1*bP5xFchClfPO5Ruo2pgwuA.png" /></figure><p>Sonrasında yeni bir projects kısmından yeni bir proje oluşturuyoruz. Ve Routing bizim endpointleri yöneteceğimiz kısım olacaktır. Sessions kullanıcıların ıd’leri sayesinde aynı kullanıcı ile içerideki HTTP istekleri yönetmesini sağlıyor. Websocket bildiğimiz üzere asıl konumuz olan anlık olarak verileri işleyeceğimiz ve android alanında dinleyeceğimiz yapı olacaktır. Authentication JWT ise kullanıcıların JWT token sayesinde tekrar giriş yapmadan JWT token bakarak kullanıcıyı uygulamaya girişini sağlamak için yapıdır. Daha detaylı bilgisi için <a href="https://tugrulbayrak.medium.com/jwt-json-web-tokens-nedir-nasil-calisir-5ca6ebc1584a"><em>bakınız</em></a>. Ayrıca eğer verilerimizi Json formatından göndermek istiyorsak alt kısımdaki Gson yapısını seçip ilerliyoruz.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ii0xqFCgTeuTjKjRP3xzgw.png" /></figure><p>Uygulamamızın grup ıd ve artifact id siz dilediğiniz gibi verebilirsiniz. Project adımızı da veriyor ve projemizi oluşturuyoruz. Gradle dosyamızın gerekli kütüphanelerini yüklemesini bekliyoruz.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*heWDRaIfumKCiclCdZ6r7Q.png" /></figure><p>Harika, projemiz oluşturduk ve artık çalıştıralım ve backendimizin local’de çalıştığını görelim. Çalıştırmak için main fonksiyonumuzu çalıştırıyoruz.</p><pre>fun main(args: Array&lt;String&gt;): Unit = io.ktor.server.netty.EngineMain.main(args)</pre><p>Default olarak 8080 portunda çalışmaktadır. Eğer 8080 portu kullanan bir başka servisiniz varsa default portunu değiştirebilirsiniz. Değiştirmek isterseniz Resources içerisindeki application.conf dosyasındaki port değerini değiştirmeniz yeterli olacaktır. Localhost’da çalıştığından internet sitesinden <a href="http://localhost:8080/">http://localhost:8080</a> portuna istek attığımızda göreceğimiz hello world yapısını backend kodumuzdan bakalım.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qfkmlJ2M7U4qSHYwt6cWig.png" /></figure><pre>get(&quot;/&quot;) <strong>{<br>    </strong><em>call</em>.respondText(&quot;HELLO WORLD!&quot;, contentType = ContentType.Text.Plain)<br><strong>}</strong></pre><p>Görüldüğü üzere <em>“/”</em> istek attığımızda text yapısı olarak Hello World dönmekte. Yani backend servisimiz ayakta gözüküyor :) Şimdi gelelim bizim asıl konumuz olan Websocket yapımıza. Aynı şekilde peki istek atalım <a href="http://localhost:8080/myws/echo">http://localhost:8080/myws/echo</a> ne alacağız ? Hata mı bu değil çünkü websocket yapısı get isteği atmış oluyoruz. Bu kısımda artık websocket yapımızı dinleyebilmemiz için Postman ihtiyacımız oluyor. Postman indirme ve kurmak için <a href="https://www.postman.com/"><em>bakınız</em></a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hTxfWbc-D8DZkLOxTfy7Cw.png" /></figure><p>Postman kurduk ve giriş yaptıktan sonra File-&gt;New diyerek bir yeni Websocket request yapımızı açıyoruz.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oBhs3R8f-3rxTPSK2xUfXg.png" /></figure><p>Şimdi localhost’daki istek yapımızı buraya yazıyoruz. Burada ufak bir değişikliğimiz var o da http değil artık WebSocket yapısı kullandığımızdan başına ws yapımız geliyor eğer WebSocket localde kullanıyorsak ws eğer SSL servisli bir yapı kullanıyorsak wss olmaktadır. Detaylı bilgi stackoverflow’da bu soruya cevap verilmiştir <a href="https://stackoverflow.com/questions/46557485/difference-between-ws-and-wss"><em>bakınız</em></a><em>.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rF3KTCaiEPJfBB3yTDMhcA.png" /></figure><p>Harika artık servisimize bağlandık ve dinliyoruz. Servisimize bir yazı gönderelim ve dönen cevap yazdığımızda gelen bildirimi görüyorsunuz. Serviste bu yapıyı alıp geriye bize bir Text mesajı döndürülmekte. Sarı ışıkla giden yapımız bizim gönderdiğimiz text mesajı mavi ile gelen ise servisten bize dönen yapıyı görmekteyiz. Burada server sadece bize yazdıklarımızı geri döndürüyor ancak normal bir konuşma tabi ki böyle olmaz :) Şimdi backend tarafımızda birkaç değişiklik yapmamız gerekiyor. Src dosyamıza bir Connection sınıfı açıyoruz ve constructorda WebSocketSession’dan extend alan DefaultWebSocketSession interface ekliyoruz, Companion object içerisinde bir AtomicInteger tutuyoruz ve defaul olarak 0 değeri setliyoruz. AtomicInteger eşzamanlı olarak thread’lerin arttırma sağlamak istediğinde senkronize olarak arttırılmasını sağlamaktadır. İşletim sistemi derslerinde gördüğümüz Race Condition problemine çözüm sağlamaktadır. Ayrıca AtomicInteger <a href="https://tr.waldorf-am-see.org/418440-practical-uses-for-atomicinteger-UYEFPA"><em>bakınız</em></a>;</p><blockquote>İki ana kullanım alanı vardır AtomicInteger:</blockquote><blockquote>- Atomik bir sayaç olarak (incrementAndGet(), vb.) eşzamanlı olarak birçok iş parçacığı tarafından kullanılabilen.</blockquote><blockquote>- Karşılaştır ve takas talimatını destekleyen bir ilkel olarak (compareAndSet()) engellemeyen algoritmaları uygulamak için.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QdWqtnVLJSL3fISEnYOgoA.png" /></figure><p>Application dosyamızdaki Routing scope altında bir connections listesi tutmaktayız kaç kullanıcı olduğunu bilgisini tutmak için. Chat uygulamamıza eklenen her bir kullanıcı Connection(this) objesi üreterek bu objeyi connections listemize ekliyoruz. (Her bir obje kendisine benzersiz bir kullanıcı atamaktadır)</p><pre>val connections = Collections.synchronizedSet&lt;Connection?&gt;(LinkedHashSet())</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/734/1*oqySF_pBPBamj058FPjoDA.png" /></figure><p>Try catch ile uygulamamızı crash alması durumunda hatayı yakalamak ve kullanıcılara neden hata olduğunu belirtebiliriz. Şu anlık localde print yapıyoruz. İlk kullanıcı girdiğinde chat uygulamamıza bu chat uygulamasında kaç kişi online olduğunu belirten mesajı gönderiyoruz. Sonrasında gelen textleri dinlemeye başlıyoruz. Eğer gelen mesaj Text olarak gelmediyse uygulama devam ediyor. Eğer text olarak geliyorsa bu mesajı alıyor ve hangi kullanıcı attığını thisConnection sayesinde adını tutuyorduk objemizde bunu yazıyoruz ve yazdığı mesajı ekliyor ve bağlanan tüm kullanıcılara gönderiyoruz. Eğer kullanıcı disconnect olduğunda bu durumu finally durumunda bağlanan kullanıcı tüm kullanıcılara kim çıktığı hakkında bildirim gönderiyoruz ve connection yapımızdan o kişiyi düşürüyoruz.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*2nHDUiCa8bZdEn_BnI4FCw.gif" /><figcaption><a href="https://www.youtube.com/watch?v=eQ7PmtMxK4I&amp;t=9s"><strong>Youtube</strong></a></figcaption></figure><p>Eee biz bunu konuşmak için ettik, telefonuma mesaj gelmezse ben bu yapıyı neden yaptım :) Şimdi gelelim bu yapıyı Android tarafında nasıl dinleyeceğiz ? Hemen bir proje açalım ve aşağıdaki WebSocket kütüphanemizi ekleyelim. Bu kütüphane sayesinde WebSocket yapımıza bağlanıp dinleme işlemini yapacağız.</p><pre><a href="https://github.com/TooTallNate/Java-WebSocket"><strong><em>// WebSocket<br>implementation &quot;org.java-websocket:Java-WebSocket:1.5.1&quot;</em></strong></a></pre><p>Kütüphanemizi ekledikten sonrasında viewBinding ekliyoruz. Viewbinding tasarımımız olan XML ile ilişki kurmamızı ve XML’deki verilerimize erişmemizi sağlamakta. Bunun için ufak bir yapı ekliyoruz gradle dosyamıza. Daha detaylı bilgi için <a href="https://developer.android.com/topic/libraries/view-binding"><em>bakınız.</em></a></p><pre>buildFeatures<strong>{<br>    </strong>viewBinding true<br><strong>}</strong></pre><p>Şimdi ufak bir tasarım yapıyorum. Ama siz siz olun benim gibi güzel UI’lar hazırlamayın :) Şaka bir yana daha güzel bir UI ile kullanıcılarınızı tutmanız gerekmektedir. Ben demo olarak yapıldığından dolayı basit bir text ,editText ve send butonu koyuyorum.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a71729b90aacdd6d8b0c24fbbaacd283/href">https://medium.com/media/a71729b90aacdd6d8b0c24fbbaacd283/href</a></iframe><p>Tasarımımız tamamladıktan sonra diğer bir işlemimiz Utils objesi oluşturalım ve IP adresimizi ve port yapımızı yapalım neden mi ? Android emülatör localhost yapısı ile dinleyememekteyiz. Ufak bir arama yaptığımda localhost olarak android bu değeri yazmamızı istiyor lakin denedim olmadı :) 10.0.2.2 Sonuç olarak internet adresimizin IPv4 adresini almamız gerekiyor. Bunun için windows için cmd yazarak komut işlemcisini açalım ve ipconfig diyerek IPv4 adresimize erişelim. IPv4 adresinizi nasıl öğrenebilirsiniz buraya <a href="https://www.wikihow.com/Refresh-Your-IP-Address-on-a-Windows-Computer"><em>bakınız.</em></a></p><p>Bu değerlerimizi const val olarak Constants değerimizde tutuyoruz. Portumuz backendte ayarladığımız port olacaktır. Bu değerleri gitignore ekleyebilirsniz Constants değerlerinizi.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/347/1*zSk0xWytlG8quDuLVqe3JQ.png" /></figure><p>MainActivity’mize gelmeden önce kullandığımız trafik http olduğundan dolayı AndroidManifest.xml dosyamıza usesCleartextTraffic true olarak atamamız gerekmektedir. Aksi takdirde Android bize uyarıda bulunmaktadır. Eğer gerçek bir socket yapısıyla SSL güvenlikli bir yapıyla çıkıyorsanız bu değer setlenmesini kaldırın.</p><pre>android:usesCleartextTraffic=&quot;true&quot;</pre><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4980e39d12cba8d9535529f5d52caddb/href">https://medium.com/media/4980e39d12cba8d9535529f5d52caddb/href</a></iframe><p>Gelelim kodumuza aslında çok basit bir yapımız var. ViewBinding setlememizi yapıyoruz. ve onDestroy kısmında ise _binding=null setliyoruz memory leak oluşturmaması için. Android Lifecycle’dan bildiğimiz gibi onResume aktif olduğunda initWebSocket yapımızı çalıştırıyoruz. initWebSocket yapımız URI olarak <strong>WEB_SOCKET_URL</strong> yapımızı veriyor ve WebSocket yapımızı ayağa kaldırıyoruz. Sonradan initlize edeceğimizi belirttiğimiz webSocket yapımıza WebSocketClient nesnesinden bir obje üretiyoruz ve setleme işlemini gerçekleştiriyoruz. Burada 4 metod karşılıyor bizi</p><blockquote><strong>onOpen</strong> → WebSockete bağlanıldığı ilk an olacaktır burada ilk bağlanıldığında servise göndermek istediğiniz parametreleri yazabilirsiniz.</blockquote><blockquote><strong>onMessage</strong> → Burası en çok ilgilendiren konumuz bu kısımda her mesaj geldiğinde bu yapımız çalışacaktır ve mesajımızı buradan string olarak alıyoruz.</blockquote><blockquote><strong>onClose</strong> → WebSockete disconnect olduğumuzda servise bildirebileceğimiz fonksiyondur.</blockquote><blockquote><strong>onError</strong> → Burada WebSocket bağlanma hatalarını yakaladığımız yerdir</blockquote><p>Gene bildiğimiz Android Lifecycle’dan eğer kullanıcı telefonu aşağıya veya kapanma durumda bu metod çalışacak ve WebSocket bağlanma yapımızı kapatacağız. Bu kısımda eğer sürekli çalışmasını istiyorsak. Bu yapımızı Workmanager yapımıza ekleyip dinleme işlemini arka kısımda halledebiliriz. Çok yakında <a href="https://developer.android.com/topic/libraries/architecture/workmanager/basics"><em>Workmanager’larla</em></a> ilgili bir yazı yazmayı düşünüyorum takipte kalın esen kalın :) Gelelim artık sonucumuz ne oldu →</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FNkA7VMa1t_Q%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DNkA7VMa1t_Q&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FNkA7VMa1t_Q%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/b4d7f1c6041fefc0e879342db1da0194/href">https://medium.com/media/b4d7f1c6041fefc0e879342db1da0194/href</a></iframe><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Ftenor.com%2Fembed%2F7606203&amp;display_name=Tenor&amp;url=https%3A%2F%2Ftenor.com%2Fview%2Fleyla-ile-mecnun-gif-7606203&amp;image=https%3A%2F%2Fc.tenor.com%2FRTtWTSmM-y8AAAAC%2Fleyla-ile.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=tenor" width="600" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/80ad6d92e252f78d42d94c8f70662b43/href">https://medium.com/media/80ad6d92e252f78d42d94c8f70662b43/href</a></iframe><h3>💻Projelerin github linkleri →</h3><ul><li><a href="https://github.com/fatihkurcenli/KtorWebSocket">GitHub - fatihkurcenli/KtorWebSocket: Kotlin ktor backend web socket</a></li><li><a href="https://github.com/fatihkurcenli/WebSocketAndroid">GitHub - fatihkurcenli/WebSocketAndroid: Kotlin WebSocket Android</a></li></ul><h3>📚Dokümanlar →</h3><ul><li><a href="https://ktor.io/docs/creating-web-socket-chat.html#creating-the-chat-client">Creating a WebSocket chat | Ktor</a></li><li><a href="https://github.com/TooTallNate/Java-WebSocket">GitHub - TooTallNate/Java-WebSocket: A barebones WebSocket client and server implementation written in 100% Java.</a></li><li><a href="https://medium.com/swlh/android-tutorial-part-1-using-java-websocket-with-kotlin-646a5f1f09de">Android Tutorial Part 1 Using Java-WebSocket With Kotlin</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a757d445fd04" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Google Harita ile Yer İşaretleri]]></title>
            <link>https://medium.com/cnk-tech/google-harita-ile-yer-i%CC%87%C5%9Faretleri-d126f9836a0?source=rss-350d6c9c2df8------2</link>
            <guid isPermaLink="false">https://medium.com/p/d126f9836a0</guid>
            <category><![CDATA[maps]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[android-google-map]]></category>
            <category><![CDATA[androiddev]]></category>
            <dc:creator><![CDATA[Fatih Kurçenli]]></dc:creator>
            <pubDate>Wed, 01 Sep 2021 14:53:03 GMT</pubDate>
            <atom:updated>2021-09-01T14:53:03.787Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*syYDgLodokZeRAdQLc3VRA.jpeg" /><figcaption><a href="https://unsplash.com/photos/eyfMgGvo9PA">Used Unsplash site, made by Brett Zeck</a></figcaption></figure><p>Merhabalar arkadaşlar bu yazımda mobil dünyasında çokça kullandığımız haritalardaki işaretlerden bahsedeceğim. Bildiğiniz üzere konum adresimiz gönderirken veya bir konumu bulmak için işaretler kullanırız ve o adrese doğru yolculuk ederiz. Bazen ise bu adresler bir banka ATM’si, bazen bir restoran, bazen bir hastane gibi devam etmekte. Bazı yerlerde düşünüldüğünde birden fazla ATM bankasını işaretlemek zorunda kalıyoruz ve burada işaretler iç içe giriyor ve kaç ATM bankası sayısını bilmekte zorlanıyoruz. Haritalarda bu kısmı düzeltmek için Google Maps’te kullandığımız Cluster yapısını bugün değineceğim.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2Fl378jPZA8DVxUhCjS%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2Fl378jPZA8DVxUhCjS%2Fgiphy.gif%3Fcid%3D790b7611bbf1221a41eb490cccca1cf18e5cd75065351cf6%26rid%3Dgiphy.gif%26ct%3Dg&amp;image=https%3A%2F%2Fi.giphy.com%2Fmedia%2Fl378jPZA8DVxUhCjS%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="242" frameborder="0" scrolling="no"><a href="https://medium.com/media/e7445948144267ba9b4dd53f1a29b7d3/href">https://medium.com/media/e7445948144267ba9b4dd53f1a29b7d3/href</a></iframe><p>💻 İşaretçilerimizden önce google maps’imizi kuralım ve ekranımızda gösterlim. Eklememiz gereken iki kütüphaneyi app modulü altında dependency kısmında ekliyoruz. Birincisi Google Maps servisimiz ikincisi ise Cluster yapımız için kullanacağız. Eğer bu yazı tarihinden sonra güncellemeler geldiyse güncel değerlerini giriniz.</p><pre>//Google Maps<br>implementation &#39;com.google.android.gms:play-services-maps:17.0.1&#39;<br>implementation &#39;com.google.maps.android:android-maps-utils:2.2.5&#39;</pre><p>Kütüphanelerimizi eklediğimize göre diğer bir kısım olan Google Map API key alıyoruz ve local.properties MAPS_API_KEY=? yazıyoruz ve manifest dosyamızda meta data olarak ve google gms version meta datamızı ekliyoruz. İnternet izni ve lokasyon bilgisini almak için izinlerimizi ekliyoruz. Meta datamız &lt;application... tagın içerisinde olmasına dikkat ediyoruz. Eğer uygulamamız API leveli 28 ve üstü ve kütüphanemiz 16.0.0 üstü ise Google apache.http.legacy metadatamızı eklememizi istiyor aksi takdirde eklememize gerek olmadığı <a href="https://developers.google.com/maps/documentation/android-sdk/config#apache_http_legacy_library"><em>yazmakta</em></a>.</p><pre>&lt;uses-permission android:name=&quot;android.permission.ACCESS_COARSE_LOCATION&quot; /&gt;<br>&lt;uses-permission android:name=&quot;android.permission.ACCESS_FINE_LOCATION&quot; /&gt;<br>&lt;uses-permission android:name=&quot;android.permission.INTERNET&quot; /&gt;</pre><pre>&lt;application...</pre><pre>&lt;meta-data<br>    android:name=&quot;com.google.android.geo.API_KEY&quot;<br>    android:value=&quot;${MAPS_API_KEY}&quot; /&gt; </pre><pre>&lt;meta-data<br>    android:name=&quot;com.google.android.gms.version&quot;<br>    android:value=&quot;@integer/google_play_services_version&quot; /&gt;</pre><pre>&lt;!-- Eğer api levelimiz 28 ve üstüyse eklememiz gerekiyor--&gt;<br>&lt;uses-library<br>    android:name=&quot;org.apache.http.legacy&quot;<br>    android:required=&quot;false&quot; /&gt;</pre><pre>&lt;/application&gt;</pre><p>Kullanıcıdan lokasyon iznini isteyeceğiz neden kabul etmesi gerek hakkında bilgi vereceğiz. İzinler hakkında çok yakında bir yazı daha gelecek. Şimdilik izin için istenen kodu aşağıdaki gibi yazıyoruz.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2a6561a0a5cf181e0c484e01fefdb1bc/href">https://medium.com/media/2a6561a0a5cf181e0c484e01fefdb1bc/href</a></iframe><p>Şimdi xml dosyamızı düzenleyelim main sayfamızda bir framelayout koyarak fragmentımızı koyacağız.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/97bd059fa67d757bc0555a402b5a545a/href">https://medium.com/media/97bd059fa67d757bc0555a402b5a545a/href</a></iframe><p>Fragment yapımızı tasarımını yapalım.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d369a385598116235eb285940dfc8d4b/href">https://medium.com/media/d369a385598116235eb285940dfc8d4b/href</a></iframe><p>MainActivity’de fragmentımızı ekliyoruz.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/35ee9b496dd90b0e013290c1432dc218/href">https://medium.com/media/35ee9b496dd90b0e013290c1432dc218/href</a></iframe><p>Tasarımlarımız tamamladıktan sonra fragment yapımızı yazalım.Boş bir fragment yapısı oluşturuyoruz. Maps koyacağımız fragment view supportMapFragment sayesinde fragment yapımızı setliyoruz.</p><pre>//onCreatedView kısmında view layoutumuzu setleyip dönüyoruz.<br>View view = inflater.inflate(R.layout.<em>fragment_map</em>, container, false);<br>//initialize map fragment<br>SupportMapFragment supportMapFragment = (SupportMapFragment) getChildFragmentManager().findFragmentById(R.id.<em>google_map</em>);</pre><p>Artık nesnesini ürettiğimizin supportMapFragment yapısında getAsyncMap fonksiyonumuzu çağırıyoruz. Asenkron fonksiyonlar uygulamamız açılırken yeni bir thread açarak asenkron bir şekilde çalışmasını sağlar bu sayede kullanıcı UI ekranında kasma görmemekte ve stabil bir şekilde arka tarafta isteklerimizi atarken kullanıcı uygulamada gezinebilmeyi sağlamakta.</p><pre>private GoogleMap mMap;<br>private ClusterManager&lt;MyClusterItem&gt; clusterManager;</pre><pre>supportMapFragment.getMapAsync(new OnMapReadyCallback() {<br>    @Override<br>    public void onMapReady(@NonNull GoogleMap googleMap) {<br>       mMap = googleMap;<br>    }<br>});</pre><p>onMapReady fonksiyonumuz override ederek artık googleMap nesnemize erişebilmekteyiz. Private olarak sınıfımızın içerisinde fonksiyonlarımız erişmesi için GoogleMap’ten mMap nesnesine eşitliyoruz.</p><p>Sırada Cluster’larımızı yerleştirmekte. Öncelikle MyClusterItem adlı bir sınıf kuruyoruz ve ClusterItem’dan impelements almasını sağlıyoruz. ClusterItem kütüphanesi import ediyoruz.</p><pre>import com.google.maps.android.clustering.ClusterItem;</pre><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f6670c8b5ba84925519d5ff4e8c24288/href">https://medium.com/media/f6670c8b5ba84925519d5ff4e8c24288/href</a></iframe><p>MyClusterItem yapımızda new bir position için latitude and longitude değerlerini constructor yapımızda alıyoruz ayrıca her bir yer işareti için title ve snippet alanı alıyoruz. ve ClusterItem’dan implements aldığımız fonksiyonlarımızı override ediyoruz. Pozisyon değeri null bir değer olamaması için NonNull annotation yazıyoruz. Şimdi setupCluster() fonksiyonumuzu oluşturuyoruz. Bu fonksiyonumuzda ClusterManager nesnemizi setliyoruz. Ayrıca başlangıç olarak İstanbul kordinatlarını veriyorum ve açıldığı zaman map ilk olarak İstanbul açılmasını sağlıyoruz</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/01a90392db9004b296fc89f70bde9039/href">https://medium.com/media/01a90392db9004b296fc89f70bde9039/href</a></iframe><p>ClusterManager nesnesi oluşturuyoruz ve bu nesnemize context ve oluşturduğumuz mMap(GoogleMap) nesnesini consturctora veriyoruz. Eğer activity kullanıyorsak thisdiyerek context yapısına erişebiliriz. mMap yapımıza setOnCameraIdleListener() yapısına oluşturduğumuz clusterManager nesnemizi veriyoruz. Bu sayede clusterManager yapımız map hareketliliklerini dinleyerek işlem yapacaktır. Ayrıca Mapte tıklama hareketlerini de setliyoruz. Yer işaretlerimizi oluşturmak için setMarkerList() fonksiyonumuzu yazıyoruz.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6756bb70dfbbb6f4f326c3b1cbc72726/href">https://medium.com/media/6756bb70dfbbb6f4f326c3b1cbc72726/href</a></iframe><p>Datalarımızı yüklüyoruz. Buradaki değerleri ben Mock data olarak ekledim. Eğer servisten gelen verileriniz var ise burada setlemeniz gerekmektedir. Son olarak Fragment yapımız aşağıdaki gibi olmaktadır.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2af5e2c215915388c4428587dd0cc550/href">https://medium.com/media/2af5e2c215915388c4428587dd0cc550/href</a></iframe><p>Sonuç olarak belli bir alanda birden fazla yer işaretleri olduğu zaman eğer haritayı büyüttüğümüzde yer işaretleri toplanarak kaç tane yer işareti olduğunu gösteren haritamızı elde etmiş oluyoruz.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/360/1*J1NlttZb5PCTosxWpFER7w.gif" /><figcaption>Cluster Markers</figcaption></figure><p>Uygulamanın github linki;</p><p><a href="https://github.com/fatihkurcenli/ClusterMarkersMap">GitHub - fatihkurcenli/ClusterMarkersMap: ClusterMarkers with Google maps using Java Language</a></p><p>📚 Kaynaklar</p><ul><li><a href="https://developers.google.com/maps/documentation/android-sdk/utility/setup">Maps SDK for Android Utility Setup | Google Developers</a></li><li><a href="https://developers.google.com/maps/documentation/android-sdk/utility/marker-clustering#maps_android_utils_clustering_cluster_item-kotlin">Google Maps Android Marker Clustering Utility | Maps SDK for Android</a></li></ul><p>Bir sonraki yazıma kadar görüşmek üzere keyifli kodlamalar dilerim. :)</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2F1pAe8oyaf96Me1ClgH%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2F1pAe8oyaf96Me1ClgH%2Fgiphy-downsized-large.gif%3Fcid%3D790b7611683abdab2b3814bcf9d3232d108dcf8598c92cc8%26rid%3Dgiphy-downsized-large.gif%26ct%3Dg&amp;image=https%3A%2F%2Fi.giphy.com%2Fmedia%2F1pAe8oyaf96Me1ClgH%2Fgiphy-downsized-large.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="435" frameborder="0" scrolling="no"><a href="https://medium.com/media/f296c3384fb9365081f9990e9876c3a7/href">https://medium.com/media/f296c3384fb9365081f9990e9876c3a7/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d126f9836a0" width="1" height="1" alt=""><hr><p><a href="https://medium.com/cnk-tech/google-harita-ile-yer-i%CC%87%C5%9Faretleri-d126f9836a0">Google Harita ile Yer İşaretleri</a> was originally published in <a href="https://medium.com/cnk-tech">CNK Tech</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Flutter Star Background]]></title>
            <link>https://medium.com/cnk-tech/flutter-star-background-d348f2409759?source=rss-350d6c9c2df8------2</link>
            <guid isPermaLink="false">https://medium.com/p/d348f2409759</guid>
            <category><![CDATA[flutter-app-development]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[flutter-widget]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <dc:creator><![CDATA[Fatih Kurçenli]]></dc:creator>
            <pubDate>Wed, 31 Mar 2021 17:34:34 GMT</pubDate>
            <atom:updated>2021-03-31T17:34:34.685Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/650/1*9YFEp8_HhppgA7b-6oxs5A.gif" /><figcaption>Stars</figcaption></figure><p>Hello everyone, today we’ll make you a beautifully animated star on the background flutter app. Let’s code it.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FCjmvTCZf2U3p09Cn0h%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2FCjmvTCZf2U3p09Cn0h%2Fgiphy.gif&amp;image=https%3A%2F%2Fi.giphy.com%2Fmedia%2FCjmvTCZf2U3p09Cn0h%2Fgiphy.gif&amp;key=d04bfffea46d4aeda930ec88cc64b87c&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="409" frameborder="0" scrolling="no"><a href="https://medium.com/media/299d92410c85baea4abbb6ad6d7f7285/href">https://medium.com/media/299d92410c85baea4abbb6ad6d7f7285/href</a></iframe><p>First of all, we open a flutter project and create a <a href="https://api.flutter.dev/flutter/widgets/StatefulWidget-class.html">stateful widget</a>. Why do we need a stateful widget. Because we will provide our animations with SingleTickerProviderStateMixin So we need a stateful widget.</p><p>Let’s write our class that will make our starts in different places. This will allow us to produce stars in different places.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7b00b36dea048436c302963c7b21f63f/href">https://medium.com/media/7b00b36dea048436c302963c7b21f63f/href</a></iframe><p>Okay, now we will do the process, keep a list, and production values from this class. However, I want the values we will produce to be random; in this case import &#39;dart:math&#39; Using the Random library. We are generating a ‘List&lt;WhereStar&gt; listStar’ list in our stateful widget. We assign random values from the WhereStar class we created in our init state method and add them to our list.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f3e50a1c5ce1ba8fa966ef8ce6a50dbb/href">https://medium.com/media/f3e50a1c5ce1ba8fa966ef8ce6a50dbb/href</a></iframe><p>Here you can adjust the values that we multiply by 500 according to you. To explain the values here one by one;</p><ul><li>Left = How far will it be from the left</li><li>Bottom = How far will it be from the bottom</li><li>Top = How far will it be from the top</li><li>ExtraSize = Makes every star a different size</li><li>Angle = Star rotational value</li><li>TypeFade = This is the part of labelling certain stars and making them burn out with animation.</li></ul><p>We will take these values that we create and place these stars as Random, thanks to the Position widget that a flutter provides us.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/29cd55f6824d7a3fe5f2f1aded4b709a/href">https://medium.com/media/29cd55f6824d7a3fe5f2f1aded4b709a/href</a></iframe><p>There are three important events here, one of which is transformed rotate, transform translate and opacity. These will provide our animation. We place the values we created thanks to the position as the bottom left and top. With alignment:FractionalOffset.center , it is average within the container. Transform rotate angle, and we randomly generated how much the star should rotate; we give that value. Transform translate offset, and we make the star displace. We will mention that the value here is _animation where we write the animation code. We are querying in Opacity; if 1, the first group of stars is burning 2,3,4. These values are changing, and we change the animation code.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/36d659730337ee695645a73ae71bf911/href">https://medium.com/media/36d659730337ee695645a73ae71bf911/href</a></iframe><p>Now it has come to produce many times from the widget we created, and we are placing a new List&lt;Widget&gt; in a for a loop. And we keep these created values in Stack.</p><p>Let’s create our animations now.</p><blockquote>Animation _animation;</blockquote><blockquote>Animation fadeAnimStar1, fadeAnimStar2, fadeAnimStar3, fadeAnimStar4;</blockquote><blockquote>AnimationController _animationController;</blockquote><p>Let’s give the init state values we created.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/36e72489fb3f74aa35b7d733b1e0bc7e/href">https://medium.com/media/36e72489fb3f74aa35b7d733b1e0bc7e/href</a></iframe><p>Thanks to the animated star we have created here, we create animation values Tween and give them to the stars in our application. We make it blink synchronously with the Interval feature.</p><p>This is the output of our application.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/360/1*MBzzu7htDUax9RDTZd9W0Q.gif" /></figure><p>Thank you for reading my article. See you again very soon. Keep going code like a baby. :)</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2Fl4pTeSVeMlLSXVhm0%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2Fl4pTeSVeMlLSXVhm0%2Fgiphy.gif&amp;image=https%3A%2F%2Fmedia2.giphy.com%2Fmedia%2Fv1.Y2lkPTc5MGI3NjExbW4xNDIyZjFmdnc2bWY4c3c2ZWdtOTFvdGJkN2N5c3NjZjVvMXlnbSZlcD12MV9naWZzX2dpZklkJmN0PWc%2Fl4pTeSVeMlLSXVhm0%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="435" frameborder="0" scrolling="no"><a href="https://medium.com/media/761a0a32f4320865725f739de09436e0/href">https://medium.com/media/761a0a32f4320865725f739de09436e0/href</a></iframe><p><a href="https://github.com/fatihkurcenli/Star-Animation">fatihkurcenli/Star-Animation</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d348f2409759" width="1" height="1" alt=""><hr><p><a href="https://medium.com/cnk-tech/flutter-star-background-d348f2409759">Flutter Star Background</a> was originally published in <a href="https://medium.com/cnk-tech">CNK Tech</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Android Line Chart]]></title>
            <link>https://medium.com/cnk-tech/android-line-chart-621f56410883?source=rss-350d6c9c2df8------2</link>
            <guid isPermaLink="false">https://medium.com/p/621f56410883</guid>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[android-apps]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Fatih Kurçenli]]></dc:creator>
            <pubDate>Sun, 21 Feb 2021 13:16:54 GMT</pubDate>
            <atom:updated>2021-03-29T19:27:25.416Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*lHtDF6_0TnFZoDsecZ8jlQ.gif" /><figcaption>Android Graph</figcaption></figure><p>I’ll share my experience of drawing line charts with Kotlin on Android today. Nowadays, we are trying to present the data most simply, and we know that drawing a graph is the best tool we use for this. We also need to install additional libraries to display line graphs in the Android application. You can find many Android graphics libraries, but I will explain using the <a href="https://github.com/PhilJay/MPAndroidChart">MPChart </a>library in this article. I also share the links you will use for your further research at the bottom.</p><ul><li><a href="https://github.com/diogobernardino/williamchart"><strong><em>WiliamChart</em></strong></a></li><li><a href="https://github.com/PhilJay/MPAndroidChart"><strong><em>MPChart</em></strong></a></li><li><a href="https://github.com/FarshidRoohi/LineGraph"><strong><em>LineGraph</em></strong></a></li><li><a href="https://github.com/robinhood/spark"><strong><em>Spark</em></strong></a></li></ul><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Ftenor.com%2Fembed%2F4422719&amp;display_name=Tenor&amp;url=https%3A%2F%2Ftenor.com%2Fview%2Flet-gif-4422719&amp;image=https%3A%2F%2Fmedia.tenor.com%2Fimages%2F1e730b9156dd714e1d13dddde515b624%2Fraw&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=tenor" width="600" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/357cd50822ad71e96af3a60361112aed/href">https://medium.com/media/357cd50822ad71e96af3a60361112aed/href</a></iframe><p>Let’s coding and draw some graph. First of all, we have implementations that we need to add to the build.gradle file so that we can use this library.</p><pre>//We add the repositories folder in allprojects <br>allprojects <strong>{<br>    </strong>repositories <strong>{<br>        </strong>google()<br>        jcenter()<br>        maven <strong>{ </strong>url &#39;https://jitpack.io&#39; <strong>}<br>    }<br>}</strong></pre><pre>//We are also adding our implementation under dependencies<br>dependencies <strong>{</strong><br>    implementation &#39;com.github.PhilJay:MPAndroidChart:v3.1.0&#39;<br><strong>}</strong></pre><p>Now, let’s start making our submission. We need a UI design first.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f4ce64e719b40145d0ed833c1278f6cf/href">https://medium.com/media/f4ce64e719b40145d0ed833c1278f6cf/href</a></iframe><p>Okay, we added our LineChart for UI design and designed our ConstarintLayout app for responsive. I also have an article for design to read that article thanks to the <a href="https://fatihkurcenli.medium.com/android-layouts-16615ad2bda3">link </a>here. Then, start to show our data thanks to Kotlin; the part that needs to be considered here is that our data values are float.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b38b6cb6d0adc1434126f8933791156c/href">https://medium.com/media/b38b6cb6d0adc1434126f8933791156c/href</a></iframe><p>Here we are making the viewBinding additions.Then we write a setLineChartData() function and call this function in main. We create an ArrayList containing an entry object. Entry object can take values such as X, Y, Icon and any data; we are currently creating our chart by only entering float values in X and Y values. Then we create a val variable val linedatasetfor this data set we created. We can also customize our linedataset .Change the colour with the getColor function under our resources folder as colour. We can increase the radius value of our selected points. With the setDrawFilled function, we can paint the lower parts of our chart. We can define the colour value we want to paint under the resources folder and call it. By giving the text value, we can enlarge it or change its colour. On the other hand, with the function, we pass our graphic not as a direct line, but as a cubic in a more appealing way. To show these values on the UI screen, we set the data we created in the LineData object and threw them into the data variable, and then we send these values to our data with getTheGraph id in the activity_main.xml file viewBinding.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FfuKdUp3yolu4aBSo7Y%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2FfuKdUp3yolu4aBSo7Y%2Fgiphy.gif&amp;image=https%3A%2F%2Fi.giphy.com%2Fmedia%2FfuKdUp3yolu4aBSo7Y%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="252" frameborder="0" scrolling="no"><a href="https://medium.com/media/5fb9cb33adec3fdf5d9c35811ba7da9f/href">https://medium.com/media/5fb9cb33adec3fdf5d9c35811ba7da9f/href</a></iframe><p>Is that enough? If we want to draw graphics? Yes! However, we want our application to be more effective and appealing to the user, so we need to add animation. By giving duration with animatedXY function, we make our chart look more effective while drawing it. There are also many animation options in MPChart, and you can write your own animation functions if you want; you can look <a href="https://github.com/PhilJay/MPAndroidChart/wiki/Animations"><strong><em>here</em></strong></a> for detailed information. The codes of our application are at the bottom, and the output of our application is as follows;</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/360/1*XqV_FMIv5t-YZUO_MM4aBg.gif" /><figcaption>GraphExample Application</figcaption></figure><p>Thank you for reading my article. See you again very soon. Keep going code like a baby. :)</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Ftenor.com%2Fembed%2F17689613&amp;display_name=Tenor&amp;url=https%3A%2F%2Ftenor.com%2Fview%2Fbaby-typing-computer-cute-gif-17689613&amp;image=https%3A%2F%2Fmedia.tenor.com%2Fimages%2Fa4155aca7b6e777d1053a29ff0411ebd%2Ftenor.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=tenor" width="600" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/6a2381402fc281019033d5807a50d792/href">https://medium.com/media/6a2381402fc281019033d5807a50d792/href</a></iframe><p><a href="https://github.com/fatihkurcenli/GraphAndroid">fatihkurcenli/GraphAndroid</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=621f56410883" width="1" height="1" alt=""><hr><p><a href="https://medium.com/cnk-tech/android-line-chart-621f56410883">Android Line Chart</a> was originally published in <a href="https://medium.com/cnk-tech">CNK Tech</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Android Retrofit]]></title>
            <link>https://medium.com/cnk-tech/android-retrofit-99903d8ab8ca?source=rss-350d6c9c2df8------2</link>
            <guid isPermaLink="false">https://medium.com/p/99903d8ab8ca</guid>
            <category><![CDATA[android-apps]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[androiddev]]></category>
            <category><![CDATA[android-retrofit]]></category>
            <dc:creator><![CDATA[Fatih Kurçenli]]></dc:creator>
            <pubDate>Tue, 09 Feb 2021 15:26:43 GMT</pubDate>
            <atom:updated>2021-03-29T19:28:37.059Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*dWOsKviGw_TGzGayKkF0pQ.png" /></figure><p>Hello guys, today I will show you how we show the data in JSON format on Android on the recycler view screen.</p><p>First, let’s talk about JSON data;</p><blockquote>JSON stands for <strong>J</strong>ava<strong>S</strong>cript <strong>O</strong>bject <strong>N</strong>otation</blockquote><blockquote>JSON is a lightweight format for storing and transporting data</blockquote><blockquote>JSON is often used when data is sent from a server to a web page</blockquote><blockquote>JSON is “self-describing” and easy to understand</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Sc_EejTnUlrA9APQEyVv2w.png" /><figcaption>Data coming from a database with API</figcaption></figure><p>We send a request from the phone, and the API requests the data in the section where this request is located by accessing the database and returns the data to us in JSON format.</p><p>Web services allow different applications to communicate with each other. Platform independent. It also uses the HTPP protocol. No matter what language the data are written in. Web services are of two types;</p><ul><li>SOAP (Simple Object Access Protocol)</li><li>REST (Representational State Transfer)</li></ul><p>While SOAP sends in XML format, REST uses JSON format. Also, the REST service runs faster than SOAP.</p><h3>Retrofit</h3><p>We first look at the concepts of Retrofit and Gson. Retrofit is an open-source type-safe HTTP client library developed by Square. You can check out the Github source code. ( <a href="https://github.com/square/retrofit">Link</a> ) It is the most used and most efficient library for network requests in applications. We can import this library like this our project. We need to add this library to the dependencies section.</p><p>impletation &#39;com.squareup.retrofit2:retrofit:2.9.0</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2bc1d8d378bc529f14b04dd9b5a3a29c/href">https://medium.com/media/2bc1d8d378bc529f14b04dd9b5a3a29c/href</a></iframe><p>We write our functions by establishing an interface here, and then we create a data class and keep the data returned from this data there.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/80d6c26bf761beaf49cc955dd999b40a/href">https://medium.com/media/80d6c26bf761beaf49cc955dd999b40a/href</a></iframe><p>We are also using the converter-gson library.</p><p>implemantation &#39;com.squareup.retrofit2:converter-gson:{latest-version}&#39;</p><p>Then we create our retrofit object. And we need to enter the BaseUrl and addConverterFactory values.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3fa22b5e4a962f59a81ee812858bff21/href">https://medium.com/media/3fa22b5e4a962f59a81ee812858bff21/href</a></iframe><p>We discard our requests and then keep these requests in our data and keep it in a variable called service. After that, we reach this service and start using our functions.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/98139afdaac4ab598ca8f3c41477b703/href">https://medium.com/media/98139afdaac4ab598ca8f3c41477b703/href</a></iframe><p>It includes two methods. onFailure and onResponse. If we get an error, we need to inform the users in the UI section with the method we wrote in the onFailure function. If we are getting a successful request, here we write our function to show our data.</p><p>I leave a simple request application on the link for you. Data is available on the debug console LogCat.</p><p><a href="https://github.com/fatihkurcenli/BasicRetrofit">fatihkurcenli/BasicRetrofit</a></p><p>Hope to see you until my new post. Happy coding :)</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Ftenor.com%2Fembed%2F18815626&amp;display_name=Tenor&amp;url=https%3A%2F%2Ftenor.com%2Fview%2Fdroidcon-synesthesia-android-gif-18815626&amp;image=https%3A%2F%2Fmedia.tenor.com%2Fimages%2Fe5d2944d538e61cd12b6df8a1ac7c79c%2Ftenor.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=tenor" width="600" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/545051fa9f72f95c285ad9ecb06b8725/href">https://medium.com/media/545051fa9f72f95c285ad9ecb06b8725/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=99903d8ab8ca" width="1" height="1" alt=""><hr><p><a href="https://medium.com/cnk-tech/android-retrofit-99903d8ab8ca">Android Retrofit</a> was originally published in <a href="https://medium.com/cnk-tech">CNK Tech</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Android Layouts]]></title>
            <link>https://medium.com/cnk-tech/android-layouts-16615ad2bda3?source=rss-350d6c9c2df8------2</link>
            <guid isPermaLink="false">https://medium.com/p/16615ad2bda3</guid>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[android-layout]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[androiddev]]></category>
            <dc:creator><![CDATA[Fatih Kurçenli]]></dc:creator>
            <pubDate>Sat, 23 Jan 2021 13:26:58 GMT</pubDate>
            <atom:updated>2021-03-29T19:29:08.788Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*I0q0FJSbboKV8kvBT4mt2Q@2x.png" /></figure><p>Hello everyone, today I’m gonna talk about what is these android layouts.</p><p>First of all, everything we see in the UI is the view. There are certain basic components we frequently use in Views. Some of these;</p><ul><li>TextView</li><li>EditText</li><li>Button</li><li>CheckBox</li><li>RadioButton</li><li>Menu</li><li>ScrollView</li><li>RecyclerView</li><li>ImageView</li></ul><p>What are this ViewGroup and View hierarchy? Let’s look at this. Groups that contain views in the ViewGroup</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Bi_DHPsT-Xqg2-AGuzkPEg.png" /></figure><p>A parent viewGroup is created, child ViewGroups can also be created under this created group, and we can use our widgets here. WievGroup is a subclass for layouts and view containers.</p><blockquote>RecyclerView: List structure hosting a View or ViewGroup</blockquote><blockquote>LinearLayout: Adjust the views in it horizontally/vertically</blockquote><blockquote>ScrollView: Makes the child view inside it scrollable</blockquote><h3>What is Layout?</h3><p>A layout defines the structure for a user interface in your app, such as in an activity. All elements in the layout are built using a hierarchy of View and ViewGroup objects. Layouts include;</p><blockquote>Consists of ViewGroups</blockquote><blockquote>Subclasses of the ViewGroup</blockquote><blockquote>They contain child Views</blockquote><blockquote>They can be used as rows, columns, grids, tables.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TjRsZm0g1t8a6XVt7dBaWA.png" /></figure><h3>Types Of Layouts</h3><ul><li><strong>LinearLayout: </strong><em>Horizontal or vertical alignment</em></li><li><strong>RelativeLayout: </strong><em>İnterconnected child views</em></li><li><strong>TableLayout: </strong><em>Rows and columns</em></li><li><strong>FrameLayout: </strong><em>Can overlap child views</em></li><li><strong>GridView: </strong><em>Grid view</em></li><li><strong>ConstraintLayout: </strong><em>İnterconnected child views, RelativeLayout’s advanced layout types</em></li></ul><p>LinearLayout is extending ViewGroup, RelativeLayout extends ViewGroup, ViewGroup is extending View implements ViewParent, ViewManager.</p><h3>LinearLayout</h3><p>The biggest reason for choosing this layout is to use the horizontal or vertical feature. You can see these two examples. While the first one uses horizontal, the second is when using vertical. İf we want to divide it into how many parts in the linear layout can use it. android:weightSum And then, we can set how much space that button can’t use by giving. android:layout_weight . Also, we can use margin, padding, gravity, orientation …</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5uS-_q0AjrZ8kbuqUFBjHg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pLvx_9NWghc6iejUnZLaeQ.png" /><figcaption>Horizontal/Vertical</figcaption></figure><h3>RelativeLayout</h3><p>RelativeLayout helps us make a responsive design. Provides the same look on different devices. Besides, the biggest feature apart from linear layout is that it does not offer a nested design. In this approach, we make these structures a responsive structure by giving features such as layout_centerInParent , depending on how and according to what we want the structures we use to be aligned. When we use the layout_alignBottom structure, it allows us to align according to that structure&#39;s lower value.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mQZkKzxn3BpEKLnw4YwrjQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*i0Fsd3sTGo6FMG8XuR_4Kw.png" /></figure><h3>FrameLayout</h3><p>FrameLayout is the simplest implementation of ViewGroup. Child views are drawn in a stack where the latest added view is drawn at the top. Usually, we can use one of the next approaches or combine them. The widget we added last is placed at the top of our frame layout.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hlGF3rlWtIsJQpxFIrFQeA.png" /></figure><h3>ConstraintLayout</h3><p>ConstraintLayout, which is now the default layout in Android Studio, gives you many ways to place objects. We can constrain them to their container, to each other, or guidelines. This allows us to create large, complex, dynamic, and responsive views in a flat hierarchy. Also, it even supports animations.</p><p>It’s advantageous for us to use constraint layout as a performance. Because every relative layout or fragment layout we use runs behind a java code, it will take time for us to run these codes. However, running a single class using the constraint layout we use will reflect positively for us as speed. Since constraint layout is a library, we need to call this library from build.gradle .</p><pre>implementation &#39;androidx.constraintlayout:constraintlayout:2.0.4&#39;</pre><p>Android Studio automatically adds new versions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xEYLwy0_fK1bbtJVBDEd-Q.png" /></figure><p>Cycle chanStyle in the application can separate horizontally and vertically in the screen view with proper order and equal spacing. Like this;</p><p>app:layout_constraintHorizontal_chainStyle=&#39;spread_inside&#39;</p><p>The helper guideline option helps us make a smoother design thanks to the ruler where we will place our widgets.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jWUVhJ2AAs8Q1Hdz_NvQGg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ljesn31WeLnF-8baSqJDCw.png" /></figure><p>By adding barriers, we can avoid design problems in our application. In this way, our writings will remove the possibility of overflowing and having text on them, as they will not pass to the opposite side in case of overflow. Thanks to guidelines, we connect our widgets with the vertical and horizontal rulers, allowing us to automatically change our widget values when the design change and the margin value changes.</p><p>Thank you for reading my article, see you again very soon. Keep going code like a baby. :)</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Ftenor.com%2Fembed%2F14973771&amp;display_name=Tenor&amp;url=https%3A%2F%2Ftenor.com%2Fview%2Fmargot-margot-saves-margot-to-save-hoeffner-fast-fingers-gif-14973771&amp;image=https%3A%2F%2Fmedia.tenor.com%2Fimages%2Fdc5a52d5b1d70864effb279abc440f69%2Ftenor.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=tenor" width="600" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/fafac9668a6b038a38f918aa545f5fd6/href">https://medium.com/media/fafac9668a6b038a38f918aa545f5fd6/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=16615ad2bda3" width="1" height="1" alt=""><hr><p><a href="https://medium.com/cnk-tech/android-layouts-16615ad2bda3">Android Layouts</a> was originally published in <a href="https://medium.com/cnk-tech">CNK Tech</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[MVVM Design Pattern with Flutter]]></title>
            <link>https://medium.com/cnk-tech/mvvm-design-pattern-with-flutter-a6886dbd0c03?source=rss-350d6c9c2df8------2</link>
            <guid isPermaLink="false">https://medium.com/p/a6886dbd0c03</guid>
            <category><![CDATA[design-patterns]]></category>
            <category><![CDATA[mvvm]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <dc:creator><![CDATA[Fatih Kurçenli]]></dc:creator>
            <pubDate>Thu, 05 Nov 2020 14:12:20 GMT</pubDate>
            <atom:updated>2021-03-29T19:29:45.318Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/941/1*NvvHhA24kizVjj7W50AnuA.png" /></figure><p>Hello everyone, today I will tell you about MVVM design pattern.</p><p>When we write our codes, we are faced with many problems when they are written irregularly.<br>These appear as view logic and business logic. Since there are no restrictions when writing our application in Flutter, the codes we write are more complex and since each page is made as a widget, it is very difficult to manage and test writing. As a result, we need to rewrite our code because the first one has become too complex. We use Model-View-ViewModel(MVVM) to solve this complexity by separating the business logic and view logic.</p><h4>Why Use MVVM ?</h4><ul><li>It allows you to test more parts of your application.</li><li>Reuse code easily.</li><li>Better code readability.</li><li>Better performance.</li></ul><h4>How It Works ?</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/875/1*tLd4cqWNUX3ltxP3GqCsXg.png" /></figure><p>Business logic is located in ViewModel. It serves as the mediator between the View and the Model. In business logic, it is used to transfer the data from the model to the view. If there is a change from the view, we run this function in the business logic and ask the model to update the data, and we reflect the data from the result back to the view.</p><p><strong>Model</strong>: It consists of POCO and asset classes used to send our data from the data source. It is the section that includes all the services of our application and the processes of calling data modeled.</p><p><strong>View: </strong>It is the section where all the design structures in your application are located. It is the last interface seen by users. It provides the connection between the application we write and the user.</p><p><strong>ViewModel: </strong>ViewModel is the structure that connects model structure to view structure. The ViewModel structure cannot directly access the view, but the ViewModel can access the view. The ViewModel structure can access the model structure, but the model structure cannot access the ViewModel structure.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FWyeodYfrqvHCo%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2FWyeodYfrqvHCo%2Fgiphy.gif&amp;image=https%3A%2F%2Fi.giphy.com%2Fmedia%2FWyeodYfrqvHCo%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="287" frameborder="0" scrolling="no"><a href="https://medium.com/media/cf0434b551c6e1e20c1470c32a5569e0/href">https://medium.com/media/cf0434b551c6e1e20c1470c32a5569e0/href</a></iframe><p><strong>Let’s look at the sample project.</strong></p><p>First of all we have to create one flutter project. Then we add the <a href="https://pub.dev/packages/http"><strong>http</strong> </a>library in the pubspec.yamlfile. We need a Rest API server, we will do this using the <a href="https://jsonplaceholder.typicode.com/"><strong>jsonplaceholder </strong></a>website. We use posts data.</p><p>Let’s create a model class for our data. We will use <a href="https://javiercbk.github.io/json_to_dart/">JSON to dart</a> website for this. If you use json to dart we have to like this model class.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c3a3511696f70fddf9d09a70d3d238f5/href">https://medium.com/media/c3a3511696f70fddf9d09a70d3d238f5/href</a></iframe><p>Then we create a stateful widget but we will code them to communicate with each other.</p><p>First file like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fffae2d7b8e400922353750104d91108/href">https://medium.com/media/fffae2d7b8e400922353750104d91108/href</a></iframe><p>Now, we will write our<strong> getPost()</strong> method in business logic. In this method, we will send a service request and check the response body and send it to the list we opened as postModel. If there is an error, we show it to the user with a showDialog.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fdd1f4dd427efdd1b3968497057fee31/href">https://medium.com/media/fdd1f4dd427efdd1b3968497057fee31/href</a></iframe><p>Finally, we will show the incoming data to the user. Using a ListViewBuilder, we will display our data in a list. If the data is loaded, the loading icon will be active in the appbar.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/237fb6e5ae68f988b158e129237ed25a/href">https://medium.com/media/237fb6e5ae68f988b158e129237ed25a/href</a></iframe><p>Thus, we have created a view model and viewModel. Our structure is now combined with a business structure that allows it to communicate with each other. The output of our application is like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/263/1*d1ezztXXAqzzfHMtUzTTow.gif" /></figure><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2F3o84U9arAYRM73AIvu%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2F3o84U9arAYRM73AIvu%2Fgiphy.gif&amp;image=https%3A%2F%2Fi.giphy.com%2Fmedia%2F3o84U9arAYRM73AIvu%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="290" frameborder="0" scrolling="no"><a href="https://medium.com/media/c859c423f8c4679ac9a4184ca0581b55/href">https://medium.com/media/c859c423f8c4679ac9a4184ca0581b55/href</a></iframe><p>You can find the application here:</p><p><a href="https://github.com/fatihkurcenli/Flutter-mvvm-example">fatihkurcenli/Flutter-mvvm-example</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a6886dbd0c03" width="1" height="1" alt=""><hr><p><a href="https://medium.com/cnk-tech/mvvm-design-pattern-with-flutter-a6886dbd0c03">MVVM Design Pattern with Flutter</a> was originally published in <a href="https://medium.com/cnk-tech">CNK Tech</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Android Platform Version]]></title>
            <link>https://medium.com/hardwareandro/android-platform-version-6abae75b304a?source=rss-350d6c9c2df8------2</link>
            <guid isPermaLink="false">https://medium.com/p/6abae75b304a</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[version]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <dc:creator><![CDATA[Fatih Kurçenli]]></dc:creator>
            <pubDate>Wed, 19 Aug 2020 20:04:42 GMT</pubDate>
            <atom:updated>2020-08-20T13:36:21.025Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*E8pYA1HrVC0_aDwls7_0qA.png" /></figure><p>Merhaba herkese. Bu yazımda size android platform versiyonlarının ne olduğunu ve hangisini kullanmak gerektiğini ve versiyon farklılıkların ne olduğunu dilimin döndüğü kadarıyla anlatmaya çalışacağim keyifli okumalar.</p><h4>Android Nedir ?</h4><p>Öncelikle android ne olduğundan bahsedelim. Android, temel olarak akıllı telefonlar ve tabletler gibi dokunmatik ekranlı mobil cihazlar için tasarlanmış, Linux çekirdeğinin ve diğer açık kaynaklı yazılımların değiştirilmiş bir sürümünü temel alan bir mobil işletim sistemidir. Android, Google developerlar tarafından geliştirilmiştir. Mobil işletim olarak sürülen ve ilk kez Eylül 2008&#39;de piyasaya sürülen ilk ticari Android cihazla 2007&#39;de tanıtıldı.</p><h4>Android API Nedir ?</h4><p>Her Android Framework API’sinin integer cinsinden tekil (unique) bir API Level değeri bulunur. Framework API, uygulamamız ile işletim sisteminin haberleşmesini ve etkileşimde bulunmasına yarar. Android platformu, uygulamaların temeldeki Android sistemiyle etkileşimde bulunmak için kullanabileceği bir framework API sağlar.</p><p>Peki bir framework API nelerden oluşur ?</p><ul><li>Temel paketler ve sınıflar kümesi.</li><li>Bir manifest dosyası bildirmek için bir dizi XML öğesi ve nitelik.</li><li>Kaynakları bildirmek ve bunlara erişmek için bir dizi XML öğesi ve öznitelik.</li><li>Android geliştirmek için oluşan amaçlar.</li><li>Uygulamaların talep edebileceği izin ve sisteme dahil edilmek için istenen izin uygulamaları.</li></ul><p>Android platformun birbirini izleyen her sürümünde sunduğu Android uygulama frameworku API’sına göre güncelleme isteyebilir. Peki yapılan güncellemeler sonrasında bu API’dan sonra kullanımaz hale gelmiyor ve yeni gelen framework API önceki sürümleriyle uyumlu kalabilmesi için tasarlanılıyor. Başka bir deyişle API’daki çoğu değişiklik eklemelidir ve yeni veya değiştirme işlevi sunmaktadır. API’ın parçaları yükseldikçe, değiştirilen eski parçalar kullanımdan kaldırılır ancak tam olarak silinmez ki mevcut uygulamaların bunları kullanmaya devam edebilir olması sağlanır böylece. Bazı önemli durumlarda tam kaldırılma sağlanması olabilmektedir güvenlik ve sistem sağlamlığı açısından önemli değişikliklerde silme veya değiştirme yapılır.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Ftenor.com%2Fembed%2F8915687&amp;display_name=Tenor&amp;url=https%3A%2F%2Ftenor.com%2Fview%2Fandroid-kit-kat-candy-gif-8915687&amp;image=https%3A%2F%2Fmedia.tenor.com%2Fimages%2Fa4ffd942a85dec19ebd07f3063e7f394%2Ftenor.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=tenor" width="600" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/913d9603877b799327c08d8859848005/href">https://medium.com/media/913d9603877b799327c08d8859848005/href</a></iframe><h4>Android API levellerin kullanımları</h4><p>API levelleri, kullanıcılar ve uygulama geliştiricileri için mümkün olan en iyi deneyimi sağlamada önemli bir rol oynar:</p><ul><li>Uygulamaların, ihtiyaç duydukları framework API gözden geçirmeye ve açıklamasına olanak sağlar.</li><li>Eğer o uygulama o sürümde desteklemiyorsa kullanıcılara uygulamanın kurulumunda yüklenmez ve bunun hakkında bilgiler sağlar.</li><li>Her Android platform sürümü, API leveli Android sisteminin kendisinde dahili olarak depolar.</li></ul><h4>Android geliştiriciler için geliştirme hususları</h4><p>İleriye dönük uygulama özelliği</p><ul><li>Android uygulamaları genellikle Android platformunun yeni sürümleriyle ileriyle uyumludur çünkü API frameworkun neredeyse tümü eklemelidir, API’nin herhangi bir sürümünde bir Android platformunun sonraki sürümleri ve daha fazla yüksek API düzeyleri ile ileriye dönük olarak uyumludur.</li></ul><p>Geriye dönük uygulama özelliği</p><ul><li>Android uygulamaların, derlendikleri sürümden daha eski Android platforma ihtiyaç duymaz ancak her yeni sürümde değişen API parçaları olduğunda ileriki uygulamaların kullanabildiği özellikleri kullanması için API level değişimi yapması gerekmektedir.</li></ul><p>Bir platform seçme ve API seviyesi seçme</p><ul><li>Uygulamamızı geliştirirken, uygulamayı derleyeceğimiz platform sürmümüzü seçmek gerekecektir. Genel olarak uygulamamızı destekleyebilceği ve mümkün olan en düşük sürüme göre derlemeliyiz.</li></ul><p>Minimum API seviyesini belirlemek</p><ul><li>Eğer ki API’leri veya sistem özelliklerini kullanan bir uygulama oluşturursanız, <strong>android: minSdkVersion</strong> özniteliğini en son platform sürümünün API Düzeyine ayarlamalısınız. Bu da uygulamanızın cihazlarında düzgün çalışabilmesini sağlar.</li></ul><p>API yüksel levellerde uygulama testi</p><ul><li>Uygulamamızı derledikten sonra, uygulamanın <strong>android: minSdkVersion</strong> özniteliğinde belirtilen platformda test ettiğinizden emin olmalıyız. Bunu yapmak için daha yüksek bir API emülatör kullanabiliriz.</li></ul><pre>&lt;uses-sdk android:<a href="https://developer.android.com/guide/topics/manifest/uses-sdk-element#min"><strong>minSdkVersion</strong></a>=&quot;<em>integer</em>&quot;<br>          android:<a href="https://developer.android.com/guide/topics/manifest/uses-sdk-element#target"><strong>targetSdkVersion</strong></a>=&quot;<em>integer</em>&quot;<br>          android:<a href="https://developer.android.com/guide/topics/manifest/uses-sdk-element#max"><strong>maxSdkVersion</strong></a>=&quot;<em>integer</em>&quot; /&gt;</pre><p>Google Play, uygulamanızı platform sürümü gereksinimlerini karşılamayan cihazlardan filtrelemek için uygulamanızın manifestinde belirtilen <strong>&lt;uses-sdk&gt;</strong> özelliklerini kullanır. Bu özellikleri ayarlamadan önce, minSdkVersion, targetSdkVersion ve maxSdkVersion değerlerini vermeliyiz. Bu kodu da <strong>&lt;manifest&gt;</strong> dosyasının içine koymamız gerekiyo. Manifest kodunu da sizinle paylaşımda bulunayım.Burada belirttiğimiz değer ile uygulamamızın en düşük hangi Android sürümünde çalışabileceğini belirtiyoruz.Uygulamamızın bir cihaza yüklenebilmesi için cihaz üzerinde koşan işletim sisteminin API Level değeri, bizim belirttiğimiz “<strong>minSdkVersion</strong>” değerinden düşük olmaması gerekiyor, aksi halde uygulamayı cihazımıza kuramayızBurada belirttiğimiz değer ile uygulamamızı belirtilen API Level’de düzgün bir şekilde çalıştığını garanti etmiş oluyoruz. Eğer “<strong>targetSdkVersion</strong>” değeri belirtilmemişse varsayılan değer olarak “<strong>minSdkVersion</strong>” değeri verilir. <strong>maxSdkVersion u</strong>ygulamanın üzerinde çalışmak üzere tasarlandığı maksimum API Düzeyini belirten bir tam sayı.</p><pre>&lt;manifest xmlns:<a href="https://developer.android.com/guide/topics/manifest/manifest-element#nspace"><strong>android</strong></a>=&quot;http://schemas.android.com/apk/res/android&quot;<br>          <a href="https://developer.android.com/guide/topics/manifest/manifest-element#package"><strong>package</strong></a>=&quot;<em>string</em>&quot;<br>          android:<a href="https://developer.android.com/guide/topics/manifest/manifest-element#uid"><strong>sharedUserId</strong></a>=&quot;<em>string</em>&quot;<br>          android:<a href="https://developer.android.com/guide/topics/manifest/manifest-element#uidlabel"><strong>sharedUserLabel</strong></a>=&quot;<em>string resource</em>&quot; <br>          android:<a href="https://developer.android.com/guide/topics/manifest/manifest-element#vcode"><strong>versionCode</strong></a>=&quot;<em>integer</em>&quot;<br>          android:<a href="https://developer.android.com/guide/topics/manifest/manifest-element#vname"><strong>versionName</strong></a>=&quot;<em>string</em>&quot;<br>          android:<a href="https://developer.android.com/guide/topics/manifest/manifest-element#install"><strong>installLocation</strong></a>=[&quot;auto&quot; | &quot;internalOnly&quot; | &quot;preferExternal&quot;] &gt;<br>    . . .<br>&lt;/manifest&gt;</pre><p>Burdaki fonksiyonların detaylarını <a href="https://developer.android.com/guide/topics/manifest/manifest-element">burdan </a>ulaşabilirsiniz.</p><p>Gelelim asıl mevzumuza hangisi kullanmalı hangisini seçmeliyiz. Android kullanıcıların tabiki de en son sürümü kullanması uygulamalar açısından çok iyidir lakin geliştiriciler için bazen böyle olmayabiliyor. Bizim developer olarak hangisini kullanmamız gerektiğini seçmemiz gerek onu anlatmaya çalışcam. Öncellikle Android Kitkat ile Android Oreo kıyaslaması yaparak başlayalım. Diğer tüm API özelliklerini bu <a href="https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels">link </a>üzerinden bakabilirsiniz.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/690/1*DLg9N9-PpRhWFQZHsboL2A.png" /><figcaption>Android Oreo vs Android Kitkat</figcaption></figure><h3>Android Oreo(8.1) vs Android Kitkat(4.4)</h3><p>Öncelikle seçeceğimiz API’ları tabiki yapcağımız uygulamaya göre seçmemiz gerekiyor biz developerlar olarak çünkü belirlememiz gerek konu <strong>minSdkVersion </strong>peki hangisini seçmeliyiz. Ayrıca her paketler arasında ne farklar olduğunu google bizlere bildirmektedir. Bkz:API level <a href="https://developer.android.com/sdk/api_diff/19/changes">19–18</a> ve <a href="https://developer.android.com/sdk/api_diff/27/changes">26–27</a></p><p>Android Kitkat sürümünde printing framework, SMS provider, wireless and connectivity, multimedia, animation and graphics, user content, user input ve user interface gibi çok önemli konularda geliştirmeler yapıldı. Tabiki android 4.0 Kitkat üzerine geliştirmeler ile birlikte gerçekten şuan piyasada cumulative distribution (kümülatif dağılım) yani piyasada şuan kullanabilirlik olarak düşünebiliriz. Android 8.1 ile Android 4.4 arasında belli özellikler user interface ve başlıca güvenlik olmak üzere bir sürü yenilik eklenmiştir. En önemli özelliklerden biri 2011 yılında piyasaya çıkan lakin kararlı sürüm olarak 2017 yılında karşımıza gelen kotlin sayesinde android sürümlerinde kodlamalarda ve yeni bir dil olarak gelen kotlin bizim hem kodlarımızı daha optimizasyon ederek ilerlemesini sağlamıştır. Bu bizim developerlar için biraz riskli gözüksede kolayca Javadan kotline geçiş sağlayabiliyoruz bir basit örnekle anlatayım.</p><p>AndroidManifest.xml</p><pre>&lt;manifest&gt;<br>    &lt;application&gt;<br>        ...<br>        <strong>&lt;meta-data android:name=&quot;android.webkit.WebView.EnableSafeBrowsing&quot;<br>                   android:value=&quot;true&quot; /&gt;</strong><br>    &lt;/application&gt;<br>&lt;/manifest&gt;</pre><blockquote>Kotlin</blockquote><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2db68cbea87db2e7eaeabacb6e9873f7/href">https://medium.com/media/2db68cbea87db2e7eaeabacb6e9873f7/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/05e7d9a11ea1b2f48fbaa208814d99ae/href">https://medium.com/media/05e7d9a11ea1b2f48fbaa208814d99ae/href</a></iframe><blockquote>Java</blockquote><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/80d3ec0edde5b93bdace7d4c6909a7ce/href">https://medium.com/media/80d3ec0edde5b93bdace7d4c6909a7ce/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/add54ecada029d9e56805d2d75ec9527/href">https://medium.com/media/add54ecada029d9e56805d2d75ec9527/href</a></iframe><p>Bu kodda yapılan iş güvenli tarama API’sinin web görünümü uygulamasını kullanarak, uygulamamız bir web görünümü örneğinin Google’ın bilinen tehdit olarak sınıflandırdığı bir URL’ye gitmeye çalıştığını algılar. Varsayılan olarak, web görünümü, kullanıcıları bilinen tehdit konusunda uyaran bir geçiş reklamı gösterir. Bu ekran, kullanıcılara URL’yi yine de yükleme veya güvenli olan önceki bir sayfaya dönme seçeneği sunar.</p><p>Aslında Google geliştirdiği API’larda önce güvenlikleri ve sonra user interface ve system optimizasyonlarını gerçekleştirmekte. Android güvenlik olarak bir örnek verilirse</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FNUnVWK6ei8s%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DNUnVWK6ei8s&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FNUnVWK6ei8s%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/3fb4499bab419a2907d4944ff3d4ca3f/href">https://medium.com/media/3fb4499bab419a2907d4944ff3d4ca3f/href</a></iframe><p>2015 yıllarında Android 6 ve öncesi olarak kullanabilen ve güvenlik açığından Stagefright Exploit kullanarak tek bir link göndererek karşı kişinin telefonun root erişimine sağlanabiliyordu. Google Android güvenlik olarak yeni paketlerinde ve yamalar sayesinde bu açığı hızlıca kapatmıştır.</p><blockquote>Ayrıca Google Play konsolu, Ağustos 2018 ‘ den başlayarak yeni uygulamaların API düzeyi 26 ‘ ı (Android 8,0) veya üstünü hedef alacak. Mevcut uygulamalar, 2018 Kasım ‘Dan başlayarak API düzeyi 26 veya daha üstünü hedeflemek için gerekecektir. Daha fazla bilgi için bkz. <a href="https://android-developers.googleblog.com/2017/12/improving-app-security-and-performance.html">yıllar için Google Play uygulama güvenliğini ve performansını artırma</a>.</blockquote><p>Böylelikle sistemimizi seçerken güvenlik, hızlı sistem özellikleri, makine öğrenmesi, multimedia kullanıp kullanmama vb. daha birçok özelliklerini kullanırken hem herkese hitap edebileceğimiz bir API leveli seçmek istiyorsak yapacağımız uygulamanın en düşük ve uygulamamızı çalıştırabilcek API levelini belirlemeliyiz.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Ftenor.com%2Fembed%2F16220073&amp;display_name=Tenor&amp;url=https%3A%2F%2Ftenor.com%2Fview%2Fyou-need-google-google-gif-16220073&amp;image=https%3A%2F%2Fmedia.tenor.com%2Fimages%2F482581aa25f51258035dd6a55e27802c%2Ftenor.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=tenor" width="600" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/5ee58c3e65b8e6ba1c28cfd33b637821/href">https://medium.com/media/5ee58c3e65b8e6ba1c28cfd33b637821/href</a></iframe><p>Bir sonraki yazıma kadar görüşmek üzere 👋</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6abae75b304a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/hardwareandro/android-platform-version-6abae75b304a">Android Platform Version</a> was originally published in <a href="https://medium.com/hardwareandro">HardwareAndro</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>