Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Contributeしてない俺がDroidKaigiアプリについてゴニョゴニョ話す会

E77b6a5f919f7366d94f21eee9a014f5?s=47 operandoOS
February 28, 2018

 Contributeしてない俺がDroidKaigiアプリについてゴニョゴニョ話す会

E77b6a5f919f7366d94f21eee9a014f5?s=128

operandoOS

February 28, 2018
Tweet

Transcript

  1. Contributeͯ͠ͳ͍Զ͕ DroidKaigiΞϓϦʹ͍ͭͯ
 ΰχϣΰχϣ࿩͢ձ Souzoh Android Talk #2

  2. DroidKaigiΞϓϦ • https://github.com/konifar/droidkaigi2018-flutter • https://github.com/DroidKaigi/conference-app-2018 • https://github.com/kikuchy/DroidKaigi2018iOS

  3. ࠓ೔࿩͢ͷ͸
 DroidKaigi/conference-app-2018

  4. ߹ΘͤͯಡΈ͍ͨʂ • DroidKaigi 2018 App Architecture by takahirom • https://speakerdeck.com/takahirom/

    droidkaigi-2018-app-architecture • DroidKaigi ΞϓϦͷ಺෦ΛݟΔ by tatsuhama50 • https://www.slideshare.net/kenichitatsuhama/ droidkaigi-88921455
  5. CircleCIͷΠϝʔδ͸ެࣜͷͰྑͦ͞͏ • ͖ͬͱެࣜΠϝʔδΛFROMͰࢦఆͯ͠
 RubyΛೖΕͯΔͷ͔ͳʁ jobs: build: docker: - image: punchdrunker/android-27-ruby

  6. CircleCIͷΠϝʔδ͸ެࣜͷͰྑͦ͞͏ • ࣮͸ެࣜͷΠϝʔδʹ΋Ruby͸ೖͬͯΔʂ • https://github.com/CircleCI-Public/circleci- dockerfiles/blob/master/android/images/ api-27-alpha/Dockerfile#L125-L134

  7. CircleCIͷImage • CircleCI͕ఏڙͯ͠ΔImageͷDockerfile͸Githubʹ·ͱ·ͬͯΔ • https://github.com/CircleCI-Public/circleci-dockerfiles • AndroidͷDockerfile΋΋ͪΖΜ͋ΔΑ • https://github.com/CircleCI-Public/circleci-dockerfiles/tree/master/ android/images

    • circleci/android:api-27-alphaͷDockerfileͳΒҎԼ • https://github.com/CircleCI-Public/circleci-dockerfiles/blob/master/ android/images/api-27-alpha/Dockerfile
  8. ϖʔδΛอ࣋ͯ͘͠ΕʂཔΉʂ • SearchFragment͸ViewPagerͱTabLayoutͷߏ੒ • SpeakerλϒʹҠಈͯ͠ɺSessionλϒΛ։͘ͱ Page͕࠶ߏஙʹͳΔ • εΫϩʔϧͯͨ͠ҐஔมΘͬͪΌ͏ • Sessionλϒʹ੾Γସ͑Δ࣌ʹएׯ΋ͬ͞Γ͢Δ

  9. ϖʔδΛอ࣋ͯ͘͠ΕʂཔΉʂ • ͦ͜ͰViewPagerͷoffscreenPageLimitͰ͢ΑͶʂ • offscreenͷlimitΛมߋ͢Δ • σϑΥϧτͰ͸1 • σϑΥϧτ 1ͳͷͰɺSpeakerλϒʹҠಈ͢Δͱ

    Sessionλϒ͕ফ͑Δ
  10. ϖʔδΛอ࣋ͯ͘͠ΕʂཔΉʂ • SpeakerλϒʹҠಈͯ͠΋Sessionλϒ͕
 ফ͑ͳ͍Α͏ʹ͍ͨ͠ʂ • offscreenPageLimitΛ2ʹ͢Ε͹Αͦ͞͏ʂ • binding.sessionsViewPager.offscreenPageLimit = 2

  11. Demo

  12. ϖʔδอ࣋Ͱ͖ͨʂ • ΍ͬͨͶʂ • ϖʔδ਺͕ͲΕ͘Β͍͔Θ͔ͬͯΔͳΒ
 ࠷దԽ͢Δ΄͏͕͍͍ • ϖʔδͷอ࣋͢Δ෼ɺϝϞϦΛ࢖͏ͷͰ஫ҙ

  13. ViewPager#offscreenPageLimit • ViewPager#offscreenPageLimit API Document • https://developer.android.com/reference/ android/support/v4/view/ ViewPager.html#setOffscreenPageLimit(int)

  14. OkHttpͷLog͸ϦϦʔε൛͸
 ग़͞ͳ͍ํ͕͍͍ʂ

  15. OkHttpͷLog͸ϦϦʔε൛͸
 ग़͞ͳ͍ํ͕͍͍ʂ

  16. OkHttpͷLog͸ϦϦʔε൛͸
 ग़͞ͳ͍ํ͕͍͍ʂ

  17. OkHttpͷLog͸ϦϦʔε൛͸
 ग़͞ͳ͍ํ͕͍͍ʂ

  18. OkHttpͷLog͸ϦϦʔε൛͸
 ग़͞ͳ͍ํ͕͍͍ʂ

  19. ͭ·Γ

  20. OkHttpͷLog͸ϦϦʔε൛͸
 ग़͞ͳ͍ํ͕͍͍ʂ • ϦϦʔε൛ͷΞϓϦͰ͸HttpLoggingInterceptorΛ Interceptorʹઃఆ͠ͳ͍ํ͕͍͍ • ·ͨ͸NONEʹઃఆ͢Δ • OkHttpͷݶΒͣɺLogcatʹྲྀ͢಺༰͸ϚδͰؾΛͭ ͚͍ͯͩ͘͞ʂ

  21. λϒ λοϓͨ࣌͠ʹ
 Listͷઌ಄ʹ໭Δͷ͍͍ΑͶʂ • ·ͨ·ͨSearchFragment͞ΜͰ͢ • TabLayout.OnTabSelectedListenerΛ࢖ͬͯɺλοϓΠϕϯτΛ औͬͯΔ • λϒ͕λοϓ͞ΕΔͱɺViewPagerʹΞλον͞ΕͯΔ

    FragmentʹλονΠϕϯτ͕఻ΘΔ • FragmentͷRecyclerViewʹsmoothScrollToPosition(0)ͯ͠
 ઌ಄·ͰεΫϩʔϧͤ͞Δ
  22. Demo

  23. λϒ λοϓͨ࣌͠ʹ
 Listͷઌ಄ʹ໭Δͷ͍͍ΑͶʂ • ࣮૷؆୯͚ͩͲɺΊͬͪΌศརʹͳΔͷͰ
 ؾʹೖͬͨΒΈΜͳ࣮૷ͯ͠ΈͯͶʂ • ϝϧΧϦ Χ΢ϧͰ΋ࣅͨΑ͏ͳ࣮૷ͯ͠ΔΑʂ

  24. @CheckResult Annotation • APIͱ͔DBͱ͔Repositoryͷ໭Γ஋ͱ͔ʹ
 ͪΐ͍ͪΐ͍͚ͭΒΕͯͨ • DroidKaigiΞϓϦͰ࢖ΘΕͯΔͱ͜Ζ • https://github.com/DroidKaigi/conference- app-2018/search?

    q=CheckResult&type=Code&utf8=%E2%9C%93
  25. @CheckResult Annotation “ϝιουͷ݁Ռ·ͨ͸໭Γ஋͕࣮ࡍʹ࢖༻͞Ε͍ͯ Δ͔Ͳ͏͔Λݕূ͢Δʹ͸ @CheckResult Ξϊςʔ γϣϯΛ࢖༻͠·͢ɻ
 
 ͢΂ͯͷඇ void

    ϝιουʹ @CheckResult Ξϊςʔ γϣϯΛ෇͚ΔͷͰ͸ͳ͘ɺෳࡶͳϝιουͷ݁Ռ Λ໌֬ʹ͢ΔͨΊʹΞϊςʔγϣϯΛ௥Ճ͠·͢ɻ”
  26. @CheckResult Annotation “ͨͱ͑͹ɺܦݧͷઙ͍ Java σϕϩούʔ͸ɺ <String>.trim() ͕ݩͷจࣈྻ͔ΒۭനΛ࡟আ͢ Δ΋ͷͩͱצҧ͍͢Δ͜ͱ͕͋Γ·͢ɻϝιο υʹ @CheckResult

    ΞϊςʔγϣϯΛ෇͚Δ ͱɺݺͼग़͠ݩͰ <String>.trim() ͷ໭Γ஋Λ Ұ੾࢖༻͍ͯ͠ͳ͍৔߹ʹܯࠂ͕ग़·͢ɻ”
  27. ࢖͍ํͱઆ໌͕
 ׬ᘳ͗ͯ͢਒͑ͨ͆

  28. @CheckResult Annotation • https://developer.android.com/studio/write/ annotations.html#check-result • https://developer.android.com/reference/ android/support/annotation/ CheckResult.html

  29. ࠃࡍԽΛҙࣝͨ͠Notification Channel • Notification Channelͱ͸ʁ • ௨஌ΛChannelͱ͍͏୯ҐʹΧςΰϥΠζ͠Α͏ʂ • ৄ͘͠͸υΩϡϝϯτಡΜͰʂ •

    https://developer.android.com/guide/topics/ui/ notifiers/notifications.html#ManageChannels
  30. ͳͥࠃࡍԽΛҙࣝ͠ͳ͍ͱ͍͚ͳ͍ͷ͔ • NotificationChannelΛnew͢Δ࣌ͷname͸Ϣʔβʹ
 ݟ͑Δνϟϯωϧͷ֓ཁతͳ΍ͭ • ͜ΕઃఆΞϓϦͱ͔͕resource͔Βग़͢Θ͚Ͱ͸ͳ͍ • ChannelΛੜ੒ͨ࣌͠ͷݴޠͷϦιʔεʹґଘ͢Δͬͯ͜ͱ • ೔ຊޠઃఆͰChannelΛ࡞੒ͯ͠ɺӳޠઃఆʹ͢Δͱ

    Channelͷઆ໌͕೔ຊޠʹͳΔͱ͍͏໰୊͕ى͖Δ
  31. ࠃࡍԽΛҙࣝͨ͠Notification Channel • ݴޠઃఆ͕มΘͬͨλΠϛϯάͰChannelΛ࡞Γ௚͢ • android.intent.action.LOCALE_CHANGEDΛ
 BroadcastReceiverͰϑοΫ͢Δ • ͦͷλΠϛϯάͰνϟϯωϧΛ࡞Γ௚͢ •

    NotificationManager.createNotificationChannel͸
 ಉ͡Channel IDʹରͯ͠࠶౓ੜ੒Λݺͼग़͢ͱname΍ descriptionΛߋ৽Ͱ͖Δ
  32. ࠃࡍԽΛҙࣝͨ͠Notification Channel • ͜ͷ͜ͱͪΌΜͱυΩϡϝϯτʹ΋ॻ͍ͯ͋Δ • https://developer.android.com/reference/ android/app/ NotificationChannel.html#NotificationChannel (java.lang.String, java.lang.CharSequence,

    int)
  33. ࠃࡍԽΛҙࣝͨ͠Notification Channel “You can rename this channel when the system

    locale changes by listening for the ACTION_CHANGED broadcast.”
  34. ࠃࡍԽΛҙࣝͨ͠Notification Channel • Incomplete Implementation of Notification Channel • https://github.com/DroidKaigi/conference-

    app-2018/pull/406 • ʲAndroid Oʳ௨஌νϟϯωϧΛࠃࡍԽ͢Δ • https://qiita.com/Shiozawa/items/ 095e77d38fc00681e898
  35. DrawerLayout • Α͘Ͱ͖ͯΔʂ • ͔͠΋Ͳͷը໘Ͱ΋Drawerग़ͤΔΑ͏ʹͳͬͯΔʂ • Google͕ਪ঑??ͯ͠Δಈ͘ͳͷͰΑ͍

  36. resValue • Gradle͔ΒResouce΋ੜ੒Ͱ͖Δʂ • ศརʂ

  37. resValue • app/build/generated/res/resValues/debug/ values഑Լʹੜ੒͞ΕΔ <?xml version="1.0" encoding="utf-8"?> <resources> <!-- Automatically

    generated file. DO NOT MODIFY --> <!-- Values from the variant --> <string name="versionInfo" translatable="false">1.0.0-debug</string> <!-- Values from build type: debug --> <string name="app_name" translatable="false">DroidKaigi 2018 Dev</string> </resources>
  38. BindingAdapter • TextBinding.ktʹͳΔ΄Ͳʔ͍ͬͯ͏ͷ͋ͬͨʂ • android:textͰDate౉ͤΔΑ͏ʹ͢Δ࣮૷ʂ @BindingAdapter(value = ["android:text"]) fun TextView.setDateText(date:

    Date?) { date ?: return text = date.toReadableDateTimeString() }
  39. ͋ͱͳΜ͔ΞϓϦΫϥογϡͨ͆͠ Shutting down VM FATAL EXCEPTION: main Process: io.github.droidkaigi.confsched2018, PID:

    11577 b.a at io.github.droidkaigi.confsched2018.presentation.feed.a.a$a.onPreDraw(FeedItem.kt:58) at android.view.ViewTreeObserver.dispatchOnPreDraw(ViewTreeObserver.java:977) at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2349) at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1392) at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6752) 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:6494) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
  40. ͞ΒʹಡΉͱ໘നͦ͏ͳͱ͜Ζ • Mapper͍͍ͬ͢Ͷ • Room • binding.prevSession = prevSessionͱ binding.nextSession

    = nextSession • RTLରԠ
  41. ͞ΒʹಡΉͱ໘നͦ͏ͳͱ͜Ζ • FirebaseFirestore • Firestore offline͸ແޮԽͯ͠Δ • in memory cache͸͋Δʁ

    • https://firebase.google.com/docs/firestore/manage-data/enable- offline?hl=ja • ͍͍ͶʂΦϑϥΠϯͷঢ়ଶͰ։͘ͱΞϓϦͷProcess kill͢Δ·Ͱऔಘ Ͱ͖ͳ͍ʁʁ • ΦϯϥΠϯʹͯ͠ProcessϨϕϧͰΞϓϦ্ཱͪ͛௚͢ͱऔಘͰ͖Δ
  42. ࿩͔͚ͨͬͨ͠Ͳ࣌ؒͷ౎߹্ ࿩ͤͳ͔ͬͨ͜ͱ • EmojiCompat • Support LibraryͷDownloadable Fonts΍EmojiCompatʹରԠ
 ͨ͠ΞϓϦΛ࡞Ζ͏ by

    takahirom • https://speakerdeck.com/takahirom/support- libraryfalsedownloadable-fontsyaemojicompatnidui-ying- sitaapuriwozuo-rou • Resultύλʔϯ • FeedItemͳΜ͔bugͬͯΔ
  43. ࿩͔͚ͨͬͨ͠Ͳ࣌ؒͷ౎߹্ ࿩ͤͳ͔ͬͨ͜ͱ • NotificationHelper.kt • NotificationChannelTypeΑ͞ • Gradle Versions Plugin

    • ೖͬͯΔ͚ͲCIͱ͔Ͱ͸࢖ΘΕͯͳ͍ͷͰ๨Ε͕͚ͪͩͲΊͬͪΌศར • https://github.com/ben-manes/gradle-versions-plugin • AlarmManager.setAndAllowWhileIdle + Doze • https://qiita.com/FumihikoSHIROYAMA/items/ b1d6dbda120462d0e209
  44. ࿩͔͚ͨͬͨ͠Ͳ࣌ؒͷ౎߹্ ࿩ͤͳ͔ͬͨ͜ͱ • Open Source Notices • https://developers.google.com/android/guides/opensource • https://qiita.com/sho5nn/items/f63ebd7ccc0c86d98e4b

    • Kotlin DSL • https://github.com/gradle/kotlin-dsl • Kotlin + buildSrc for Better Gradle Dependency Management • https://handstandsam.com/2018/02/11/kotlin-buildsrc-for-better-gradle- dependency-management/ • Ϛϧν Ϟδϡʔϧ͔ͩΒόʔδϣϯͷ؅ཧ͸͜͏ͨ͠ํָ͕
  45. ࿩͔͚ͨͬͨ͠Ͳ࣌ؒͷ౎߹্ ࿩ͤͳ͔ͬͨ͜ͱ • MessageProcessorΛฦ͢ͷ͔ • ͳΔ΄Ͳʔ • ॲཧΛMessageProcessor͝ͱʹॻ͚ΔͷͰྑͦ͞͏ • ࣅͨΑ͏ͳ͜ͱΛϝϧΧϦ

    Χ΢ϧͰ΋Custom URLͰ ΍ͬͯΔ
  46. ͞Βʹ͜ͷ࣮૷΋͋Ε͹ྑ͔ͬͨʔ • Runtime Permission • ͍Βͳ͍ͳΒແཧʹ΍Δඞཁͳ͍ΑͶ

  47. DroidKaigi 2018 Flutter App • https://github.com/konifar/droidkaigi2018-flutter • git clone͔ͯ͠ΒAndroidϏϧυͰ͖Ͷʔw

  48. Thanks