diff --git a/app/build.gradle b/app/build.gradle
index 59c4418..a9f0d49 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -8,7 +8,7 @@ android {
targetSdkVersion 28
versionCode 1
versionName "1.0"
- testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
+ testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
@@ -16,21 +16,64 @@ android {
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
+
+ compileOptions {
+ sourceCompatibility JavaVersion.VERSION_1_8
+ targetCompatibility JavaVersion.VERSION_1_8
+ }
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
- implementation 'com.android.support:appcompat-v7:28.0.0'
- implementation 'com.android.support.constraint:constraint-layout:1.1.3'
- implementation 'com.android.support:support-v4:28.0.0'
- testImplementation 'junit:junit:4.12'
- implementation 'de.hdodenhof:circleimageview:3.0.0'
+ implementation 'androidx.appcompat:appcompat:1.0.2'
+ implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
+ implementation 'com.google.android.material:material:1.0.0'
+
+ // Dependecias Archutecture components
+ // Room database
+ implementation "androidx.room:room-runtime:2.1.0"
+ implementation 'androidx.legacy:legacy-support-v4:1.0.0'
+ annotationProcessor "androidx.room:room-compiler:2.1.0"
+ implementation "androidx.room:room-rxjava2:2.1.0"
+
+ // ViewModel and LiveData
+ implementation "androidx.lifecycle:lifecycle-extensions:2.0.0"
+ implementation "androidx.lifecycle:lifecycle-common-java8:2.0.0"
+ implementation "androidx.lifecycle:lifecycle-reactivestreams:2.0.0"
+
+ /*############################ Gson: Json Converter ##########################*/
+ implementation "com.google.code.gson:gson:2.8.5"
- androidTestImplementation 'com.android.support.test:runner:1.0.2'
- androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
- implementation 'com.android.support:design:28.0.0'
- implementation 'com.android.support:recyclerview-v7:28.0.0'
- implementation 'com.android.support:cardview-v7:28.0.0'
+ /*########################### ReactiveX ######################################*/
+ implementation "io.reactivex.rxjava2:rxandroid:2.0.2"
+ implementation "io.reactivex.rxjava2:rxjava:2.1.9"
+ /*############################################################################*/
+ /*############################ Retrofit ######################################*/
+ implementation "com.squareup.retrofit2:adapter-rxjava2:2.3.0"
+ implementation "com.squareup.retrofit2:retrofit:2.4.0"
+ implementation "com.squareup.okhttp3:logging-interceptor:3.4.1"
+ // Facebook Sthetho
+ implementation "com.facebook.stetho:stetho:1.5.0"
+ implementation "com.facebook.stetho:stetho-okhttp3:1.5.0"
+ implementation "com.squareup.retrofit2:converter-gson:2.4.0"
+ /*############################################################################*/
+ implementation 'com.squareup.picasso:picasso:2.71828'
+
+ /*############################# REDES SOCIAIS ##################################*/
+ implementation 'com.google.android.gms:play-services-auth:17.0.0'
+ implementation 'com.facebook.android:facebook-android-sdk:[5,6)'
+
+ testImplementation 'junit:junit:4.12'
+ androidTestImplementation 'androidx.test:runner:1.2.0'
+ androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
+ implementation 'de.hdodenhof:circleimageview:3.0.0'
+
+ /*########################### FIRE BASE ################################*/
+ implementation 'com.google.firebase:firebase-core:17.0.1'
+ implementation 'com.google.firebase:firebase-auth:18.1.0'
+ implementation 'com.google.firebase:firebase-database:18.0.0'
}
+apply plugin: 'com.google.gms.google-services' // Google Play services Gradle plugin
+
diff --git a/app/google-services.json b/app/google-services.json
new file mode 100644
index 0000000..f5ba2b2
--- /dev/null
+++ b/app/google-services.json
@@ -0,0 +1,48 @@
+{
+ "project_info": {
+ "project_number": "981079449550",
+ "firebase_url": "https://dhnews-4c852.firebaseio.com",
+ "project_id": "dhnews-4c852",
+ "storage_bucket": "dhnews-4c852.appspot.com"
+ },
+ "client": [
+ {
+ "client_info": {
+ "mobilesdk_app_id": "1:981079449550:android:653cf61d23a7be21",
+ "android_client_info": {
+ "package_name": "br.com.dhnews"
+ }
+ },
+ "oauth_client": [
+ {
+ "client_id": "981079449550-4e5fo4k6lfn85iv2faqhqv431fvdd0hc.apps.googleusercontent.com",
+ "client_type": 1,
+ "android_info": {
+ "package_name": "br.com.dhnews",
+ "certificate_hash": "1b0640848fe97a8b39b4f28bdf31cbcd1ecd2cdf"
+ }
+ },
+ {
+ "client_id": "981079449550-4v0clknv22gpjt5b1roiltht80magor3.apps.googleusercontent.com",
+ "client_type": 3
+ }
+ ],
+ "api_key": [
+ {
+ "current_key": "AIzaSyC-IVM1cWS9Tnou_UbeqNnlFW4Kf9dQWTU"
+ }
+ ],
+ "services": {
+ "appinvite_service": {
+ "other_platform_oauth_client": [
+ {
+ "client_id": "981079449550-4v0clknv22gpjt5b1roiltht80magor3.apps.googleusercontent.com",
+ "client_type": 3
+ }
+ ]
+ }
+ }
+ }
+ ],
+ "configuration_version": "1"
+}
\ No newline at end of file
diff --git a/app/src/androidTest/java/br/com/dhnews/ExampleInstrumentedTest.java b/app/src/androidTest/java/br/com/dhnews/ExampleInstrumentedTest.java
index f32b42e..6e87e99 100644
--- a/app/src/androidTest/java/br/com/dhnews/ExampleInstrumentedTest.java
+++ b/app/src/androidTest/java/br/com/dhnews/ExampleInstrumentedTest.java
@@ -1,8 +1,8 @@
package br.com.dhnews;
import android.content.Context;
-import android.support.test.InstrumentationRegistry;
-import android.support.test.runner.AndroidJUnit4;
+import androidx.test.InstrumentationRegistry;
+import androidx.test.runner.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 3b10362..1f3d913 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -2,6 +2,9 @@
+
+
+
-
-
-
+
+
+
+
+
@@ -30,7 +35,7 @@
android:name="preloaded_fonts"
android:resource="@array/preloaded_fonts" />
-
+
\ No newline at end of file
diff --git a/app/src/main/ic_launcher-web.png b/app/src/main/ic_launcher-web.png
new file mode 100644
index 0000000..2342b49
Binary files /dev/null and b/app/src/main/ic_launcher-web.png differ
diff --git a/app/src/main/java/br/com/dhnews/adapters/NoticiasAdapter.java b/app/src/main/java/br/com/dhnews/adapters/NoticiasAdapter.java
deleted file mode 100644
index 145fae3..0000000
--- a/app/src/main/java/br/com/dhnews/adapters/NoticiasAdapter.java
+++ /dev/null
@@ -1,125 +0,0 @@
-package br.com.dhnews.adapters;
-
-import android.support.annotation.NonNull;
-import android.support.v4.content.ContextCompat;
-import android.support.v7.widget.RecyclerView;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.ImageView;
-import android.widget.TextView;
-
-import java.util.List;
-
-import br.com.dhnews.interfaces.RecyclerViewClickListener;
-import br.com.dhnews.R;
-import br.com.dhnews.model.Noticias;
-import br.com.dhnews.model.Usuario;
-
-
-public class NoticiasAdapter extends RecyclerView.Adapter {
-
- private List listaNoticias;
- private RecyclerViewClickListener listener;
- private Usuario usuario;
-
-
- public NoticiasAdapter(List listaNoticias, RecyclerViewClickListener listener) {
- this.listaNoticias = listaNoticias;
- this.listener = listener;
- }
-
- @NonNull
- @Override
- public ViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int position) {
-
- View view = LayoutInflater.from(viewGroup.getContext()).inflate
- (R.layout.layout_lista_item_noticias, viewGroup, false);
-
- return new ViewHolder(view);
- }
-
-
- @Override
- public void onBindViewHolder(@NonNull NoticiasAdapter.ViewHolder viewHolder, final int position) {
-
- final Noticias noticias = listaNoticias.get(position);
- viewHolder.setaNoticiasNaTela(noticias);
-
- //Click na imagem da noticia para chamar o detalhe da noticia
- viewHolder.imagemNoticias.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- listener.onClick(noticias);
- }
- });
-
- //Click no titulo da noticia para chamar o detalhe da noticia
- viewHolder.tituloNoticia.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- listener.onClick(noticias);
- }
- });
-
- //Click na descrição da noticia para chamar o detalhe da noticia
- viewHolder.descricaoNoticia.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- listener.onClick(noticias);
- }
- });
-
- viewHolder.imagemBookMarkListaNoticia.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
-
- Usuario usuarioLocal = new Usuario();
-
- if (usuario == null) {
- usuarioLocal.setEmailUsuario("teste");
- }
-
- listener.onClick(usuarioLocal);
- }
- });
- }
-
- @Override
- public int getItemCount() {
- return listaNoticias.size();
- }
-
-
- public class ViewHolder extends RecyclerView.ViewHolder {
- TextView tituloNoticia;
- TextView descricaoNoticia;
- TextView horaNoticia;
- TextView assuntoNoticia;
- ImageView imagemNoticias;
- ImageView imagemBookMarkListaNoticia;
-
- public ViewHolder(@NonNull View itemView) {
- super(itemView);
-
- tituloNoticia = itemView.findViewById(R.id.txtTitulo);
- descricaoNoticia = itemView.findViewById(R.id.txtDescricao);
- horaNoticia = itemView.findViewById(R.id.txtHora);
- assuntoNoticia = itemView.findViewById(R.id.txtAssunto);
- imagemNoticias = itemView.findViewById(R.id.iconeNoticia);
- imagemBookMarkListaNoticia = itemView.findViewById(R.id.imagemBookMarkListaNoticia);
- }
-
-
- //Atribui o as views os valores da variável contato
- public void setaNoticiasNaTela(Noticias noticias) {
-
- tituloNoticia.setText(noticias.getTituloNoticia());
- descricaoNoticia.setText(noticias.getDescricaoNoticia());
- horaNoticia.setText(noticias.getHoraNoticia());
- assuntoNoticia.setText(noticias.getAssuntoNoticia());
- imagemNoticias.setImageDrawable(ContextCompat.getDrawable(
- imagemNoticias.getContext(), noticias.getImagemNoticias()));
- }
- }
-}
\ No newline at end of file
diff --git a/app/src/main/java/br/com/dhnews/adapters/RecyclerViewLerDepoisAdapter.java b/app/src/main/java/br/com/dhnews/adapters/RecyclerViewLerDepoisAdapter.java
new file mode 100644
index 0000000..6de40bc
--- /dev/null
+++ b/app/src/main/java/br/com/dhnews/adapters/RecyclerViewLerDepoisAdapter.java
@@ -0,0 +1,125 @@
+package br.com.dhnews.adapters;
+
+import android.app.Activity;
+import android.content.Intent;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.ImageView;
+import android.widget.TextView;
+
+import androidx.annotation.NonNull;
+import androidx.core.app.ActivityOptionsCompat;
+import androidx.recyclerview.widget.RecyclerView;
+
+import com.squareup.picasso.Picasso;
+
+import java.util.List;
+
+import br.com.dhnews.R;
+import br.com.dhnews.interfaces.FavoriteItemClick;
+import br.com.dhnews.interfaces.RecyclerViewClickListener;
+import br.com.dhnews.model.noticias.Article;
+import br.com.dhnews.model.noticias.Noticias;
+import br.com.dhnews.model.noticias.Source;
+import br.com.dhnews.view.lerdepois.DetalheLerDepoisActivity;
+import br.com.dhnews.view.noticias.DetalheNoticiaActivity;
+
+import static br.com.dhnews.util.AppUtil.formatarData;
+
+public class RecyclerViewLerDepoisAdapter extends RecyclerView.Adapter {
+ private List listaNoticias;
+
+
+ public RecyclerViewLerDepoisAdapter(List listaNoticias) {
+ this.listaNoticias = listaNoticias;
+
+ }
+
+ @NonNull
+ @Override
+ public RecyclerViewLerDepoisAdapter.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
+ View view = LayoutInflater.from(parent.getContext()).inflate
+ (R.layout.item_ler_depois, parent, false);
+
+ return new ViewHolder(view);
+
+ }
+
+ @Override
+ public void onBindViewHolder(@NonNull RecyclerViewLerDepoisAdapter.ViewHolder viewHolder, int position) {
+ Article result = listaNoticias.get(position);
+ viewHolder.bind(result);
+
+ viewHolder.itemView.setOnClickListener(v -> {
+ String transitionName = "image_" + position;
+ Intent intent = new Intent(viewHolder.itemView.getContext(),
+ DetalheLerDepoisActivity.class);
+ intent.putExtra("NOTICIAS", result);
+ intent.putExtra("transitionName", transitionName);
+
+ viewHolder.imagemNoticias.setTransitionName(transitionName);
+
+ ActivityOptionsCompat options = ActivityOptionsCompat.
+ makeSceneTransitionAnimation((Activity) viewHolder.itemView.getContext(),
+ viewHolder.imagemNoticias, transitionName);
+
+ viewHolder.itemView.getContext().startActivity(intent, options.toBundle());
+ });
+ }
+
+ @Override
+ public int getItemCount() {
+ return listaNoticias.size();
+ }
+
+ public class ViewHolder extends RecyclerView.ViewHolder {
+ private TextView tituloNoticia;
+ private TextView descricaoNoticia;
+ private TextView horaNoticia;
+ private TextView categoriaNoticia;
+ private ImageView imagemNoticias;
+ private ImageView imagemBookMarkListaNoticia;
+
+ public ViewHolder(@NonNull View itemView) {
+ super(itemView);
+ tituloNoticia = itemView.findViewById(R.id.txtTitulo);
+ descricaoNoticia = itemView.findViewById(R.id.txtDescricao);
+ horaNoticia = itemView.findViewById(R.id.txtHora);
+ categoriaNoticia = itemView.findViewById(R.id.txtFonte);
+ imagemNoticias = itemView.findViewById(R.id.iconeNoticia);
+ imagemBookMarkListaNoticia = itemView.findViewById(R.id.imagemBookMarkListaNoticia);
+ }
+
+ public void bind(Article result) {
+
+
+ // Source autor = result.getSource();
+ // categoriaNoticia.setText(autor.getName());
+ tituloNoticia.setText(result.getTitle());
+ horaNoticia.setText(formatarData(result.getPublishedAt()));
+ descricaoNoticia.setText(result.getDescription());
+
+ if (result.getUrlToImage() != null) {
+
+ Picasso.get().setIndicatorsEnabled(true);
+ Picasso.get()
+ .load(result.getUrlToImage())
+ .error(R.mipmap.ic_launcher)
+ .placeholder(R.drawable.progress_animation)
+ .into(imagemNoticias);
+ }
+ }
+ }
+
+ public void update(List resultList) {
+ this.listaNoticias = resultList;
+ notifyDataSetChanged();
+
+ }
+
+ public void clear() {
+ this.listaNoticias.clear();
+ notifyDataSetChanged();
+ }
+}
diff --git a/app/src/main/java/br/com/dhnews/adapters/RecyclerViewNoticiasAdapter.java b/app/src/main/java/br/com/dhnews/adapters/RecyclerViewNoticiasAdapter.java
new file mode 100644
index 0000000..bb8b0b7
--- /dev/null
+++ b/app/src/main/java/br/com/dhnews/adapters/RecyclerViewNoticiasAdapter.java
@@ -0,0 +1,136 @@
+package br.com.dhnews.adapters;
+
+import android.app.Activity;
+import android.content.Intent;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.ImageView;
+import android.widget.TextView;
+
+import androidx.annotation.NonNull;
+import androidx.core.app.ActivityOptionsCompat;
+import androidx.recyclerview.widget.RecyclerView;
+
+import com.squareup.picasso.Picasso;
+
+import java.util.List;
+
+import br.com.dhnews.R;
+import br.com.dhnews.model.noticias.Article;
+import br.com.dhnews.model.noticias.Source;
+import br.com.dhnews.view.noticias.DetalheNoticiaActivity;
+
+import static br.com.dhnews.util.AppUtil.formatarData;
+
+
+public class RecyclerViewNoticiasAdapter extends RecyclerView.Adapter {
+
+ private List listaNoticias;
+
+
+ public RecyclerViewNoticiasAdapter(List listaNoticias) {
+ this.listaNoticias = listaNoticias;
+ }
+
+ @Override
+ public long getItemId(int position) {
+ return position;
+ }
+
+ @NonNull
+ @Override
+ public ViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int position) {
+ View view = LayoutInflater.from(viewGroup.getContext()).inflate
+ (R.layout.layout_lista_item_noticias, viewGroup, false);
+
+ return new ViewHolder(view);
+ }
+
+
+ @Override
+ public void onBindViewHolder(@NonNull ViewHolder viewHolder, int position) {
+ Article result = listaNoticias.get(position);
+ viewHolder.bind(result);
+
+ viewHolder.itemView.setOnClickListener(v -> {
+ String transitionName = "image_" + position;
+ Intent intent = new Intent(viewHolder.itemView.getContext(),
+ DetalheNoticiaActivity.class);
+ intent.putExtra("NOTICIAS", result);
+ intent.putExtra("transitionName", transitionName);
+
+ viewHolder.imagemNoticias.setTransitionName(transitionName);
+
+ ActivityOptionsCompat options = ActivityOptionsCompat.
+ makeSceneTransitionAnimation((Activity) viewHolder.itemView.getContext(),
+ viewHolder.imagemNoticias, transitionName);
+
+ viewHolder.itemView.getContext().startActivity(intent, options.toBundle());
+ });
+
+ }
+
+ @Override
+ public int getItemCount() {
+ return listaNoticias.size();
+ }
+ {
+ }
+
+
+ class ViewHolder extends RecyclerView.ViewHolder {
+
+ private TextView tituloNoticia;
+ private TextView descricaoNoticia;
+ private TextView horaNoticia;
+ private TextView categoriaNoticia;
+ private ImageView imagemNoticias;
+ private ImageView imagemBookMarkListaNoticia;
+
+ public ViewHolder(@NonNull View itemView) {
+ super(itemView);
+ tituloNoticia = itemView.findViewById(R.id.txtTitulo);
+ descricaoNoticia = itemView.findViewById(R.id.txtDescricao);
+ horaNoticia = itemView.findViewById(R.id.txtHora);
+ categoriaNoticia = itemView.findViewById(R.id.txtFonte);
+ imagemNoticias = itemView.findViewById(R.id.iconeNoticia);
+ imagemBookMarkListaNoticia = itemView.findViewById(R.id.imagemBookMarkListaNoticia);
+ }
+
+ public void bind(Article result) {
+
+
+ Source autor = result.getSource();
+ categoriaNoticia.setText(autor.getName());
+ tituloNoticia.setText(result.getTitle());
+ horaNoticia.setText(formatarData(result.getPublishedAt()));
+ descricaoNoticia.setText(result.getDescription());
+
+ if (result.getUrlToImage() != null) {
+
+ Picasso.get().setIndicatorsEnabled(true);
+ Picasso.get()
+ .load(result.getUrlToImage())
+ .error(R.mipmap.ic_launcher)
+ .placeholder(R.drawable.progress_animation)
+ .into(imagemNoticias);
+ }
+ }
+ }
+ public void update(List resultList) {
+ for (Article item: resultList) {
+ if(!this.listaNoticias.contains(item)){
+ this.listaNoticias.add(item);
+ }
+ }
+
+ notifyDataSetChanged();
+
+ }
+
+ public void clear(){
+ this.listaNoticias.clear();
+ notifyDataSetChanged();
+ }
+ }
diff --git a/app/src/main/java/br/com/dhnews/database/Converters.java b/app/src/main/java/br/com/dhnews/database/Converters.java
new file mode 100644
index 0000000..d6bdb1b
--- /dev/null
+++ b/app/src/main/java/br/com/dhnews/database/Converters.java
@@ -0,0 +1,38 @@
+package br.com.dhnews.database;
+
+import androidx.room.TypeConverter;
+
+import com.google.gson.Gson;
+import com.google.gson.reflect.TypeToken;
+
+import java.lang.reflect.Type;
+
+import br.com.dhnews.model.noticias.Source;
+
+public class Converters {
+ @TypeConverter
+ public Source fromSource(String value) {
+ Type listType = (Type) new TypeToken() {
+ }.getType();
+ return new Gson().fromJson(value, listType);
+ }
+
+ @TypeConverter
+ public String fromSource(Source list) {
+ Gson gson = new Gson();
+ return gson.toJson(list);
+ }
+
+ @TypeConverter
+ public Object fromObject(String value) {
+ Type listType = (Type) new TypeToken