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
KiroでGameDay開催してみよう(準備編)
yuuuuuuu168
1
120
Rethinking Incident Response: Context-Aware AI in Practice - Incident Buddy Edition -
rrreeeyyy
0
130
Goでマークダウンの独自記法を実装する
lag129
0
210
生成AI利用プログラミング:誰でもプログラムが書けると 世の中どうなる?/opencampus202508
okana2ki
0
190
Exadata Database Service on Dedicated Infrastructure セキュリティ、ネットワーク、および管理について
oracle4engineer
PRO
1
360
キャリアを支え組織力を高める「多層型ふりかえり」 / 20250821 Kazuki Mori
shift_evolve
PRO
2
280
EKS Pod Identity における推移的な session tags
z63d
1
200
第64回コンピュータビジョン勉強会@関東(後編)
tsukamotokenji
0
220
[kickflow]20250319_少人数チームでのAutify活用
otouhujej
0
200
メルカリIBIS:AIが拓く次世代インシデント対応
0gm
2
520
夢の印税生活 / Life on Royalties
tmtms
0
280
MySQL HeatWave:サービス概要のご紹介
oracle4engineer
PRO
4
1.7k
Featured
See All Featured
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
33
2.4k
A Tale of Four Properties
chriscoyier
160
23k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
26k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
49
3k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
161
15k
Scaling GitHub
holman
462
140k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
283
13k
Principles of Awesome APIs and How to Build Them.
keavy
126
17k
Building an army of robots
kneath
306
45k
A better future with KSS
kneath
239
17k
Docker and Python
trallard
45
3.5k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
32
1.4k
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