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

iOS anti pattern thinking ANDROID

yutaabe200
September 12, 2018

iOS anti pattern thinking ANDROID

アプリ開発と言うとほとんどがAndroid・iOS両OS開発するシーンがほとんどかと思われます。
その中でiOSでは容易に実装できるけどAndroidではキツイ!と言う実装やその逆のパターンも数多くあります。
本セッションではAndroid実装を考慮するとiOSでやってはいけないアンチパターンを両0S開発の経験を基にお話しします。

https://ore-con.firebaseapp.com/

yutaabe200

September 12, 2018
Tweet

More Decks by yutaabe200

Other Decks in Programming

Transcript

  1. " / % 3 0 * % Λ ߟ ͑

    ͨ * 0 4 Ξ ϯ ν ύ λ ʔϯ            0 3 & $ 0 /       ʙ       5 3 " $ ,  #  : 6 5"  " # &
  2. 32 ΞϯνύλʔϯʙϥΠϑαΠΫϧฤʙ "OESPJEͷը໘ճస 08-28 14:06:27.420 16839-16839/bio.enoque.enoque_android D/debug: onCreate() 08-28 14:06:27.436

    16839-16839/bio.enoque.enoque_android D/debug: onStart() 08-28 14:06:27.437 16839-16839/bio.enoque.enoque_android D/debug: onResume() 08-28 14:06:31.625 16839-16839/bio.enoque.enoque_android D/debug: onPause() 08-28 14:06:31.626 16839-16839/bio.enoque.enoque_android D/debug: onStop() 08-28 14:06:31.626 16839-16839/bio.enoque.enoque_android D/debug: onDestroy() 08-28 14:06:31.833 16839-16839/bio.enoque.enoque_android D/debug: onCreate() 08-28 14:06:31.835 16839-16839/bio.enoque.enoque_android D/debug: onStart() 08-28 14:06:31.835 16839-16839/bio.enoque.enoque_android D/debug: onResume()
  3. 33 ΞϯνύλʔϯʙϥΠϑαΠΫϧฤʙ "OESPJEͷը໘ճస 08-28 14:06:27.420 16839-16839/bio.enoque.enoque_android D/debug: onCreate() 08-28 14:06:27.436

    16839-16839/bio.enoque.enoque_android D/debug: onStart() 08-28 14:06:27.437 16839-16839/bio.enoque.enoque_android D/debug: onResume() 08-28 14:06:31.625 16839-16839/bio.enoque.enoque_android D/debug: onPause() 08-28 14:06:31.626 16839-16839/bio.enoque.enoque_android D/debug: onStop() 08-28 14:06:31.626 16839-16839/bio.enoque.enoque_android D/debug: onDestroy() 08-28 14:06:31.833 16839-16839/bio.enoque.enoque_android D/debug: onCreate() 08-28 14:06:31.835 16839-16839/bio.enoque.enoque_android D/debug: onStart() 08-28 14:06:31.835 16839-16839/bio.enoque.enoque_android D/debug: onResume() ͜͜Ͱը໘ճస
  4. 43 ΞϯνύλʔϯʙϨΠΞ΢τฤʙ private fun tabSelectedListener() { val tabLayout = findViewById<TabLayout>(R.id.HomeTabLayoutID)

    tabLayout.getTabAt(0)!!.setIcon(R.mipmap.ic_home_selected) tabLayout.getTabAt(1)!!.setIcon(R.mipmap.ic_search) val fragmentManager = supportFragmentManager val transaction = fragmentManager.beginTransaction() transaction.add(R.id.ContainerID, AccountFragment()).commit() tabLayout.addOnTabSelectedListener(object: TabLayout.OnTabSelectedListener { override fun onTabSelected(tab: TabLayout.Tab) { when(tab.position) { 0 -> { supportActionBar?.setDisplayHomeAsUpEnabled(false) tabLayout.getTabAt(0)!!.setIcon(R.mipmap.ic_home_selected) val fragmentManager = supportFragmentManager val transaction = fragmentManager.beginTransaction() transaction.replace(R.id.ContainerID, AccountFragment()).commit() } 1 -> { supportActionBar?.setDisplayHomeAsUpEnabled(false) tabLayout.getTabAt(1)!!.setIcon(R.mipmap.ic_search_selected) val fragmentManager = supportFragmentManager val transaction = fragmentManager.beginTransaction() transaction.replace(R.id.ContainerID, MapFragment()).commit() } } } "DUJWJUZ
  5. 44 ΞϯνύλʔϯʙϨΠΞ΢τฤʙ private fun tabSelectedListener() { val tabLayout = findViewById<TabLayout>(R.id.HomeTabLayoutID)

    tabLayout.getTabAt(0)!!.setIcon(R.mipmap.ic_home_selected) tabLayout.getTabAt(1)!!.setIcon(R.mipmap.ic_search) val fragmentManager = supportFragmentManager val transaction = fragmentManager.beginTransaction() transaction.add(R.id.ContainerID, AccountFragment()).commit() tabLayout.addOnTabSelectedListener(object: TabLayout.OnTabSelectedListener { override fun onTabSelected(tab: TabLayout.Tab) { when(tab.position) { 0 -> { supportActionBar?.setDisplayHomeAsUpEnabled(false) tabLayout.getTabAt(0)!!.setIcon(R.mipmap.ic_home_selected) val fragmentManager = supportFragmentManager val transaction = fragmentManager.beginTransaction() transaction.replace(R.id.ContainerID, AccountFragment()).commit() } 1 -> { supportActionBar?.setDisplayHomeAsUpEnabled(false) tabLayout.getTabAt(1)!!.setIcon(R.mipmap.ic_search_selected) val fragmentManager = supportFragmentManager val transaction = fragmentManager.beginTransaction() transaction.replace(R.id.ContainerID, MapFragment()).commit() } } } "DUJWJUZ
  6. 45 ΞϯνύλʔϯʙϨΠΞ΢τฤʙ val fragmentManager = supportFragmentManager val transaction = fragmentManager.beginTransaction()

    transaction.add(R.id.ContainerID, AccountFragment()).commit() tabLayout.addOnTabSelectedListener(object: TabLayout.OnTabSelectedListener { override fun onTabSelected(tab: TabLayout.Tab) { when(tab.position) { 0 -> { supportActionBar?.setDisplayHomeAsUpEnabled(false) tabLayout.getTabAt(0)!!.setIcon(R.mipmap.ic_home_selected) val fragmentManager = supportFragmentManager val transaction = fragmentManager.beginTransaction() transaction.replace(R.id.ContainerID, AccountFragment()).commit() } … } "DUJWJUZ
  7. 46 ΞϯνύλʔϯʙϨΠΞ΢τฤʙ private fun settingPager() { this.frame?.let { val viewPager

    = it.findViewById<ViewPager>(R.id.ViewPagerID) val fragmentPagerAdapter = AccountPagerAdapter(this.getChildFragmentManager()) viewPager.adapter = fragmentPagerAdapter val tabLayout = it.findViewById<TabLayout>(R.id.TabLayoutID) tabLayout.setupWithViewPager(viewPager) tabLayout.getTabAt(0)!!.setText("ޚगҹҰཡ") tabLayout.getTabAt(1)!!.setText("ઃఆ") } } 'SBHNFOU ୈҰ֊૚
  8. 47 ΞϯνύλʔϯʙϨΠΞ΢τฤʙ private fun settingPager() { this.frame?.let { val viewPager

    = it.findViewById<ViewPager>(R.id.ViewPagerID) val fragmentPagerAdapter = AccountPagerAdapter(this.getChildFragmentManager()) viewPager.adapter = fragmentPagerAdapter val tabLayout = it.findViewById<TabLayout>(R.id.TabLayoutID) tabLayout.setupWithViewPager(viewPager) tabLayout.getTabAt(0)!!.setText("ޚगҹҰཡ") tabLayout.getTabAt(1)!!.setText("ઃఆ") } } 'SBHNFOU ୈҰ֊૚
  9. 49 ΞϯνύλʔϯʙϨΠΞ΢τฤʙ class AccountPagerAdapter(fragmentManager: FragmentManager): FragmentPagerAdapter(fragmentManager) { override fun getCount():

    Int { return 2 } override fun getItem(position: Int): Fragment { when (position) { 0 -> { return AccountMarksFragment() } 1 -> { return SettingFragment() } } return Fragment() } } 'SBHNFOU1BHFS"EBQUFS
  10. 50 ΞϯνύλʔϯʙϨΠΞ΢τฤʙ class AccountPagerAdapter(fragmentManager: FragmentManager): FragmentPagerAdapter(fragmentManager) { override fun getCount():

    Int { return 2 } override fun getItem(position: Int): Fragment { when (position) { 0 -> { return AccountMarksFragment() } 1 -> { return SettingFragment() } } return Fragment() } } 'SBHNFOU1BHFS"EBQUFS HFU$IJME'SBHNFOU.BOBHFS͡Ό ͳ͍ͱ5BCͰ'SBHNFOUΛ཭Εͨ ࣌ʹHFU*UFN ͕ݺ͹Εͳ͍
  11. 51 ΞϯνύλʔϯʙϨΠΞ΢τฤʙ class AccountMarksFragment : Fragment() { private var frame:

    View? = null override fun onCreateView(inflater: LayoutInflater?, container: ViewGroup?, savedInstanceState: Bundle?): View? { this.frame = inflater!!.inflate(R.layout.fragment_account_marks, container, false) return this.frame } override fun onStart() { super.onStart() this.onMarkPostButtonClick() } private fun onMarkPostButtonClick() { MarkPostButtonID.setOnClickListener { val activity = activity as AccountActivity val intent = Intent(activity, MarkPostActivity::class.java) startActivity(intent) } } } 'SBHNFOU ୈೋ֊૚
  12. 52 ΞϯνύλʔϯʙϨΠΞ΢τฤʙ class AccountMarksFragment : Fragment() { private var frame:

    View? = null override fun onCreateView(inflater: LayoutInflater?, container: ViewGroup?, savedInstanceState: Bundle?): View? { this.frame = inflater!!.inflate(R.layout.fragment_account_marks, container, false) return this.frame } override fun onStart() { super.onStart() this.onMarkPostButtonClick() } private fun onMarkPostButtonClick() { MarkPostButtonID.setOnClickListener { val activity = activity as AccountActivity val intent = Intent(activity, MarkPostActivity::class.java) startActivity(intent) } } } 'SBHNFOU ୈೋ֊૚ PO$SFBUF7JFX ͩͱ8JEHFU ؔ࿈͕ੜ੒͞Ε͍ͯͳ͍