Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Desafio Android - Completo #36

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
*.iml
.gradle
/local.properties
/.idea/caches
/.idea/libraries
/.idea/modules.xml
/.idea/workspace.xml
/.idea/navEditor.xml
/.idea/assetWizardSettings.xml
.DS_Store
/build
/captures
.externalNativeBuild
.cxx
local.properties
3 changes: 3 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions .idea/.name

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 30 additions & 0 deletions .idea/jarRepositories.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions .idea/runConfigurations.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 20 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,51 +12,51 @@ http://docs.starwarsfavorites.apiary.io/#

### Lista de Personagens

Para obter os personagens, sua aplicação deverá utilizar o recurso `people` da Swapi (documentação disponível no topo do documento). A aplicação deve exibir todos os 87 personagens e permitir pesquisar o personagem pelo nome. Sugerimos exibir as primeiras páginas enquanto carrega as outras, em um formato de scroll infinito.
Para obter os personagens, sua aplicação deverá utilizar o recurso `people` da Swapi (documentação disponível no topo do documento). A aplicação deve exibir todos os 87 personagens✔️ e permitir pesquisar o personagem pelo nome✔️. Sugerimos exibir as primeiras páginas enquanto carrega as outras, em um formato de scroll infinito✔️.

A lista de itens deve exibir as seguintes informações:
A lista de itens deve exibir as seguintes informações:✔️
+ Nome [name]
+ Altura [height]
+ Genero [gender]
+ Peso [mass]

Os dados devem ser salvos em banco de dados local para acesso offline e atualizados sempre que a tela for aberta.
Os dados devem ser salvos em banco de dados local para acesso offline e atualizados sempre que a tela for aberta.✔️

### Detalhes do Personagem

Ao clicar em um item da lista o seu app deve mostrar as informações abaixo:

+ name
+ height
+ mass
+ hair_color
+ skin_color
+ eye_color
+ birth_year
+ gender
+ Nome do Planeta Natal
+ name✔️
+ height✔️
+ mass ✔️
+ hair_color✔️
+ skin_color✔️
+ eye_color✔️
+ birth_year✔️
+ gender✔️
+ Nome do Planeta Natal ✔️
+ Nome da Espécie

A busca pelo nome do planeta e da espécie deve ser feita em paralelo.
A busca pelo nome do planeta✔️ e da espécie deve ser feita em paralelo.

### Favoritos

Na lista e nos detalhes deve ser possível adicionar e remover um personagem a sua lista de favoritos. Tambem deve ser possível filtrar quais personagens foram favoritados na lista principal.
Na lista e nos detalhes deve ser possível adicionar e remover um personagem a sua lista de favoritos✔️. Tambem deve ser possível filtrar quais personagens foram favoritados na lista principal✔️.

##### Adição e Remoção de Favoritos

URL BASE: http://private-782d3-starwarsfavorites.apiary-mock.com/

Ao adicionar um favorito a aplicação deve fazer um request para a api starwarsfavorites (documentação disponível no topo do documento).
Ao adicionar um favorito a aplicação deve fazer um request para a starWars starwarsfavorites✔️ (documentação disponível no topo do documento).
A aplicação deve:
+ Exibir a mensagem de retorno da API em caso de sucesso ou erro.
+ Exibir a mensagem de retorno da API em caso de sucesso ou erro.✔️
+ Reenviar a requisição da próxima vez que o app for aberto em caso de erro.
+ Salvar no banco de dados local quais personagens foram favoritados.
+ Tratar a remoção de favoritos apenas no banco de dados local.
+ Salvar no banco de dados local quais personagens foram favoritados.✔️
+ Tratar a remoção de favoritos apenas no banco de dados local.✔️

Em metade das requisições enviadas para a api starwarsfavorites a aplicação deve adicionar o header `Prefer` com o valor `status=400`.
Em metade das requisições enviadas para a starWars starwarsfavorites a aplicação deve adicionar o header `Prefer` com o valor `status=400`.

P.S.: O candidato deve escolher o ID.
P.S.: O candidato deve escolher o ID.✔️

---
#### LICENSE
Expand Down
1 change: 1 addition & 0 deletions app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
48 changes: 48 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
plugins {
id 'com.android.application'
}

android {
compileSdkVersion 30
buildToolsVersion "30.0.3"

defaultConfig {
applicationId "br.com.star_wars_wiki"
minSdkVersion 16
targetSdkVersion 30
versionCode 1
versionName "1.0"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}

dependencies {

implementation 'androidx.appcompat:appcompat:1.3.0'
implementation 'com.google.android.material:material:1.3.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation 'androidx.room:room-runtime:2.2.5'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
annotationProcessor 'androidx.room:room-compiler:2.2.5'

implementation 'com.squareup.retrofit:retrofit:1.8.0'
implementation 'com.squareup.okhttp:okhttp:2.1.0'
implementation 'com.squareup.okhttp:okhttp-urlconnection:2.1.0'

//Dependência para material search view
implementation 'com.miguelcatalan:materialsearchview:1.4.0'
}
21 changes: 21 additions & 0 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package br.com.star_wars_wiki;

import android.content.Context;

import androidx.test.platform.app.InstrumentationRegistry;
import androidx.test.ext.junit.runners.AndroidJUnit4;

import org.junit.Test;
import org.junit.runner.RunWith;

import static org.junit.Assert.*;

/**
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
assertEquals("br.com.star_wars_wiki", appContext.getPackageName());
}
}
26 changes: 26 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="br.com.star_wars_wiki">

<uses-permission android:name="android.permission.INTERNET" />

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.Starwarswiki">
<activity android:name=".ActPersonagem"></activity>
<activity android:name=".ActFavorito" />
<activity android:name=".ActListaPersonagem" />
<activity android:name=".ActHome">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>

</manifest>
Binary file added app/src/main/ic_chew-playstore.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/ic_darth-playstore.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/ic_favoritos-playstore.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/ic_personagens-playstore.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
64 changes: 64 additions & 0 deletions app/src/main/java/br/com/star_wars_wiki/ActFavorito.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
package br.com.star_wars_wiki;

import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import androidx.lifecycle.Observer;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import android.os.Bundle;
import android.view.View;
import android.widget.ProgressBar;

import java.util.List;

import br.com.star_wars_wiki.adapter.FavoriteAdapter;
import br.com.star_wars_wiki.entity.Favorite;
import br.com.star_wars_wiki.view_model.FavoriteViewModel;

public class ActFavorito extends AppCompatActivity {

private ProgressBar progressBarFavorito;
private RecyclerView recyclerFavoritos;
private FavoriteViewModel favoriteViewModel;
private FavoriteAdapter favoriteAdapter;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.act_favoritos);

Toolbar toolbar = findViewById(R.id.toolbar_simples);
toolbar.setTitle(R.string.act_favoritos);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setDisplayShowHomeEnabled(true);

progressBarFavorito = findViewById(R.id.progress_bar_favorite);
recyclerFavoritos = findViewById(R.id.recycler_favoritos);

RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(getApplicationContext());
recyclerFavoritos.setLayoutManager(layoutManager);

recyclerFavoritos.setVisibility(View.GONE);

favoriteViewModel = new FavoriteViewModel(getApplication());
favoriteViewModel.getAllFavorites().observe(this, new Observer<List<Favorite>>() {
@Override
public void onChanged(List<Favorite> favorites) {
progressBarFavorito.setVisibility(View.GONE);
recyclerFavoritos.setVisibility(View.VISIBLE);

favoriteAdapter = new FavoriteAdapter(favorites);
recyclerFavoritos.setAdapter(favoriteAdapter);
}
});

}

@Override
public boolean onSupportNavigateUp() {
onBackPressed();
return true;
}
}
Loading