intervalo técnico - qg mobile
TRANSCRIPT
QG - Mobile Desafios e Soluções
• Massilon Gomes • Tadeu Marinho • Vitor Albuquerque
• Alex Batista • Daniel Herszenhorn • Felipe J. Martins • Jader Alcântara • Marcely Santos
Proposta e A&P
Massilon Gomes
Proposta e A&P
• Cliente: Queiroz Galvão; • Escopo:
• Apontamento Eletrônico (App Android); • Baixa de Eventos App (App Android); • Dashboard (JEE7 e Wildfly);
• Duração: 17 semanas; • Equipe: Gerente de Projetos, Analista de Negócios,
Designer, Arquiteto, 4 Desenvolvedores.
Proposta e A&P
Planejamento Concepção
Sprints
Design Definição
Webservices
Arquitetura
e BD
Teste Formal Homologação
5 semanas (Apontamento, Baixa de Eventos e Dashboard)
• Planejamento na proposta:
Proposta e A&P
Planejamento Concepção Design Definição
Webservices
Arquitetura
e BD
6 semanas (Apontamento e Dashboard)
• O que de fato aconteceu:
• Cronograma;
• Riscos;
• ...
• Levantamento de
informações;
• Definição das estórias.
• Wireframe;
• Construção das telas.
Proposta e A&P
• O que fizemos diferente: • 5 semanas de Analista, Arquiteto e Designer fulltime; • 1 semana no cliente pra levantamento de informações
(GP, Analista, Arquiteto e Designer); • Foco na estabilização dos requisitos; • Foco na definição da Arquitetura da solução; • Foco no Wireframe da aplicação.
Proposta e A&P
• O que ganhamos: • Maior produtividade no desenvolvimento; • Mais confiança nas decisões sobre a arquitetura da
solução; • Melhor entendimento da necessidade do cliente,
incluindo a usabilidade do aplicativo na obra; • Melhor relacionamento com o cliente.
O Negócio
Marcely Santos
O Negócio
• Apontamento Eletrônico: • Permitir o apontamento eletrônico das tarefas executadas
no canteiro de obras através de um Smartphone e/ou Tablet Android.
O Negócio
• Dashboard:
O Negócio
• Baixa de Eventos: • Será responsável pela baixa dos eventos executados na
obra através de um Smartphone e/ou Tablet Android.
UI Experience
Alex Batista
UI Experience
• Processo de UX; • Métodos utilizados; • Wireframe; • Design;
UI Experience
• Processo de UX:
UI Experience
• Métodos: • Entrevista com o usuário; • Cenários; • Personas; • Análise da Tarefa;
UI Experience
• Métodos: • Entrevista com o usuário; • Cenários; • Personas; • Análise da Tarefa;
UI Experience
• Wireframe; • Design;
Contextualização
Tadeu Marinho
Contextualização
Contextualização
REST Client
Tadeu Marinho
REST Client
Fonte: http://stackoverflow.com/questions/16902716/comparison-of-android-networking-libraries-okhttp-retrofit-volley
Retrofit
Tadeu Marinho
Retrofit
• API utilizada como alternativa simples, rápida e eficiente em desenvolvimento da camada de comunicação de aplicações que utilizem padrão REST.
TW Technology Radar Jan 2015
Retrofit
• Web Client
Retrofit
• E tem mais ...
Retrofit
• E tem mais ...
More... http://square.github.io/retrofit/
http://assets.thoughtworks.com/assets/technology-radar-jan-2015-pt.pdf http://instructure.github.io/blog/2013/12/09/volley-vs-retrofit/
http://stackoverflow.com/questions/16902716/comparison-of-android-networking-libraries-okhttp-retrofit-volley
Retrofit
SQLite
Tadeu Marinho
SQLite
• SQLite is a software library that implements a self-contained, serverless, zero-configuration, transactional SQL database engine;
• The source code for SQLite is in the public domain; • Development and maintenance of SQLite is sponsored in
part by SQLite Consortium members, including:
A world leader in financial-information technology.
Comprehensive software solutions for Sustaining
Infrastructure.
Working to preserve choice and innovation on
the internet.
SQLite
• SQL Ansi (PRAGMA foreign_keys=ON)
SQLite
• Performance inserts:
private void insertOneHundredRecords() {
for (int i = 0; i<100; i++) {
ContentValues values = new ContentValues();
values.put("FirstNumber", i);
values.put("SecondNumber", i);
values.put("Result", i*i);
sampleDB.insert(SAMPLE_TABLE_NAME,null,values);
}
} 1627ms
SQLite
• Bulk insertion:
private void bulkInsertOneHundredRecords() {
String sql = "INSERT INTO " + SAMPLE_TABLE_NAME + " VALUES (?,?,?);";
SQLiteStatement statement = sampleDB.compileStatement(sql);
sampleDB.beginTransaction();
for (int i = 0; i < 100; i++) {
statement.clearBindings();
statement.bindLong(1, i);
statement.bindLong(2, i);
statement.bindLong(3, i * i);
statement.execute();
}
sampleDB.setTransactionSuccessful();
sampleDB.endTransaction();
} 92ms
More... https://www.sqlite.org
https://www.sqlite.org/pragma.html#pragma_defer_foreign_keys http://www.techrepublic.com/blog/software-engineer/ turbocharge
-your-sqlite-inserts-on-android/
SQLite
MVP
Felipe J. Martins
MVC (Model – Controller - View)
Controller
View Model
S
S = State of the UI
L = UI logic
Acronyms:
L
MVP (Model – Presenter - View)
View
(XML)
Activity
S L
Exception Handler!
Model
Life Cycle!
Event Handler!
Acronyms: S = State of the UI
L = UI logic
Acronyms:
View
(Class)
MVP (Model – Presenter - View)
Activity
S
L
Model
View
(XML)
Android API
Exception Handler!
Life Cycle!
Event Handler!
S = State of the UI
L = UI logic
Acronyms:
Presenter View
(Class)
MVP (Model – Presenter - View)
Activity
S L
Model View
(XML)
Android API
Exception Handler!
Life Cycle!
Event Handler!
S = State of the UI
L = UI logic
Acronyms:
Activity
Presenter
View Model
MVP (Android)
Butter Knife View "injection" library for Android
Felipe J. Martins
Butter Knife Field and method binding for Android views which uses annotation processing to generate boilerplate code for you.
• Eliminate findViewById calls by using @InjectView on fields.
• Eliminate anonymous inner-classes for listeners by annotating methods with @OnClick and others.
TextView textView1;
textView1 = (TextView) v.findViewById(R.id.textView1);
Toast.makeText(this,textView1.getText(),Toast.LENGTH_SHORT).show();
<TextView
android:id=”@+id/textView1”
android:layout_width=”wrap_content”
android:height=”wrap_content”
android:text=”@string/helloWorld” />
Xml
Java
Butter Knife
fab = (FloatingActionButton) v.findViewById(R.id.fab);
totalLayout = (LinearLayout) v.findViewById(R.id.totalLayout);
historicoLayout = (LinearLayout) v.findViewById(R.id.historicoLayout);
eventosListView = (ListView) v.findViewById(R.id.eventosListView);
eventoAtualTextView = (TextView) v.findViewById(R.id.eventoAtualTextView);
comecarTempo = (ImageView) v.findViewById(R.id.comecarTempo);
totalHoras = (TextView) v.findViewById(R.id.totalHoras);
terminoHora = (EditText) v.findViewById(R.id.terminoHora);
inicioHora = (EditText) v.findViewById(R.id.inicioHora);
nomeEquipamentoText = (TextView) v.findViewById(R.id.nomeEquipamentoText);
fotoEquipamento = (ImageView) v.findViewById(R.id.fotoEquipamento);
Java Boilerplate code
Butter Knife
@InjectView(R.id.footer)
TextView footer;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.simple_activity);
ButterKnife.inject(this);
// TODO Use "injected" views...
}
@InjectView
Eliminate findViewById calls by using @InjectView on fields.
Butter Knife
@OnClick(R.id.submit)
public void submit(View view) {
// TODO submit data to server...
}
@OnClick
public void submit() {
Button submitBtn = (Button) findViewById(R.id.submit);
submitBtn.setOnClickListener(new View.OnClickListener() {
});
// TODO submit data to server...
}
Boilerplate code
Butter Knife
More... https://github.com/JakeWharton/butterknife
Butter Knife
Vitor Albuquerque
Envio em Background
Envio em Background
• Rodar em background; • Enviar apontamentos ao detectar conexão com a
internet; • Enviar os apontamentos esporadicamente (a cada
15 minutos); • Atualizar menu de Enviar Apontamentos após envio
ou falha;
Vitor Albuquerque
Intent Service
Intent Service
• Criando um serviço:
Intent Service
• Chamando um serviço:
Vitor Albuquerque
AlarmManager
AlarmManager
• Criando um alarme:
AlarmManager
• Boas práticas: • Não rodar em horário fixo (ex.: Todos os dias às
12h); • Não acordar o aparelho desnecessariamente; • Evitar criar alarmes baseados em tempos fixos; • Evitar alarmes de alta precisão; • Fazer o SO gerenciar os alarmes;
Vitor Albuquerque
EventBus Android optimized publish/subscribe event bus
EventBus
• Como funciona:
EventBus
• Le código:
EventBus
• Le código:
EventBus • Escutando eventos de serviços background (antes)
EventBus • Resultado da sincronia para a Activity (antes)
EventBus
• Vocês agora:
EventBus • Escutando eventos de serviços background
(EventBus)
EventBus • Escutando eventos de serviços background
(EventBus)
EventBus
Saiba mais... https://github.com/greenrobot/EventBus
Jader Alcântara
NFC Near Field Connection
Características
• Tecnologia wireless de curta distância (4cm) • Reader/writer mode
• P2P mode (Android Bean) • Card emulation mode
Utilização no QG
• Processo sem NFC
Utilização no QG
• Processo com NFC
Saiba mais... http://nfc-forum.org/
ZXing Zebra Crossing
Jader Alcântara
ZXing no QG
public static void irParaLeitorQrCodeBarras(Fragment fragment) {
IntentIntegrator intentIntegrator = IntentIntegrator.forSupportFragment(fragment);
intentIntegrator.setPrompt(fragment.getString(R.string.aponte_qrcode));
intentIntegrator.setOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
intentIntegrator.initiateScan();
}
Java
Saiba mais... https://github.com/zxing/zxing
Dashboard
Daniel Herszenhorn
Características
• WildFly; • Maven; • JEE7; • JSF + Primefaces; • WebSocket;
Considerações Finais
Tadeu Marinho
Dúvidas?