AndroidStudioのテンプレートを覗いてみよう

 AndroidStudioのテンプレートを覗いてみよう

9d4a459864f822fb5aa7a5741e60e26b?s=128

Keisuke kiuchi

April 13, 2018
Tweet

Transcript

  1. "OESPJE4UVEJPͷ
 ςϯϓϨʔτΛ೷͍ͯΈΑ͏ LJVDIJLFJTVLF
 4IJCVZBBQL

  2. ໦಺ܒี w ৬ۀɿ"OESPJEΤϯδχΞ݉ҭࣇύύ w झຯͰ࡞ͬͨΞϓϦɿʮΒ͘ͰΜʯ w Ϟοτʔɿ໌೔ͷࣗ෼ʹ༏͍͠ίʔυΛॻ͘ w 4/4
 5XJUUFS!GFJ@LPNF


    (JUIVC!LJVDIJLFJTVLF
 2JJUB!L@LFJTVLF
  3. ࠷ۙͷΞΫςΟϏςΟ IUUQTXXXZPVUVCFDPNXBUDI WU(#W:M2.+UT

  4. $MFBO"SDIJUFDUVSF
 5FNQMBUFGPS,PUMJO w %BHHFS w 3Y+BWB w 3FBMN w $POTUSBJOU-BZPVU

    w 3FUSPpU w 4XBHHFS w BOESPJELUY w %BUB#JOEJOH w 7JFX.PEFM IUUQTHJUIVCDPNLJVDIJLFJTVLF"OESPJE4UVEJP$MFBO"SDIJUFDUVSFUFNQMBUF GPS,PUMJO
  5. %SPJE,BJHJͰग़͖ͯͨ ΪϞϯ

  6. ςϯϓϨʔτͬͯ
 Ͳ͏΍ͬͯ࡞Δͷʁ

  7. ςϯϓϨʔτͷத਎Λ ೷͍ͯΈΑ͏

  8. ͷલʹɾɾɾ

  9. ςϯϓϨʔτ࡞ΕΔͱ Կ͕خ͍͠ͷʁ

  10. ςϯϓϨʔτ࡞ΕΔͱʜ w ৽͍͠ը໘Λ࡞Δࡍͷ਽ܗΛࣗ෼޷Έʹ࡞ΕΔ
 ˠඞཁे෼ͳ"DUJWJUZ΍MBZPVUϑΝΠϧ͕Ͱ͖Δ w ΞʔΩςΫνϟΛ࠾༻͢Δࡍͷ਽ܗΛ࡞ΕΔ
 ˠϓϩδΣΫτ಺Ͱ࣮૷ͷΏΒ͗Λ཈ࢭ͢Δ
 ˠఆܕจతʹ࣮૷͢ΔΫϥεΛࣗಈͰ࡞੒͢Δ
  %BHHFSͷ.PEVMF

    $PNQPOFOUΫϥεͳͲ  w ৽نϓϩδΣΫτ࡞੒࣌ͷEFQFOEFODZͷॳظઃఆΛ
 ࣗ༝ʹઃఆͰ͖Δ
 ˠʮϥΠϒϥϦԿ͕͍ΔΜ͚ͩͬʜʯ͔Βղ์͞ΕΔ
  11. վΊͯɺςϯϓϨʔτͷ த਎Λ೷͍ͯΈΑ͏

  12. ͦ΋ͦ΋ςϯϓϨʔτͬͯʁ

  13. Ͳ͜ʹ͋Δͷʁ w .BD
 "QQMJDBUJPOT"OESPJE4UVEJPBQQ$POUFOUT QMVHJOTBOESPJEMJCUFNQMBUFTBDUJWJUJFT w 8JOEPXT
 "/%30*%@456%*0@'0-%&3 aQMVHJOTaBOESPJEaMJCaUFNQMBUFTaBDUJWJUJFTa

  14. ϑΝΠϧߏ੒ͲΜͳײ͡ʁ BaseActivity + globals.xml.ftl + recipe_fragmentxml.ftl + recipe.xml.ftl + template_basic_activity_fragment.png

    + template_basic_activity.png + template.xml + root + res | + layout | + activity_fragment_container.xml.ftl | + fragment_simple.xml.ftl + src + app_package + SimpleActivity.java.ftl + SimpleActivity.kt.ftl + SimpleActivityFragment.java.ftl + SimpleActivityFragment.kt.ftl
  15. UFNQMBUFYNM <parameter id="activityClass" name="Activity Name" type="string" constraints="class|unique|nonempty" suggest="${layoutToActivity(layoutName)}" default="MainActivity" help="The

    name of the activity class to create"/>
  16. UFNQMBUFYNM w ςϯϓϨʔτશମͰ࢖͑ΔύϥϝʔλΛઃఆͰ͖Δ w 4USJOH #PPMFBO &OVN w ςϯϓϨʔτͷΠϝʔδը૾ΛઃఆͰ͖Δ w

    ύϥϝʔλΛݩʹSFDJQFYNMGUMΛ࣮ߦ͢Δ
  17. SFDJQFYNMGUM <!- - ྫ̍ʢBaseActivityͷςϯϓϨʔτ͔Βൈਮʣ - ->
 <#if generateKotlin> <instantiate 


    from="root/src/app_package/SimpleActivity.kt.ftl" to="${escapeXmlAttribute(srcOut)}/${activityClass}.kt" 
 /> <open file="${escapeXmlAttribute(srcOut)}/${activityClass}.kt" /> <#else> <instantiate 
 from="root/src/app_package/SimpleActivity.java.ftl" to="${escapeXmlAttribute(srcOut)}/${activityClass}.java"
 /> <open file="${escapeXmlAttribute(srcOut)}/${activityClass}.java" /> </#if> 
 <!- - ྫ̎ - ->
 <mkdir at="${escapeXmlAttribute(projectOut)}/src/main/kotlin"/> 
 
 <!- - ྫ̏ - -> <merge from="root/build.gradle.ftl" to="${escapeXmlAttribute(projectOut)}/build.gradle" /> <dependency mavenUrl="com.google.dagger:dagger:2.+" />
  18. SFDJQFYNMGUM w 'SFF.BLFSͰॻ͔Ε͍ͯΔ ֦ுࢠ͕GUMͷϑΝΠϧ 
 IUUQTGSFFNBSLFSBQBDIFPSH w ϑΝΠϧͷੜ੒ Ϛʔδ 0QFOΛߦ͑Δ

    w ϑΥϧμͷੜ੒Λߦ͑Δ w EFQFOEFODZͷઃఆΛߦ͑Δ
  19. 4JNQMF"DUJWJUZLUGUM package ${escapeKotlinIdentifiers(packageName)} import android.os.Bundle <#if hasAppBar> import android.support.design.widget.Snackbar import

    android.support.v7.app.AppCompatActivity <#else> import ${superClassFqcn} </#if> import kotlinx.android.synthetic.main.${layoutName}.* class ${activityClass} : ${superClass}() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.${layoutName}) <#if hasAppBar> setSupportActionBar(toolbar) fab.setOnClickListener { view -> Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG).setAction("Action", null).show() } </#if>
  20. 4JNQMF"DUJWJUZLUGUM w SPPUҎԼʹ਽ܗͱͳΔϑΝΠϧ܈͕഑ஔ͞Ε͍ͯΔ w SPPUTSDdΫϥεܥͷϑΝΠϧɻ w SPPUSFTdϦιʔεܥͷϑΝΠϧ w SPPU্هҎ֎ͷϑΝΠϧ "OESPJE.BOJGFTU

    CVJMEHSBEMF 
  21. ·ͱΊ w ςϯϓϨʔτΛࣗ࡞Ͱ͖Δͱෳ਺ͷΫϥεΛಉ࣌ʹ࡞੒ͱ͔ɺ ΞʔΩςΫνϟʹଇͬͨΫϥεઃܭΛ࡞ͬͨΓͱ͔Ͱ͖ΔΑʂ w UFNQMBUFYNMͰ͸ςϯϓϨʔτ࡞੒ʹඞཁͳύϥϝʔλΛ
 ઃఆͰ͖ΔΑʂ w SFDJQFYNMGUMͰ͸ϑΝΠϧ࡞੒ͷΞϨίϨΛઃఆͰ͖ΔΑʂ w

    SPPUҎԼʹੜ੒͢Δ਽ܗΛ഑ஔ͢ΔΑʂ
  22. ৄ͘͠͸8FCͰʂ
 IUUQTHPPHM#[R&3