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
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
Faru
September 06, 2016
Technology
88
0
Share
Android Bootstrap
Best practices to start a new project
Faru
September 06, 2016
Other Decks in Technology
See All in Technology
oracle-to-databricks-migration-with-llm-and-dbt
casek
0
160
Geek Woman の育ち方 〜コミュニティとAIと〜
chicaco
0
420
Agentic AI時代における メルカリのAIガバナンスとガードレール実装
naoichihara
15
15k
なぜハノーバーメッセに行くべきなのか 〜初参加だから語れること〜
tanakaseiya
0
120
Python開発環境にハーネス適用を検討する
yuuka51
1
520
A Harness for Behaviour: how to get AI to generate code that does what we intend, or "TDD in the age of AI"
xpmatteo
0
430
NFLコンペ2026 解法
lycorptech_jp
PRO
0
110
Gradle×GitHub_ActionsでCI時間を約50%短縮 ジョブ分割の設計と落とし穴 / Cutting CI Time by ~50% with Gradle and GitHub Actions: Job-Splitting Design and Pitfalls
takatty
0
160
データ分析基盤の信頼を支える視点と設計
yuki_saito
1
690
【ハノーバーメッセ振り返りイベントat名古屋】データは集約からAI起点の収集に ~組織内・組織間でのデータ連携~
tanakaseiya
0
120
Copilot CLI・IDE・Web・スマホで途切れない開発フローを目指して / One Copilot flow - CLI IDE Web Mobile
aeonpeople
1
1k
DI コンテナ自動生成ツールを実装してみた / intro-autodi
uhzz
0
870
Featured
See All Featured
The Cost Of JavaScript in 2023
addyosmani
55
9.9k
First, design no harm
axbom
PRO
2
1.2k
How Software Deployment tools have changed in the past 20 years
geshan
0
34k
Leadership Guide Workshop - DevTernity 2021
reverentgeek
1
290
ラッコキーワード サービス紹介資料
rakko
1
3.4M
The SEO Collaboration Effect
kristinabergwall1
1
460
Lightning Talk: Beautiful Slides for Beginners
inesmontani
PRO
1
550
The Anti-SEO Checklist Checklist. Pubcon Cyber Week
ryanjones
0
140
What does AI have to do with Human Rights?
axbom
PRO
1
2.2k
Git: the NoSQL Database
bkeepers
PRO
432
67k
A Soul's Torment
seathinner
6
2.8k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
360
30k
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