Intro
1. Goals
2. Structure
3. Challenges
Architectural	decisions
UI Presenter Repository
Local
storage
Remote
storage
1. Retrofit
2. Crashlytics
3. Gson
1. Gson
2. SharedPrefs
3. Realm(in	plans)
1. rxjava1. Rxjava
2. Glide
3. Support	(Constrain	
layout)
4. DataBinding
5. Facebook	sdk
6. Firebase
7. VK	sdk
8. Custom	views
1. Retrolambda
2. Dagger
3. annimon:stream
4. Crashlytics
5. Own	libs
Dagger2	advocating
1. Reusable	code	
2. Testability
3. Easy	scalability
4. Boilerplate	code	reduction*
Dagger2	structure	in	R.I.D.
AppComponent:
- Repository
- Context
Activity1:
Inject	in	Activity1	class	
Repository
Activity2:
Inject	in	Activity1	class	
Repository
ActivityN:
Inject	in	Activity1	class	
Repository
(first	edition)
Not	so	good	L
Dagger2	structure	in	R.I.D.
AppComponent:
- Repository
- Context
- ModuleFactory BaseActivityComponent:
- BaseActivity Presenters
(Inject	in	BaseActivity class)
ActivityComponent_1:
- Activity_1	Presenters
(Inject	in	Activity1	class)
ActivityComponent_2:
- Activity_2	Presenters
(Inject	in	Activity2	class)
ActivityComponent_N:
- Activity_1	Presenters
(Inject	in	ActivityN class)
Any	other	app	component
(second	edition)
Dagger2	structure	in	R.I.D.
(code	samples)
AppComponent
AppModule
@Module
public class AppModule {
@Singleton
@Provides
public Context provideContext() {return mContext;}
@Singleton
@Provides
public Repository provideRepository() {
return getRepository();}
@Provides
@Singleton
public PresenterFactoryExtended provideExtendedModuleFactory() {
return getExtendedModuleFactory();}
@Singleton
@Component(modules = AppModule.class)
public interface AppComponent {
void inject(IntroActivity activity);
void inject(SplashActivity activity);
PresenterFactoryExtended getExtendedPresenterFactory();
BaseActivityComponent plus(BaseActivityModule module);
}
Dagger2	structure	in	R.I.D.
(code	samples)
BaseActivityComponent
BaseActivityModule
@Module
@Singleton
public class BaseActivityModule {
@Provides
public SuggestWordPresenter provideSuggestPresenter(Repository repository) {
return getSuggestPresenter(repository);
}
@Provides
@Named("BaseActivity")
public UserAccountPresenter provideUserPresenter(Repository repository) {
return getUserPresenter(repository);
}
@BaseActivityScope
@Subcomponent(modules = BaseActivityModule.class)
@Singleton
public interface BaseActivityComponent {
void inject(BaseActivity activity);
PresenterFactory getScopeModule();
FirstComponent plus(FirstModule module);
…
NthComponent plus(NthModule module);
}
Dagger2	structure	in	R.I.D.
(code	samples)
In	BaseActivity class
That	is	all:	just	use	presenter	now
In	Activity	class
P.S.	Have	you	noticed	generated	classes?
public BaseActivityComponent getBaseActivityComponent() {
if (baseactivityComponent == null) {
AppComponent comp = ((RidApp) getApplication()).getAppComponent();
baseactivityComponent = comp.plus(comp.getExtendedPresenterFactory()
.provideBaseActivityModule(this, this));
}
return baseactivityComponent;
}
@Inject DictionaryPresenter mPresenter;
private void injectDependencies() {
mDictionaryComponent =
getAppComponent().plus(getBaseActivityComponent().getScopeModule().getModule(this));
mDictionaryComponent.inject(this);
}
Dagger2	structure	in	R.I.D.
(code	samples)
ActivityComponent
ActivityModule
package com.smartpresenter.generated;
@Module
public class DailyWordsModule {
private com.ua.rid.contract.DailyWordsContract.View mContract;
public DailyWordsModule(com.ua.rid.contract.DailyWordsContract.View contract) {
this.mContract = contract;
}
@Provides
public com.ua.rid.presenter.DailyWordsPresenter providePresenter(com.ua.rid.model.Repository repository){
return getPresenter(repository);
}
package com.smartpresenter.generated;
import dagger.Subcomponent;
import com.ua.rid.di.ActivityScope;
@ActivityScope
@Subcomponent(modules =
com.smartpresenter.generated.DailyWordsModule.class)
public interface DailyWordsComponent {
void inject(com.ua.rid.ui.activity.DailyWordsActivity target);
}
Dagger2	custom	apt	in	R.I.D.
In	Presenter	class
In	dependencies.gradle
@DaggerSubComponent(
whereToInject = {DailyWordsActivity.class},
repository = Repository.class,
contract = DailyWordsContract.View.class)
public class DailyWordsPresenter extends BasePresenter implements
DailyWordsContract.Presenter {…}
compile files('lib/presenterfactoryprocessor.jar')
Dagger2	custom	apt	in	R.I.D.
@Target(ElementType.TYPE)
public @interface DaggerSubComponent {
//List of classes where this presenter will be used
Class[] whereToInject() default {};
//Repository to which this presenter would refer
Class repository() default XmlJavaTypeAdapter.DEFAULT.class;
//View Contract for callBacks
Class contract() default XmlJavaTypeAdapter.DEFAULT.class;
}
Custom	annotation
@SupportedAnnotationTypes("com.processor.DaggerSubComponent")
@SupportedSourceVersion(SourceVersion.RELEASE_7)
public class PresenterFactoryProcessor extends AbstractProcessor {
@Override
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
//Do your magic here…
return true;
}
Generate	code
- How	to	write	classes	to	be	generated
- Few	words	about	apt	sequence
Test	advocating
1. Be	sure	in	your	code	validity	
2. Makes	your	code	clean	
3. Keep	calm	and	go	refactor
4. Describes	your	dev	level
5. World	wide	trend!!!
UI	Tests
Tests	hook	for	dagger
@Module
public class TestAppModule extends AppModule {
@Override
public PresenterFactory getModuleFactory() {
return Mockito.mock(PresenterFactory.class);
}
@Override
protected PresenterFactoryExtended getExtendedModuleFactory() {
return Mockito.mock(PresenterFactoryExtended.class);
}
@NonNull
@Override
public Repository getRepository() {
return Mockito.mock(Repository.class);
}
}
1.	Override	AppModule and	return	mocks
UI	Tests
Tests	hook	for	dagger
2.	Create	custom	test	rule
public class MyTestRule implements TestRule {
public MyTestRule(Context context) {
…
mTestComponent = DaggerTestAppComponent
.builder()
.testAppModule(new TestAppModule(application.getApplicationContext())).build();
}
@Override
public Statement apply(Statement base, Description description) {
return new Statement() {
@Override
public void evaluate() throws Throwable {
…
application.setMainComponent(mTestComponent);
base.evaluate();
application.setMainComponent(null);
}
};
}
}
UI	Tests
Tests	hook	for	dagger
3.	Chain	rules	in	test
final MyTestRule component =
new MyTestRule(InstrumentationRegistry.getTargetContext());
private final ActivityTestRule<DailyWordsActivity> mActivityRule =
new ActivityTestRule<>(YourActivity.class, false, false);
@Rule
public TestRule chain = RuleChain.outerRule(component).around(mActivityRule);
@Override
public void setUp() {
super.setUp();
setUpPresenter();
}
private void setUpPresenter() {
when(mMockPresenterFactory.getModule(mCallBackCaptor.capture())).thenReturn(mMockModule);
when(mMockModule.providePresenter(any())).thenReturn(mMockPresenter);
}
4.	SetUp your	mocks
UI	Tests
Simplicity	of	Espresso
onView(withId(R.id.tv_mainWord1)).check(matches(withText("test1")));
Check	if	given	view	shows	needed	text
onView(withId(R.id.dictionary_recycler_view)).check(new RecyclerViewItemCountAssertion(6));
Check	if	given	RecyclerView has	6	childs (custom	ViewAssertion)
if (isElementVisible(withId(R.id.dictionary_recycler_view))) {
onView(withId(R.id.dictionary_recycler_view)).perform(RecyclerViewActions
.actionOnItemAtPosition(1, click()));
//check intent
intended(expectedIntent);
Intents.release();
} else {
assertTrue("Failed to find recycler", false);
}
Click	RecyclerView child	at	position	==	1	and	check	intent
Espresso	cheat	sheet
UI	Tests
What	exactly	is	tested?
1. View logic	(what	will	happen	if	one	clicks	this	
button?)
2. Do	not	test	presenters	- MOCK	them	
3. Be	aware	of	animations	(of	any	kind)
4. Do	not	test	changes	of	activities/fragments/etc -
test	intents
Unit	tests
Again	what	exactly	is	tested?
1. Test	YOUR	logic	(2	+	2	=	4?)
2. Test	edge	cases
3. Avoid	testing	android
4. Do	not	test	3d	party	libs	(smbd`s already	done)
5. Try	to	test	all	public	methods
6. I`m	pretty	sure	U	must	not	test	private	methods… (if	your	
code	is	good	it`s	done	automatically)
Unit	tests
RX	Schedulers
io()	is	waiting	for	smth but	test	won`t.	Custom	Scheduler
public class AppSchedulers {
public interface SchedulerProvider {
Scheduler mainThread();
Scheduler io();
}
public static Scheduler mainThread() {
return instance.mainThread();
}
public static Scheduler io() {
return instance.io();
}
public static class DefaultSchedulerProvider implements SchedulerProvider {
@Override
public Scheduler mainThread() {
return AndroidSchedulers.mainThread();
}
@Override
public Scheduler io() {
return Schedulers.io();
}
}
}
Unit	tests
RX	Schedulers
Custom	rule	->	substitute	real	Scheduler
public class SynchronousSchedulers extends ExternalResource {
@Override
protected void before() throws Throwable {
AppSchedulers.setInstance(new AppSchedulers.SchedulerProvider() {
@Override
public Scheduler mainThread() {
return Schedulers.immediate();
}
@Override
public Scheduler io() {
return Schedulers.immediate();
}
});
}
@Override
protected void after() {
AppSchedulers.setInstance(new AppSchedulers.DefaultSchedulerProvider());
}
}
Yes,	I	know	about	TestSubscriber,	but	it`s	our	LSD,	our	universe,	our	Schedulers))))
Tests	approach	and	TDD	Holly	War
1. My	way 2.	R.I.D.	way
Reading	test	results
1. UI	+	unit	results
2. Lines	coverage
3. Branches	cov.
4. Static	code	analysis	
few	words
How	to	merge	coverage*
Plans
1. Continuous	integration
2. Apps	environment	infrastructure	(more	apps)	
3. Project	infrastructure	(marketing,	offline	events)
We	are	hiring
1. IOS	dev
2. Android	dev
3. BackEnd (Ruby)	dev
4. UI/UX	designer
5. Front	end	developer
Find	us:
http://rid.ck.ua/
The	end
Sergiy	Grechukha
Android	Engineer,	Techery
mail:	sergey.grechukha@gmail.com
com.ua.rid D/AndroidRuntime:	Shutting	down	VM

More Related Content

PPT
Using Maven2
PPT
Gerência de Configuração com Maven
PDF
Gradle Introduction
PDF
Gradle build tool that rocks with DSL JavaOne India 4th May 2012
PDF
OpenJDK-Zulu talk at JEEConf'14
PPTX
OpenDaylight Developer Experience 2.0
PPTX
How To Dependency Inject a Kitten: An Introduction to Dagger 2
PDF
In the Brain of Hans Dockter: Gradle
Using Maven2
Gerência de Configuração com Maven
Gradle Introduction
Gradle build tool that rocks with DSL JavaOne India 4th May 2012
OpenJDK-Zulu talk at JEEConf'14
OpenDaylight Developer Experience 2.0
How To Dependency Inject a Kitten: An Introduction to Dagger 2
In the Brain of Hans Dockter: Gradle

What's hot (20)

PDF
Apache DeltaSpike
PDF
OpenWebBeans and DeltaSpike at ApacheCon
PDF
An Introduction to JUnit 5 and how to use it with Spring boot tests and Mockito
PDF
Java SE 9 modules (JPMS) - an introduction
PPTX
Core java
PDF
Idiomatic Gradle Plugin Writing - GradleSummit 2016
PDF
Testing Django Applications
PPT
What is Java Technology (An introduction with comparision of .net coding)
PDF
Overview of Android Infrastructure
PDF
Introduction maven3 and gwt2.5 rc2 - Lesson 01
PDF
Toward dynamic analysis of obfuscated android malware
PPT
Python Evolution
PDF
Migrating to java 9 modules
PDF
ProbeDroid - Crafting Your Own Dynamic Instrument Tool on Android for App Beh...
PPTX
Quickly Testing Qt Desktop Applications
PPT
Object Oriented Programming-JAVA
PPTX
Core Java introduction | Basics | free course
PPTX
Testing basics for developers
PDF
Java Course 15: Ant, Scripting, Spring, Hibernate
Apache DeltaSpike
OpenWebBeans and DeltaSpike at ApacheCon
An Introduction to JUnit 5 and how to use it with Spring boot tests and Mockito
Java SE 9 modules (JPMS) - an introduction
Core java
Idiomatic Gradle Plugin Writing - GradleSummit 2016
Testing Django Applications
What is Java Technology (An introduction with comparision of .net coding)
Overview of Android Infrastructure
Introduction maven3 and gwt2.5 rc2 - Lesson 01
Toward dynamic analysis of obfuscated android malware
Python Evolution
Migrating to java 9 modules
ProbeDroid - Crafting Your Own Dynamic Instrument Tool on Android for App Beh...
Quickly Testing Qt Desktop Applications
Object Oriented Programming-JAVA
Core Java introduction | Basics | free course
Testing basics for developers
Java Course 15: Ant, Scripting, Spring, Hibernate
Ad

Similar to Android App Architecture with modern libs in practice. Our way in R.I.D., Sergey Grechukha (20)

PDF
Using Dagger in a Clean Architecture project
PDF
Metamodeling of custom Pharo images
PPTX
Preparing for java 9 modules upload
PDF
Building Top-Notch Androids SDKs
PDF
Writing Plugged-in Java EE Apps: Jason Lee
PDF
A Journey through the JDKs (Java 9 to Java 11)
PPTX
What's New in Java 9
PDF
Writing Android Libraries
PDF
Understanding And Using Reflection
PDF
MicroProfile Devoxx.us
PDF
Daggerate your code - Write your own annotation processor
PDF
Java 9 / Jigsaw - AJUG/VJUG session
PPTX
Dynamic Groovy Edges
PDF
Fundamental Concepts of React JS for Beginners.pdf
PDF
Workshop 26: React Native - The Native Side
PDF
DevoxxFR17 - Préparez-vous à la modularité selon Java 9
PDF
Devoxx17 - Préparez-vous à la modularité selon Java 9
PPTX
Context and Dependency Injection 2.0
PDF
Comment développer une application mobile en 8 semaines - Meetup PAUG 24-01-2023
PDF
Using Dagger in a Clean Architecture project
Metamodeling of custom Pharo images
Preparing for java 9 modules upload
Building Top-Notch Androids SDKs
Writing Plugged-in Java EE Apps: Jason Lee
A Journey through the JDKs (Java 9 to Java 11)
What's New in Java 9
Writing Android Libraries
Understanding And Using Reflection
MicroProfile Devoxx.us
Daggerate your code - Write your own annotation processor
Java 9 / Jigsaw - AJUG/VJUG session
Dynamic Groovy Edges
Fundamental Concepts of React JS for Beginners.pdf
Workshop 26: React Native - The Native Side
DevoxxFR17 - Préparez-vous à la modularité selon Java 9
Devoxx17 - Préparez-vous à la modularité selon Java 9
Context and Dependency Injection 2.0
Comment développer une application mobile en 8 semaines - Meetup PAUG 24-01-2023
Ad

More from Sigma Software (20)

PPTX
Fast is Best. Using .NET MinimalAPIs
PPTX
"Are you developing or declining? Don't become an IT-dinosaur"
PPTX
Michael Smolin, "Decrypting customer's cultural code"
PPTX
Max Kunytsia, “Why is continuous product discovery better than continuous del...
PPTX
Marcelino Moreno, "Product Management Mindset"
PDF
Andrii Pastushok, "Product Discovery in Outsourcing - What, When, and How"
PPTX
Elena Turkenych “BA vs PM: Who' the right person, for the right job, with the...
PPTX
Eleonora Budanova “BA+PM+DEV team: how to build the synergy”
PPTX
Stoyan Atanasov “How crucial is the BA role in an IT Project"
PPTX
Olexandra Kovalyova, "Equivalence Partitioning, Boundary Values ​​Analysis, C...
PPTX
Yana Lysa — "Decision Tables, State-Transition testing, Pairwase Testing"
PPTX
VOLVO x HACK SPRINT
PPTX
Business digitalization trends and challenges
PPTX
Дмитро Терещенко, "How to secure your application with Secure SDLC"
PPTX
Яна Лиса, “Ефективні методи написання хороших мануальних тестових сценаріїв”
PDF
Тетяна Осетрова, “Модель зрілості розподіленної проектної команди”
PDF
Training solutions and content creation
PDF
False news - false truth: tips & tricks how to avoid them
PPTX
Анна Бойко, "Хороший контракт vs очікування клієнтів. Що вбереже вас, якщо вд...
PPTX
Дмитрий Лапшин, "The importance of TEX and Internal Quality. How explain and ...
Fast is Best. Using .NET MinimalAPIs
"Are you developing or declining? Don't become an IT-dinosaur"
Michael Smolin, "Decrypting customer's cultural code"
Max Kunytsia, “Why is continuous product discovery better than continuous del...
Marcelino Moreno, "Product Management Mindset"
Andrii Pastushok, "Product Discovery in Outsourcing - What, When, and How"
Elena Turkenych “BA vs PM: Who' the right person, for the right job, with the...
Eleonora Budanova “BA+PM+DEV team: how to build the synergy”
Stoyan Atanasov “How crucial is the BA role in an IT Project"
Olexandra Kovalyova, "Equivalence Partitioning, Boundary Values ​​Analysis, C...
Yana Lysa — "Decision Tables, State-Transition testing, Pairwase Testing"
VOLVO x HACK SPRINT
Business digitalization trends and challenges
Дмитро Терещенко, "How to secure your application with Secure SDLC"
Яна Лиса, “Ефективні методи написання хороших мануальних тестових сценаріїв”
Тетяна Осетрова, “Модель зрілості розподіленної проектної команди”
Training solutions and content creation
False news - false truth: tips & tricks how to avoid them
Анна Бойко, "Хороший контракт vs очікування клієнтів. Що вбереже вас, якщо вд...
Дмитрий Лапшин, "The importance of TEX and Internal Quality. How explain and ...

Recently uploaded (20)

PPTX
Advanced SystemCare Ultimate Crack + Portable (2025)
PDF
How to Make Money in the Metaverse_ Top Strategies for Beginners.pdf
PDF
Ableton Live Suite for MacOS Crack Full Download (Latest 2025)
PDF
AI-Powered Threat Modeling: The Future of Cybersecurity by Arun Kumar Elengov...
PDF
Cost to Outsource Software Development in 2025
PPTX
Weekly report ppt - harsh dattuprasad patel.pptx
DOCX
Modern SharePoint Intranet Templates That Boost Employee Engagement in 2025.docx
PDF
EaseUS PDF Editor Pro 6.2.0.2 Crack with License Key 2025
PDF
iTop VPN Crack Latest Version Full Key 2025
PPTX
Why Generative AI is the Future of Content, Code & Creativity?
PPTX
Tech Workshop Escape Room Tech Workshop
DOCX
How to Use SharePoint as an ISO-Compliant Document Management System
PPTX
CNN LeNet5 Architecture: Neural Networks
PDF
How Tridens DevSecOps Ensures Compliance, Security, and Agility
PDF
Product Update: Alluxio AI 3.7 Now with Sub-Millisecond Latency
PDF
AI/ML Infra Meetup | Beyond S3's Basics: Architecting for AI-Native Data Access
PPTX
Computer Software - Technology and Livelihood Education
PDF
Designing Intelligence for the Shop Floor.pdf
PPTX
Introduction to Windows Operating System
PDF
Time Tracking Features That Teams and Organizations Actually Need
Advanced SystemCare Ultimate Crack + Portable (2025)
How to Make Money in the Metaverse_ Top Strategies for Beginners.pdf
Ableton Live Suite for MacOS Crack Full Download (Latest 2025)
AI-Powered Threat Modeling: The Future of Cybersecurity by Arun Kumar Elengov...
Cost to Outsource Software Development in 2025
Weekly report ppt - harsh dattuprasad patel.pptx
Modern SharePoint Intranet Templates That Boost Employee Engagement in 2025.docx
EaseUS PDF Editor Pro 6.2.0.2 Crack with License Key 2025
iTop VPN Crack Latest Version Full Key 2025
Why Generative AI is the Future of Content, Code & Creativity?
Tech Workshop Escape Room Tech Workshop
How to Use SharePoint as an ISO-Compliant Document Management System
CNN LeNet5 Architecture: Neural Networks
How Tridens DevSecOps Ensures Compliance, Security, and Agility
Product Update: Alluxio AI 3.7 Now with Sub-Millisecond Latency
AI/ML Infra Meetup | Beyond S3's Basics: Architecting for AI-Native Data Access
Computer Software - Technology and Livelihood Education
Designing Intelligence for the Shop Floor.pdf
Introduction to Windows Operating System
Time Tracking Features That Teams and Organizations Actually Need

Android App Architecture with modern libs in practice. Our way in R.I.D., Sergey Grechukha