<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Fevzi Ömür Tekin</title>
    <description>The latest articles on DEV Community by Fevzi Ömür Tekin (@fevziomurtekin).</description>
    <link>https://dev.to/fevziomurtekin</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F130665%2F16fb5bb9-57a8-48d5-9a73-38c73c807901.jpg</url>
      <title>DEV Community: Fevzi Ömür Tekin</title>
      <link>https://dev.to/fevziomurtekin</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/fevziomurtekin"/>
    <language>en</language>
    <item>
      <title>“No view found for id for fragment” error of Nested Viewpager</title>
      <dc:creator>Fevzi Ömür Tekin</dc:creator>
      <pubDate>Fri, 13 Sep 2019 12:56:22 +0000</pubDate>
      <link>https://dev.to/fevziomurtekin/no-view-found-for-id-for-fragment-error-of-nested-viewpager-1hgl</link>
      <guid>https://dev.to/fevziomurtekin/no-view-found-for-id-for-fragment-error-of-nested-viewpager-1hgl</guid>
      <description>&lt;div class="ltag__stackexchange--container"&gt;
  &lt;div class="ltag__stackexchange--title-container"&gt;
    
      &lt;div class="ltag__stackexchange--title"&gt;
        &lt;div class="ltag__stackexchange--header"&gt;
          &lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev.to%2Fassets%2Fstackoverflow-logo-b42691ae545e4810b105ee957979a853a696085e67e43ee14c5699cf3e890fb4.svg" alt=""&gt;
          &lt;a href="https://stackoverflow.com/questions/57919749/no-view-found-for-id-for-fragment-error-of-nested-viewpager" rel="noopener noreferrer"&gt;
            "No view found for id for fragment" error of Nested Viewpager
          &lt;/a&gt;
        &lt;/div&gt;
        &lt;div class="ltag__stackexchange--post-metadata"&gt;
          &lt;span&gt;Sep 13 '19&lt;/span&gt;
            &lt;span&gt;Comments: 1&lt;/span&gt;
            &lt;span&gt;Answers: 0&lt;/span&gt;
        &lt;/div&gt;
      &lt;/div&gt;
      &lt;a class="ltag__stackexchange--score-container" href="https://stackoverflow.com/questions/57919749/no-view-found-for-id-for-fragment-error-of-nested-viewpager" rel="noopener noreferrer"&gt;
        &lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev.to%2Fassets%2Fstackexchange-arrow-up-eff2e2849e67d156181d258e38802c0b57fa011f74164a7f97675ca3b6ab756b.svg" alt=""&gt;
        &lt;div class="ltag__stackexchange--score-number"&gt;
          2
        &lt;/div&gt;
        &lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev.to%2Fassets%2Fstackexchange-arrow-down-4349fac0dd932d284fab7e4dd9846f19a3710558efde0d2dfd05897f3eeb9aba.svg" alt=""&gt;
      &lt;/a&gt;
    
  &lt;/div&gt;
  &lt;div class="ltag__stackexchange--body"&gt;
    
&lt;p&gt;I'm getting an error in the title. Application I also have a mixed structure and use a few nested structures.&lt;/p&gt;
&lt;p&gt;There is a structure like &lt;b&gt;" CategoryFragment -&amp;gt; ViewPager -&amp;gt; RecyclerView inside CategoryDetailsFragment -&amp;gt; ViewPager-&amp;gt; HeadlinePagerFragment"&lt;/b&gt;&lt;/p&gt;

&lt;p&gt;when changed to CategoryFragment then return to back will be this error.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;CategoryFragment &lt;/li&gt;
&lt;/ul&gt;

&lt;pre&gt;&lt;code&gt;val&lt;/code&gt;&lt;/pre&gt;…
    
  &lt;/div&gt;
  &lt;div class="ltag__stackexchange--btn--container"&gt;
    &lt;a href="https://stackoverflow.com/questions/57919749/no-view-found-for-id-for-fragment-error-of-nested-viewpager" class="ltag__stackexchange--btn" rel="noopener noreferrer"&gt;Open Full Question&lt;/a&gt;
  &lt;/div&gt;
&lt;/div&gt;


&lt;p&gt;I'm getting an error in the title. Application I also have a mixed structure and use a few nested structures.&lt;/p&gt;

&lt;p&gt;There is a structure like &lt;b&gt;" CategoryFragment -&amp;gt; ViewPager -&amp;gt; RecyclerView inside CategoryDetailsFragment -&amp;gt; ViewPager-&amp;gt; HeadlinePagerFragment"&lt;/b&gt;&lt;/p&gt;

&lt;p&gt;when changed to CategoryFragment then return to back will be this error.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;CategoryFragment
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight kotlin"&gt;&lt;code&gt;&lt;span class="kd"&gt;val&lt;/span&gt; &lt;span class="py"&gt;adapter&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;CategoriesPagerAdapter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;activity&lt;/span&gt;&lt;span class="o"&gt;?.&lt;/span&gt;&lt;span class="n"&gt;supportFragmentManager&lt;/span&gt;&lt;span class="o"&gt;!!&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;list&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="nc"&gt;List&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;MutableMap&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&amp;gt;)&lt;/span&gt;
&lt;span class="n"&gt;vp_categories_pager&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;adapter&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;adapter&lt;/span&gt;
&lt;span class="n"&gt;tl_categories&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;setupWithViewPager&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;vp_categories_pager&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;CategoryDetailsFragment
This class use recyclerview and usage inside of childview viewpager.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight kotlin"&gt;&lt;code&gt;&lt;span class="n"&gt;rv_category_details&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;adapter&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;ContentAdapter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
            &lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="o"&gt;!!&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="nd"&gt;@CategoryDetailsFragment&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;usage&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;fragment&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
            &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="nd"&gt;@CategoryDetailsFragment&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;-&amp;gt; Adapter&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight kotlin"&gt;&lt;code&gt; &lt;span class="n"&gt;vp_headline&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;adapter&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="nc"&gt;HeadlineAdapter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
                            &lt;span class="n"&gt;fragment&lt;/span&gt;&lt;span class="o"&gt;?.&lt;/span&gt;&lt;span class="n"&gt;childFragmentManager&lt;/span&gt;&lt;span class="o"&gt;!!&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                            &lt;span class="n"&gt;items&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;itemClickListener&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
                    &lt;span class="n"&gt;tl_headline_indicator&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;setupWithViewPager&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;vp_headline&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;HeadlineAdapter
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight kotlin"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;HeadlineAdapter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;fragment&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;FragmentManager&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="py"&gt;list&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nc"&gt;MutableList&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;MutableMap&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="err"&gt;*&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="err"&gt;*&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&amp;gt;,&lt;/span&gt;
    &lt;span class="kd"&gt;val&lt;/span&gt; &lt;span class="py"&gt;itemclickListener&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nc"&gt;ContentAdapter&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Itemclicklistener&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nc"&gt;FragmentPagerAdapter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;fragment&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
    &lt;span class="k"&gt;override&lt;/span&gt; &lt;span class="k"&gt;fun&lt;/span&gt; &lt;span class="nf"&gt;getItem&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;position&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Int&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="nc"&gt;Fragment&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt;
        &lt;span class="nc"&gt;HeadlinePagerFragment&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;PutData&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;mutableMapOf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="sc"&gt;'m'&lt;/span&gt; &lt;span class="n"&gt;to&lt;/span&gt; &lt;span class="n"&gt;list&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;position&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
        &lt;span class="sc"&gt;'l'&lt;/span&gt; &lt;span class="n"&gt;to&lt;/span&gt; &lt;span class="n"&gt;itemclickListener&lt;/span&gt;
    &lt;span class="p"&gt;)))&lt;/span&gt;

    &lt;span class="k"&gt;override&lt;/span&gt; &lt;span class="k"&gt;fun&lt;/span&gt; &lt;span class="nf"&gt;getCount&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt; &lt;span class="nc"&gt;Int&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;list&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;size&lt;/span&gt;

    &lt;span class="k"&gt;override&lt;/span&gt; &lt;span class="k"&gt;fun&lt;/span&gt; &lt;span class="nf"&gt;getItemPosition&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;`object`&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Any&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="nc"&gt;Int&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nc"&gt;PagerAdapter&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;POSITION_NONE&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Return this error&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;No view found for id 0x7f0901de (com.bursadabugun.android:id/vp_headline) for fragment HeadlinePagerFragment{17872d5 (85c9643d-c164-417e-a428-7105105970a1) id=0x7f0901de android:switcher:2131296734:0}
        at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java:875)
        at androidx.fragment.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManagerImpl.java:1238)
        at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java:1303)
        at androidx.fragment.app.FragmentManagerImpl.dispatchStateChange(FragmentManagerImpl.java:2656)
        at androidx.fragment.app.FragmentManagerImpl.dispatchActivityCreated(FragmentManagerImpl.java:2610)
        at androidx.fragment.app.Fragment.performActivityCreated(Fragment.java:2619)
        at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java:904)
        at androidx.fragment.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManagerImpl.java:1238)
        at androidx.fragment.app.BackStackRecord.executeOps(BackStackRecord.java:434)
        at androidx.fragment.app.FragmentManagerImpl.executeOps(FragmentManagerImpl.java:2076)
        at androidx.fragment.app.FragmentManagerImpl.executeOpsTogether(FragmentManagerImpl.java:1866)
        at androidx.fragment.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManagerImpl.java:1821)
        at androidx.fragment.app.FragmentManagerImpl.execSingleAction(FragmentManagerImpl.java:1696)
        at androidx.fragment.app.BackStackRecord.commitNowAllowingStateLoss(BackStackRecord.java:299)
        at androidx.fragment.app.FragmentPagerAdapter.finishUpdate(FragmentPagerAdapter.java:230)
        at androidx.viewpager.widget.ViewPager.populate(ViewPager.java:1244)
        at androidx.viewpager.widget.ViewPager.populate(ViewPager.java:1092)
        at androidx.viewpager.widget.ViewPager.onMeasure(ViewPager.java:1622)
        at android.view.View.measure(View.java:22094)
        at androidx.constraintlayout.widget.ConstraintLayout.internalMeasureChildren(ConstraintLayout.java:1227)
        at androidx.constraintlayout.widget.ConstraintLayout.onMeasure(ConstraintLayout.java:1572)
        at android.view.View.measure(View.java:22094)
        at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6613)
        at android.widget.FrameLayout.onMeasure(FrameLayout.java:185)
        at android.view.View.measure(View.java:22094)
        at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6613)
        at android.widget.FrameLayout.onMeasure(FrameLayout.java:185)
        at android.view.View.measure(View.java:22094)
        at androidx.constraintlayout.widget.ConstraintLayout.internalMeasureChildren(ConstraintLayout.java:1227)
        at androidx.constraintlayout.widget.ConstraintLayout.onMeasure(ConstraintLayout.java:1572)
        at android.view.View.measure(View.java:22094)
        at androidx.drawerlayout.widget.DrawerLayout.onMeasure(DrawerLayout.java:1119)
        at android.view.View.measure(View.java:22094)
        at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6613)
        at android.widget.FrameLayout.onMeasure(FrameLayout.java:185)
        at androidx.appcompat.widget.ContentFrameLayout.onMeasure(ContentFrameLayout.java:143)
        at android.view.View.measure(View.java:22094)
        at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6613)
        at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1514)
        at android.widget.LinearLayout.measureVertical(LinearLayout.java:806)
        at android.widget.LinearLayout.onMeasure(LinearLayout.java:685)
        at android.view.View.measure(View.java:22094)
        at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6613)
        at android.widget.FrameLayout.onMeasure(FrameLayout.java:185)
        at android.view.View.measure(View.java:22094)
        at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6613)
        at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1514)
        at android.widget.LinearLayout.measureVertical(LinearLayout.java:806)
E/AndroidRuntime:     at android.widget.LinearLayout.onMeasure(LinearLayout.java:685)
        at android.view.View.measure(View.java:22094)
        at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6613)
        at android.widget.FrameLayout.onMeasure(FrameLayout.java:185)
        at com.android.internal.policy.DecorView.onMeasure(DecorView.java:724)
        at android.view.View.measure(View.java:22094)
        at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2483)
        at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1549)
        at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1806)
        at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1432)
        at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6826)
        at android.view.Choreographer$CallbackRecord.run(Choreographer.java:911)
        at android.view.Choreographer.doCallbacks(Choreographer.java:723)
        at android.view.Choreographer.doFrame(Choreographer.java:658)
        at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:897)
        at android.os.Handler.handleCallback(Handler.java:790)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:164)
        at android.app.ActivityThread.main(ActivityThread.java:6543)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:440)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:810)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
    </item>
    <item>
      <title>Open Source Library - PayView</title>
      <dc:creator>Fevzi Ömür Tekin</dc:creator>
      <pubDate>Fri, 05 Jul 2019 08:54:25 +0000</pubDate>
      <link>https://dev.to/fevziomurtekin/open-source-library-payview-3fi6</link>
      <guid>https://dev.to/fevziomurtekin/open-source-library-payview-3fi6</guid>
      <description>&lt;p&gt;&lt;a href="https://jitpack.io/#fevziomurtekin/PayView"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--e8BQRoBt--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://jitpack.io/v/fevziomurtekin/PayView.svg" alt=""&gt;&lt;/a&gt; &lt;a href="https://android-arsenal.com/details/1/7724"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--cqtZk2Zt--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://img.shields.io/badge/Android%2520Arsenal-PayView-green.svg%3Fstyle%3Dflat" alt="Android Arsenal"&gt;&lt;/a&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--epFRFcBC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://img.shields.io/twitter/follow/fevziomurtekin.svg%3Flabel%3Dfevziomurtekin%26style%3Dsocial" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--epFRFcBC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://img.shields.io/twitter/follow/fevziomurtekin.svg%3Flabel%3Dfevziomurtekin%26style%3Dsocial" alt="Twitter Follow"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--bnxvF4y5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://raw.githubusercontent.com/fevziomurtekin/PayView/master/art/record.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--bnxvF4y5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://raw.githubusercontent.com/fevziomurtekin/PayView/master/art/record.gif"&gt;&lt;/a&gt;
&lt;br&gt;
💳 Payment View library for Credit and Debit Card. 
&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--F_nh6Pvy--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://raw.githubusercontent.com/fevziomurtekin/PayView/master/art/visa.svg%3Fsanitize%3Dtrue" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--F_nh6Pvy--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://raw.githubusercontent.com/fevziomurtekin/PayView/master/art/visa.svg%3Fsanitize%3Dtrue" width="55" height="55"&gt;&lt;/a&gt;  &lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--D7CrRyQ8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://raw.githubusercontent.com/fevziomurtekin/PayView/master/art/mastercard.svg%3Fsanitize%3Dtrue" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--D7CrRyQ8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://raw.githubusercontent.com/fevziomurtekin/PayView/master/art/mastercard.svg%3Fsanitize%3Dtrue" width="55" height="55"&gt;&lt;/a&gt;  &lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--sE2JGYhD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://raw.githubusercontent.com/fevziomurtekin/PayView/master/art/americanexpress.svg%3Fsanitize%3Dtrue" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--sE2JGYhD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://raw.githubusercontent.com/fevziomurtekin/PayView/master/art/americanexpress.svg%3Fsanitize%3Dtrue" width="55" height="55"&gt;&lt;/a&gt;  &lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--NfP8jXEc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://raw.githubusercontent.com/fevziomurtekin/PayView/master/art/jcb.svg%3Fsanitize%3Dtrue" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--NfP8jXEc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://raw.githubusercontent.com/fevziomurtekin/PayView/master/art/jcb.svg%3Fsanitize%3Dtrue" width="55" height="55"&gt;&lt;/a&gt;  &lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--30OA8Ba7--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://raw.githubusercontent.com/fevziomurtekin/PayView/master/art/discover.svg%3Fsanitize%3Dtrue" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--30OA8Ba7--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://raw.githubusercontent.com/fevziomurtekin/PayView/master/art/discover.svg%3Fsanitize%3Dtrue" width="55" height="55"&gt;&lt;/a&gt;  &lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Y1WTAwLk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://raw.githubusercontent.com/fevziomurtekin/PayView/master/art/dinnersclub.svg%3Fsanitize%3Dtrue" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Y1WTAwLk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://raw.githubusercontent.com/fevziomurtekin/PayView/master/art/dinnersclub.svg%3Fsanitize%3Dtrue" width="55" height="55"&gt;&lt;/a&gt;  &lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--DwCKQOEz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://raw.githubusercontent.com/fevziomurtekin/PayView/master/art/undefined.svg%3Fsanitize%3Dtrue" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--DwCKQOEz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://raw.githubusercontent.com/fevziomurtekin/PayView/master/art/undefined.svg%3Fsanitize%3Dtrue" width="55" height="55"&gt;&lt;/a&gt;&lt;/p&gt; 



&lt;h1&gt;
  
  
  Demo
&lt;/h1&gt;

&lt;p&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--LXTQswo4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://github.com/fevziomurtekin/PayView/blob/master/art/record.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--LXTQswo4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://github.com/fevziomurtekin/PayView/blob/master/art/record.gif" width="360" height="640"&gt;&lt;/a&gt;
&lt;/p&gt;

&lt;h1&gt;
  
  
  Setup
&lt;/h1&gt;

&lt;h2&gt;
  
  
  Gradle
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight gradle"&gt;&lt;code&gt;&lt;span class="k"&gt;allprojects&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;repositories&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="o"&gt;...&lt;/span&gt;
    &lt;span class="n"&gt;maven&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt; &lt;span class="n"&gt;url&lt;/span&gt; &lt;span class="s1"&gt;'https://jitpack.io'&lt;/span&gt; &lt;span class="o"&gt;}&lt;/span&gt;
  &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;

  &lt;span class="o"&gt;.....&lt;/span&gt;

&lt;span class="k"&gt;dependencies&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
      &lt;span class="n"&gt;implementation&lt;/span&gt; &lt;span class="s1"&gt;'com.github.fevziomurtekin:PayView:1.0.1'&lt;/span&gt;
      &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Layout
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight xml"&gt;&lt;code&gt; &lt;span class="nt"&gt;&amp;lt;com.fevziomurtekin.payview.Payview&lt;/span&gt;
        &lt;span class="na"&gt;android:id=&lt;/span&gt;&lt;span class="s"&gt;"@+id/payview"&lt;/span&gt;
        &lt;span class="na"&gt;android:layout_width=&lt;/span&gt;&lt;span class="s"&gt;"wrap_content"&lt;/span&gt;
        &lt;span class="na"&gt;android:layout_height=&lt;/span&gt;&lt;span class="s"&gt;"wrap_content"&lt;/span&gt;
        &lt;span class="na"&gt;app:cardBgColor=&lt;/span&gt;&lt;span class="s"&gt;"@android:color/holo_blue_light"&lt;/span&gt;
        &lt;span class="na"&gt;app:cardFgColor=&lt;/span&gt;&lt;span class="s"&gt;"@android:color/white"&lt;/span&gt;
        &lt;span class="na"&gt;app:cardTextColor=&lt;/span&gt;&lt;span class="s"&gt;"@color/black"&lt;/span&gt;
        &lt;span class="na"&gt;app:cardNameHelperText=&lt;/span&gt;&lt;span class="s"&gt;"Enter to card name. Max 25 characters."&lt;/span&gt;
        &lt;span class="na"&gt;app:cardCvTextSize=&lt;/span&gt;&lt;span class="s"&gt;"14"&lt;/span&gt;
        &lt;span class="na"&gt;app:cardNoTextSize=&lt;/span&gt;&lt;span class="s"&gt;"14"&lt;/span&gt;
        &lt;span class="na"&gt;app:cardNumberHelperText=&lt;/span&gt;&lt;span class="s"&gt;"You must enter your 16-digit card number."&lt;/span&gt;
        &lt;span class="na"&gt;app:cardYearTextSize=&lt;/span&gt;&lt;span class="s"&gt;"13"&lt;/span&gt;
        &lt;span class="na"&gt;app:cardNameTextSize=&lt;/span&gt;&lt;span class="s"&gt;"15"&lt;/span&gt;
        &lt;span class="na"&gt;app:cardMonthTextSize=&lt;/span&gt;&lt;span class="s"&gt;"13"&lt;/span&gt;
        &lt;span class="na"&gt;app:cardAnimationType=&lt;/span&gt;&lt;span class="s"&gt;"vertical"&lt;/span&gt;
    &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Listeners
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight kotlin"&gt;&lt;code&gt;   &lt;span class="n"&gt;payview&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;setOnDataChangedListener&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;object&lt;/span&gt; &lt;span class="err"&gt;: &lt;/span&gt;&lt;span class="nc"&gt;Payview&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;OnChangelistener&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="k"&gt;override&lt;/span&gt; &lt;span class="k"&gt;fun&lt;/span&gt; &lt;span class="nf"&gt;onChangelistener&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;payModel&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;PayModel&lt;/span&gt;&lt;span class="p"&gt;?)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="nc"&gt;Log&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;d&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"payView"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"data : ${payModel?.cardOwnerName}"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

            &lt;span class="p"&gt;}&lt;/span&gt;

        &lt;span class="p"&gt;})&lt;/span&gt;

    &lt;span class="n"&gt;payview&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;setPayOnclickListener&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;View&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;OnClickListener&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nc"&gt;Log&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;d&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"payView "&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s"&gt;" clicked."&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="p"&gt;})&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;# Attributes&lt;/p&gt;

&lt;p&gt;| Attribute | Description |&lt;br&gt;
| --- | --- |&lt;br&gt;
| &lt;code&gt;cardBgColor&lt;/code&gt; | The color in int of the card background color (by default android.R.color.holo_blue_light) | &lt;br&gt;
| &lt;code&gt;cardFgColor&lt;/code&gt; | The color in int of the card foreground color (by default android.R.color.white)|&lt;br&gt;
| &lt;code&gt;cardTextColor&lt;/code&gt; | The color in int of the card text color (by default android.R.color.black)|&lt;br&gt;
| &lt;code&gt;cardAnimationType&lt;/code&gt; | Animation in AnimationType of the PayView (by default horizontal)|&lt;br&gt;
| &lt;code&gt;cardNameTextSize&lt;/code&gt; | The size in sp of the search text size (by default 15sp) |&lt;br&gt;
| &lt;code&gt;cardNoTextSize&lt;/code&gt; | The size in sp of the search text size (by default 14sp)|&lt;br&gt;
|&lt;code&gt;cardYearTextSize&lt;/code&gt;|The size in sp of the search text size (by default 13sp) |&lt;br&gt;
| &lt;code&gt;cardMonthTextSize&lt;/code&gt; |The size in sp of the search text size (by default 13sp) |&lt;br&gt;
| &lt;code&gt;cardCvTextSize&lt;/code&gt;|The size in sp of the result text size (by default 14sp) |&lt;br&gt;
|&lt;code&gt;cardNumberHelperText&lt;/code&gt;| Default text, "You must enter your 16-digit card number. "|&lt;br&gt;
|&lt;code&gt;cardNameHelperText&lt;/code&gt;| Default text "Enter to card name. You'll enter max 25 characters"|&lt;/p&gt;

&lt;h2&gt;
  
  
  License
&lt;/h2&gt;

&lt;p&gt;The Apache License 2.0 - see &lt;a href="https://dev.toLICENSE"&gt;&lt;code&gt;LICENSE&lt;/code&gt;&lt;/a&gt; for more details&lt;/p&gt;

&lt;h2&gt;
  
  
  Github Link
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://github.com/fevziomurtekin/PayView"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--j9k_8RI_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://github.githubassets.com/images/modules/open_graph/github-mark.png"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>opensource</category>
      <category>androiddev</category>
      <category>pay</category>
      <category>view</category>
    </item>
    <item>
      <title>Dependencies Injection with Koin</title>
      <dc:creator>Fevzi Ömür Tekin</dc:creator>
      <pubDate>Wed, 22 May 2019 10:23:40 +0000</pubDate>
      <link>https://dev.to/fevziomurtekin/dependencies-injection-with-koin-42k</link>
      <guid>https://dev.to/fevziomurtekin/dependencies-injection-with-koin-42k</guid>
      <description>&lt;center&gt;
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--2FvjQG69--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/2400/1%2A6m-AFxXhemIsv8RjZBFB_Q.png" alt="Crepe"&gt; &lt;/center&gt;
&lt;br&gt;

&lt;p&gt;Hello to everyone,&lt;br&gt;
In this article, I will tell you why I prefer Koin (small and medium-sized projects) when there is a library such as Dagger and the Dependencies Injection principle, which is one of the five pillars of S.O.L.I.D.&lt;/p&gt;
&lt;h2&gt;
  
  
  WHAT'S DEPENDENCIES INJECTION?
&lt;/h2&gt;


&lt;p&gt; Simply speaking of dependencies injection, Dependency Injection is mainly used for the control and management of dependencies.&lt;/p&gt;

&lt;p&gt;How do we manage to control and manage dependencies? If you're asking why we should use it, you can get more detailed information about this from the following two articles.&lt;/p&gt;


&lt;center&gt;
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--LaEs9j6z--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/2600/1%2ArU6KNs9KfdROiENL-UQTNA.jpeg" alt=""&gt;&lt;br&gt;&lt;a href="https://medium.freecodecamp.org/a-quick-intro-to-dependency-injection-what-it-is-and-when-to-use-it-7578c84fa88f"&gt;A quick intro to Dependency Injection: what it is, and when to use it&lt;/a&gt; &lt;/center&gt;
&lt;br&gt;


&lt;center&gt;
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--feV9jm7a--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://koenig-media.raywenderlich.com/uploads/2016/11/Dagger-feature.png" alt=""&gt;&lt;br&gt;&lt;a href="https://www.raywenderlich.com/262-dependency-injection-in-android-with-dagger-2-and-kotlin"&gt;Dependency Injection in Android with Dagger 2 and Kotlin&lt;/a&gt; &lt;/center&gt;
&lt;br&gt;
&lt;h3&gt;
  
  
  What is Koin?
&lt;/h3&gt;


&lt;p&gt; Koin is a simple and powerful dependencies injection library. It's written with Kotlin.&lt;/p&gt;
&lt;h3&gt;
  
  
  Why should we use Koin when there is Dagger? Why do I use Koin?
&lt;/h3&gt;

&lt;p&gt;The reason I use Koin; Dagger; it comes to me as a structure that is difficult to learn and practice because of the formation of too many classes and the mixed structure. I use Koin because of its simpler structure and light weight.&lt;/p&gt;

&lt;p&gt;Dagger to explain when you should prefer Koin; a simple project with both Dagger and Koin to create the differences between the two Let's examine one by one.&lt;/p&gt;
&lt;h3&gt;
  
  
  KOIN VS DAGGER
&lt;/h3&gt;

&lt;blockquote&gt;
&lt;p&gt;Dagger and Koin libraries will be compared through a project using MVVM.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;ul&gt;
&lt;li&gt;&lt;b&gt;Comparison of DI packet structure&lt;/b&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;center&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ZQLWgWAJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.ibb.co/m0xrTPc/koindi.png" alt="Crepe"&gt;&lt;/center&gt; &lt;br&gt;

&lt;p&gt;In the first picture, we see the classes and package structure used by Dagger and the second picture to create Koin içins dependencies. Koin is being created with a simpler and less number of classes.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;b&gt;Number of codes before and after compile&lt;/b&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;center&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--SZmjb2iJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.ibb.co/fr2BQZM/lineofcodes.png" alt="Crepe"&gt;&lt;/center&gt; &lt;br&gt;

&lt;p&gt;As seen in the example, there is a half-way difference between the number of codes generated by the coin and dagger. This shows that Koin is a lighter structure.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;b&gt; Build Time &lt;/b&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    Koin:
    BUILD SUCCESSFUL in 19s
    120 actionable tasks: 112executed, 7up-to-date

    Dagger:
    BUILD SUCCESSFUL in 21s
    118 actionable tasks: 112 executed, 7up-to-date
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;&lt;b&gt;Setup/Package and Class Structure&lt;/b&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;b&gt;&lt;em&gt;Dagger&lt;/em&gt;&lt;/b&gt;&lt;/p&gt;

&lt;p&gt;Implementation the Dagger Sdk to the project;&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    kapt "com.google.dagger:dagger-compiler:$dagger_version"
    kapt "com.google.dagger:dagger-android-processor:$dagger_version"
    implementation "com.google.dagger:dagger:$dagger_version"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;Classes for injection of activity, fragment and viewmodels;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;ActivityModule
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight gradle"&gt;&lt;code&gt;  &lt;span class="nd"&gt;@Module&lt;/span&gt;
&lt;span class="kd"&gt;abstract&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;ActivityModule&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="nd"&gt;@ContributesAndroidInjector&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;modules&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="nl"&gt;FragmentModule:&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="kd"&gt;class&lt;/span&gt;&lt;span class="err"&gt;])&lt;/span&gt;
    &lt;span class="nc"&gt;abstract&lt;/span&gt; &lt;span class="n"&gt;fun&lt;/span&gt; &lt;span class="n"&gt;contributeMainActivity&lt;/span&gt;&lt;span class="o"&gt;():&lt;/span&gt; &lt;span class="n"&gt;MainActivity&lt;/span&gt;

    &lt;span class="c1"&gt;//Add your other activities here&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt;FragmentModule
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight gradle"&gt;&lt;code&gt;    &lt;span class="nd"&gt;@Module&lt;/span&gt;
    &lt;span class="kd"&gt;abstract&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;FragmentModule&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="nd"&gt;@ContributesAndroidInjector&lt;/span&gt;
        &lt;span class="kd"&gt;abstract&lt;/span&gt; &lt;span class="n"&gt;fun&lt;/span&gt; &lt;span class="nf"&gt;contributeNewsFragment&lt;/span&gt;&lt;span class="o"&gt;():&lt;/span&gt; &lt;span class="n"&gt;NewsFragment&lt;/span&gt;

        &lt;span class="nd"&gt;@ContributesAndroidInjector&lt;/span&gt;
        &lt;span class="kd"&gt;abstract&lt;/span&gt; &lt;span class="n"&gt;fun&lt;/span&gt; &lt;span class="nf"&gt;contributeNewDetailsFragment&lt;/span&gt;&lt;span class="o"&gt;():&lt;/span&gt; &lt;span class="n"&gt;NewDetailsFragment&lt;/span&gt;

    &lt;span class="o"&gt;}&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt;ViewModelModule
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight gradle"&gt;&lt;code&gt;    &lt;span class="nd"&gt;@Module&lt;/span&gt;
    &lt;span class="kd"&gt;abstract&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;ViewModelModule&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;

        &lt;span class="nd"&gt;@Binds&lt;/span&gt;
        &lt;span class="kd"&gt;abstract&lt;/span&gt; &lt;span class="n"&gt;fun&lt;/span&gt; &lt;span class="nf"&gt;bindViewModelFactory&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nl"&gt;factory:&lt;/span&gt; &lt;span class="n"&gt;ViewModelFactory&lt;/span&gt;&lt;span class="o"&gt;):&lt;/span&gt; &lt;span class="n"&gt;ViewModelProvider&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;Factory&lt;/span&gt;

        &lt;span class="nd"&gt;@Binds&lt;/span&gt;
        &lt;span class="nd"&gt;@IntoMap&lt;/span&gt;
        &lt;span class="nd"&gt;@ViewModelKey&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nl"&gt;MainViewModel:&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="kd"&gt;class&lt;/span&gt;&lt;span class="err"&gt;)&lt;/span&gt;
        &lt;span class="nc"&gt;abstract&lt;/span&gt; &lt;span class="n"&gt;fun&lt;/span&gt; &lt;span class="n"&gt;bindMainViewModel&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nl"&gt;mainViewModel:&lt;/span&gt; &lt;span class="n"&gt;MainViewModel&lt;/span&gt;&lt;span class="o"&gt;):&lt;/span&gt; &lt;span class="n"&gt;ViewModel&lt;/span&gt;

        &lt;span class="nd"&gt;@Binds&lt;/span&gt;
        &lt;span class="nd"&gt;@IntoMap&lt;/span&gt;
        &lt;span class="nd"&gt;@ViewModelKey&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nl"&gt;NewsViewModel:&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="kd"&gt;class&lt;/span&gt;&lt;span class="err"&gt;)&lt;/span&gt;
        &lt;span class="nc"&gt;abstract&lt;/span&gt; &lt;span class="n"&gt;fun&lt;/span&gt; &lt;span class="n"&gt;bindNewsViewModel&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nl"&gt;newsViewModel:&lt;/span&gt;  &lt;span class="n"&gt;NewsViewModel&lt;/span&gt;&lt;span class="o"&gt;):&lt;/span&gt; &lt;span class="n"&gt;ViewModel&lt;/span&gt;

        &lt;span class="nd"&gt;@Binds&lt;/span&gt;
        &lt;span class="nd"&gt;@IntoMap&lt;/span&gt;
        &lt;span class="nd"&gt;@ViewModelKey&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nl"&gt;NewDetailsViewModel:&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="kd"&gt;class&lt;/span&gt;&lt;span class="err"&gt;)&lt;/span&gt;
        &lt;span class="nc"&gt;abstract&lt;/span&gt; &lt;span class="n"&gt;fun&lt;/span&gt; &lt;span class="n"&gt;bindNewDetailsViewModel&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nl"&gt;newDetailsViewModel:&lt;/span&gt;  &lt;span class="n"&gt;NewDetailsViewModel&lt;/span&gt;&lt;span class="o"&gt;):&lt;/span&gt; &lt;span class="n"&gt;ViewModel&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;After creating the modules and components to be injected into the project;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight gradle"&gt;&lt;code&gt;
    &lt;span class="n"&gt;Class&lt;/span&gt; &lt;span class="n"&gt;BaseApplication&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;Application&lt;/span&gt;&lt;span class="o"&gt;(),&lt;/span&gt; &lt;span class="n"&gt;HasActivityInjector&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt; 
  &lt;span class="nd"&gt;@Inject&lt;/span&gt;
      &lt;span class="n"&gt;lateinit&lt;/span&gt; &lt;span class="n"&gt;var&lt;/span&gt; &lt;span class="nl"&gt;dispatchingAndroidInjector:&lt;/span&gt;    &lt;span class="n"&gt;DispatchingAndroidInjector&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;Activity&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;

    &lt;span class="n"&gt;override&lt;/span&gt; &lt;span class="n"&gt;fun&lt;/span&gt; &lt;span class="nf"&gt;activityInjector&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;dispatchingAndroidInjector&lt;/span&gt;

    &lt;span class="n"&gt;fun&lt;/span&gt; &lt;span class="nf"&gt;initDagger&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
       &lt;span class="n"&gt;DaggerAppComponent&lt;/span&gt;
          &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;builder&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt;
          &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;application&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
          &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;build&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt;
          &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;inject&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
      &lt;span class="o"&gt;}&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;b&gt;&lt;em&gt;Koin&lt;/em&gt;&lt;/b&gt;&lt;/p&gt;

&lt;p&gt;İmplementation the Koin SDK to the project&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight gradle"&gt;&lt;code&gt;
  &lt;span class="n"&gt;implementation&lt;/span&gt; &lt;span class="s2"&gt;"org.koin:koin-android-viewmodel:$koin_version"&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;The difference of Koin from dagger; Instead of creating separate classes for Activity, fragment, and viewmodule, we do it all in one class. This will take care of everything in one class and prevent branching.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;ul&gt;
&lt;li&gt;App Module
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight gradle"&gt;&lt;code&gt;
  &lt;span class="kn"&gt;package&lt;/span&gt; &lt;span class="nn"&gt;com.fevziomurtekin.di&lt;/span&gt;

    &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;androidx.room.Room&lt;/span&gt;
    &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;com.fevziomurtekin.hackernewsapp.data.room.*&lt;/span&gt;
    &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;com.fevziomurtekin.hackernewsapp.ui.main.MainViewModel&lt;/span&gt;
    &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;com.fevziomurtekin.hackernewsapp.ui.newdetails.NewsDetailsViewModel&lt;/span&gt;
    &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;com.fevziomurtekin.hackernewsapp.ui.news.NewsViewModel&lt;/span&gt;
    &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;com.fevziomurtekin.hackernewsapp.util.ApplicationSchedulerProvider&lt;/span&gt;
    &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;com.fevziomurtekin.hackernewsapp.util.SchedulerProvider&lt;/span&gt;
    &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;org.koin.android.architecture.ext.viewModel&lt;/span&gt;
    &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;org.koin.android.ext.koin.androidApplication&lt;/span&gt;
    &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;org.koin.dsl.module.applicationContext&lt;/span&gt;



    &lt;span class="n"&gt;val&lt;/span&gt; &lt;span class="n"&gt;appModule&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;applicationContext&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;


        &lt;span class="n"&gt;viewModel&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt; &lt;span class="n"&gt;MainViewModel&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;get&lt;/span&gt;&lt;span class="o"&gt;(),&lt;/span&gt;&lt;span class="n"&gt;get&lt;/span&gt;&lt;span class="o"&gt;())&lt;/span&gt; &lt;span class="o"&gt;}&lt;/span&gt;

        &lt;span class="n"&gt;viewModel&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt; &lt;span class="n"&gt;NewsViewModel&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;get&lt;/span&gt;&lt;span class="o"&gt;())&lt;/span&gt; &lt;span class="o"&gt;}&lt;/span&gt;

        &lt;span class="n"&gt;viewModel&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt; &lt;span class="n"&gt;NewsDetailsViewModel&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;get&lt;/span&gt;&lt;span class="o"&gt;())&lt;/span&gt; &lt;span class="o"&gt;}&lt;/span&gt;

        &lt;span class="c1"&gt;// ItemRepository providers.&lt;/span&gt;
        &lt;span class="n"&gt;bean&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt; &lt;span class="n"&gt;ItemRepositoryImpl&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;get&lt;/span&gt;&lt;span class="o"&gt;(),&lt;/span&gt;&lt;span class="n"&gt;get&lt;/span&gt;&lt;span class="o"&gt;())&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;ItemRepository&lt;/span&gt; &lt;span class="o"&gt;}&lt;/span&gt;

        &lt;span class="n"&gt;bean&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt; &lt;span class="n"&gt;UserRepositoryImpl&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;get&lt;/span&gt;&lt;span class="o"&gt;(),&lt;/span&gt;&lt;span class="n"&gt;get&lt;/span&gt;&lt;span class="o"&gt;())&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;UserRepository&lt;/span&gt; &lt;span class="o"&gt;}&lt;/span&gt;

        &lt;span class="c1"&gt;// provider to Room database.&lt;/span&gt;
        &lt;span class="n"&gt;bean&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
            &lt;span class="n"&gt;Room&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;databaseBuilder&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;androidApplication&lt;/span&gt;&lt;span class="o"&gt;(),&lt;/span&gt;&lt;span class="nl"&gt;Database:&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="kd"&gt;class&lt;/span&gt;&lt;span class="err"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;java&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;&lt;span class="s2"&gt;"hackernews-db"&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
                &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;allowMainThreadQueries&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt;
                &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;fallbackToDestructiveMigration&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt;
                &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;build&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt;
        &lt;span class="o"&gt;}&lt;/span&gt;

        &lt;span class="n"&gt;bean&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt; &lt;span class="n"&gt;ApplicationSchedulerProvider&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;SchedulerProvider&lt;/span&gt; &lt;span class="o"&gt;}&lt;/span&gt;

        &lt;span class="c1"&gt;// Expose ItemDao directly&lt;/span&gt;
        &lt;span class="n"&gt;bean&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt; &lt;span class="n"&gt;get&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;Database&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;().&lt;/span&gt;&lt;span class="na"&gt;itemDao&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;ItemDao&lt;/span&gt; &lt;span class="o"&gt;}&lt;/span&gt;

        &lt;span class="c1"&gt;// Expose UserDao directly&lt;/span&gt;
        &lt;span class="n"&gt;bean&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt; &lt;span class="n"&gt;get&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;Database&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;().&lt;/span&gt;&lt;span class="na"&gt;userDao&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;}&lt;/span&gt;

    &lt;span class="o"&gt;}&lt;/span&gt;


    &lt;span class="n"&gt;val&lt;/span&gt; &lt;span class="n"&gt;onlineNewsApp&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;listOf&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;appModule&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;remoteModule&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Koin and the components of Koin that we need to know when writing this article in AppModule&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;b&gt;get () →&lt;/b&gt; This component is usually used to inject into constructive method (you can only inject the structures defined in App.module with get ())&lt;/li&gt;
&lt;li&gt;
&lt;b&gt;factory →&lt;/b&gt;This component is used to give you a new sample every time you request it.&lt;/li&gt;
&lt;li&gt;
&lt;b&gt;bean →&lt;/b&gt; This component is used when performing single identification.&lt;/li&gt;
&lt;li&gt;
&lt;b&gt;name =&lt;/b&gt; This component is required when you want to have more than one instance of the same class in different classes.&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;For Koin to start after you create the modules and components;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight gradle"&gt;&lt;code&gt;    &lt;span class="kn"&gt;package&lt;/span&gt; &lt;span class="nn"&gt;com.fevziomurtekin.hackernewsapp&lt;/span&gt;

    &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;android.app.Application&lt;/span&gt;
    &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;com.fevziomurtekin.di.onlineNewsApp&lt;/span&gt;
    &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;org.koin.android.ext.android.startKoin&lt;/span&gt;

    &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;BaseApplication&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;Application&lt;/span&gt;&lt;span class="o"&gt;(){&lt;/span&gt;

        &lt;span class="n"&gt;override&lt;/span&gt; &lt;span class="n"&gt;fun&lt;/span&gt; &lt;span class="nf"&gt;onCreate&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
            &lt;span class="kd"&gt;super&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;onCreate&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt;

            &lt;span class="n"&gt;startKoin&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;onlineNewsApp&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;

        &lt;span class="o"&gt;}&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;After injecting the Koini into our project, we call the mainViewModel we created in AppModule as an example;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;val viewModel by viewModel ()&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  Resources and Conclusion
&lt;/h3&gt;


&lt;center&gt;
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--3jniTdYi--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://raw.githubusercontent.com/InsertKoinIO/koin/master/img/koin_2.0.jpg" alt=""&gt;&lt;br&gt;&lt;a href="https://github.com/InsertKoinIO/koin"&gt;Koin Github&lt;/a&gt; &lt;/center&gt;
&lt;br&gt;


&lt;center&gt;
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--3jniTdYi--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://raw.githubusercontent.com/InsertKoinIO/koin/master/img/koin_2.0.jpg" alt=""&gt;&lt;br&gt;&lt;a href="https://github.com/InsertKoinIO/getting-started-koin-android"&gt;Getting started Koin Android&lt;/a&gt; &lt;/center&gt;
&lt;br&gt;

&lt;p&gt;I tried to explain why I prefer Koin, how I use it, and how much if I use dagger and coin on a simple project, as far as I can. More information can be found at. Next&lt;/p&gt;

&lt;p&gt;Link to the project I developed with Koin:&lt;/p&gt;



&lt;center&gt;
&lt;br&gt;
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--e_Jc2Zta--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.ibb.co/C5rMFd0/hackernews.png" alt=""&gt;&lt;br&gt;&lt;a href="https://github.com/fevziomurtekin/hackernewsapp"&gt;HackerNewsApp&lt;/a&gt; &lt;/center&gt;
&lt;br&gt;

</description>
      <category>di</category>
      <category>koin</category>
      <category>kotlin</category>
      <category>android</category>
    </item>
    <item>
      <title>Using Sqlite in Go Programming.</title>
      <dc:creator>Fevzi Ömür Tekin</dc:creator>
      <pubDate>Mon, 25 Feb 2019 08:28:36 +0000</pubDate>
      <link>https://dev.to/fevziomurtekin/using-sqlite-in-go-programming-3g2c</link>
      <guid>https://dev.to/fevziomurtekin/using-sqlite-in-go-programming-3g2c</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--P3QZrytU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/sav2nuu7iubw2qv2sxfa.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--P3QZrytU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/sav2nuu7iubw2qv2sxfa.png" alt="alt text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;SQLite is an open source code that is a relational sql search engine. The most important advantage of a host is that the server does not need a local server.&lt;/p&gt;

&lt;p&gt;In this example I'll make a simple example running on sqlite with go.&lt;/p&gt;

&lt;h2&gt;
  
  
  Used Libraries
&lt;/h2&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import (
  "database/sql"
  "fmt"
  "strconv"
  _ "github.com/mattn/go-sqlite3"
)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h2&gt;
  
  
  Model Structure
&lt;/h2&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;type User struct {
  id         int
  username   string
  surname    string
  age        int
  university string
  //I created a struct with a struct to select the rows in the table and add data.
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;br&gt; I am using a user model consisting of "id", "username", "surname", "age" and "university".&lt;/p&gt;

&lt;h2&gt;
  
  
  CRUD Methods
&lt;/h2&gt;

&lt;p&gt;I have done CRUD operations using Sqlite database with Go programming language.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;func addUser(db *sql.DB, username string, surname string, age int, university string) {
  tx, _ := db.Begin()
  stmt, _ := tx.Prepare("insert into testTable (username,surname,age,university) values (?,?,?,?)")
  _, err := stmt.Exec(username, surname, age, university)
  checkError(err)
  tx.Commit()
}
func getUsers(db *sql.DB, id2 int) User {
  rows, err := db.Query("select * from testTable")
  checkError(err)
  for rows.Next() {
    var tempUser User
    err =
      rows.Scan(&amp;amp;tempUser.id, &amp;amp;tempUser.username, &amp;amp;tempUser.surname, &amp;amp;tempUser.age, &amp;amp;tempUser.university)
    checkError(err)
    if tempUser.id == id2 {
      return tempUser
    }
  }
  return User{}
}
func updateUser(db *sql.DB, id2 int, username string, surname string, age int, university string) {
  sage := strconv.Itoa(age) // int to string
  sid := strconv.Itoa(id2)  // int to string
  tx, _ := db.Begin()
  stmt, _ := tx.Prepare("update testTable set username=?,surname=?,age=?,university=? where id=?")
  _, err := stmt.Exec(username, surname, sage, university, sid)
  checkError(err)
  tx.Commit()
}
func deleteUser(db *sql.DB, id2 int) {
  sid := strconv.Itoa(id2) // int to string
  tx, _ := db.Begin()
  stmt, _ := tx.Prepare("delete from testTable where id=?")
  _, err := stmt.Exec(sid)
  checkError(err)
  tx.Commit()
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h2&gt;
  
  
  Main Function
&lt;/h2&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;db, _ := sql.Open("sqlite3", "database/godb.db")
  db.Exec("create table if not exists testTable (id integer,username text, surname text,age Integer,university text)")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;br&gt;I'm writing code that allows you to connect to the database and run. Then I use the methods that let me perform the CRUD operations above.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;func main() {
  db, _ := sql.Open("sqlite3", "database/godb.db")
  db.Exec("create table if not exists testTable (id integer,username text, surname text,age Integer,university text)")
  addUser(db, "fevzi omur ", "tekin", 24, "Sakarya University") // added data to database
  updateUser(db, 2, "Ken", "Thompson", 75, "California university") //update data to database
  deleteUser(db, 1) // delete data to database
  fmt.Println(getUsers(db, 2)) // printing the user
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Note :&lt;/strong&gt; The codes of the project can be found at &lt;a href="https://github.com/fevziomurtekin/go-sqlite"&gt;this address.&lt;/a&gt; &lt;/p&gt;

</description>
      <category>go</category>
      <category>sqlite</category>
      <category>database</category>
      <category>crud</category>
    </item>
    <item>
      <title>CSV to JSON Converter with Go </title>
      <dc:creator>Fevzi Ömür Tekin</dc:creator>
      <pubDate>Mon, 25 Feb 2019 08:22:41 +0000</pubDate>
      <link>https://dev.to/fevziomurtekin/csv-to-json-converter-with-go--h29</link>
      <guid>https://dev.to/fevziomurtekin/csv-to-json-converter-with-go--h29</guid>
      <description>&lt;p&gt;Files with a CSV extension are files that are written and saved in a specific order by separating the data with commas for database users. This type of file is needed  when you want to transfer data in Excel. I will develop a program with the Go programming language, which can be converted and saved to.&lt;/p&gt;

&lt;h2&gt;
  
  
  Used CSV Files
&lt;/h2&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;## Used CSV Files
plaka,bolge,il,ilce
1,AKDENİZ,ADANA,ALADAĞ
1,AKDENİZ,ADANA,CEYHAN
1,AKDENİZ,ADANA,ÇUKUROVA
1,AKDENİZ,ADANA,FEKE
1,AKDENİZ,ADANA,İMAMOĞLU
......
......
......
3,EGE,AFYONKARAHİSAR,BAŞMAKÇI
3,EGE,AFYONKARAHİSAR,BAYAT
3,EGE,AFYONKARAHİSAR,BOLVADİN
3,EGE,AFYONKARAHİSAR,ÇAY
3,EGE,AFYONKARAHİSAR,ÇOBANLAR
3,EGE,AFYONKARAHİSAR,DAZKIRI
3,EGE,AFYONKARAHİSAR,DİNAR
3,EGE,AFYONKARAHİSAR,EMİRDAĞ
3,EGE,AFYONKARAHİSAR,EVCİLER
3,EGE,AFYONKARAHİSAR,HOCALAR
3,EGE,AFYONKARAHİSAR,İHSANİYE
3,EGE,AFYONKARAHİSAR,İSCEHİSAR
.....
.....
.....
.....
14,KARADENİZ,BOLU,DÖRTDİVAN
14,KARADENİZ,BOLU,GEREDE
14,KARADENİZ,BOLU,GÖYNÜK
14,KARADENİZ,BOLU,KIBRISCIK
14,KARADENİZ,BOLU,MENGEN
14,KARADENİZ,BOLU,MUDURNU
.....
.....
.....
.....
16,MARMARA,BURSA,GÜRSU
16,MARMARA,BURSA,HARMANCIK
16,MARMARA,BURSA,İNEGÖL
16,MARMARA,BURSA,İZNİK
16,MARMARA,BURSA,KARACABEY
16,MARMARA,BURSA,KELES
....
....
....
....
31,AKDENİZ,HATAY,DEFNE
31,AKDENİZ,HATAY,ARSUZ
31,AKDENİZ,HATAY,PAYAS
45,EGE,MANİSA,ŞEHZADELER
45,EGE,MANİSA,YUNUSEMRE
46,AKDENİZ,KAHRAMANMARAŞ,DULKADİROĞLU
46,AKDENİZ,KAHRAMANMARAŞ,ONİKİŞUBAT
47,GÜNEYDOĞU ANADOLU,MARDİN,ARTUKLU
.....
.....
.....
.....
63,GÜNEYDOĞU ANADOLU,ŞANLURFA,HALİLİYE
63,GÜNEYDOĞU ANADOLU,ŞANLIURFA,KARAKÖPRÜ
65,DOĞU ANADOLU,VAN,TUŞBA
65,DOĞU ANADOLU,VAN,İPEKYOLU
67,KARADENİZ,ZONGULDAK,KİLİMLİ
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h2&gt;
  
  
  Used Libraries
&lt;/h2&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import (
  "encoding/csv"
  "encoding/json"
  "os"
  "strconv"
)

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;br&gt; &lt;strong&gt;Note:&lt;/strong&gt; encoding/csv and encoding/json, csv to json converting Libraries.&lt;/p&gt;

&lt;h2&gt;
  
  
  Steps to Program
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;We are opening our .csv file first. &lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;src, err := os.Open("illerilceler.csv")
if err != nil {
panic(err)
}
defer src.Close()
&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The .json file was created.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;dst, err := os.Create("il-ilce.json")
if err != nil {
  panic(err)
}
defer dst.Close()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;ul&gt;
&lt;li&gt;Then, we open the .csv file that we opened, and we save it to the .json file that we created&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;records := make([]Record, 0, len(rows)) // We are opening up a number of rows.
  for _, row := range rows {
    plaka, _ := strconv.ParseInt(row[0], 0, 64) // parsing.
    bolge := row[1]
    il := row[2]
    ilce := row[3]
    /*read the data in the first row and add it to the records recorder.*/
    records = append(records, Record{
      Plaka: plaka,
      Bolge: bolge,
      Il:    il,
      Ilce:  ilce,
    })
  }
  /*We're moving the recorder to json.*/
  err = json.NewEncoder(dst).Encode(records)
  if err != nil {
    panic(err)
  }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h2&gt;
  
  
  All Codes
&lt;/h2&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package main
import (
  "encoding/csv"
  "encoding/json"
  "os"
  "strconv"
)
type Record struct {
  Plaka int64
  Bolge string
  Il    string
  Ilce  string
  // High, Low, Close
}
func main() {
  src, err := os.Open("illerilceler.csv")
  if err != nil {
    panic(err)
  }
  defer src.Close()
  dst, err := os.Create("il-ilce.json")
  if err != nil {
    panic(err)
  }
  defer dst.Close()
  rows, err := csv.NewReader(src).ReadAll()
  if err != nil {
    panic(err)
  }
  records := make([]Record, 0, len(rows)) 
  for _, row := range rows {
    plaka, _ := strconv.ParseInt(row[0], 0, 64) // parseliyoruz.
    bolge := row[1]
    il := row[2]
    ilce := row[3]

    records = append(records, Record{
      Plaka: plaka,
      Bolge: bolge,
      Il:    il,
      Ilce:  ilce,
    })
  }

  err = json.NewEncoder(dst).Encode(records)
  if err != nil {
    panic(err)
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Note :&lt;/strong&gt; The codes of the project can be found at &lt;a href="https://github.com/fevziomurtekin/csv-to-json"&gt;this address.&lt;/a&gt;&lt;/p&gt;

</description>
      <category>go</category>
      <category>json</category>
      <category>csv</category>
      <category>converter</category>
    </item>
    <item>
      <title>Voice Assistant using Dialogflow with Kotlin</title>
      <dc:creator>Fevzi Ömür Tekin</dc:creator>
      <pubDate>Tue, 29 Jan 2019 05:28:59 +0000</pubDate>
      <link>https://dev.to/fevziomurtekin/voice-assistant-using-dialogflow-with-kotlin-3p98</link>
      <guid>https://dev.to/fevziomurtekin/voice-assistant-using-dialogflow-with-kotlin-3p98</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--S7Fdwu-x--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/kl1jo37h27jl8x4jjw1f.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--S7Fdwu-x--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/kl1jo37h27jl8x4jjw1f.png" alt="Crepe"&gt;&lt;/a&gt; &lt;br&gt;&lt;br&gt;&lt;/p&gt;

&lt;p&gt;Hello to everyone,&lt;/p&gt;

&lt;p&gt;In this article, I'm going to talk about the step-by-step implementation of a simple assistant application with Kotlin using the Dialogflow platform.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is Dialogflow?
&lt;/h2&gt;

&lt;p&gt;Google 2016 year-end (formerly Api.ai) company is a platform used to develop chatbots for multiple devices with AI side voice and speech interfaces.&lt;/p&gt;

&lt;p&gt;Let's get to know the components to better understand Dialogflow.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--mRz56t4g--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/anz1og6h1cwcyxhau0pt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--mRz56t4g--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/anz1og6h1cwcyxhau0pt.png" alt="Crepe"&gt;&lt;/a&gt; &lt;br&gt;&lt;br&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Agent
&lt;/h3&gt;

&lt;p&gt;It helps you process configured data to return the appropriate response to users' entries.&lt;/p&gt;

&lt;p&gt;The Agent consists of 3 different components.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;b&gt;Training Phrases : &lt;/b&gt; Defines sample expressions that users say. Dialogflow uses these expressions and expands with similar expressions to create a matching model.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;b&gt;Action and Parameters : &lt;/b&gt; (We'll explain this item in the intent item.)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;b&gt; Responses &lt;/b&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--11n9MKhU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/0w3jwva1vtfjb7eh1g9s.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--11n9MKhU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/0w3jwva1vtfjb7eh1g9s.png" alt="Crepe"&gt;&lt;/a&gt; &lt;br&gt;&lt;br&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Intent
&lt;/h3&gt;

&lt;p&gt;Intent represents the match that corresponds to what the user says. You can create different intentions according to our purposes.&lt;/p&gt;

&lt;p&gt;To better explain; this is where we create different types of questions in this component and create answers to these questions.&lt;/p&gt;

&lt;h3&gt;
  
  
  Fulfillment
&lt;/h3&gt;

&lt;p&gt;Fulfillment is the place where the necessary actions are taken to return the answer to the question we ask from any of our web services.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--wcwPBimQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/u6h5cxmvvixk1f1yesgn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--wcwPBimQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/u6h5cxmvvixk1f1yesgn.png" alt="Crepe"&gt;&lt;/a&gt; &lt;br&gt;&lt;br&gt;&lt;/p&gt;

&lt;p&gt;If we have some idea of the components, let's start the project step by step.&lt;/p&gt;

&lt;h2&gt;
  
  
  Development Stages
&lt;/h2&gt;

&lt;p&gt;Scenario of the project we will develop:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;b&gt;User:&lt;/b&gt; Hello / Hey / Hi &lt;br&gt;&lt;br&gt;
&lt;b&gt;Assistant:&lt;/b&gt; Welcome! how can I help you? &lt;br&gt;&lt;br&gt;
&lt;b&gt;User:&lt;/b&gt;  Who are you? / Can you explain yourself? &lt;br&gt;&lt;br&gt;
&lt;b&gt;Assistant:&lt;/b&gt;  Step assistant. I'm a week. Within Turkey you tell me the name of any city, it will also help you to learn about the weather :)&lt;br&gt;&lt;br&gt;
&lt;b&gt;User:&lt;/b&gt; How is the weather in Bursa? How is Bursa? / Bursa - (to be mentioned in other provinces instead of Bursa.)  &lt;br&gt;&lt;br&gt;
&lt;b&gt;Assistant:&lt;/b&gt; In Bursa, the weather is 8 degrees partly cloudy. &lt;br&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h4&gt;
  
  
  &lt;b&gt;Creating our new agent &lt;/b&gt;
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://console.dialogflow.com/api-client/"&gt;First, we go to link to create our agent.&lt;/a&gt; &lt;br&gt;&lt;br&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--NMfnFE36--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/nuailex32jhbu0xx0aj2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--NMfnFE36--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/nuailex32jhbu0xx0aj2.png" alt="Crepe"&gt;&lt;/a&gt; &lt;br&gt;&lt;br&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;b&gt;Create Intent&lt;/b&gt;
&lt;/h4&gt;

&lt;p&gt; After creating an agent, we determine our scenario and determine what answers our assistant will answer.&lt;/p&gt;

&lt;p&gt;We're creating Intent -&amp;gt; Create Intent and creating our new intention.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--M_XiOiEK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/xcksbxwzs6kzjd04a9xr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--M_XiOiEK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/xcksbxwzs6kzjd04a9xr.png" alt="Crepe"&gt;&lt;/a&gt; &lt;br&gt;&lt;br&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--K741NUCE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/xkuuc9i53u4trxordpie.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--K741NUCE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/xkuuc9i53u4trxordpie.png" alt="Crepe"&gt;&lt;/a&gt; &lt;br&gt;&lt;br&gt;&lt;/p&gt;

&lt;p&gt;Then we identify and record the questions and answers. As you can see, I entered the questions that we would get the same answers and identified one answer.&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;b&gt;Web service response to the answer to our question&lt;/b&gt;
&lt;/h4&gt;

&lt;p&gt;This stage is optional. You can also create and use intentions without using a web service.&lt;/p&gt;

&lt;p&gt;Select Fullfilment; We can ensure that the answers are received from the inline editor or from our webservice.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;I've also used webhook and I've taken advantage of the current weather api for &lt;a href=""&gt;&lt;/a&gt;&lt;a href="http://i.apixu.com"&gt;http://i.apixu.com&lt;/a&gt;. You can reach the codes from.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ClgaBBO7--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/1atjadl0s5bul3wxiyd7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ClgaBBO7--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/1atjadl0s5bul3wxiyd7.png" alt="Crepe"&gt;&lt;/a&gt; &lt;br&gt;&lt;br&gt;&lt;/p&gt;

&lt;p&gt;Then, with the intent we just created, we determine which questions will return data from the web service.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--7pv2ICqR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/p6pur019bevrkuiao3yx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--7pv2ICqR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/p6pur019bevrkuiao3yx.png" alt="Crepe"&gt;&lt;/a&gt; &lt;br&gt;&lt;br&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--wQwXq8Vo--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/qxdmpcs556qv91vw56kz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--wQwXq8Vo--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/qxdmpcs556qv91vw56kz.png" alt="Crepe"&gt;&lt;/a&gt; &lt;br&gt;&lt;br&gt;&lt;/p&gt;

&lt;p&gt;The important part here is; Bursa (variable) to make the selected part and make it a key. I've assigned geo-city. According to this key, I also do the necessary service. For more information about Webhook, &lt;a href="https://github.com/fevziomurtekin/dialogflow-voice-assistant/tree/master/webhook"&gt;please visit&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Integration of Kotlin and Dialogflow platform
&lt;/h4&gt;

&lt;p&gt; We follow app -&amp;gt; build.gradle and add dialogflow and java client v2 libraries.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    // DialogFlow SDK depencies &amp;lt;br&amp;gt;
    implementation 'ai.api:sdk:2.0.7@aar' &amp;lt;br&amp;gt;
    implementation 'ai.api:libai:1.6.12' &amp;lt;br&amp;gt;
    // Java v2 &amp;lt;br&amp;gt;
    implementation 'com.google.cloud:google-cloud-dialogflow:0.67.0-alpha' &amp;lt;br&amp;gt;
    implementation 'io.grpc:grpc-okhttp:1.15.1' &amp;lt;br&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;blockquote&gt;
&lt;p&gt;Java Client v2 is the java client for dialogflow. (You can also use the v1 version, but v1 will be available on October 23, 2019.)&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;For us to use the Java Client library, we would like to create a json from the Google IAM console. To create this json,&lt;/p&gt;

&lt;p&gt;First of all, we are entering the project that we created in IAM console.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Ki-vk6nJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/mcqhlt9d4qf30xogr1cx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Ki-vk6nJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/mcqhlt9d4qf30xogr1cx.png" alt="Crepe"&gt;&lt;/a&gt; &lt;br&gt;&lt;br&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s---YhRTJIw--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/opbtyxggk4ffe5ww6hit.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s---YhRTJIw--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/opbtyxggk4ffe5ww6hit.png" alt="Crepe"&gt;&lt;/a&gt; &lt;br&gt;&lt;br&gt;&lt;br&gt;
After clicking the edit first, we call it creating a new key.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s---ieCCf4_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/t5562c82ztdl9v0gs46q.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s---ieCCf4_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/t5562c82ztdl9v0gs46q.png" alt="Crepe"&gt;&lt;/a&gt; &lt;br&gt;&lt;br&gt;&lt;/p&gt;

&lt;p&gt;Json. It will automatically come down to our computer after creation. This file in our application to create a raw directory and put the .json file into raw.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;      private fun initAsisstant() {
            try {
                val stream = resources.openRawResource(R.raw.asistan)
                val credentials = GoogleCredentials.fromStream(stream)
                val projectId = (credentials as ServiceAccountCredentials).projectId

                val settingsBuilder = SessionsSettings.newBuilder()
                val sessionsSettings =
                    settingsBuilder.setCredentialsProvider(FixedCredentialsProvider.create(credentials)).build()
                client = SessionsClient.create(sessionsSettings)
                session = SessionName.of(projectId, uuid)
            } catch (e: Exception) {
                e.printStackTrace()
            }

        }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt; By reading our json file created in our activity, we define our client.&lt;/p&gt;

&lt;p&gt;We then create a class that will allow our message to communicate with Dialogflow.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class RequestTask : AsyncTask&amp;lt;Void, Void, DetectIntentResponse&amp;gt; {

    var activity: Activity? = null
    private var session: SessionName? = null
    private var sessionsClient: SessionsClient? = null
    private var queryInput: QueryInput? = null


    constructor(activity: Activity,session:SessionName,sessionsClient: SessionsClient,queryInput: QueryInput){
        this.activity=activity
        this.session=session
        this.queryInput=queryInput
        this.sessionsClient=sessionsClient
    }

    override fun doInBackground(vararg params: Void?): DetectIntentResponse? {
        try {
            val detectIntentRequest = DetectIntentRequest.newBuilder()
                .setSession(session.toString())
                .setQueryInput(queryInput)
                .build()
            return sessionsClient?.detectIntent(detectIntentRequest)
        } catch (e: Exception) {
            e.printStackTrace()
        }


        return null
    }

    override fun onPostExecute(result: DetectIntentResponse?) {
        (activity as MainActivity).onResult(result)
    }

}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;The return message is in the Activity function on the On Result function.&lt;/p&gt;

&lt;h4&gt;
  
  
  Integrating TextToSpeech and SpeechToText
&lt;/h4&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   private fun sendMicrophoneMessage(view:View){
           val intent: Intent = Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH)
           intent.putExtra(
               RecognizerIntent.EXTRA_LANGUAGE_MODEL,
               RecognizerIntent.LANGUAGE_MODEL_FREE_FORM
           )
           intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, Locale.getDefault())
           intent.putExtra(
               RecognizerIntent.EXTRA_PROMPT,
               getString(R.string.speech_prompt)
           )
           try {
               startActivityForResult(intent, SPEECH_INPUT)
           } catch (a: ActivityNotFoundException) {
               Toast.makeText(
                   applicationContext,
                   getString(R.string.speech_not_supported),
                   Toast.LENGTH_SHORT
               ).show()
           }

       }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Speech to Text function.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    private fun sendMicrophoneMessage(view:View){
           val intent: Intent = Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH)
           intent.putExtra(
               RecognizerIntent.EXTRA_LANGUAGE_MODEL,
               RecognizerIntent.LANGUAGE_MODEL_FREE_FORM
           )
           intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, Locale.getDefault())
           intent.putExtra(
               RecognizerIntent.EXTRA_PROMPT,
               getString(R.string.speech_prompt)
           )
           try {
               startActivityForResult(intent, SPEECH_INPUT)
           } catch (a: ActivityNotFoundException) {
               Toast.makeText(
                   applicationContext,
                   getString(R.string.speech_not_supported),
                   Toast.LENGTH_SHORT
               ).show()
           }

       }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Speech to Text function does not work long after it detects the text.&lt;/p&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    private fun initAsisstantVoice() {
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;      asistan_voice= TextToSpeech(applicationContext,object : TextToSpeech.OnInitListener {
          override fun onInit(status: Int) {
              if (status!=TextToSpeech.ERROR){
                  asistan_voice?.language=Locale("tr")
              }
          }

      })

  }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h4&gt;
&lt;br&gt;
  &lt;br&gt;
  &lt;br&gt;
  Reading messages and adding layout&lt;br&gt;
&lt;/h4&gt;

&lt;p&gt;RequestTask class returned to the value of the return function of our activity onResult function. We add the response value in our onResult function to our layout.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;If the user type is BOT, we have TextToSpeech done.&lt;/p&gt;
&lt;/blockquote&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    fun onResult(response: DetectIntentResponse?) {&lt;br&gt;
           try {&lt;br&gt;
               if (response != null) {&lt;br&gt;
                   var botReply:String=""&lt;br&gt;
                   if(response.queryResult.fulfillmentText==" ")&lt;br&gt;
                       botReply= response.queryResult.fulfillmentMessagesList[0].text.textList[0].toString()&lt;br&gt;
                   else&lt;br&gt;
                       botReply= response.queryResult.fulfillmentText
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;               appendText(botReply, BOT)
           } else {
               appendText(getString(R.string.anlasilmadi), BOT)
           }
       }catch (e:Exception){
           appendText(getString(R.string.anlasilmadi), BOT)
       }
   }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    private fun appendText(message: String, type: Int) {&lt;br&gt;
            val layout: FrameLayout&lt;br&gt;
            when (type) {&lt;br&gt;
                USER -&amp;gt; layout = appendUserText()&lt;br&gt;
                BOT -&amp;gt; layout = appendBotText()&lt;br&gt;
                else -&amp;gt; layout = appendBotText()&lt;br&gt;
            }&lt;br&gt;
            layout.isFocusableInTouchMode = true&lt;br&gt;
            linear_chat.addView(layout)&lt;br&gt;
            val tv = layout.findViewById&amp;lt;TextView&amp;gt;(R.id.chatMsg)&lt;br&gt;
            tv.setText(message)&lt;br&gt;
            Util.hideKeyboard(this)&lt;br&gt;
            layout.requestFocus()&lt;br&gt;
            edittext.requestFocus() // change focus back to edit text to continue typing&lt;br&gt;
            if(type!= USER) asistan_voice?.speak(message,TextToSpeech.QUEUE_FLUSH,null)&lt;br&gt;
        }&lt;br&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h1&gt;
&lt;br&gt;
  &lt;br&gt;
  &lt;br&gt;
  Application&lt;br&gt;
&lt;/h1&gt;

&lt;p&gt;&lt;a href="https://medium.com/@fevziomurtekin/kotlin-ile-dialogflow-kullanarak-sesli-asistan-yap%C4%B1m%C4%B1-205ef81e78d0?_branch_match_id=580614660615400010"&gt;&lt;br&gt;
 &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--bKH2Gj1M--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/http://img.youtube.com/vi/SkkNB5XDq8I/0.jpg" alt="Dialogflow kullanarak kotlin ile sesli asistan"&gt;&lt;br&gt;
&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Medium
&lt;/h1&gt;

&lt;p&gt;&lt;a href="https://medium.com/@fevziomurtekin/kotlin-ile-dialogflow-kullanarak-sesli-asistan-yap%C4%B1m%C4%B1-205ef81e78d0?_branch_match_id=580614660615400010"&gt;&lt;br&gt;
 &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--vd_0pcia--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/720/1%2AHDxwPlSqkUnpCef4sUk4zg.png" alt="Dialogflow kullanarak kotlin ile sesli asistan"&gt;&lt;br&gt;
&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Github
&lt;/h1&gt;

&lt;p&gt;&lt;a href="https://github.com/fevziomurtekin/dialogflow-voice-assistant"&gt;&lt;br&gt;
 &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Bb2j2_MH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/adfe65awjzgvn4urxlgb.png" alt="Github project"&gt;&lt;br&gt;
 &lt;/a&gt;&lt;/p&gt;

&lt;p&gt;With Dialogflow, I tried to explain the voice assistant as much as I could. I hope I've been successful.&lt;/p&gt;

&lt;p&gt;In the later stages of the project, I aim to make the Google Asisstant, Slack integrations more complicated. After completing these integrations to discuss with new articles.&lt;/p&gt;

</description>
      <category>kotlin</category>
      <category>dialogflow</category>
    </item>
  </channel>
</rss>
