Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
ecarrara-araujo committed Sep 13, 2017
2 parents 6cf7612 + 6684b48 commit 7058e7e
Show file tree
Hide file tree
Showing 133 changed files with 4,010 additions and 472 deletions.
88 changes: 74 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,86 @@
Popular Movies
====================================================
# Popular Movies

Concept app to fetch and list popular movies from
The Movie DB api (www.themoviedb.org).
Concept app to fetch and list popular movies from The Movie DB api (www.themoviedb.org).

Basic Instructions
===================================================
This application was created to exercise a few concepts regarding Android Development.

To start developing you should get and api key at
www.themoviedb.org.
If you just want to give it a try download the test apk [here](https://drive.google.com/file/d/0BxuNaEVyDit0d0wzcFZ0M2VqR0E/view?usp=sharing).

With the key in hands create app/secrets.properties
file. It is a key/value pairs based file and you
must add keys for Debug and Release versions using
the following entries:
## Table of Contents
* [Showcase](#showcase)
* [Feature List](#features)
* [Tools and Libs](#tools)
* [TODOs](#todos)
* [Basic Instructions](#instructions)

<a name="showcase"></a>
## Showcase

<p align="center">
<img src="screenshots/my_movies_recording.gif" align="center" width=200>
<img src="screenshots/mymovies_01.png" align="center" width=200>
<img src="screenshots/mymovies_02.png" align="center" width=200>
<img src="screenshots/mymovies_03.png" align="center" width=200>
<img src="screenshots/mymovies_04.png" align="center" width=200>
<img src="screenshots/mymovies_05.png" align="center" width=200>
<img src="screenshots/mymovies_06.png" align="center" width=400>
</p>

<a name="features"></a>
## Feature List

* List Top Rated and Most Popular Movies from The Movie DB Api.
* Display the Movie Details for a selected Movie.
* Allow the user to add movies to favorites.
* Allow user to watch trailers.
* Allow user to share trailers.
* Allow user to read reviews.
* List user's favorites.
* List favorite movie details.
* Offline support for favorite movies.
* Landscape layout for movie details.

<a name="tools"></a>
## Tools and Libs

* RxJava2
* ReactiveNetwork
* Retrofit2
* Picasso
* Gson
* AutoValues
* Butterknife
* Dagger2
* Android Support Libs:
* RecyclerView
* CardView
* Design Support Library
* ConstraintLayout
* Vector Drawables

<a name="todos"/></a>
## ToDos

* Improve error messages displayed to the user.
* Unit and Instrumented Tests.
* Animations

<a name="instructions"></a>
## Basic Instructions

To start developing you should get and api key at www.themoviedb.org.

With the key in hands create app/secrets.properties file. It is a key/value pairs based file and you
must add keys for Debug and Release versions using the following entries:

```
DEBUG_THE_MOVIE_DB_API_KEY=YOUR_KEY_HERE
RELEASE_THE_MOVIE_DB_API_KEY=YOUR_KEY_HERE
```

You can use the same key for both entries.

The entries will be available in the BuildConfig
generated class.
The entries will be available in the BuildConfig generated class.



33 changes: 25 additions & 8 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,20 @@ projectProperties.load(new FileInputStream(new File(projectDir, '/secrets.proper

final String THE_MOVIE_DB_API_KEY_NAME = "THE_MOVIE_DB_API_KEY"

ext {
ANDROID_SUPPORT_LIBS_VERSION = '26.0.1'
DAGGER_VERSION = '2.10'
}

android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
compileSdkVersion 26
buildToolsVersion ANDROID_SUPPORT_LIBS_VERSION
defaultConfig {
applicationId "br.com.ecarrara.popularmovies"
minSdkVersion 19
targetSdkVersion 25
versionCode 1
versionName "1.0"
targetSdkVersion 26
versionCode 2
versionName "1.1"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
Expand All @@ -47,8 +52,11 @@ dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')

// Android Support Libraries
compile 'com.android.support:appcompat-v7:25.1.0'
compile 'com.android.support:recyclerview-v7:25.1.0'
compile "com.android.support:appcompat-v7:${ANDROID_SUPPORT_LIBS_VERSION}"
compile "com.android.support:recyclerview-v7:${ANDROID_SUPPORT_LIBS_VERSION}"
compile "com.android.support:cardview-v7:${ANDROID_SUPPORT_LIBS_VERSION}"
compile "com.android.support:design:${ANDROID_SUPPORT_LIBS_VERSION}"
compile 'com.android.support.constraint:constraint-layout:1.0.2'

// Networking Libs
compile 'com.google.code.gson:gson:2.8.0'
Expand All @@ -60,15 +68,24 @@ dependencies {
compile 'com.squareup.picasso:picasso:2.5.2'

// Reactive Libs
compile 'io.reactivex.rxjava2:rxjava:2.0.4'
compile 'io.reactivex.rxjava2:rxjava:2.1.3'
compile 'io.reactivex.rxjava2:rxandroid:2.0.1'
compile 'com.jakewharton.retrofit:retrofit2-rxjava2-adapter:1.0.0'
compile 'com.github.pwittchen:reactivenetwork-rx2:0.12.1'

// Auto Values
annotationProcessor 'com.google.auto.value:auto-value:1.2-rc1'
annotationProcessor 'com.ryanharter.auto.value:auto-value-gson:0.4.5'
provided 'com.ryanharter.auto.value:auto-value-gson:0.4.5'

// Dependency Injection
compile 'com.jakewharton:butterknife:8.5.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.5.1'

compile "com.google.dagger:dagger:${DAGGER_VERSION}"
annotationProcessor "com.google.dagger:dagger-compiler:${DAGGER_VERSION}"


// Test Dependencies
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
Expand Down
2 changes: 1 addition & 1 deletion app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# By default, the flags in this file are appended to flags specified
# in /home/ecarrara/tools/android/sdk/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
# directive in buildPosterUrl.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
Expand Down
12 changes: 11 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,29 @@
<uses-permission android:name="android.permission.INTERNET" />

<application
android:name=".core.MyPopularMoviesApplication"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">

<provider
android:name=".favorites.data.datasource.contentprovider.FavoritesProvider"
android:authorities="br.com.ecarrara.popularmovies"
android:enabled="true"
android:exported="false" />

<activity android:name=".movies.presentation.view.MovieListActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".movies.presentation.view.MovieDetailActivity"></activity>

<activity android:name=".movies.presentation.view.MovieDetailActivity"
android:parentActivityName=".movies.presentation.view.MovieListActivity"/>
</application>

</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package br.com.ecarrara.popularmovies.core;

import android.app.Application;

import br.com.ecarrara.popularmovies.core.di.Injector;

public class MyPopularMoviesApplication extends Application {

@Override
public void onCreate() {
super.onCreate();
Injector.initialize(this);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package br.com.ecarrara.popularmovies.core.data.datasource.contentprovider;

import android.net.Uri;

public final class ContentProviderContract {

private ContentProviderContract() { /* Must not be instantiated */ }

public static final String CONTENT_AUTHORITY = "br.com.ecarrara.popularmovies";
public static final Uri BASE_CONTENT_URI = Uri.parse("content://" + CONTENT_AUTHORITY);

public static final String DATE_FORMAT = "yyyy-MM-dd";

public static final long ENTRY_NOT_PERSISTED_ID = -1L;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package br.com.ecarrara.popularmovies.core.data.datasource.sqlite;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

import br.com.ecarrara.popularmovies.favorites.data.datasource.contentprovider.FavoritesContract;

public class SqliteDatabaseHelper extends SQLiteOpenHelper {

private static final String DATABASE_NAME = "mypopularmovies.db";
private static final int DATABASE_VERSION = 1;

public SqliteDatabaseHelper(Context context) {
super(context, DATABASE_NAME, null, DATABASE_VERSION);
}

@Override
public void onCreate(SQLiteDatabase db) {
db.execSQL(FavoritesContract.FavoriteMovieEntry.SQL_CREATE_FAVORITE_MOVIE_TABLE);
db.execSQL(FavoritesContract.FavoriteEntry.SQL_CREATE_FAVORITE_TABLE);
}

@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
/* Do Nothing for this version */
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package br.com.ecarrara.popularmovies.core.di;

import javax.inject.Singleton;

import br.com.ecarrara.popularmovies.core.networking.di.NetworkingModule;
import br.com.ecarrara.popularmovies.favorites.di.FavoritesModule;
import br.com.ecarrara.popularmovies.movies.di.MoviesModule;
import br.com.ecarrara.popularmovies.movies.presentation.view.MovieDetailActivity;
import br.com.ecarrara.popularmovies.movies.presentation.view.MovieListActivity;
import br.com.ecarrara.popularmovies.reviews.di.ReviewsModule;
import br.com.ecarrara.popularmovies.reviews.presentation.view.MovieReviewsFragment;
import br.com.ecarrara.popularmovies.trailers.di.TrailersModule;
import br.com.ecarrara.popularmovies.trailers.presentation.view.TrailerListFragment;
import dagger.Component;

@Singleton
@Component(modules = {
ApplicationModule.class,
NetworkingModule.class,
MoviesModule.class,
ReviewsModule.class,
TrailersModule.class,
FavoritesModule.class
})
public interface ApplicationComponent {
void inject(MovieDetailActivity movieDetailActivity);
void inject(MovieReviewsFragment movieReviewsFragment);
void inject(TrailerListFragment trailerListFragment);
void inject(MovieListActivity movieListActivity);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package br.com.ecarrara.popularmovies.core.di;

import android.content.Context;
import android.support.annotation.NonNull;

import javax.inject.Singleton;

import br.com.ecarrara.popularmovies.core.MyPopularMoviesApplication;
import dagger.Module;
import dagger.Provides;

@Singleton
@Module
public class ApplicationModule {

private MyPopularMoviesApplication applicationContext;

public ApplicationModule(@NonNull MyPopularMoviesApplication applicationContext) {
this.applicationContext = applicationContext;
}

@Provides
@Singleton
public Context providesApplicationContext() {
return this.applicationContext;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package br.com.ecarrara.popularmovies.core.di;

import android.app.Application;

import br.com.ecarrara.popularmovies.core.MyPopularMoviesApplication;

public final class Injector {

private Injector() { /* must not be constructed */ }

private static ApplicationComponent applicationComponent;

public static void initialize(MyPopularMoviesApplication application) {
applicationComponent = DaggerApplicationComponent.builder()
.applicationModule(new ApplicationModule(application))
.build();
}

public static ApplicationComponent applicationComponent() {
return applicationComponent;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package br.com.ecarrara.popularmovies.core.networking.connectivity;

import io.reactivex.Observable;

public interface ConnectivityObserver {

Observable<Boolean> observeConnectivity();

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package br.com.ecarrara.popularmovies.core.networking.connectivity;

import android.content.Context;
import android.net.NetworkInfo;

import com.github.pwittchen.reactivenetwork.library.rx2.ReactiveNetwork;

import io.reactivex.Observable;
import io.reactivex.schedulers.Schedulers;

public class ConnectivityObserverImpl implements ConnectivityObserver {

private Context applicationContext;

public ConnectivityObserverImpl(Context applicationContext) {
this.applicationContext = applicationContext;
}

@Override
public Observable<Boolean> observeConnectivity() {
return ReactiveNetwork.observeNetworkConnectivity(applicationContext)
.observeOn(Schedulers.io())
.flatMap(connectivity ->
Observable.just(connectivity.getState().equals(NetworkInfo.State.CONNECTED))
);
}

}
Loading

0 comments on commit 7058e7e

Please sign in to comment.