Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
cf2ba22
Create the initial state of common, local and remote modules.
Muhammadyoussef Sep 7, 2019
31effeb
architecture
Muhammadyoussef Sep 8, 2019
277e0ba
Create remote-model module with MovieResponse POJO class
AhmedSaber0 Sep 9, 2019
69423fd
Create local-model module with MovieLocal POJO class "which is room e…
AhmedSaber0 Sep 9, 2019
ee44162
- Create models package that will contains remote-model, local-model,…
AhmedSaber0 Sep 12, 2019
7b9c7bd
- Create datasource package that will contains remote and local modules.
AhmedSaber0 Sep 12, 2019
7272a03
- Create features package that will contains all the application feat…
AhmedSaber0 Sep 12, 2019
6d46456
- Create presentation package that will contains presentation modules…
AhmedSaber0 Sep 12, 2019
ae6e283
- add access network permission in the remote module.
AhmedSaber0 Sep 13, 2019
a2e8659
Update datasource/remote/src/main/java/com/egdroid/datasource/remote/…
AhmedSaber0 Sep 19, 2019
4e6214f
update AndroidManifest.xml
AhmedSaber0 Sep 19, 2019
ed786ce
update build.gradle
AhmedSaber0 Sep 19, 2019
9c705fb
Update datasource/local/src/main/java/com/egdroid/datasource/local/mo…
AhmedSaber0 Sep 19, 2019
952d99d
Merge remote-tracking branch 'origin/feature/popular-movies' into fea…
AhmedSaber0 Sep 19, 2019
4e871d1
- resolve session comments
AhmedSaber0 Sep 19, 2019
8b09b0f
- convert popular movies feature to be reactive using rxJava.
AhmedSaber0 Sep 27, 2019
4edc166
- replace anotationProcessor to kapt to support kotlin.
AhmedSaber0 Sep 27, 2019
450a4a2
- move popular movies fragment and adapter to app module
AhmedSaber0 Oct 17, 2019
3d47135
- add movie entity and movie ui modules
AhmedSaber0 Oct 17, 2019
08f010d
- enabled proguard to the project
AhmedSaber0 Oct 17, 2019
3e0c8ed
- save api key in ndk
AhmedSaber0 Oct 17, 2019
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
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ obj/
.idea/copyright/profiles_settings.xml
.idea/encodings.xml
.idea/misc.xml
.idea/gradle.xml
.idea/modules.xml
.idea/scopes/scope_settings.xml
.idea/dictionaries
Expand Down Expand Up @@ -132,4 +133,5 @@ fabric.properties

!/gradle/wrapper/gradle-wrapper.jar

# End of https://www.gitignore.io/api/androidstudio
# End of https://www.gitignore.io/api/androidstudio
src/main/java/com/egdroid/movieapp/di/
2 changes: 1 addition & 1 deletion .idea/misc.xml

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

92 changes: 16 additions & 76 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,96 +1,36 @@
apply plugin: 'com.android.application'
apply from: "$project.rootDir/tools/gradle/script/quality.gradle"
apply from: "$project.rootDir/tools/gradle/base.gradle"

android {
compileSdkVersion deps.build.compileSdkVersion
defaultConfig {
applicationId "com.egdroid.movieapp"
minSdkVersion deps.build.minSdkVersion
targetSdkVersion deps.build.targetSdkVersion
versionCode deps.build.versionCode
versionName deps.build.versionName
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
externalNativeBuild {
ndkBuild {
path 'src/main/jni/Android.mk'
}
}
buildTypes {
release {
minifyEnabled false
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
debug {
minifyEnabled false
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}

dependencies {
//UI
implementation deps.support.design
implementation deps.support.recyclerview
implementation deps.support.constraintLayout

// Arch Component
implementation deps.architecturecomponents.lifecycles
implementation deps.architecturecomponents.room
annotationProcessor deps.architecturecomponents.room_compiler

// Rx
implementation deps.rx.java
implementation deps.rx.relay
implementation deps.rx.android
implementation deps.rx.binding
implementation deps.rx.retrofitAdapter

// Dependency Injection
implementation deps.dependencyInjection.dagger
implementation deps.dependencyInjection.daggerSupportAndroid
annotationProcessor deps.dependencyInjection.daggerCompiler
annotationProcessor deps.dependencyInjection.daggerAndroidCompiler

// View Binding
implementation deps.viewBinding.butterknife
annotationProcessor deps.viewBinding.butterknifeCompiler

// Images
implementation deps.image.glide
annotationProcessor deps.image.glideCompiler

// Network
implementation deps.network.retrofit
implementation deps.network.retrofitGsonConverter
configurations {
compile.exclude group: 'androidx.annotation', module: 'annotation'
}

// Log
implementation deps.log.timber
debugImplementation deps.log.leakCanaryDebug
releaseImplementation deps.log.leakCanaryRelease
dependencies{

// Testing
testImplementation deps.test.junit
androidTestImplementation deps.test.runner
androidTestImplementation deps.test.robolectric
androidTestImplementation deps.test.espresso
androidTestImplementation deps.test.mockito
androidTestImplementation deps.test.powermock_mockito
androidTestImplementation deps.test.powermock_easymock
androidTestImplementation deps.test.powermock_reflect
androidTestImplementation deps.test.powermock_junit4
androidTestImplementation deps.test.powermock_junit4_rule
androidTestImplementation deps.test.powermock_classloading
implementation project(":presentation:popularmoviespresentation")

implementation fileTree(dir: 'libs', include: ['*.jar'])
configurations.all {
resolutionStrategy {
force deps.support.annotations
}
resolutionStrategy.eachDependency { details ->
if (details.requested.group == 'com.android.support'
&& !details.requested.name.contains('multidex')) {
details.useVersion deps.versions.support
}
}
}
}
}
3 changes: 3 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.egdroid.movieapp">

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:name=".EgdoidApp"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
Expand Down
15 changes: 15 additions & 0 deletions app/src/main/java/com/egdroid/movieapp/EgdoidApp.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.egdroid.movieapp

import android.app.Application
import timber.log.Timber

class EgdoidApp : Application() {

override fun onCreate() {
super.onCreate()

if (BuildConfig.DEBUG) {
Timber.plant(Timber.DebugTree())
}
}
}
14 changes: 0 additions & 14 deletions app/src/main/java/com/egdroid/movieapp/MainActivity.java

This file was deleted.

23 changes: 23 additions & 0 deletions app/src/main/java/com/egdroid/movieapp/MainActivity.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.egdroid.movieapp

import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import com.egdroid.presentation.popularmoviespresentation.PopularMoviesFragment


class MainActivity : AppCompatActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)

// val key1 = String(Base64.decode(getNativeKey1(), Base64.DEFAULT))
// Timber.w(key1)


val manager = supportFragmentManager
val transaction = manager.beginTransaction()
transaction.replace(R.id.container, PopularMoviesFragment())
transaction.commit()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package com.egdroid.presentation.popularmoviespresentation

import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import com.bumptech.glide.Glide
import com.egdroid.models.popularmovies.MovieUi
import com.egdroid.movieapp.R
import kotlinx.android.synthetic.main.popular_movie_row.view.*

class PopularMovieAdapter : RecyclerView.Adapter<PopularMovieAdapter.MovieViewHolder>() {

private val moviesList: MutableList<MovieUi> = arrayListOf()

override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): MovieViewHolder {
val inflater = LayoutInflater.from(parent.context)
return MovieViewHolder(inflater, parent)
}

override fun onBindViewHolder(holder: MovieViewHolder, position: Int) {
val movie: MovieUi = moviesList[position]
holder.bind(movie)
}

override fun getItemCount(): Int = moviesList.size

fun addPopularMovies(movies: List<MovieUi>) {
moviesList.addAll(movies)
notifyDataSetChanged()
}

class MovieViewHolder(inflater: LayoutInflater, parent: ViewGroup) :
RecyclerView.ViewHolder(inflater.inflate(R.layout.popular_movie_row, parent, false)) {

fun bind(movie: MovieUi) {
Glide.with(itemView).load("https://image.tmdb.org/t/p/w600_and_h900_bestv2/" + movie.posterPath).into(itemView.movieImageView)
itemView.titleTextView.text = movie.title
itemView.overviewTextView.text = movie.overview
}

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package com.egdroid.presentation.popularmoviespresentation

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import androidx.lifecycle.Observer
import androidx.recyclerview.widget.LinearLayoutManager
import com.egdroid.movieapp.R
import com.egdroid.presentation.popularmoviespresentation.PopularMoviePresentationFactory.providePopularMoviesViewModel
import kotlinx.android.synthetic.main.fragment_popular_movies.view.*

/**
* A simple [Fragment] subclass.
*/
class PopularMoviesFragment : Fragment() {

private lateinit var popularMovieAdapter: PopularMovieAdapter

override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?): View? {
val view = inflater.inflate(R.layout.fragment_popular_movies, container, false)

val popularMoviesViewModel = providePopularMoviesViewModel(activity!!)

setupRecyclerView(view)

popularMoviesViewModel.getMovies().observe(this, Observer {
if (it != null) {
popularMovieAdapter.addPopularMovies(it)
}
})
return view
}

private fun setupRecyclerView(view: View) {
popularMovieAdapter = PopularMovieAdapter()
view.popularMoviesRecyclerView.setLayoutManager(LinearLayoutManager(activity))
view.popularMoviesRecyclerView.adapter = popularMovieAdapter
}
}
8 changes: 8 additions & 0 deletions app/src/main/jni/Android.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

LOCAL_MODULE := keys
LOCAL_SRC_FILES := keys.c

include $(BUILD_SHARED_LIBRARY)
1 change: 1 addition & 0 deletions app/src/main/jni/Application.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
APP_ABI := all
14 changes: 14 additions & 0 deletions app/src/main/jni/keys.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#include <jni.h>

//JNIEXPORT jstring JNICALL
//Java_com_egdroid_movieapp_MainActivity_getNativeKey1(JNIEnv *env, jobject instance) {
//
// return (*env)-> NewStringUTF(env, "ODI4MTU3MDk1YTU0ZWQ4ZjY4Yjg4ODI2MjRlZDc2NjA=");
//}

JNIEXPORT jstring JNICALL
Java_com_egdroid_datasource_remote_movie_MoviesServiceFactory_getNativeKey(JNIEnv *env,
jobject instance) {

return (*env)->NewStringUTF(env, "ODI4MTU3MDk1YTU0ZWQ4ZjY4Yjg4ODI2MjRlZDc2NjA=");
}
16 changes: 9 additions & 7 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@
android:layout_height="match_parent"
tools:context=".MainActivity">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!"
<FrameLayout
android:id="@+id/container"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent">

</FrameLayout>

</androidx.constraintlayout.widget.ConstraintLayout>
14 changes: 14 additions & 0 deletions app/src/main/res/layout/emptyview.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">

<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="@string/empty"
android:textAppearance="?android:attr/textAppearanceMedium" />
</RelativeLayout>
23 changes: 23 additions & 0 deletions app/src/main/res/layout/fragment_popular_movies.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".PopularMoviesFragment">

<com.malinskiy.superrecyclerview.SuperRecyclerView
android:id="@+id/popularMoviesRecyclerView"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_empty="@layout/emptyview"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:mainLayoutId="@layout/layout_recyclerview_verticalscroll"
app:recyclerClipToPadding="false"
app:recyclerPadding="16dp"
app:scrollbarStyle="insideInset" />

</androidx.constraintlayout.widget.ConstraintLayout>
Loading