SlideShare a Scribd company logo
1 of 26
Download to read offline
Popup view
on Mortar
@KeithYokoma - Drivemode, Inc.
potatotips #21
@KeithYokoma
Keishin Yokomaku at Drivemode, Inc. as Engineer
Experience
1.SNS client and photo book application for Android
2.Driver’s application for Android
Publications
1.Android Training
2.Mixi official smartphone application development guide
Like
Motorsport, Bicycle, Photography, Tumblr
Flow & Mortar
Mortar
• Mortar
• Enumerates app’s UI states and navigates between them
• Alternative but good old practice for building UI parts
• Based on “View” system on Android and…
• Replaces fussy “Fragment” system
Fragments vs. Presenters
ListFragment
Fragment
DialogFragment
} View &Screen.Presenter
?
Fragments vs. Presenters
ListFragment
Fragment
DialogFragment
} View &Screen.Presenter
Popup & Screen.PopupPresenter
Popup
public class ConfirmationPopup implements Popup<Info, Boolean> {
private final Context mContext;
private AlertDialog mDialog;
@Override
public void show(Info info, boolean withFlourish, PopupPresenter<Info, Boolean> presenter) {
if (mDialog != null) throw new IllegalStateException(“already shown!”);
mDialog = new AlertDialog.Builder(getContext())
.setMessage(info.getMessage())
.setPositiveButton(info.getPositive(),
(dialog, which) -> presenter.onDismissed(true))
.setNegativeButton(info.getNegative(),
(dialog, which) -> presenter.onDismissed(false))
.show();
}
}
Popup
public class ConfirmationPopup implements Popup<Info, Boolean> {
private final Context mContext;
private AlertDialog mDialog;
@Override
public void show(Info info, boolean withFlourish, PopupPresenter<Info, Boolean> presenter) {
if (mDialog != null) throw new IllegalStateException(“already shown!”);
mDialog = new AlertDialog.Builder(getContext())
.setMessage(info.getMessage())
.setPositiveButton(info.getPositive(),
(dialog, which) -> presenter.onDismissed(true))
.setNegativeButton(info.getNegative(),
(dialog, which) -> presenter.onDismissed(false))
.show();
}
}
Popup
public class ConfirmationPopup implements Popup<Info, Boolean> {
private final Context mContext;
private AlertDialog mDialog;
@Override
public void show(Info info, boolean withFlourish, PopupPresenter<Info, Boolean> presenter) {
if (mDialog != null) throw new IllegalStateException(“already shown!”);
mDialog = new AlertDialog.Builder(getContext())
.setMessage(info.getMessage())
.setPositiveButton(info.getPositive(),
(dialog, which) -> presenter.onDismissed(true))
.setNegativeButton(info.getNegative(),
(dialog, which) -> presenter.onDismissed(false))
.show();
}
}
Popup
public class ConfirmationPopup implements Popup<Info, Boolean> {
private final Context mContext;
private AlertDialog mDialog;
@Override
public void show(Info info, boolean withFlourish, PopupPresenter<Info, Boolean> presenter) {
if (mDialog != null) throw new IllegalStateException(“already shown!”);
mDialog = new AlertDialog.Builder(getContext())
.setMessage(info.getMessage())
.setPositiveButton(info.getPositive(),
(dialog, which) -> presenter.onDismissed(true))
.setNegativeButton(info.getNegative(),
(dialog, which) -> presenter.onDismissed(false))
.show();
}
}
Popup
public class ConfirmationPopup implements Popup<Info, Boolean> {
private final Context mContext;
private AlertDialog mDialog;
@Override
public void show(Info info, boolean withFlourish, PopupPresenter<Info, Boolean> presenter) {
if (mDialog != null) throw new IllegalStateException(“already shown!”);
mDialog = new AlertDialog.Builder(getContext())
.setMessage(info.getMessage())
.setPositiveButton(info.getPositive(),
(dialog, which) -> presenter.onDismissed(true))
.setNegativeButton(info.getNegative(),
(dialog, which) -> presenter.onDismissed(false))
.show();
}
}
public class ConfirmationPopup implements Popup<Info, Boolean> {
private final Context mContext;
private AlertDialog mDialog;
@Override
public void show(Info info, boolean withFlourish, PopupPresenter<Info, Boolean> presenter) {
if (mDialog != null) throw new IllegalStateException(“already shown!”);
mDialog = new AlertDialog.Builder(getContext())
.setMessage(info.getMessage())
.setPositiveButton(info.getPositive(),
(dialog, which) -> presenter.onDismissed(true))
.setNegativeButton(info.getNegative(),
(dialog, which) -> presenter.onDismissed(false))
.show();
}
}
withFlourish
{
true if Popup is explicitly shown/dismissed through Presenter
false otherwise
Popup
public class ConfirmationPopup implements Popup<Info, Boolean> {
private final Context mContext;
private AlertDialog mDialog;
@Override
public boolean isShowing() { return mDialog != null; }
@Override
public Context getContext() { return mContext; }
@Override
public void dismiss(boolean withFlourish) {
mDialog.dismiss();
mDialog = null;
}
}
PopupPresenter
public class SomeView extends FrameLayout {
// do not inject popup presenter and popup here.
private PopupPresenter<Info, Boolean> mPopupPresenter = new PopupPresenter<>() {
@Override
public void onPopupResult(Boolean result) { } // result == user’s choice
}
private Popup mPopup;
@Override
public void onAttachedToWindow() {
super.onAttachedToWindow();
mPopup = new ConfirmationPopup(getContext());
mPopupPresenter.takeView(mPopup);
}
}
PopupPresenter
public class SomeView extends FrameLayout {
// do not inject popup presenter and popup here.
private PopupPresenter<Info, Boolean> mPopupPresenter = new PopupPresenter<>() {
@Override
public void onPopupResult(Boolean result) { } // result == user’s choice
}
private Popup mPopup;
@Override
public void onAttachedToWindow() {
super.onAttachedToWindow();
mPopup = new ConfirmationPopup(getContext());
mPopupPresenter.takeView(mPopup);
}
}
PopupPresenter
public class SomeView extends FrameLayout {
// do not inject popup presenter and popup here.
private PopupPresenter<Info, Boolean> mPopupPresenter = new PopupPresenter<>() {
@Override
public void onPopupResult(Boolean result) { } // result == user’s choice
}
private Popup mPopup;
@Override
public void onAttachedToWindow() {
super.onAttachedToWindow();
mPopup = new ConfirmationPopup(getContext());
mPopupPresenter.takeView(mPopup);
}
}
PopupPresenter
public class SomeView extends FrameLayout {
// do not inject popup presenter and popup here.
private PopupPresenter<Info, Boolean> mPopupPresenter = new PopupPresenter<>() {
@Override
public void onPopupResult(Boolean result) { } // result == user’s choice
}
private Popup mPopup;
@Override
public void onDetachedFromWindow() {
mPopupPresenter.dropView(mPopup);
super.onDetachedFromWindow();
}
}
PopupPresenter
public class SomeView extends FrameLayout {
// do not inject popup presenter and popup here.
private PopupPresenter<Info, Boolean> mPopupPresenter = new PopupPresenter<>() {
@Override
public void onPopupResult(Boolean result) { } // result == user’s choice
}
private Popup mPopup;
@Override
public void onDetachedFromWindow() {
mPopupPresenter.dropView(mPopup);
super.onDetachedFromWindow();
}
}
PopupPresenter
public class SomeView extends FrameLayout {
// do not inject popup presenter and popup here.
private PopupPresenter<Info, Boolean> mPopupPresenter = new PopupPresenter<>() {
@Override
public void onPopupResult(Boolean result) { } // result == user’s choice
}
private Popup mPopup;
@OnClick(R.id.submit)
public void onSubmit() {
mPopupPresenter.show(Info.create(“Is it ok?”, “ok”, “cancel”));
}
}
PopupPresenter
public class SomeView extends FrameLayout {
// do not inject popup presenter and popup here.
private PopupPresenter<Info, Boolean> mPopupPresenter = new PopupPresenter<>() {
@Override
public void onPopupResult(Boolean result) { } // result == user’s choice
}
private Popup mPopup;
@OnClick(R.id.submit)
public void onSubmit() {
mPopupPresenter.show(Info.create(“Is it ok?”, “ok”, “cancel”));
}
}
Popup & PopupPresenter
• PopupPresenter<D extends Parcelable, R>
• Alternative to FragmentManager
• Handles user’s choice callback at “onPopupResult”
• Type param D must implement “equals” and “hashCode”,

and may not be null(otherwise Popup will not be shown)
Popup & PopupPresenter
• Popup<D extends Parcelable, R>
• Alternative to DialogFragment
• Receives arguments without Bundle (like DialogFragment)
• Presenter will publish user’s choice data for you
–Hollywood Principle
“Don't call us, we'll call you”
Popup view
on Mortar
@KeithYokoma - Drivemode, Inc.
potatotips #21
Join our team? Contact me!

More Related Content

What's hot

AWT Packages , Containers and Components
AWT Packages , Containers and ComponentsAWT Packages , Containers and Components
AWT Packages , Containers and ComponentsSohanur63
 
A comprehensive guide on developing responsive and common react filter component
A comprehensive guide on developing responsive and common react filter componentA comprehensive guide on developing responsive and common react filter component
A comprehensive guide on developing responsive and common react filter componentKaty Slemon
 
Android UI Reference
Android UI ReferenceAndroid UI Reference
Android UI ReferenceGauntFace
 
Conquering the code in softimage
Conquering the code in softimageConquering the code in softimage
Conquering the code in softimageJared Glass
 
Intro to Google TV
Intro to Google TVIntro to Google TV
Intro to Google TVGauntFace
 
Modern Android Architecture
Modern Android ArchitectureModern Android Architecture
Modern Android ArchitectureEric Maxwell
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAAiman Hud
 
Применение шаблона проектирования MVVM при разработке архитектуры Windows Pho...
Применение шаблона проектирования MVVM при разработке архитектуры Windows Pho...Применение шаблона проектирования MVVM при разработке архитектуры Windows Pho...
Применение шаблона проектирования MVVM при разработке архитектуры Windows Pho...Nikolay Rumyantsev
 
STYLISH FLOOR
STYLISH FLOORSTYLISH FLOOR
STYLISH FLOORABU HASAN
 
Effective Android Data Binding
Effective Android Data BindingEffective Android Data Binding
Effective Android Data BindingEric Maxwell
 
Developing Mobile Apps, Lecture 5
Developing Mobile Apps, Lecture 5Developing Mobile Apps, Lecture 5
Developing Mobile Apps, Lecture 5fpatton
 

What's hot (13)

AWT Packages , Containers and Components
AWT Packages , Containers and ComponentsAWT Packages , Containers and Components
AWT Packages , Containers and Components
 
A comprehensive guide on developing responsive and common react filter component
A comprehensive guide on developing responsive and common react filter componentA comprehensive guide on developing responsive and common react filter component
A comprehensive guide on developing responsive and common react filter component
 
Android UI Reference
Android UI ReferenceAndroid UI Reference
Android UI Reference
 
Conquering the code in softimage
Conquering the code in softimageConquering the code in softimage
Conquering the code in softimage
 
Intro to Google TV
Intro to Google TVIntro to Google TV
Intro to Google TV
 
Modern Android Architecture
Modern Android ArchitectureModern Android Architecture
Modern Android Architecture
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
 
Применение шаблона проектирования MVVM при разработке архитектуры Windows Pho...
Применение шаблона проектирования MVVM при разработке архитектуры Windows Pho...Применение шаблона проектирования MVVM при разработке архитектуры Windows Pho...
Применение шаблона проектирования MVVM при разработке архитектуры Windows Pho...
 
STYLISH FLOOR
STYLISH FLOORSTYLISH FLOOR
STYLISH FLOOR
 
Effective Android Data Binding
Effective Android Data BindingEffective Android Data Binding
Effective Android Data Binding
 
Developing Mobile Apps, Lecture 5
Developing Mobile Apps, Lecture 5Developing Mobile Apps, Lecture 5
Developing Mobile Apps, Lecture 5
 
Java: GUI
Java: GUIJava: GUI
Java: GUI
 
Dojo1.0_Tutorials
Dojo1.0_TutorialsDojo1.0_Tutorials
Dojo1.0_Tutorials
 

Similar to Popup view on Mortar

softshake 2014 - Java EE
softshake 2014 - Java EEsoftshake 2014 - Java EE
softshake 2014 - Java EEAlexis Hassler
 
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
 
Building maintainable app #droidconzg
Building maintainable app #droidconzgBuilding maintainable app #droidconzg
Building maintainable app #droidconzgKristijan Jurković
 
Google Plus SignIn : l'Authentification Google
Google Plus SignIn : l'Authentification GoogleGoogle Plus SignIn : l'Authentification Google
Google Plus SignIn : l'Authentification GoogleMathias Seguy
 
Introduction to cdi given at java one 2014
Introduction to cdi given at java one 2014Introduction to cdi given at java one 2014
Introduction to cdi given at java one 2014Antoine Sabot-Durand
 
Android Event and IntentAndroid Event and Intent
Android Event and IntentAndroid Event and IntentAndroid Event and IntentAndroid Event and Intent
Android Event and IntentAndroid Event and Intentadmin220812
 
Declarative presentations UIKonf
Declarative presentations UIKonfDeclarative presentations UIKonf
Declarative presentations UIKonfNataliya Patsovska
 
Architecting your GWT applications with GWT-Platform - Lesson 02
Architecting your GWT applications with GWT-Platform - Lesson 02Architecting your GWT applications with GWT-Platform - Lesson 02
Architecting your GWT applications with GWT-Platform - Lesson 02rhemsolutions
 
Diving in the Flex Data Binding Waters
Diving in the Flex Data Binding WatersDiving in the Flex Data Binding Waters
Diving in the Flex Data Binding Watersmichael.labriola
 
A GWT Application with MVP Pattern Deploying to CloudFoundry using Spring Roo
A GWT Application with MVP Pattern Deploying to CloudFoundry using  Spring Roo A GWT Application with MVP Pattern Deploying to CloudFoundry using  Spring Roo
A GWT Application with MVP Pattern Deploying to CloudFoundry using Spring Roo Ali Parmaksiz
 
Windows Store app using XAML and C#: Enterprise Product Development
Windows Store app using XAML and C#: Enterprise Product Development Windows Store app using XAML and C#: Enterprise Product Development
Windows Store app using XAML and C#: Enterprise Product Development Mahmoud Hamed Mahmoud
 
Android Architecture Components
Android Architecture ComponentsAndroid Architecture Components
Android Architecture ComponentsBurhanuddinRashid
 
Visual Studio tool windows
Visual Studio tool windowsVisual Studio tool windows
Visual Studio tool windowsPVS-Studio
 
MVVM Design Pattern NDC2009
MVVM Design Pattern NDC2009MVVM Design Pattern NDC2009
MVVM Design Pattern NDC2009Jonas Follesø
 
[22]Efficient and Testable MVVM pattern
[22]Efficient and Testable MVVM pattern[22]Efficient and Testable MVVM pattern
[22]Efficient and Testable MVVM patternNAVER Engineering
 
Встреча Google Post IO ( Владимир Иванов, Катерина Заворотченко и Сергей Комлач)
Встреча Google Post IO ( Владимир Иванов, Катерина Заворотченко и Сергей Комлач)Встреча Google Post IO ( Владимир Иванов, Катерина Заворотченко и Сергей Комлач)
Встреча Google Post IO ( Владимир Иванов, Катерина Заворотченко и Сергей Комлач)Alina Vilk
 

Similar to Popup view on Mortar (20)

Devoxx 2012 (v2)
Devoxx 2012 (v2)Devoxx 2012 (v2)
Devoxx 2012 (v2)
 
softshake 2014 - Java EE
softshake 2014 - Java EEsoftshake 2014 - Java EE
softshake 2014 - Java EE
 
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)
 
Building maintainable app #droidconzg
Building maintainable app #droidconzgBuilding maintainable app #droidconzg
Building maintainable app #droidconzg
 
Google Plus SignIn : l'Authentification Google
Google Plus SignIn : l'Authentification GoogleGoogle Plus SignIn : l'Authentification Google
Google Plus SignIn : l'Authentification Google
 
Introduction to cdi given at java one 2014
Introduction to cdi given at java one 2014Introduction to cdi given at java one 2014
Introduction to cdi given at java one 2014
 
Android workshop
Android workshopAndroid workshop
Android workshop
 
Building maintainable app
Building maintainable appBuilding maintainable app
Building maintainable app
 
Android Event and IntentAndroid Event and Intent
Android Event and IntentAndroid Event and IntentAndroid Event and IntentAndroid Event and Intent
Android Event and IntentAndroid Event and Intent
 
Declarative presentations UIKonf
Declarative presentations UIKonfDeclarative presentations UIKonf
Declarative presentations UIKonf
 
Architecting your GWT applications with GWT-Platform - Lesson 02
Architecting your GWT applications with GWT-Platform - Lesson 02Architecting your GWT applications with GWT-Platform - Lesson 02
Architecting your GWT applications with GWT-Platform - Lesson 02
 
Diving in the Flex Data Binding Waters
Diving in the Flex Data Binding WatersDiving in the Flex Data Binding Waters
Diving in the Flex Data Binding Waters
 
Vaadin7
Vaadin7Vaadin7
Vaadin7
 
A GWT Application with MVP Pattern Deploying to CloudFoundry using Spring Roo
A GWT Application with MVP Pattern Deploying to CloudFoundry using  Spring Roo A GWT Application with MVP Pattern Deploying to CloudFoundry using  Spring Roo
A GWT Application with MVP Pattern Deploying to CloudFoundry using Spring Roo
 
Windows Store app using XAML and C#: Enterprise Product Development
Windows Store app using XAML and C#: Enterprise Product Development Windows Store app using XAML and C#: Enterprise Product Development
Windows Store app using XAML and C#: Enterprise Product Development
 
Android Architecture Components
Android Architecture ComponentsAndroid Architecture Components
Android Architecture Components
 
Visual Studio tool windows
Visual Studio tool windowsVisual Studio tool windows
Visual Studio tool windows
 
MVVM Design Pattern NDC2009
MVVM Design Pattern NDC2009MVVM Design Pattern NDC2009
MVVM Design Pattern NDC2009
 
[22]Efficient and Testable MVVM pattern
[22]Efficient and Testable MVVM pattern[22]Efficient and Testable MVVM pattern
[22]Efficient and Testable MVVM pattern
 
Встреча Google Post IO ( Владимир Иванов, Катерина Заворотченко и Сергей Комлач)
Встреча Google Post IO ( Владимир Иванов, Катерина Заворотченко и Сергей Комлач)Встреча Google Post IO ( Владимир Иванов, Катерина Заворотченко и Сергей Комлач)
Встреча Google Post IO ( Владимир Иванов, Катерина Заворотченко и Сергей Комлач)
 

More from Keishin Yokomaku

More from Keishin Yokomaku (14)

UI optimization for night
UI optimization for nightUI optimization for night
UI optimization for night
 
Regexp in Android and Java
Regexp in Android and JavaRegexp in Android and Java
Regexp in Android and Java
 
Deep Inside Android Hacks
Deep Inside Android HacksDeep Inside Android Hacks
Deep Inside Android Hacks
 
Make it compatible
Make it compatibleMake it compatible
Make it compatible
 
Signature
SignatureSignature
Signature
 
Android Media Hacks
Android Media HacksAndroid Media Hacks
Android Media Hacks
 
Null, the Abyss
Null, the AbyssNull, the Abyss
Null, the Abyss
 
?
??
?
 
Building stable and flexible libraries
Building stable and flexible librariesBuilding stable and flexible libraries
Building stable and flexible libraries
 
Typeface
TypefaceTypeface
Typeface
 
Version Management
Version ManagementVersion Management
Version Management
 
イカしたライブラリを作った話
イカしたライブラリを作った話イカしたライブラリを作った話
イカしたライブラリを作った話
 
Google I/O 2013 報告会 Android Studio と Gradle
Google I/O 2013 報告会 Android Studio と GradleGoogle I/O 2013 報告会 Android Studio と Gradle
Google I/O 2013 報告会 Android Studio と Gradle
 
自己組織化
自己組織化自己組織化
自己組織化
 

Recently uploaded

Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 

Recently uploaded (20)

Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 

Popup view on Mortar

  • 1. Popup view on Mortar @KeithYokoma - Drivemode, Inc. potatotips #21
  • 2. @KeithYokoma Keishin Yokomaku at Drivemode, Inc. as Engineer Experience 1.SNS client and photo book application for Android 2.Driver’s application for Android Publications 1.Android Training 2.Mixi official smartphone application development guide Like Motorsport, Bicycle, Photography, Tumblr
  • 3.
  • 5. Mortar • Mortar • Enumerates app’s UI states and navigates between them • Alternative but good old practice for building UI parts • Based on “View” system on Android and… • Replaces fussy “Fragment” system
  • 7. Fragments vs. Presenters ListFragment Fragment DialogFragment } View &Screen.Presenter Popup & Screen.PopupPresenter
  • 8. Popup public class ConfirmationPopup implements Popup<Info, Boolean> { private final Context mContext; private AlertDialog mDialog; @Override public void show(Info info, boolean withFlourish, PopupPresenter<Info, Boolean> presenter) { if (mDialog != null) throw new IllegalStateException(“already shown!”); mDialog = new AlertDialog.Builder(getContext()) .setMessage(info.getMessage()) .setPositiveButton(info.getPositive(), (dialog, which) -> presenter.onDismissed(true)) .setNegativeButton(info.getNegative(), (dialog, which) -> presenter.onDismissed(false)) .show(); } }
  • 9. Popup public class ConfirmationPopup implements Popup<Info, Boolean> { private final Context mContext; private AlertDialog mDialog; @Override public void show(Info info, boolean withFlourish, PopupPresenter<Info, Boolean> presenter) { if (mDialog != null) throw new IllegalStateException(“already shown!”); mDialog = new AlertDialog.Builder(getContext()) .setMessage(info.getMessage()) .setPositiveButton(info.getPositive(), (dialog, which) -> presenter.onDismissed(true)) .setNegativeButton(info.getNegative(), (dialog, which) -> presenter.onDismissed(false)) .show(); } }
  • 10. Popup public class ConfirmationPopup implements Popup<Info, Boolean> { private final Context mContext; private AlertDialog mDialog; @Override public void show(Info info, boolean withFlourish, PopupPresenter<Info, Boolean> presenter) { if (mDialog != null) throw new IllegalStateException(“already shown!”); mDialog = new AlertDialog.Builder(getContext()) .setMessage(info.getMessage()) .setPositiveButton(info.getPositive(), (dialog, which) -> presenter.onDismissed(true)) .setNegativeButton(info.getNegative(), (dialog, which) -> presenter.onDismissed(false)) .show(); } }
  • 11. Popup public class ConfirmationPopup implements Popup<Info, Boolean> { private final Context mContext; private AlertDialog mDialog; @Override public void show(Info info, boolean withFlourish, PopupPresenter<Info, Boolean> presenter) { if (mDialog != null) throw new IllegalStateException(“already shown!”); mDialog = new AlertDialog.Builder(getContext()) .setMessage(info.getMessage()) .setPositiveButton(info.getPositive(), (dialog, which) -> presenter.onDismissed(true)) .setNegativeButton(info.getNegative(), (dialog, which) -> presenter.onDismissed(false)) .show(); } }
  • 12. Popup public class ConfirmationPopup implements Popup<Info, Boolean> { private final Context mContext; private AlertDialog mDialog; @Override public void show(Info info, boolean withFlourish, PopupPresenter<Info, Boolean> presenter) { if (mDialog != null) throw new IllegalStateException(“already shown!”); mDialog = new AlertDialog.Builder(getContext()) .setMessage(info.getMessage()) .setPositiveButton(info.getPositive(), (dialog, which) -> presenter.onDismissed(true)) .setNegativeButton(info.getNegative(), (dialog, which) -> presenter.onDismissed(false)) .show(); } }
  • 13. public class ConfirmationPopup implements Popup<Info, Boolean> { private final Context mContext; private AlertDialog mDialog; @Override public void show(Info info, boolean withFlourish, PopupPresenter<Info, Boolean> presenter) { if (mDialog != null) throw new IllegalStateException(“already shown!”); mDialog = new AlertDialog.Builder(getContext()) .setMessage(info.getMessage()) .setPositiveButton(info.getPositive(), (dialog, which) -> presenter.onDismissed(true)) .setNegativeButton(info.getNegative(), (dialog, which) -> presenter.onDismissed(false)) .show(); } } withFlourish { true if Popup is explicitly shown/dismissed through Presenter false otherwise
  • 14. Popup public class ConfirmationPopup implements Popup<Info, Boolean> { private final Context mContext; private AlertDialog mDialog; @Override public boolean isShowing() { return mDialog != null; } @Override public Context getContext() { return mContext; } @Override public void dismiss(boolean withFlourish) { mDialog.dismiss(); mDialog = null; } }
  • 15. PopupPresenter public class SomeView extends FrameLayout { // do not inject popup presenter and popup here. private PopupPresenter<Info, Boolean> mPopupPresenter = new PopupPresenter<>() { @Override public void onPopupResult(Boolean result) { } // result == user’s choice } private Popup mPopup; @Override public void onAttachedToWindow() { super.onAttachedToWindow(); mPopup = new ConfirmationPopup(getContext()); mPopupPresenter.takeView(mPopup); } }
  • 16. PopupPresenter public class SomeView extends FrameLayout { // do not inject popup presenter and popup here. private PopupPresenter<Info, Boolean> mPopupPresenter = new PopupPresenter<>() { @Override public void onPopupResult(Boolean result) { } // result == user’s choice } private Popup mPopup; @Override public void onAttachedToWindow() { super.onAttachedToWindow(); mPopup = new ConfirmationPopup(getContext()); mPopupPresenter.takeView(mPopup); } }
  • 17. PopupPresenter public class SomeView extends FrameLayout { // do not inject popup presenter and popup here. private PopupPresenter<Info, Boolean> mPopupPresenter = new PopupPresenter<>() { @Override public void onPopupResult(Boolean result) { } // result == user’s choice } private Popup mPopup; @Override public void onAttachedToWindow() { super.onAttachedToWindow(); mPopup = new ConfirmationPopup(getContext()); mPopupPresenter.takeView(mPopup); } }
  • 18. PopupPresenter public class SomeView extends FrameLayout { // do not inject popup presenter and popup here. private PopupPresenter<Info, Boolean> mPopupPresenter = new PopupPresenter<>() { @Override public void onPopupResult(Boolean result) { } // result == user’s choice } private Popup mPopup; @Override public void onDetachedFromWindow() { mPopupPresenter.dropView(mPopup); super.onDetachedFromWindow(); } }
  • 19. PopupPresenter public class SomeView extends FrameLayout { // do not inject popup presenter and popup here. private PopupPresenter<Info, Boolean> mPopupPresenter = new PopupPresenter<>() { @Override public void onPopupResult(Boolean result) { } // result == user’s choice } private Popup mPopup; @Override public void onDetachedFromWindow() { mPopupPresenter.dropView(mPopup); super.onDetachedFromWindow(); } }
  • 20. PopupPresenter public class SomeView extends FrameLayout { // do not inject popup presenter and popup here. private PopupPresenter<Info, Boolean> mPopupPresenter = new PopupPresenter<>() { @Override public void onPopupResult(Boolean result) { } // result == user’s choice } private Popup mPopup; @OnClick(R.id.submit) public void onSubmit() { mPopupPresenter.show(Info.create(“Is it ok?”, “ok”, “cancel”)); } }
  • 21. PopupPresenter public class SomeView extends FrameLayout { // do not inject popup presenter and popup here. private PopupPresenter<Info, Boolean> mPopupPresenter = new PopupPresenter<>() { @Override public void onPopupResult(Boolean result) { } // result == user’s choice } private Popup mPopup; @OnClick(R.id.submit) public void onSubmit() { mPopupPresenter.show(Info.create(“Is it ok?”, “ok”, “cancel”)); } }
  • 22. Popup & PopupPresenter • PopupPresenter<D extends Parcelable, R> • Alternative to FragmentManager • Handles user’s choice callback at “onPopupResult” • Type param D must implement “equals” and “hashCode”,
 and may not be null(otherwise Popup will not be shown)
  • 23. Popup & PopupPresenter • Popup<D extends Parcelable, R> • Alternative to DialogFragment • Receives arguments without Bundle (like DialogFragment) • Presenter will publish user’s choice data for you
  • 24. –Hollywood Principle “Don't call us, we'll call you”
  • 25. Popup view on Mortar @KeithYokoma - Drivemode, Inc. potatotips #21
  • 26. Join our team? Contact me!