SlideShare a Scribd company logo
1 of 21
Android Studio Plugin 作ってみた
〜 CreateIntent method Generator 〜
関西モバイルアプリ研究会 #9
Ryo Sotoyama
自己紹介
● 外山 椋 (そとやま りょう)
● シーサー株式会社
● Androidアプリ開発
private int mIntVal;
private long mLongVal;
private String mStringVal;
private ArrayList<String> mStringList;
問題点: Activityへのデータ渡し
問題点: Activityへのデータ渡し
private int mIntVal;
private long mLongVal;
private String mStringVal;
private ArrayList<String> mStringList;
public static Intent createIntent(Context context, int intVal, long
longVal, String stringVal, ArrayList<String> stringList) {
Intent intent = new Intent(context, SampleActivity.class);
intent.putExtra(ARG_INT_VAL, intVal);
intent.putExtra(ARG_LONG_VAL, longVal);
intent.putExtra(ARG_STRING_VAL, stringVal);
intent.putStringArrayListExtra(ARG_STRING_LIST, stringList);
}
public void restore(Intent intent) {
this.mIntVal = intent.getIntExtra(ARG_INT_VAL, -1);
this.mLongVal = intent.getLongExtra(ARG_LONG_VAL, -1L);
this.mStringVal = intent.getStringExtra(ARG_STRING_VAL);
this.mStringList = intent.getStringArrayListExtra(ARG_STRING_LIST);
}
つらい :(
Solution
● Android Studio(IntelliJ) Plugin
● Android Processing Tool (APT)
Solution
● Android Studio(IntelliJ) Plugin
● Android Processing Tool (APT)
Plugin Example
Code Generator
● ButterKnife Zelezny
● ParcelableGenerator
Navigation
● Dagger IntelliJ Plugin
● Otto IntelliJ Plugin
Intentへ値の出し入れする
プラグイン作ってみた
CreateIntent method Generator
どんなプログラムでプラグインが
作られているか軽く紹介
例:int s = 1; をクラス内に生成するプラグイン
Code Generator Plugin
public class ActionClass extends AnAction {
@Override
public void actionPerformed(AnActionEvent e) {
}
}
Code Generator Plugin
public class ActionClass extends AnAction {
@Override
public void actionPerformed(AnActionEvent e) {
final Project project = e.getProject();
final Editor editor = e.getData(DataKeys.EDITOR);
final PsiFile file = PsiUtilBase.getPsiFileInEditor(editor, project);
}
}
Code Generator Plugin
public class ActionClass extends AnAction {
@Override
public void actionPerformed(AnActionEvent e) {
final Project project = e.getProject();
final Editor editor = e.getData(DataKeys.EDITOR);
final PsiFile file = PsiUtilBase.getPsiFileInEditor(editor, project);
new WriteCommandAction.Simple(project, file) {
@Override
protected void run() throws Throwable {
}
}.execute();
}
}
Code Generator Plugin
public class ActionClass extends AnAction {
@Override
public void actionPerformed(AnActionEvent e) {
final Project project = e.getProject();
final Editor editor = e.getData(DataKeys.EDITOR);
final PsiFile file = PsiUtilBase.getPsiFileInEditor(editor, project);
new WriteCommandAction.Simple(project, file) {
@Override
protected void run() throws Throwable {
generate(project, file, editor);
}
}.execute();
}
}
private void generate(Project project, PsiFile file, Editor editor){
// fieldインスタンス作成
PsiElementFactory elementFactory = JavaPsiFacade.getElementFactory(project);
PsiField field = elementFactory.createFieldFromText("int s = 1;", null);
}
Code Generator Plugin
private void generate(Project project, PsiFile file, Editor editor){
// fieldインスタンス作成
PsiElementFactory elementFactory = JavaPsiFacade.getElementFactory(project);
PsiField field = elementFactory.createFieldFromText("int s = 1;", null);
// カーソルのある場所のクラスを取得
PsiElement element = file.findElementAt(editor.getCaretModel().getOffset());
PsiClass psiClass = PsiTreeUtil.getParentOfType(element, PsiClass.class);
}
Code Generator Plugin
private void generate(Project project, PsiFile file, Editor editor){
// fieldインスタンス作成
PsiElementFactory elementFactory = JavaPsiFacade.getElementFactory(project);
PsiField field = elementFactory.createFieldFromText("int s = 1;", null);
// カーソルのある場所のクラスを取得
PsiElement element = file.findElementAt(editor.getCaretModel().getOffset());
PsiClass psiClass = PsiTreeUtil.getParentOfType(element, PsiClass.class);
// 実際のクラス内にフィールド追加
JavaCodeStyleManager styleManager = JavaCodeStyleManager.getInstance(project);
PsiElement element1 =
styleManager.shortenClassReferences(psiClass.addBefore(field, psiClass.getLastChild()));
}
Code Generator Plugin
Code Generator Plugin: Result
public class GenerateSampleClass {
}
public class GenerateSampleClass {
int s = 1;
}
最初にフィールドを取得して型によって生成する文を変えれば
CreateIntent method Generatorみたいなのが作れる!

More Related Content

What's hot

Adopting F# at SBTech
Adopting F# at SBTechAdopting F# at SBTech
Adopting F# at SBTechAntya Dev
 
Lowering in C#: What really happens with your code?, from NDC Oslo 2019
Lowering in C#: What really happens with your code?, from NDC Oslo 2019Lowering in C#: What really happens with your code?, from NDC Oslo 2019
Lowering in C#: What really happens with your code?, from NDC Oslo 2019David Wengier
 
Introduction to R2DBC
Introduction to R2DBCIntroduction to R2DBC
Introduction to R2DBCRob Hedgpeth
 
Android getting started
Android getting startedAndroid getting started
Android getting startedUptech
 
iOS Keychain by 흰, 민디
iOS Keychain by 흰, 민디iOS Keychain by 흰, 민디
iOS Keychain by 흰, 민디MINJICHO20
 
Adding To the Leaf Pile
Adding To the Leaf PileAdding To the Leaf Pile
Adding To the Leaf Pilestuporglue
 

What's hot (12)

Fun with RecyclerView
Fun with RecyclerViewFun with RecyclerView
Fun with RecyclerView
 
Data backup
Data backupData backup
Data backup
 
Adopting F# at SBTech
Adopting F# at SBTechAdopting F# at SBTech
Adopting F# at SBTech
 
Recyclerview in action
Recyclerview in action Recyclerview in action
Recyclerview in action
 
Lowering in C#: What really happens with your code?, from NDC Oslo 2019
Lowering in C#: What really happens with your code?, from NDC Oslo 2019Lowering in C#: What really happens with your code?, from NDC Oslo 2019
Lowering in C#: What really happens with your code?, from NDC Oslo 2019
 
Introduction to R2DBC
Introduction to R2DBCIntroduction to R2DBC
Introduction to R2DBC
 
Android crashcourse
Android crashcourseAndroid crashcourse
Android crashcourse
 
Android getting started
Android getting startedAndroid getting started
Android getting started
 
ButterKnife
ButterKnifeButterKnife
ButterKnife
 
iOS Keychain by 흰, 민디
iOS Keychain by 흰, 민디iOS Keychain by 흰, 민디
iOS Keychain by 흰, 민디
 
Firebase ng2 zurich
Firebase ng2 zurichFirebase ng2 zurich
Firebase ng2 zurich
 
Adding To the Leaf Pile
Adding To the Leaf PileAdding To the Leaf Pile
Adding To the Leaf Pile
 

Viewers also liked

Barkley Portfolio
Barkley PortfolioBarkley Portfolio
Barkley Portfolioerbarkley91
 
Chapter 1 review
Chapter 1 reviewChapter 1 review
Chapter 1 reviewrasheeqm
 
Tight FX spreads
Tight FX spreadsTight FX spreads
Tight FX spreadsHcfarmfresh
 
Copvel ketinggian air_berbasis_sms
Copvel ketinggian air_berbasis_smsCopvel ketinggian air_berbasis_sms
Copvel ketinggian air_berbasis_sms19902
 
Omega3fattyacids1 121225062726-phpapp02
Omega3fattyacids1 121225062726-phpapp02Omega3fattyacids1 121225062726-phpapp02
Omega3fattyacids1 121225062726-phpapp02Mecompany
 
Prezidentské volby ve francii konečná verze
Prezidentské volby ve francii  konečná verzePrezidentské volby ve francii  konečná verze
Prezidentské volby ve francii konečná verzeteresmina
 
Abhishek manu singhvi
Abhishek manu singhviAbhishek manu singhvi
Abhishek manu singhvinew reporter
 
TheSeen Intro
TheSeen IntroTheSeen Intro
TheSeen Introtheseen
 
Ebook fans page dahsyat!!
Ebook fans page dahsyat!!Ebook fans page dahsyat!!
Ebook fans page dahsyat!!Ahmad Ajir
 
Practical.scada.for.industry
Practical.scada.for.industryPractical.scada.for.industry
Practical.scada.for.industryTimothy Leonard
 
American Revotution
American RevotutionAmerican Revotution
American RevotutionSeven___days
 
Carta de Dilma ao Senado e ao povo brasileiro
Carta de Dilma ao Senado e ao povo brasileiroCarta de Dilma ao Senado e ao povo brasileiro
Carta de Dilma ao Senado e ao povo brasileiroLúcio Batista
 

Viewers also liked (19)

Barkley Portfolio
Barkley PortfolioBarkley Portfolio
Barkley Portfolio
 
Chapter 1 review
Chapter 1 reviewChapter 1 review
Chapter 1 review
 
Tight FX spreads
Tight FX spreadsTight FX spreads
Tight FX spreads
 
Copvel ketinggian air_berbasis_sms
Copvel ketinggian air_berbasis_smsCopvel ketinggian air_berbasis_sms
Copvel ketinggian air_berbasis_sms
 
Omega3fattyacids1 121225062726-phpapp02
Omega3fattyacids1 121225062726-phpapp02Omega3fattyacids1 121225062726-phpapp02
Omega3fattyacids1 121225062726-phpapp02
 
Prezidentské volby ve francii konečná verze
Prezidentské volby ve francii  konečná verzePrezidentské volby ve francii  konečná verze
Prezidentské volby ve francii konečná verze
 
Scada primer
Scada primerScada primer
Scada primer
 
Managementul Calitatii
Managementul CalitatiiManagementul Calitatii
Managementul Calitatii
 
Play tune
 Play tune Play tune
Play tune
 
Abhishek manu singhvi
Abhishek manu singhviAbhishek manu singhvi
Abhishek manu singhvi
 
TheSeen Intro
TheSeen IntroTheSeen Intro
TheSeen Intro
 
Pp ptk
Pp ptkPp ptk
Pp ptk
 
Pp ptk
Pp ptkPp ptk
Pp ptk
 
Test ppt
Test pptTest ppt
Test ppt
 
Ebook fans page dahsyat!!
Ebook fans page dahsyat!!Ebook fans page dahsyat!!
Ebook fans page dahsyat!!
 
Practical.scada.for.industry
Practical.scada.for.industryPractical.scada.for.industry
Practical.scada.for.industry
 
American Revotution
American RevotutionAmerican Revotution
American Revotution
 
Carta de Dilma ao Senado e ao povo brasileiro
Carta de Dilma ao Senado e ao povo brasileiroCarta de Dilma ao Senado e ao povo brasileiro
Carta de Dilma ao Senado e ao povo brasileiro
 
LUQMAN ACTIVITY PPT SHOW
LUQMAN ACTIVITY PPT SHOWLUQMAN ACTIVITY PPT SHOW
LUQMAN ACTIVITY PPT SHOW
 

Similar to Android Studio PluginでIntentデータ渡しメソッド自動生成

Overview of Android Infrastructure
Overview of Android InfrastructureOverview of Android Infrastructure
Overview of Android InfrastructureAlexey Buzdin
 
Overview of Android Infrastructure
Overview of Android InfrastructureOverview of Android Infrastructure
Overview of Android InfrastructureC.T.Co
 
Fundamental of android
Fundamental of androidFundamental of android
Fundamental of androidAdarsh Patel
 
Windows 8 Pure Imagination - 2012-11-25 - Extending Your Game with Windows 8 ...
Windows 8 Pure Imagination - 2012-11-25 - Extending Your Game with Windows 8 ...Windows 8 Pure Imagination - 2012-11-25 - Extending Your Game with Windows 8 ...
Windows 8 Pure Imagination - 2012-11-25 - Extending Your Game with Windows 8 ...Frédéric Harper
 
That’s My App - Running in Your Background - Draining Your Battery
That’s My App - Running in Your Background - Draining Your BatteryThat’s My App - Running in Your Background - Draining Your Battery
That’s My App - Running in Your Background - Draining Your BatteryMichael Galpin
 
Android Best Practices
Android Best PracticesAndroid Best Practices
Android Best PracticesYekmer Simsek
 
Androidaop 170105090257
Androidaop 170105090257Androidaop 170105090257
Androidaop 170105090257newegg
 
create-netflix-clone-04-server-continued.pdf
create-netflix-clone-04-server-continued.pdfcreate-netflix-clone-04-server-continued.pdf
create-netflix-clone-04-server-continued.pdfShaiAlmog1
 
Thomas braun dependency-injection_with_robo_guice-presentation-final
Thomas braun dependency-injection_with_robo_guice-presentation-finalThomas braun dependency-injection_with_robo_guice-presentation-final
Thomas braun dependency-injection_with_robo_guice-presentation-finalDroidcon Berlin
 
02 hello world - Android
02   hello world - Android02   hello world - Android
02 hello world - AndroidWingston
 
From Legacy to Hexagonal (An Unexpected Android Journey)
From Legacy to Hexagonal (An Unexpected Android Journey)From Legacy to Hexagonal (An Unexpected Android Journey)
From Legacy to Hexagonal (An Unexpected Android Journey)Jose Manuel Pereira Garcia
 
Android Basic Tutorial
Android Basic TutorialAndroid Basic Tutorial
Android Basic TutorialSmartmonk
 
FlashAir Android App Development
FlashAir Android App DevelopmentFlashAir Android App Development
FlashAir Android App DevelopmentFlashAir Developers
 
Тарас Олексин - Sculpt! Your! Tests!
Тарас Олексин  - Sculpt! Your! Tests!Тарас Олексин  - Sculpt! Your! Tests!
Тарас Олексин - Sculpt! Your! Tests!DataArt
 
Modern Android app library stack
Modern Android app library stackModern Android app library stack
Modern Android app library stackTomáš Kypta
 
Sword fighting with Dagger GDG-NYC Jan 2016
 Sword fighting with Dagger GDG-NYC Jan 2016 Sword fighting with Dagger GDG-NYC Jan 2016
Sword fighting with Dagger GDG-NYC Jan 2016Mike Nakhimovich
 
Lviv MDDay 2014. Ігор Коробка “забезпечення базової безпеки в андроїд аплікац...
Lviv MDDay 2014. Ігор Коробка “забезпечення базової безпеки в андроїд аплікац...Lviv MDDay 2014. Ігор Коробка “забезпечення базової безпеки в андроїд аплікац...
Lviv MDDay 2014. Ігор Коробка “забезпечення базової безпеки в андроїд аплікац...Lviv Startup Club
 

Similar to Android Studio PluginでIntentデータ渡しメソッド自動生成 (20)

Android workshop
Android workshopAndroid workshop
Android workshop
 
Overview of Android Infrastructure
Overview of Android InfrastructureOverview of Android Infrastructure
Overview of Android Infrastructure
 
Overview of Android Infrastructure
Overview of Android InfrastructureOverview of Android Infrastructure
Overview of Android Infrastructure
 
Fundamental of android
Fundamental of androidFundamental of android
Fundamental of android
 
Windows 8 Pure Imagination - 2012-11-25 - Extending Your Game with Windows 8 ...
Windows 8 Pure Imagination - 2012-11-25 - Extending Your Game with Windows 8 ...Windows 8 Pure Imagination - 2012-11-25 - Extending Your Game with Windows 8 ...
Windows 8 Pure Imagination - 2012-11-25 - Extending Your Game with Windows 8 ...
 
That’s My App - Running in Your Background - Draining Your Battery
That’s My App - Running in Your Background - Draining Your BatteryThat’s My App - Running in Your Background - Draining Your Battery
That’s My App - Running in Your Background - Draining Your Battery
 
Android Best Practices
Android Best PracticesAndroid Best Practices
Android Best Practices
 
Androidaop 170105090257
Androidaop 170105090257Androidaop 170105090257
Androidaop 170105090257
 
create-netflix-clone-04-server-continued.pdf
create-netflix-clone-04-server-continued.pdfcreate-netflix-clone-04-server-continued.pdf
create-netflix-clone-04-server-continued.pdf
 
Vaadin7
Vaadin7Vaadin7
Vaadin7
 
Introduction toandroid
Introduction toandroidIntroduction toandroid
Introduction toandroid
 
Thomas braun dependency-injection_with_robo_guice-presentation-final
Thomas braun dependency-injection_with_robo_guice-presentation-finalThomas braun dependency-injection_with_robo_guice-presentation-final
Thomas braun dependency-injection_with_robo_guice-presentation-final
 
02 hello world - Android
02   hello world - Android02   hello world - Android
02 hello world - Android
 
From Legacy to Hexagonal (An Unexpected Android Journey)
From Legacy to Hexagonal (An Unexpected Android Journey)From Legacy to Hexagonal (An Unexpected Android Journey)
From Legacy to Hexagonal (An Unexpected Android Journey)
 
Android Basic Tutorial
Android Basic TutorialAndroid Basic Tutorial
Android Basic Tutorial
 
FlashAir Android App Development
FlashAir Android App DevelopmentFlashAir Android App Development
FlashAir Android App Development
 
Тарас Олексин - Sculpt! Your! Tests!
Тарас Олексин  - Sculpt! Your! Tests!Тарас Олексин  - Sculpt! Your! Tests!
Тарас Олексин - Sculpt! Your! Tests!
 
Modern Android app library stack
Modern Android app library stackModern Android app library stack
Modern Android app library stack
 
Sword fighting with Dagger GDG-NYC Jan 2016
 Sword fighting with Dagger GDG-NYC Jan 2016 Sword fighting with Dagger GDG-NYC Jan 2016
Sword fighting with Dagger GDG-NYC Jan 2016
 
Lviv MDDay 2014. Ігор Коробка “забезпечення базової безпеки в андроїд аплікац...
Lviv MDDay 2014. Ігор Коробка “забезпечення базової безпеки в андроїд аплікац...Lviv MDDay 2014. Ігор Коробка “забезпечення базової безпеки в андроїд аплікац...
Lviv MDDay 2014. Ігор Коробка “забезпечення базової безпеки в андроїд аплікац...
 

Recently uploaded

Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio, Inc.
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based projectAnoyGreter
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Andreas Granig
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesPhilip Schwarz
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaHanief Utama
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样umasea
 
software engineering Chapter 5 System modeling.pptx
software engineering Chapter 5 System modeling.pptxsoftware engineering Chapter 5 System modeling.pptx
software engineering Chapter 5 System modeling.pptxnada99848
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...Christina Lin
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...soniya singh
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxTier1 app
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 

Recently uploaded (20)

Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based project
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a series
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief Utama
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
 
software engineering Chapter 5 System modeling.pptx
software engineering Chapter 5 System modeling.pptxsoftware engineering Chapter 5 System modeling.pptx
software engineering Chapter 5 System modeling.pptx
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
 
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 

Android Studio PluginでIntentデータ渡しメソッド自動生成

  • 1. Android Studio Plugin 作ってみた 〜 CreateIntent method Generator 〜 関西モバイルアプリ研究会 #9 Ryo Sotoyama
  • 2. 自己紹介 ● 外山 椋 (そとやま りょう) ● シーサー株式会社 ● Androidアプリ開発
  • 3. private int mIntVal; private long mLongVal; private String mStringVal; private ArrayList<String> mStringList; 問題点: Activityへのデータ渡し
  • 4. 問題点: Activityへのデータ渡し private int mIntVal; private long mLongVal; private String mStringVal; private ArrayList<String> mStringList; public static Intent createIntent(Context context, int intVal, long longVal, String stringVal, ArrayList<String> stringList) { Intent intent = new Intent(context, SampleActivity.class); intent.putExtra(ARG_INT_VAL, intVal); intent.putExtra(ARG_LONG_VAL, longVal); intent.putExtra(ARG_STRING_VAL, stringVal); intent.putStringArrayListExtra(ARG_STRING_LIST, stringList); } public void restore(Intent intent) { this.mIntVal = intent.getIntExtra(ARG_INT_VAL, -1); this.mLongVal = intent.getLongExtra(ARG_LONG_VAL, -1L); this.mStringVal = intent.getStringExtra(ARG_STRING_VAL); this.mStringList = intent.getStringArrayListExtra(ARG_STRING_LIST); }
  • 6. Solution ● Android Studio(IntelliJ) Plugin ● Android Processing Tool (APT)
  • 7. Solution ● Android Studio(IntelliJ) Plugin ● Android Processing Tool (APT)
  • 8. Plugin Example Code Generator ● ButterKnife Zelezny ● ParcelableGenerator Navigation ● Dagger IntelliJ Plugin ● Otto IntelliJ Plugin
  • 11.
  • 13. Code Generator Plugin public class ActionClass extends AnAction { @Override public void actionPerformed(AnActionEvent e) { } }
  • 14. Code Generator Plugin public class ActionClass extends AnAction { @Override public void actionPerformed(AnActionEvent e) { final Project project = e.getProject(); final Editor editor = e.getData(DataKeys.EDITOR); final PsiFile file = PsiUtilBase.getPsiFileInEditor(editor, project); } }
  • 15. Code Generator Plugin public class ActionClass extends AnAction { @Override public void actionPerformed(AnActionEvent e) { final Project project = e.getProject(); final Editor editor = e.getData(DataKeys.EDITOR); final PsiFile file = PsiUtilBase.getPsiFileInEditor(editor, project); new WriteCommandAction.Simple(project, file) { @Override protected void run() throws Throwable { } }.execute(); } }
  • 16. Code Generator Plugin public class ActionClass extends AnAction { @Override public void actionPerformed(AnActionEvent e) { final Project project = e.getProject(); final Editor editor = e.getData(DataKeys.EDITOR); final PsiFile file = PsiUtilBase.getPsiFileInEditor(editor, project); new WriteCommandAction.Simple(project, file) { @Override protected void run() throws Throwable { generate(project, file, editor); } }.execute(); } }
  • 17. private void generate(Project project, PsiFile file, Editor editor){ // fieldインスタンス作成 PsiElementFactory elementFactory = JavaPsiFacade.getElementFactory(project); PsiField field = elementFactory.createFieldFromText("int s = 1;", null); } Code Generator Plugin
  • 18. private void generate(Project project, PsiFile file, Editor editor){ // fieldインスタンス作成 PsiElementFactory elementFactory = JavaPsiFacade.getElementFactory(project); PsiField field = elementFactory.createFieldFromText("int s = 1;", null); // カーソルのある場所のクラスを取得 PsiElement element = file.findElementAt(editor.getCaretModel().getOffset()); PsiClass psiClass = PsiTreeUtil.getParentOfType(element, PsiClass.class); } Code Generator Plugin
  • 19. private void generate(Project project, PsiFile file, Editor editor){ // fieldインスタンス作成 PsiElementFactory elementFactory = JavaPsiFacade.getElementFactory(project); PsiField field = elementFactory.createFieldFromText("int s = 1;", null); // カーソルのある場所のクラスを取得 PsiElement element = file.findElementAt(editor.getCaretModel().getOffset()); PsiClass psiClass = PsiTreeUtil.getParentOfType(element, PsiClass.class); // 実際のクラス内にフィールド追加 JavaCodeStyleManager styleManager = JavaCodeStyleManager.getInstance(project); PsiElement element1 = styleManager.shortenClassReferences(psiClass.addBefore(field, psiClass.getLastChild())); } Code Generator Plugin
  • 20. Code Generator Plugin: Result public class GenerateSampleClass { } public class GenerateSampleClass { int s = 1; }