ã¢ã¹ã¯ã¯ã§äŒçµ±çã«éå¬ãããã¢ãã€ã«éçºåŠéšãžã®åéã¯ããããå®äºããŸãã å®è·µçãªæŒç¿ã«éç¹ã眮ãããŸããããŒã ããããã«ãœã³ã§ã¯ãã³ãŒãã®èšè¿°ã«å ããŠãææ決å®ãè¡ããç©è°ãéžãåé¡ã«å¯ŸåŠããé·æèšç»ã«åãçµãå¿
èŠããããŸãã Yandexã®åŠçã¯ãåŠç-åããŒã ãåå¥ã«æ¯æŽããŸãã ä»åŸã®åŠæ ¡ã®è©³çŽ°ã«ã€ããŠã¯ã
ãã¡ããã芧ãã ãã ã 5æ6æ¥23æ59åã®ã¢ã¹ã¯ã¯æéã«ç³ã蟌ã¿ãåãä»ããŸããã¿ã¹ã¯ãå®äºããæéã¯ãŸã ãããŸãããæšå¹Žã®ããŒãžã§ã³ãäœæããããšã«ããŸããã åå¿è
ã®éçºè
ãããç¯ãééããšãæåã®ã¢ããªã±ãŒã·ã§ã³ã®ã³ãŒããæžããšãã«æ³šæãã¹ãç¹ã確èªã§ããŸãã
äŒçµ±çã«ãã¿ã¹ã¯ã¯éçºã®ããŸããŸãªåŽé¢ã«æ³šæãæãããšãã§ããããã«èšèšãããŠããŸãã ãããã«ã¯ãã¢ããªã±ãŒã·ã§ã³ã¢ãŒããã¯ãã£ãå®å®æ§ãããã©ãŒãã³ã¹ãã¬ã€ã¢ãŠãã䜿ãããããå«ãŸããŸãã ãã¹ãŠã®ã³ã³ããŒãã³ãã¯åæ§ã«éèŠã§ããã€ã³ã¿ãŒãã§ãŒã¹ã«åé¡ãããå ŽåããŸãã¯åºæ¬çãªãŠãŒã¶ãŒã¹ã¯ãªããã®å®è¡äžã«ã¯ã©ãã·ã¥ããå Žåãé«ã確çã§å®å
šã«ã³ãŒãã³ã°ããã³ã¬ã€ã€ãŒåãããã³ãŒãã§ãéžæãééããŸããã å®å
šãªã¢ããªã±ãŒã·ã§ã³ãäœæããããã®æ®éçãªã¬ã·ãã¯ãããŸãããããã¯ãéžæã«åæ Œããããšãä¿èšŒãããŠããŸãã ã¢ãŒããã¯ãã£ãæ§ç¯ããããã®å€ãã®éçºã¢ãããŒããšããŸããŸãªãªãã·ã§ã³ããããŸãããæåã®èŠçŽ ã®1ã€ã¯è¯å®çãªãŠãŒã¶ãŒãšã¯ã¹ããªãšã³ã¹ã§ãã 補åã¯ãã©ãã ã䟿å©ãªæ©èœãç»é¢ããŸãã¯èŠçŽ ãå«ãŸããŠãããã«é¢ä¿ãªããå®å
šæ§ã®å°è±¡ãäžããå¿
èŠããããŸãã
å
容
ãªããžããªãšã³ãŒãã£ã³ã°ã¹ã¿ã€ã«
åå Žã¯ãã³ã¬ãŒããå§ãŸãããããžã§ã¯ãã¯ãªããžããªããå§ãŸããŸãã
éçºãéå§ããåã«ãé©åãª
.gitignoreãã¡ã€ã«ãè¿œå ããŠãäœåãªãã¡ã€ã«ããªããžããªã«æ£ç¢ºã«å
¥ããªãããã«ããŸãã ãã®ãããIDEã®èšå®ãã¡ã€ã«ãã¢ããªã±ãŒã·ã§ã³ã«çœ²åããããã®ããŒãå«ããã¡ã€ã«ãããã³ãã°ã€ã³ãšãã¹ã¯ãŒãããªããžããªã«ä¿åããããšã¯ãå§ãããŸããã
éçºäžã¯ãé»éã®å¹³åã«åŸããŸã-äžåºŠã«ãããžã§ã¯ãã®ååãã³ãããããã¹ãã§ã¯ãããŸãããã1è¡ãŸãã¯2è¡ã«æ²¿ã£ãå€ãã®å°ããªã³ãããã¯é¿ããã¹ãã§ãã ã³ãããããšã«æ確ãªã¡ãã»ãŒãžãæžããŸãã åã
ã®æ©èœã«ã€ããŠã¯ã
ãã©ã³ãã䜿çšããŠç¬ç«ããŠæ©èœãéçºããåžžã«ãã¹ã¿ãŒãã©ã³ãã«ã¢ããªã±ãŒã·ã§ã³ã®çŸåšã®ïŒããã³åäœããïŒããŒãžã§ã³ãä¿æãã䟡å€ããããŸãã ãŸããæäœéå¿
èŠãªæ©èœãå®è£
ãããããã¹ãŠã®ãå¯æãããšæ¹åãå®è£
ããŠãã ããã å¥ã®ãã©ã³ãã«åãæ¿ããå¿
èŠããããäžå®å
šãªã³ãŒããã³ãããããããªãïŒãã ãã倱ããããªãïŒå Žåã¯ã
ãã¹ãæååã䜿çšãããšäŸ¿å©ã§ãã
ã³ãŒãã¯äžåºŠæžã蟌ãŸããäœåºŠãèªã¿åããããããã³ãŒãã£ã³ã°ã¹ã¿ã€ã«ãšå€æ°åãé©åã§ããããšãéèŠã§ãã å¿
èŠã«å¿ããŠæå³ã®ããã³ã¡ã³ããæ®ããããžãã¯ãã³ããŒãè¿œå ããããåãããšãè¡ãããŸããŸãªã©ã€ãã©ãªã®ã³ãŒããæ··ãããããªãã§ãã ããã ã³ãŒãã1人ã®éçºè
ã«ãã£ãŠèšè¿°ãããŠããå Žåãå
±éã®ã¹ã¿ã€ã«ãšã¢ãããŒããç¶æããã®ã¯ç°¡åã§ããã倧èŠæš¡ãªããŒã ã§ã¯ãããŸããŸãªã¢ãã©ã€ã¶ãŒã䜿çšããããç¬èªã®ã¹ã¿ã€ã«ãäœæããŠããŒãžã§ã³ç®¡çã·ã¹ãã ã«ã³ãããããåéçºè
ãéžæã§ããããã«ããŸãã
ä»ã«ã泚æãã¹ãç¹ãããã€ããããŸãã
- ããŒãã³ãŒãã圹ã«ç«ããªãã³ãŒããã³ã¡ã³ãã¢ãŠããããã³ãŒãã
- ã¹ãŒããŒã³ãŒã«ã
- è¿œå ã®æ³šé
- æ¬ èœããŠãã泚é
- ãããã°ã¢ã»ã³ããªã§ã®ã¿å¿
èŠãªãªãªãŒã¹ã³ãŒãã®ååŸ
- æçµä¿®é£Ÿåãæ¬ èœããŠããã
- é·ãæ¹æ³
- åãæ¹æ³
- æªäœ¿çšã®èŒžå
¥åã
- newäœãïŒïŒå²ãåœãŠãªãã
- ããžãã¯ãã³ããŒ
- ããããªãã³ãŒãã䜿çšããŠã³ããŒããŒã¹ã
- ãŸã-lintã䜿çšããŸã ã
SDKãšã©ã€ãã©ãª
Android SDKãšã©ã€ãã©ãªã䜿çšãããšãå€ãã®å Žåãåå¿è
ã®éçºè
ã®éã§çåãçããŸãã 以äžã«ãããã€ãã®äžè¬çãªåé¡ãšãã®è§£æ±ºçããªã¹ãããŸãã
ãªã¹ãã®äžé©åãªäœæ¥LinearLayout + ScrollViewã䜿çšããŠåãã¿ã€ãã®ãã¥ãŒã®å€ãã衚瀺ããããšã¯ãééããç¯ãããšãæå³ããŸãã ãã®ã¡ãœããã¯ã¡ã¢ãªã«è² è·ãäœæããŸãããã¹ãŠã®ãã¥ãŒã¯åæã«ã¡ã¢ãªå
ã«ãããŸãã ã¹ã¯ããŒã«ãé
ããªãå§ããŸãã ãã®å Žåãå°ãªããšãListViewããŸãã¯ããåªãããããé«åºŠãª
RecyclerViewã䜿çšããã®ãé©åã§ãã ãããã®ã³ã³ããã¯ããã¥ãŒã®åå©çšãæäŸããŸãïŒã¢ããã¿ã¡ã«ããºã ã䜿çšïŒã çŸåšãŠãŒã¶ãŒã«è¡šç€ºãããŠããªããã¥ãŒã«ã¯ãææ°ã®ããŒã¿ã衚瀺ãããŸãã
ããããããã§ã¯ééããç¯ãå¯èœæ§ããããŸãã RecyclerViewã¯ãListViewãšã¯ç°ãªããéçºè
ã«ViewHolderãã¿ãŒã³ã®äœ¿çšã匷å¶ããŸãã ãã®ååã瀺ãããã«ããã®ãã¿ãŒã³ã¯ããªããžã§ã¯ãããã¥ãŒéå±€ã§ãã§ã«èŠã€ãã£ããªã³ã¯ãä¿åããã¯ã©ã¹ãäœæããããšã«ãããŸãã å€ã眮ãå¿
èŠããããã³ã«findViewByIdãåŒã³åºãã¹ãã§ã¯ãããŸããã ããã¯ããã«ããŒã®äœæäžã«1åè¡ãå¿
èŠããããŸãã
ç¶æ
ä¿ååå¿è
ã«ãšã£ãŠãã1ã€ã®å€§ããªåé¡ã¯ãæ§æãå€æŽãããšãïŒããšãã°ãåããèšèªãç»é¢ãµã€ãº
ãªã©ãå€æŽããããšãïŒã«ã¢ããªã±ãŒã·ã§ã³ã®ç¶æ
ãç¶æããããšã§ãã å€ãã®å Žåãåå¿è
ã¯ãã®ãããªã±ãŒã¹ããã¹ãããŸããã ããã¯ããŠãŒã¶ãŒã®äžæºãã¯ã©ãã·ã¥ã«ããã€ãªãããŸãã æã
ãéçºè
ã¯åããä¿®æ£ããã®ãæ¢ããŸã-ãã¡ãããããã¯ä¿åããŸããã ããã«äœ¿çšå¯èœãªæ§æå€æŽããµããŒãããã«ã¯ãããã€ãã®æ¹æ³ããããŸãã ããã«ã€ããŠã¯æãäžããŸããããã€ã§ã
ããã¥ã¡ã³ããèªãããšãã§ã
ãŸã ã èŠããŠããã¹ãäž»ãªããšã¯ãç¶æ
ã埩å
ããå¿
èŠãããããããã€ã¢ãã°ã«æ³šæãæãããã«ã
AlertDialogã§ã¯ãªãDialogFragmentã䜿çšããããšãã
å§ãããããã«ããã®ãããªåé¡ãååšããããšã§ãã ç»é¢ã®ç¶æ
ãæ°žç¶ã¹ãã¢ïŒSharedPreferencesãªã©ïŒã«ä¿åããããšã¯ãå§ãã§ããŸããã ãã®çµæããã¯ãªãŒã³ãªãããŒã³ãã¯æ¢åã®ç¶æ
ã«ã€ãªããå¯èœæ§ããããããã¯ç¹ã«æ
£çšçã§ã¯ãããŸããã
ããŒã¿ã®ããŒããšãã£ãã·ã³ã°Androidã®UIã¹ããªãŒã ã§ãããã¯ãŒã¯ã«ã¢ã¯ã»ã¹ããããšã¯
çŠæ¢ãããŠããŸãã ãããã¯ãŒã¯çšã®å€ãã®ã©ã€ãã©ãªããããŸããããšãã°ãRESTã䜿çšããŠããå Žåã¯
OkHttp ã
Retrofitãè¿œå ããããç»åã®ããŠã³ããŒãçšã«Glide
ãŸã㯠PicassoããããŸãã ãããã£ãŠãé·ãéãAsyncTaskå
ã§HttpUrlConnectionã䜿çšããå¿
èŠã¯ãªããªããŸããïŒç¹ã«ç»åã®ããŠã³ããŒãã«ã¯ãå®éã«ã¯ç°¡åã§ã¯ãããŸããïŒã ããããå€ãã®åå¿è
ã¯ãããšãã°ãããŒã¿ããŒã¹ãžã®èªã¿æžããã¡ã€ã³ã¹ããªãŒã ã®ããªãŒãºã®ããã«UXã«åœ±é¿ãäžããå¯èœæ§ãããI / Oæäœã§ãããšã¯èããŠããŸããã åãããšã¯ããã¡ã€ã«ã®èªã¿åããContentProvidersãžã®ã¢ã¯ã»ã¹ã«ãåœãŠã¯ãŸããŸãã ãã®ãããªæäœã¯ãã¹ãŠãå¥ã®ã¹ã¬ããã§å®è¡ããå¿
èŠããããŸãã ãã®ããã«äœã䜿çšããã-誰ããèªåã§æ±ºå®ãããã®åœ¢åŒã§ããŸããŸãªãœãªã¥ãŒã·ã§ã³ã説æããããšã¯äžå¯èœã§ãã
[æ»ã]ãã¿ã³ã®ã·ã¹ãã åäœãå€æŽããå€ãã®å Žåããã®ã€ãã³ããå®å
šã«é£²ã¿èŸŒãïŒåŠçããŸãããåæã«äœãããŸããïŒãªã©ãã·ã¹ãã ã®æšæºã§ã¯ãªãåå¿ããã³ã°ã¢ããããèªæããããŸãã ã ãã-ããªãã»ããããã ãã®OSã®ãŠãŒã¶ãŒã«ã¯ç¿æ
£ããããæ»ãã¯åã®ç»é¢ã«ç§»åããããã¢ããªã±ãŒã·ã§ã³ãçµäºããå¿
èŠããããŸãã
建ç¯
å€ãã®å ŽåãAndroidã¢ããªã®ã¢ãŒããã¯ãã£ã¯ãçµéšè±å¯ãªéçºè
ã«ãšã£ãŠãæ©ã¿ã®çš®ã§ãã ãã®ã»ã¯ã·ã§ã³ã§ã¯ãããã€ãã®äžè¬çãªãã³ãã瀺ããŸãã ããªãããããã«åŸããã©ããã¯ããªã次第ã§ãã
ã¢ãŒããã¯ãã£ãšå解å解ã®æ¬ åŠã¯ã貧匱ãªã¢ãŒããã¯ãã£ã®å
åã§ãã ãã©ãããã©ãŒã ã¯ãã¢ããªã±ãŒã·ã§ã³ãæ£ããäœæããæ¹æ³ã«ã€ããŠæ確ãªæ瀺ãäžããŠããªããããã¢ã¯ãã£ããã£ãŸãã¯ãã©ã°ã¡ã³ãã®ã³ãŒãã«ãã¹ãŠãæžããããšãã倧ããªèªæããããŸãã ãã®çµæãã³ãŒãã¯ãã¹ãäžèœã«ãªããå€æŽãå ããããšãå°é£ã«ãªããŸãã ãã®ãããªç¶æ³ãåé¿ããããã«ãææ°ã®å»ºç¯æ
£è¡ãšèšèšãã¿ãŒã³ãé©çšã§ããŸãã MVPãMVVMãMVIã«ã€ããŠèªãã§ãã ããã æåã®3ã€ã®ã¯ã©ã¹ãäœæãããã¹ãã§ããããã«ããŒããŸãã ããããããã¹ããæžãã®ã¯é£ãããã¢ãŒããã¯ãã£ã«ã€ããŠèããå¿
èŠãããããšã«æ°ä»ãã§ãããã
æœè±¡åã«ããæ€çŽ¢GitHubãªããžããªã¯ãå€ãã®å Žåãã¢ãŒããã¯ãã£ã®ãæšæºçãªãå®è£
ã瀺ããŠããŸãã ä»ã®äººã®ã¢ãŒããã¯ãã£ãœãªã¥ãŒã·ã§ã³ã®ãã©ã€ã³ãã³ããŒã¯ãã¡ãªãããããããã ãã§ãªããäœæ¥ãè€éã«ããã¢ããªã±ãŒã·ã§ã³ã®ããã©ãŒãã³ã¹ãäœäžãããå¯èœæ§ããããŸãã ãããæ£ç¢ºããŸãã¯ãã¯ãªãŒã³ãã ãããšãã£ãŠæå³ã®ãªãã³ãŒããæžããªãããã«ããããããã®å Žåã«ãœãªã¥ãŒã·ã§ã³ã®å©ç¹ãšãã®ãµããŒããšç解ã®è€éããé¢é£ä»ããŸãã
ã³ã³ããŒãã³ãéã®æé»çãªé¢ä¿ãäžçŽãªæ©èœå€ãã®å Žåãã°ããŒãã«å€æ°ã®å€ã¯ã¢ããªã±ãŒã·ã§ã³ã«éçã«ä¿åãããã¢ããªã±ãŒã·ã§ã³ã®ããŸããŸãªéšåããå€æŽãããŸãã ã³ãŒãã®å€èŠäžã¯çŽæ¥é¢é£ããŠããªãéšåã®å®è¡ã¯ã°ããŒãã«å€æ°ã®åœ±é¿ãåãããããéçºè
ãå®è¡æã«åãåãããšãæåŸ
ããŠããªãã£ãç¶æ
ãã¢ããªã±ãŒã·ã§ã³ã§çºçããå¯èœæ§ããããŸãã ææªã®äºæ
ã¯ããã®ãããªãã°ããã£ããããŠåçŸããã®ãéåžžã«é£ããããšã§ãã
ãã¯ãªãŒã³ãªãã¡ãœãããèšè¿°ããã¯ã©ã¹ã³ã³ã¹ãã©ã¯ã¿ãŒãŸãã¯ã¡ãœããåŒæ°ã§
äŸåé¢ä¿ãæ瀺çã«
æå®ããŠãã ããã
UIïŒãªãœãŒã¹ãã°ã©ãã£ãã¯ãã¬ã€ã¢ãŠãïŒ
ã¢ããªã±ãŒã·ã§ã³ã®å€èŠ³ãšäœ¿ããããã¯éåžžã«éèŠã§ãã 䟿å©ãªãã¶ã€ã³ãäœãã®ã¯é£ããã§ãããå°ãªããšã以äžã«æŠèª¬ããç¹ã«æ³šæããããšããå§ãããŸãã
ã¬ã€ã¢ãŠãå質
Androidã®ããã©ãŒãã³ã¹ã¯ãã¬ã€ã¢ãŠãã®å質ã«å€§ããäŸåããŸãã è€éãªã³ã³ããéå±€ã¯èšç®ã«æéãããããŸãã ããã«ããã¹ãã倧ãããšãèšç®äžããã³ã¬ã³ããªã³ã°äžã«ãã©ãŒã«ãçºçããå¯èœæ§ããããŸãïŒã¹ã¿ãã¯ãªãŒããŒãããŒã®ããïŒã ConstraintLayoutã®ç»å Žã«ããïŒç¹ã«ãŠã£ã¶ãŒãããäœæããå Žåã®xmlã«ãŒãèŠçŽ ã®ã€ã³ã¹ããŒã«ã«ããïŒãåå¿è
ã«ãšã£ãŠéå±€ã¯ããã«è€éã«ãªããŸããã Nested Relative / ConstraintLayoutãæããã䜿çšãããŸãããããã¯æ ¹æ¬çã«ééã£ãŠããŸãã ConstraintLayoutã¯ãéå±€ããã©ããã«ããããã ãã«èšèšãããŠããŸãã å°ãªããšã
ããã¥ã¡ã³ãã®æŠèŠãèªã¿ããã®ã¯ã©ã¹ãæ£ããé©çšããããšããå§ãããŸãã ãŸããViewGroupãéå°ã«ãã¹ãããªãã§ãã ããã
èšèš
ãã¹ãŠã®éçºè
ãèšèšã¹ãã«ãæã£ãŠããããã§ã¯ãããŸããã å€ãã®å Žåãéçºè
ã奜ãã¢ããªã±ãŒã·ã§ã³ã«ã¯äžè²«æ§ã®ãªãã«ã©ãŒãã¬ããããããŸãããã»ãšãã©ã®ãŠãŒã¶ãŒã¯ããã§ã¯ãããŸããã é害ã®ãã人ïŒããšãã°ãè²èŠç°åžžè
ïŒã ãã§ãªããä»ã®ãŠãŒã¶ãŒãã©ãã«ãèªãããšãã§ããŸããã æšæºãã§ãã¯ïŒã©ãã«ãã°ã¬ãŒã¹ã±ãŒã«ã§è¡šç€ºãããŠããå Žåãã»ãšãã©ã®å Žåãã»ãšãã©ã®ãŠãŒã¶ãŒã«ã衚瀺ãããŸãã ã«ã©ãŒãã¬ãããšäžè¬çãªèšèšååãéžæããã«ã¯ã
material.ioãš
www.materialpalette.comã® 2ã€ã®ãªã³ã¯ãåç
§ããŠãã ããã
ä»ã«ãã䟡å€ãããããš
- ååãã¢ã€ã³ã³ãç»é¢ã«ã€ããŠãªã©ãã¢ããªã±ãŒã·ã§ã³ã®å®å
šæ§ã®æèŠãæäŸããåŽé¢ã«åãçµã¿ãŸãã
- ã¢ããªã±ãŒã·ã§ã³ã®å€èŠ³ãç»é¢äžã®ããŸããŸãªãããå¯åºŠã«é©åãããŸãã
- æªäœ¿çšã®æååãã°ã©ãã£ãã¯ãããã³ãã®ä»ã®ãªãœãŒã¹ãåé€ããŸãã
- ä»ã®èšèªã«ããŒã«ã©ã€ãºããŸãã
- åã®æ®µèœãå®äºããããå¿
èŠãªãã®ã¯ãã¹ãŠããŒã«ã©ã€ãºããŠãã ããã
ãšã©ãŒåŠç
ã¢ããªã±ãŒã·ã§ã³ã®ãŠãŒã¶ãŒã®è»éã¯ãè¯ããã¹ã¿ãŒãšããŠãããªãã®ããã«äœããå£ãæ¹æ³ãåžžã«èŠã€ããŸãã ç°åžžãªç¶æ³ã§ã¯ãå¿
ãã¢ããªã±ãŒã·ã§ã³ã確èªããŠãã ããã ãã¹ã¿ãŒã®èãæ¹ãéçºããããããçš®é¡ã®éæšæºã®äœ¿çšã·ããªãªïŒã€ã³ã¿ãŒããããªãã§éå§ãããå±¥æŽã«ãšã³ããªã2åè¿œå ãããããã€ã¹èšå®ã®çªç¶ã®å€æŽãªã©ïŒãäºæž¬ããããšãéèŠã§ãã æ©èœã®äœæ¥ãçµãããããã®æ©èœããã¹ãããããã€ãã®ã¹ã¯ãªãããå®è¡ããŠããã¹ãŠãæ©èœããããšã確èªããããšãéèŠã§ãã åé¡ã¯ãå
éšçãªæèŠãããããã¹ãŠãæ£ããæ©èœããããšãæåŸ
ããŠãããããã³ãŒãããã¹ãããããšãé£ããããšã§ãã 誰ãã¢ã€ãã«ã³ãŒããæžããããªãã ããªãã®æ°æã¡ã«åŸããªãã§ãã ããã éåžžã®æ¡ä»¶ãšå¢çæ¡ä»¶ãæã€ããã€ãã®ã·ããªãªã確èªããããšããå§ãããŸãã
ãšã©ãŒãåŠçãããšããèããã«ãã¹ãŠãåŠçããããäœãåŠçããªããšãã2ã€ã®æ¥µç«¯ãªæ¹æ³ã«é²ãããšãã§ããŸãã æããã«ã2çªç®ã®ãªãã·ã§ã³ã¯ããªãè¿
éã«ãããã¢ããããŸãããæåã®ãªãã·ã§ã³ã¯ããæœè¡æ§ãé«ããäºæž¬ã§ããªãçµæã«ã€ãªãããŸãã
ãã®ãããªãšã©ãŒã®ããã€ãã®äŸã«ã€ããŠãããã«è©³ããèŠãŠãããŸãããã
try..catch ...ã©ãã§ã
ãã®ãããªåŠçã¯ãååã瀺ãããã«ãçãããïŒäœæè
ã®èŠ³ç¹ããïŒã³ãŒããtry..catchãããã¯ã§å²ãããšã«ãããŸãã ãã£ã¹ããªãã¥ãŒã·ã§ã³ã«ã¯ã
NPEããã³
IndexOutOfBoundsException ã
IllegalArgumentExceptionãããã«ã¯
OutOfMemoryErrorããå«ãŸããŸããã€ãŸããéåžžãã¢ããªã±ãŒã·ã§ã³ã®è«çãšã©ãŒã瀺ããé©åã«åŸ©å
ã§ããªãã¢ããªã±ãŒã·ã§ã³ã®ç¶æ
ã«é¢ããäŸå€ã§ãã ãã¡ãããæ£ãã解決çã¯è«çãšã©ãŒãä¿®æ£ããããšã§ãã ããã«ãJavaã§ã³ãŒããèšè¿°ããå Žåãéçåæã䜿çšããŠãå°ãªããšã@NonNullããã³@Nullableã¢ãããŒã·ã§ã³ãå¿
èŠãªå Žæã«é
眮ã§ããŸãã ããã¯ãNPEããã£ããããã®ã«åœ¹ç«ã¡ãŸãã
WeakReference <ãã¹ãŠ>
å€ãã®å Žåãã¡ã¢ãªãªãŒã¯ã«ã€ããŠç¥ãæ°äººã¯ãç«ã®ããã«æããŸãã çµéšãäžè¶³ããŠãããããããã«ãã
WeakReferenceã®ãªããžã§ã¯ããã©ãããããå¯èœæ§ããããŸãã éåžžããã®ææ³ã¯ããªããžã§ã¯ãã®ã©ã€ããµã€ã¯ã«ãšãããã®éã®é¢ä¿ã«ã€ããŠã®äžååãªç解ã瀺ããŠããŸãã 以äžã«äŸã瀺ããŸãã
public class MyAdapter extends RecyclerView.Adapter<ViewHolder> { private final WeakReference<Context> contextRef; public MyAdapter (@NonNull Context context) { this.contextRef = new WeakReference < > (context); } @Override public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { final Context context = contextRef.get(); return context == null ? null : LayoutInflater.from(context).inflate(R.layout.item, parent, false); } ... }
ããã§ãã¢ããã¿ãŒã³ã³ã¹ãã©ã¯ã¿ãŒã«ã¯Contextãžã®ãªã³ã¯ããããŸãã ãã ããã¢ããã¿ãŒã¯UIã®äžéšã§ãããç¹å®ã®ã¢ã¯ãã£ããã£ã«è¡šç€ºãããŸãã ãããã£ãŠã圌ã¯Contextããé·ãçããã¹ãã§ã¯ãªãããã®ããšããWeakReferenceã¯ããã§ã¯å¿
èŠãããŸããã
WeakReferenceã䜿çšããå¥ã®äŸïŒ
public class MyAsyncTask extends AsyncTask<String, String, String> { private final WeakReference<Context> contextRef; public MyAsyncTask(@NonNull Context context) { this.contextRef = new WeakReference<>(context); } ... @Override protected void onPostExecute(@Nullable String result) { final Context context = contextRef.get(); if (context != null && result != null) { Toast.makeText(context, result, Toast.LENGTH_SHORT).show(); } } }
å€èŠ³ã¯äœãå€ãã£ãŠããŸããããAsyncTaskã¯ãããäœæãããã¢ã¯ãã£ããã£ã«èããããšãã§ããŸãã ãããã£ãŠãããã§ã¯WeakReferenceã®äœ¿çšãæ£åœåãããŸãã
ã¡ã¢ãªãªãŒã¯ãåé¿ããã«ã¯ããŸãã䜿çšããŠãããªããžã§ã¯ãã®ã©ã€ããµã€ã¯ã«ãäœã§ããããç解ããå¿
èŠããããŸãã
Memory Profilerãš
LeakCanaryã䜿çšããŠãæ¢åã®å€§èŠæš¡ãããžã§ã¯ãã®ã¡ã¢ãªãªãŒã¯ãæ€çŽ¢ã§ããŸãã
ãªã¯ãšã¹ããã£ã³ã»ã«ãªã
ãšã©ãŒã®åå ã¯ãéåææäœããããã¯ãŒã¯èŠæ±ãŸãã¯ã¿ã€ããŒã®ãã£ã³ã»ã«ã®æ¬ åŠã«ããå ŽåããããŸãã ãããã®æäœã®èä¹
æ§ãšé »åºŠãèæ
®ãããµãã¹ã¯ã©ã€ã/ã¢ã³ãµãã¹ã¯ã©ã€ããäœæ/ç Žæ£ãéå§/ãã£ã³ã»ã«ãªã©ã®ãã¢ã®APIã¡ãœããã«æ³šæããŠãã ããã
ãã¹ã
åäœãã¹ãã®æ¬ åŠ
補åãäœæããéã«ãããåªãããããä¿å®æ§ã®é«ãã³ãŒããäœæããã®ã«åœ¹ç«ã¡ãæéã®çµéãšãšãã«å€ããªã£ãŠããªãäžçš®ã®ããã¥ã¡ã³ããšããŠåœ¹ç«ã€ããããŠããããã¹ãã倧奜ãã§ãã äžéšã®éçºè
ã¯åäœãã¹ããæ ããŸã-æžãã®ã¯é£ãããŠæéãããããç«ã¡äžãã«ã¯å€ãã®æéãããããšåœŒãã¯èšããŸãã
ãããã®ãã€ã³ãã®ããããã«ææŠããããšãã§ããŸãã æéè²»çšã«é¢ããé
ç®ããå§ããŸãããã ããããæåã®æ®µéã§åäœãã¹ããæžãã®ã¯æéãããããŸãããçµéšãç©ããšé床ãäžãããŸãã ããã«ãåäœãã¹ãã¯å°æ¥ãžã®æè³ã§ãããå°æ¥çã«ã¯ã³ãŒããããéãæžãããšãã§ããŸãã èµ·åé床ã®åé¡ã¯ããã«ç°¡åã«è§£æ±ºãã
ãŸãã ç¶ç¶çã€ã³ãã°ã¬ãŒã·ã§ã³ãäžåºŠ
èšå®ã ããã¹ããèªåçã«å®è¡ããã ãã§ãã åäœãã¹ããæžãã®ãé£ããå Žåãæé«å質ã®ã³ãŒããæžããŠããããã§ã¯ãããŸããã åªããã¢ãŒããã¯ãã£ã«ãããã¿ã¹ã¯ãç°¡åã«ãªããŸãã
圹ã«ç«ããªããã¹ã
圹ã«ç«ããªããã¹ãã¯ããœãŒã¹ã³ãŒããç解ããã®ãé£ããããã ãã§ãªããã¢ããªã±ãŒã·ã§ã³ã®ãã«ãæéã«ã圱é¿ãäžããããã圹ã«ç«ããªãã³ãŒããããããã«ã²ã©ããªããŸãã ãã¹ãã圹ã«ç«ããªãå Žåãããã€ããããŸãã
ä»ã®äººã®ã³ãŒãããã¹ãããä»ã®èª°ãã®ã³ãŒãã«ã¯æ¢ã«ãã¹ããä»å±ããŠãããšæ³å®ãããŠããããããã®ãããªãã¹ãã«ã¯æéãããããŸãã
ãã¹ãã¯äºãã«äŸåããããå€éšèŠå ã«äŸåããŸãã1ã€ã®ãã¹ããå€æŽãããšä»ã®å€ãã®ãã¹ãã«åœ±é¿ãããããäŸåãã¹ãã®ä¿å®ã¯å°é£ã§ãã ããã«ããã¹ãã¯ç°ãªãé åºã§å®è¡ã§ããããããã¹ãã¯äºæž¬äžå¯èœã«ãªããŸãã
å®è£
ã®è©³çŽ°ããã¹ããããã¹ãã§ã¯ããã¹ããããã¯ã©ã¹ããã©ãã¯ããã¯ã¹ãšããŠèªèããå¿
èŠããããŸããããããªããšãå®è£
ãå€æŽãããšãã«ããã¹ãèªäœãå€æŽããå¿
èŠããããŸãã ããã¯äžäŸ¿ã§ãå€ãã®å Žåããã¹ããåé€ãŸãã¯ç¡èŠããŸãã
ãããã«
æšå¹Žãæ°çŸã®ãã¹ãã¿ã¹ã¯ãåæããã¢ããªã±ãŒã·ã§ã³ã®åé¡ã®äž»ãªåå ãéåžžã«åçŽã§ããããšãããäžåºŠç¢ºèªããŸããã
- ããã©ãŒãã³ã¹ãã§ãã¯ãªãã®çŽåä¿®æ£ã
- ã³ãŒãã®ãšã©ãŒåŠçã®æ¬ èœãŸãã¯èª€ãã
- ãã©ãããã©ãŒã ã¡ãœããã®ããã©ãŒãã³ã¹æ©èœãŸãã¯å¶éãèŠèœãšããAPIã¡ãœããã®èª¬æã®èª€ã£ã解éã
- ã³ã³ããŒãã³ãéã®é¢ä¿ãæŽçãããšãããªã³ã¯ãæäœãããšããããã³ãªããžã§ã¯ãã®ã©ã€ããµã€ã¯ã«ãèæ
®ãããšãã®æ³šæã®æ¬ åŠã
- ãã¹ããããŠããªãæ°ãããã¯ãããžãŒã®äœ¿çšã
ä»å¹Žã¯ãä»å¹Žå
¥åŠãããã¹ãŠã®äººãšãæåã®ã¢ããªã±ãŒã·ã§ã³ãéçºããŠãã人ã«ãå§ãããŸãã
- ãã泚æãæããç¡å®³ã«èŠããå€æŽãè¡ã£ãåŸã§ãã¢ããªã±ãŒã·ã§ã³ãæ©èœããããšã確èªããŸãã
- èšèªã®ç¹çŽ°ããåŠã³ãŸãããïŒã¡ã¢ãªãŒå
ã®ãªããžã§ã¯ããæ±ãååããªã³ã¯ã®çš®é¡ã
- éçã³ãŒãã¢ãã©ã€ã¶ãŒãšLeakCanaryãªã©ã®è¿œå ããŒã«ã䜿çšããŸãã
- 䜿çšããããã©ãããã©ãŒã ã³ã³ããŒãã³ããšã©ã€ãã©ãªã®å¶éãšæ©èœãç 究ããã
- ããç¥ãããŠãããããžã§ã¯ãã§èªåèªèº«ã蚌æããæéããªãã£ãæ°ãããã¯ãããžãŒãæ
éã«äœ¿çšããŠãã ããã APIãŸãã¯ã³ãŒããäžå®å®ã§ããå¯èœæ§ãããããããã¯ãŒã¯ã«å
žåçãªãšã©ãŒã®ããã¥ã¡ã³ããŸãã¯åæãå«ãŸããŠããªãå¯èœæ§ãããããã質åã«å¯Ÿããåçãèªåã§æ¢ãå¿
èŠããããŸãã
䟿å©ãªãªã³ã¯
Androidåãã«1è¡ãæžããŠããªãåå¿è
ããããããŒã«ãšã£ãŠã
GoogleããUdacityãŸã§ã®ã³ãŒã¹ ïŒè±èªãšãã·ã¢èªã®åå¹ïŒã§ãã£ãªã¢ãéå§ããã®ã«åœ¹ç«ã¡ãŸãã æåã®æ°æ¬ã®ãããªã®åŸã«ã³ãŒã¹ãçµäºããã«æåŸãŸã§å®äºãããšãçè«çãªç¥èã ãã§ãªããèªåã§äœæããæåã®ã¢ããªã±ãŒã·ã§ã³ãååŸã§ããŸãã
Android Developers YouTubeãã£ã³ãã«ã¯ãAndroidéçºã®äžçããã®çã説æãããªãšãã¥ãŒã¹ã®åãªã貯èµåº«ã§ãã ããã©ãŒãã³ã¹ãéèŠãªã®ã§ã
Android Performance Patternsãã芧ã«ãªãããšããå§ãããŸãã
ãã¬ã³ãã«
è¿œãã€ã ãã©ãã§ããã«çºå±ããããåžžã«ç¥ãããã«ã
AndroidãŠã£ãŒã¯ãªãŒã¡ãŒãªã³ã°ãªã¹ãã䜿çšããŠæ¯é±æ°ããããšãåŠã¶ããåž°å®
éäžã§
Fragmentedã
AndroidDevPodcastãªã©ã®ããããã£ã¹ããèŽãããšãã§ããŸãã
Kotlinãç¥ãããšã¯ã
Kotlin koansããå§ããã®ãæå
ã§ã -èšèªã®åºæ¬çãªæ§æã®ã¢ã€ãã¢ãåŸãããšãã§ããŸãã
Computer Science Centerã®ãããªã³ãŒã¹ã¯ ãèšèªããã詳ããåŠã³ããã®é·æãšçæãåŠã³ããªããã®ããã«å®è£
ãããŠããã®ããç解ãã䟡å€ããããŸãã Javaã®å Žåã
ã³ã³ãã¥ãŒã¿ãŒãµã€ãšã³ã¹ã»ã³ã¿ãŒããã®åºç€ã³ãŒã¹ããããŸããçè«çãªç¥èã¯ãå€æ°ã®å®çšçãªã¿ã¹ã¯ã«ãã£ãŠãµããŒããããŠããŸãã
Android Architecture BlueprintsãªããžããªãŒã§äžè¬çãªã¢ãŒããã¯ãã£ãŒã®å®è£
ã確èªã§ããŸãã
建ç¯ã®ãã¿ãŒã³ãç 究ããã«ã¯ãåå¿è
ãç¿åŸããã®ãé£ããæ¬ããã°ãã°æšå¥šãããŸãã
SourceMakingã¯ãæåã®ç¥ãåãã«æé©ã§ããçŽ æã¯ããæ§æãããŠããããã¿ãŒã³ã®å€§éšåã«ã¯ãJavaã§ã®å®è£
ã®æ確ãª
æ¯metaãšäŸããããŸãã
ã³ã³ãã¥ãŒã¿ãŒãµã€ãšã³ã¹ã»ã³ã¿ãŒã®ã¢ã«ãŽãªãºã ãªã³ã©ã€ã³ã³ãŒã¹ãä¿®äºãããšãåºæ¬çãªã¢ã«ãŽãªãºã ææ³ã«ç²Ÿéããå€å
žçãªã¢ã«ãŽãªãºã ãå®è£
ããéã«æãæã€ããšãã§ããŸãã ãŸããã³ãŒã¹ã§ã¯ãåèæç®ã®è¯ããªã¹ããèŠã€ããããšãã§ããŸãã ç·Žç¿ãååã§ãªãå Žåã¯ããã€ã§ã
www.hackerrank.comã§ç·Žç¿ã§ããŸãã ç°¡åãªé£æ床ã®ã¿ã¹ã¯ã«æéãç¡é§ã«ããªãã§ãã ãã-ãããã¯åçŽãããŸãã
Learngitbranching.js.orgã䜿çšãããšãgitã®åºæ¬ãåŠã¶ããšãã§ããEnkiã¢ãã€ã«ã¢ããªã§ããé«åºŠãªæ©èœãç¿åŸã§ããŸãã
ã³ã³ãœãŒã«ããã®ã¿gitã䜿çšããããšã決å®ããå Žåã¯ãããšãã°ãã²ãŒã
vim-adventures.comã䜿çšããŠãåºæ¬çãªVimã³ãã³ããåŠç¿ããããšãã
å§ãããŸãã