Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Android開発初心者にありがちなこと
Search
andfactory, inc.
October 25, 2018
Programming
260
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Android開発初心者にありがちなこと
ginyolithさん発表のスライドです。
andfactory, inc.
October 25, 2018
More Decks by andfactory, inc.
See All by andfactory, inc.
UIViewのレイアウト更新メソッドを整理する
andfactory
0
460
Codableあるある
andfactory
0
230
Androidエンジニアあるある
andfactory
0
270
Collectionの罠
andfactory
0
210
Cocoa Touch Frameworkあるある
andfactory
0
360
iOS開発に慣れてきた時にやりがちあるある
andfactory
0
220
社内勉強会資料 - スクラム・アジャイル開発
andfactory
0
660
Other Decks in Programming
See All in Programming
Herb in Rails 8.2: Your ERB views, now HTML-aware @ Kaigi on Rails 2026, Tokyo, Japan
marcoroth
2
270
AI時代のコードレビューは人に向けるな、仕組みに向けろ
texmeijin
5
3.7k
UnityでSystem.Net.WebSocketsなWebSocketサーバが動かないのでUnity Monoのコードを覗いてみた / about implementing websocket server with unity mono
drumath2237
1
610
Event is what happens
moro
2
860
現場と育てるRailsモデリング 〜Spreadsheetから始めたモデル設計〜
siroemk
2
630
Kotlinの15年とServer-Side Kotlin
n_takehata
1
150
見えないものを探る要求要件定義に必要な基本的思考 / invisible-requirement-thinking
minodriven
15
8.5k
golang-bob.pdf
iwatsukayura
0
130
PumaからFalconに移行したRailsアプリケーションでの実践
falcon8823
0
180
設計次第でAIコードの読む量は減らせる / designing-for-code-reading
minodriven
35
17k
[2026-09-26]空論ジェネリックプロセス~テスト資産とAIで紡ぐ、再現可能なパフォーマンスチューニングの話~
tosite
0
270
phperだってパンチカードでコーディングしたい
o0h
PRO
0
350
Featured
See All Featured
Side Projects
sachag
456
43k
Visual Storytelling: How to be a Superhuman Communicator
reverentgeek
2
710
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
141
35k
エンジニアに許された特別な時間の終わり
watany
109
250k
DevOps and Value Stream Thinking: Enabling flow, efficiency and business value
helenjbeal
2
410
YesSQL, Process and Tooling at Scale
rocio
174
15k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
52
6.1k
Impact Scores and Hybrid Strategies: The future of link building
tamaranovitovic
0
460
Utilizing Notion as your number one productivity tool
mfonobong
4
620
What the history of the web can teach us about the future of AI
inesmontani
PRO
2
740
Fantastic passwords and where to find them - at NoRuKo
philnash
53
4k
StorybookのUI Testing Handbookを読んだ
zakiyama
31
7k
Transcript
Android։ൃ ॳ৺ऀʹ͋Γ͕ͪͳ͜ͱ
ࣗݾհ • ໊લɿ ࢙࠸ • ॴଐɿגࣜձࣾΞΠϦοδ • ৬छɿAndroidΤϯδχΞ • LIKE
: ԻָʢΞΧϖϥʣɺࣸਅ
֓ཁ Android։ൃ࢝Ίͨͯͷ࣌ʹ • ࠔ͍ͬͯͨࣄ • ͦͷղܾࡦ Λհ
Կͯ͠ͳ͍ͷʹ Ϋϥογϡ͢Δ
None
5ISFBE͕ݪҼɾɾɾʁ
ݪҼ public class MainActivity extends Activity { TextView mTextView; @Override
protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Button button1 = findViewById(R.id.button1); mTextView = findViewById(R.id.textView); // ボタン1クリック時 button1.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { new Thread(new Runnable() { @Override public void run() { mTextView.setText("hoge"); } }).start(); } });
ݪҼ public class MainActivity extends Activity { TextView mTextView; @Override
protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Button button1 = findViewById(R.id.button1); mTextView = findViewById(R.id.textView); // ボタン1クリック時 button1.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { new Thread(new Runnable() { @Override public void run() { mTextView.setText("hoge"); } }).start(); } });
ؾΛ͚ͭΔࣄ • ݪҼɿ • UiThreadҎ֎͔ΒUIʢςΩετͳͲʣΛॻ͖ ͑Δࣄ͕ग़དྷͳ͍ • ରࡦɿ • UIThreadҎ֎͔ΒHandler.post(),
͘͠ runOnUiThread༻͍ͯUIΛૢ࡞͢Δɻ
ೖॻͱݱ࣮ͷΪϟοϓ
νϡʔτϦΞϧͷґଘϥΠϒϥϦ dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.google.android.gms:play-services-maps:15.0.0' testImplementation 'junit:junit:4.12' androidTestImplementation 'com.android.support.test:runner:1.0.2' androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' }
νϡʔτϦΞϧͷίʔυ public class MainActivity extends Activity { TextView mTextView; @Override
protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Button button1 = findViewById(R.id.button1); Button button2 = findViewById(R.id.button2); mTextView = findViewById(R.id.textView); // ボタン1クリック時 button1.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { button1Clicked(); } });
࣮ࡍͷґଘϥΠϒϥϦ dependencies { // App's dependencies, including test compile "com.android.support:appcompat-v7:$rootProject.supportLibraryVersion"
compile "com.android.support:cardview-v7:$rootProject.supportLibraryVersion" compile "com.android.support:design:$rootProject.supportLibraryVersion" compile "com.android.support:recyclerview-v7:$rootProject.supportLibraryVersion" compile "com.android.support:support-v4:$rootProject.supportLibraryVersion" compile "com.android.support.test.espresso:espresso-idling-resource:$rootProject.espressoVersion" compile "com.google.guava:guava:$rootProject.guavaVersion" compile "android.arch.persistence.room:runtime:$rootProject.roomVersion" annotationProcessor "android.arch.persistence.room:compiler:$rootProject.roomVersion" // Dagger dependencies annotationProcessor "com.google.dagger:dagger-compiler:$rootProject.daggerVersion" compile "com.google.dagger:dagger:$rootProject.daggerVersion" compile "com.google.dagger:dagger-android:$rootProject.daggerVersion" compile "com.google.dagger:dagger-android-support:$rootProject.daggerVersion" annotationProcessor "com.google.dagger:dagger-android-processor:$rootProject.daggerVersion" // Dependencies for local unit tests testCompile "junit:junit:$rootProject.ext.junitVersion" testCompile "org.mockito:mockito-all:$rootProject.ext.mockitoVersion" testCompile "org.hamcrest:hamcrest-all:$rootProject.ext.hamcrestVersion" // Android Testing Support Library's runner and rules androidTestCompile "com.android.support.test:runner:$rootProject.ext.runnerVersion" androidTestCompile "com.android.support.test:rules:$rootProject.ext.rulesVersion" androidTestCompile "android.arch.persistence.room:testing:$rootProject.roomVersion" // Dependencies for Android unit tests androidTestCompile "junit:junit:$rootProject.ext.junitVersion" androidTestCompile "org.mockito:mockito-core:$rootProject.ext.mockitoVersion" androidTestCompile "com.google.dexmaker:dexmaker:$rootProject.ext.dexmakerVersion" androidTestCompile "com.google.dexmaker:dexmaker-mockito:$rootProject.ext.dexmakerVersion"
ViewModel…? public class TaskDetailViewModel extends TaskViewModel { @Nullable private TaskDetailNavigator
mTaskDetailNavigator; public TaskDetailViewModel(Context context, TasksRepository tasksRepository) { super(context, tasksRepository); } public void setNavigator(TaskDetailNavigator taskDetailNavigator) { mTaskDetailNavigator = taskDetailNavigator; } public void onActivityDestroyed() { // Clear references to avoid potential memory leaks. mTaskDetailNavigator = null; }
ֶशͷ༏ઌ 1. ΞʔΩςΫνϟ, databindingͷ͍ํ • MVVM, MVPͳͲɻMVVMͰDatabinding͕؊ͱͳΔͷͰ߹ Θͤͯ 2. ػೳՃʹ΄΅ඞਢͳϥΠϒϥϦ
• Retrofit, OkHttpͳͲ 3. Ϟμϯͳઃܭ or هड़͕ՄೳͳϥΠϒϥϦ • RxJava, AAC, dagger2, Kotlin etc…
ͳ͔ͥToast͕දࣔ͞Εͳ͍
ͳ͔ͥToast͕දࣔ͞Εͳ͍ @Override public void showToast() { Toast.makeText(HogeActivity.this, “Hoge”, Toast.LENGTH_SHORT); }
ͳ͔ͥToast͕දࣔ͞Εͳ͍ @Override public void showToast() { Toast.makeText(HogeActivity.this, “Hoge”, Toast.LENGTH_SHORT).show(); }
KotlinΛ͏ͱ… // 拡張関数を定義 fun Activity.toast(msg : String) { Toast.makeText(this, msg,
Toast.LENGTH_SHORT).show() } // Activityを継承するクラスでtoast関数を呼ぶことが可能に fun showToast() {
[email protected]
("hoge") }
ςετ͕͍͠
Context͕औಘͰ͖ͳ͍ʂ Ͱ࣮ػςετͨ͘͠ͳ͍
ରࡦ • ϥΠϒϥϦΛ͏ • Robolectric • Android Test ( Android
Jetpack ) • ຊʹContextඞཁʁ • ઃܭΛݟ͢
Thank you for listening!