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
81
Android Bootstrap
Best practices to start a new project
Faru
September 06, 2016
Tweet
Share
Other Decks in Technology
See All in Technology
AI前提のサービス運用ってなんだろう?
ryuichi1208
8
1.5k
SDNという名のデータプレーンプログラミングの歴史
ebiken
PRO
2
220
Android 15 でウィジェットピッカーのプレビュー画像をGlanceで魅せたい/nikkei-tech-talk-27-1
nikkei_engineer_recruiting
0
100
CDCL による厳密解法を採用した MILP ソルバー
imai448
3
340
DynamoDB でスロットリングが発生したとき_大盛りver/when_throttling_occurs_in_dynamodb_long
emiki
1
500
Amplify Gen2 Deep Dive / バックエンドの型をいかにしてフロントエンドへ伝えるか #TSKaigi #TSKaigiKansai #AWSAmplifyJP
tacck
PRO
0
420
セキュリティ運用って包括的にできていますか?SaaSを使って次のステップへ / Comprehensive Cyber Security Operations for Cloud Services Using SaaS
sakaitakeshi
0
160
Next.jsとNuxtが混在? iframeでなんとかする!
ypresto
2
1.5k
リンクアンドモチベーション ソフトウェアエンジニア向け紹介資料 / Introduction to Link and Motivation for Software Engineers
lmi
4
300k
Lambda10周年!Lambdaは何をもたらしたか
smt7174
2
140
EventHub Startup CTO of the year 2024 ピッチ資料
eventhub
0
130
強いチームと開発生産性
onk
PRO
38
12k
Featured
See All Featured
Agile that works and the tools we love
rasmusluckow
327
21k
The Pragmatic Product Professional
lauravandoore
31
6.3k
Testing 201, or: Great Expectations
jmmastey
38
7.1k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
329
21k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
0
150
Optimising Largest Contentful Paint
csswizardry
33
2.9k
RailsConf 2023
tenderlove
29
910
Fantastic passwords and where to find them - at NoRuKo
philnash
50
2.9k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
44
6.8k
4 Signs Your Business is Dying
shpigford
180
21k
Site-Speed That Sticks
csswizardry
0
44
Making the Leap to Tech Lead
cromwellryan
133
8.9k
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