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
Android Bootstrap
Search
Faru
September 06, 2016
Technology
0
84
Android Bootstrap
Best practices to start a new project
Faru
September 06, 2016
Tweet
Share
Other Decks in Technology
See All in Technology
現場の壁を乗り越えて、 「計装注入」が拓く オブザーバビリティ / Beyond the Field Barriers: Instrumentation Injection and the Future of Observability
aoto
PRO
1
750
20251029_Cursor Meetup Tokyo #02_MK_「あなたのAI、私のシェル」 - プロンプトインジェクションによるエージェントのハイジャック
mk0721
PRO
6
2.2k
어떤 개발자가 되고 싶은가?
arawn
1
350
Zero Trust DNS でより安全なインターネット アクセス
murachiakira
0
130
20251027_findyさん_音声エージェントLT
almondo_event
2
520
Azure Well-Architected Framework入門
tomokusaba
1
150
IBC 2025 動画技術関連レポート / IBC 2025 Report
cyberagentdevelopers
PRO
2
230
ソースを読む時の思考プロセスの例-MkDocs
sat
PRO
1
350
AWSが好きすぎて、41歳でエンジニアになり、AAIを経由してAWSパートナー企業に入った話
yama3133
2
220
GCASアップデート(202508-202510)
techniczna
0
210
ラスベガスの歩き方 2025年版(re:Invent 事前勉強会)
junjikoide
0
710
RemoteFunctionを使ったコロケーション
mkazutaka
1
170
Featured
See All Featured
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
359
30k
The MySQL Ecosystem @ GitHub 2015
samlambert
251
13k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
36
6.1k
Build The Right Thing And Hit Your Dates
maggiecrowley
38
2.9k
Java REST API Framework Comparison - PWX 2021
mraible
34
8.9k
[RailsConf 2023] Rails as a piece of cake
palkan
57
6k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
16k
Raft: Consensus for Rubyists
vanstee
140
7.2k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
26
3.1k
The Illustrated Children's Guide to Kubernetes
chrisshort
51
51k
Producing Creativity
orderedlist
PRO
348
40k
Automating Front-end Workflow
addyosmani
1371
200k
Transcript
Android Bootstrap Melhores práticas para iniciar um projeto sustentável Roberto
Junior github.com/robertojunior @vaifaru linkedin.com/in/roberto-junior
• Migrando de backend para mobile • Encarando um monstro
• E o Designer? • Escolhendo bem suas bibliotecas • Escolhendo padrão de projeto Agenda
• Bagagem profissional • Mudança de conceito • Desempenho •
E o Front-End? Migrando para Mobile
Encarando um monstro
• Regra de negócio na Activity • Dependências desatualizadas •
Bibliotecas pesadas e geração de código • Interface copiada do iOS O Monstro
E o Designer?
Material Design Sendo mais independente na parte visual https://material.google.com/
• Documentação https://material.google.com/ • Componentes https://github.com/wasabeef/awesome-android-ui • Icones https://design.google.com/icons/ https://materialdesignicons.com/
• Paleta de cores https://www.materialpalette.com/
Google não é Deus!?
Android != iOS
None
None
None
Escolhendo bibliotecas
ButterKnife Se preocupe com o que realmente importa http://jakewharton.github.io/butterknife/
Porque usar ButterKnife? • Elimine o findViewById usando @BindView nos
campos • Elimine classes anônimas internas para os Listeners anotando métodos com @OnClick e outros. • Elimine resources lookups usando as resource annotations nos campos
buildscript { repositories { mavenCentral() } dependencies { classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
} } Usando o ButterKnife Project-level build.gradle Module-level build.gradle apply plugin: 'android-apt' android { ... } dependencies { compile 'com.jakewharton:butterknife:8.4.0' apt 'com.jakewharton:butterknife-compiler:8.4.0' }
public class MainActivity extends AppCompatActivity { TextView name; Button button;
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); TextView name = (TextView) findViewById(R.id.name); Button button = (Button) findViewById(R.id.button); } } Bind de views sem ButterKnife
public class MainActivity extends AppCompatActivity { @BindView(R.id.name) TextView name; @BindView(R.id.button)
Button button; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); ButterKnife.bind(this); } } Bind de views com ButterKnife
public class MainActivity extends AppCompatActivity { TextView name; Button button;
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); TextView name = (TextView) findViewById(R.id.name); Button button = (Button) findViewById(R.id.button); button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // ... } }); } } OnClickListener sem ButterKnife
public class MainActivity extends AppCompatActivity { @BindView(R.id.name) TextView name; @BindView(R.id.button)
Button button; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); } @OnClick(R.id.button) public void onClickButton() { // ... } } OnClickListener com ButterKnife
Retrofit Integrando sua aplicação com o backend através de serviços
REST http://square.github.io/retrofit/
Usando o Retrofit Module-level build.gradle dependencies { compile ‘com.squareup.retrofit2:retrofit:2.1.0' }
Permissão AndroidManifest.xml <uses-permission android:name="android.permission.INTERNET" />
public interface BeerService { @GET("beers") Call<List<Beer>> getBeers(); @GET("beers/{beerId}") Call<Beer> getBeer(@Path("beerId")
Long beerId); @GET("beers/random") Call<Beer> getRandomBeer(); } Transformando sua HTTP API em uma Interface
Retrofit retrofit = new Retrofit.Builder() .baseUrl("https://api.brewerydb.com/v2/") .addConverterFactory(GsonConverterFactory.create()) .build(); BeerService service
= retrofit.create(BeerService.class); Call<List<Beer>> callBeers = service.getBeers(); callBeers.enqueue(new Callback<List<Beer>>() { @Override public void onResponse(Call<List<Beer>> call, Response<List<Beer>> response) { if (response.isSuccessful()) { // ... } } @Override public void onFailure(Call<List<Beer>> call, Throwable t) { // ... } }); Retrofit cria uma implementação de BeerService
OkHttpClient.Builder httpClient = new OkHttpClient.Builder(); httpClient.addInterceptor(new Interceptor() { @Override public
okhttp3.Response intercept(Chain chain) throws IOException { final Request original = chain.request(); final Request.Builder requestBuilder = original.newBuilder() .url(original.url() + “&key=YOUR_KEY”) .method(original.method(), original.body()); final Request request = requestBuilder.build(); return chain.proceed(request); } }); retrofit = new Retrofit.Builder() .baseUrl("http://api.brewerydb.com/v2/") .addConverterFactory(GsonConverterFactory.create()) .client(httpClient.build()) .build(); Interceptor
Dagger Um pouco de DI e IOC https://github.com/google/dagger
Fresco Deixa pra quem sabe frescolib.org
Padrões de projeto
• MVC? • MVP • Clean Architecture • Nem tudo
é perfeito!
Obrigado! =) Roberto Junior github.com/robertojunior @vaifaru linkedin.com/in/roberto-junior