Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Les AsyncTasks
Search
Souleymane Sidibe
February 15, 2014
Programming
74
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Les AsyncTasks
Souleymane Sidibe
February 15, 2014
More Decks by Souleymane Sidibe
See All by Souleymane Sidibe
Android new UI ToolKit: Jetpack Compose
soulesidibe
0
190
Code sharing with Kotlin multi-platform
soulesidibe
0
120
Android Development in 2019. #devFestDakar
soulesidibe
0
120
Android App Bundle
soulesidibe
0
100
Proguard: The open source optimizer for Java bytecode
soulesidibe
2
110
Kotlin why you should consider using it
soulesidibe
0
120
Lightning talk : La trousse du développeur android
soulesidibe
0
70
Other Decks in Programming
See All in Programming
Gmail/Google DriveをトリガーにAIエージェントを動かそう! / Run AI agents with Gmail/Google Drive as triggers!
har1101
1
180
170k Jobs a Day on GKE: Scaling Mercari's CI Platform - and What's Next for AI-Native Development
junyaokabe
0
120
まずはプロンプトガイドを読もう、話はそれからだ
kiakiraki
1
160
複数の Claude Code が"放置"されてしまう問題をCLI ダッシュボードを自作して解決した話
sumihiro3
1
710
ドリフトを絶対に許さない(?)CDK運用 / CDK Ops with Zero Tolerance for Drifts (?)
akihisaikeda
1
220
AI Engineeringは、AIプロダクトだけのものか? 〜AIがソフトウェアを作る時代の新しい当たり前〜 / No AI in your product. AI Engineering in your development.
rkaga
5
490
テーブルをDELETEした
yuzneri
0
150
freeeにおけるEvalsの実践例の紹介
freee
PRO
0
130
AIと壁打ちしながら進めるコスト管理
fufuhu
1
1.1k
言葉の格闘技のススメ~紙とペンと言葉から始める、キャリアの描き方~
progresscicada
2
170
不幸な GC
chencmd
0
290
Laravel Boostに学ぶ、AIにPHPを書かせる技術 〜OSSの実装から蒸留するエージェント制御の王道〜
kentaroutakeda
3
740
Featured
See All Featured
30 Presentation Tips
portentint
PRO
1
370
The Cult of Friendly URLs
andyhume
79
7k
Speed Design
sergeychernyshev
33
2k
The Illustrated Guide to Node.js - THAT Conference 2024
reverentgeek
1
440
DevOps and Value Stream Thinking: Enabling flow, efficiency and business value
helenjbeal
1
350
From Legacy to Launchpad: Building Startup-Ready Communities
dugsong
0
300
Design of three-dimensional binary manipulators for pick-and-place task avoiding obstacles (IECON2024)
konakalab
0
550
Ecommerce SEO: The Keys for Success Now & Beyond - #SERPConf2024
aleyda
1
2.1k
Building Adaptive Systems
keathley
44
3.2k
End of SEO as We Know It (SMX Advanced Version)
ipullrank
3
4.4k
DBのスキルで生き残る技術 - AI時代におけるテーブル設計の勘所
soudai
PRO
68
57k
What does AI have to do with Human Rights?
axbom
PRO
1
2.3k
Transcript
Les AsyncTasks
Plan L’AsyncTask Les limites Android c’est du java non? La
solution magique Bonus
Un passionné d’android #nexus #startup #ios #java #play! #scala #ps3
#pes #techno #android #devops #BARCA #photos #google #api twitter: @soulesidibe gplus: plus.google.com/+souleymanesidibe
L’AsyncTask
• Traitement en background et mise a jour du UI
• Pas besoin de toucher aux Threads! AsyncTask.java
Pourquoi? AsyncTask.java
Pourquoi? • Ne pas bloquer le UI Thread! AsyncTask.java
Demo
Les limites
mAsync.cancel(true);
None
YourAsyncTask1 task1 = new YourAsyncTask1(); task1.execute(params); YourAsyncTask2 task2 = new
YourAsyncTask2(); task2.execute(params); Question: Serial or parallel?
Android c’est du java non?
Le framework Executor Executor executor = Executors.newSingleThreadExecutor(); executor.execute(new MyRunnable());
Le framework Executor Executor executor = Executors.newSingleThreadExecutor(); executor.execute(new MyRunnable()); ExecutorService
execute = Executors.newSingleThreadExecutor(); Future<Integer> future = execute.submit(new MonCallable());
Le framework Executor Executor executor = Executors.newSingleThreadExecutor(); executor.execute(new MyRunnable()); ExecutorService
execute = Executors.newSingleThreadExecutor(); Future<Integer> future = execute.submit(new MonCallable()); ScheduledExecutorService execute = Executors. newSingleThreadScheduledExecutor(); execute.scheduleAtFixedRate(new MonRunnable(), 0, 1, TimeUnit.SECONDS);
La solution magique
Fragment Activity
Fragment Activity Thread in progress
Fragment Activity Thread Done
Fragment Activity Thread Done BUS POST MyEvent
EventB MyEvent Thread Done BUS POST MyEvent MyEvent EventA EventB
EventA Subscribe Subscribe Subscribe
Event Bus Otto (goo.gl/sWxXY) EventBus (goo.gl/nAEW6) rxJava (goo.gl/TeWxWr)
Otto • Square (goo.gl/VlqRcA) • guava-based event bus • Open
Source • easy to use
Otto
Demo
Bonus
YourAsyncTask1 task1 = new YourAsyncTask1(); task1.executeOnExecutor(executor, params); YourAsyncTask2 task2 =
new YourAsyncTask2(); task2.executeOnExecutor(executor, params); Astuce
Communication entre Composants • Activity - Fragment • Fragment -
Fragment Otto, c’est doux!
Communication entre Composants Activity Fragment A Fragment B BUS
Links • #doc AsyncTask (goo.gl/MRbjQD) • #post The dark side
of AsyncTask (goo. gl/mm8IVR) • #tuto Le Framework Executor(goo. gl/MCJLq4) • #talk Android Bad Practices : comment foirer son app(goo.gl/Ix8Jsn)
MERCI!