Skip to content

Commit

Permalink
Merge pull request #32 from Urdzik/develop
Browse files Browse the repository at this point in the history
Small Fix
  • Loading branch information
Slavik Urdzik authored May 29, 2020
2 parents 348abc9 + 620d518 commit 2c51a24
Show file tree
Hide file tree
Showing 14 changed files with 75 additions and 114 deletions.
49 changes: 23 additions & 26 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -50,56 +50,53 @@ dependencies {
implementation 'com.google.android.material:material:1.2.0-alpha06'

// Android KTX
implementation 'androidx.core:core-ktx:1.2.0'
implementation 'androidx.core:core-ktx:1.3.0'

// UI
implementation "androidx.viewpager2:viewpager2:1.0.0"
implementation 'com.yarolegovich:discrete-scrollview:1.4.9'
implementation "androidx.fragment:fragment-ktx:1.3.0-alpha05"
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'

// Navigation
implementation "androidx.navigation:navigation-fragment-ktx:2.3.0-beta01"
implementation "androidx.navigation:navigation-ui-ktx:2.3.0-beta01"
def navigation_version = '2.3.0-beta01'
implementation "androidx.navigation:navigation-fragment-ktx:$navigation_version"
implementation "androidx.navigation:navigation-ui-ktx:$navigation_version"

// Coroutines for getting off the UI thread
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.5"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.5"
def coroutines_version = '1.3.5'
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutines_version"

// Retrofit for networking
implementation 'com.squareup.retrofit2:retrofit:2.7.1'
def retrofit2_version = '2.7.1'
implementation "com.squareup.retrofit2:retrofit:$retrofit2_version"
implementation "com.squareup.retrofit2:converter-gson:$retrofit2_version"
implementation 'com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:0.9.2'
implementation 'com.squareup.retrofit2:converter-gson:2.7.1'
implementation 'com.squareup.retrofit2:converter-scalars:2.7.1'
implementation 'com.squareup.retrofit2:converter-moshi:2.7.1'

//OkHTTP
implementation "com.squareup.okhttp3:okhttp:4.4.0"
implementation "com.squareup.okhttp3:logging-interceptor:4.4.0"

//Parsing the JSON format
implementation 'com.squareup.moshi:moshi:1.9.2'
implementation 'com.squareup.moshi:moshi-kotlin:1.9.2'
implementation 'com.google.code.gson:gson:2.8.6'
kapt 'com.squareup.moshi:moshi-kotlin-codegen:1.9.2'

//OkHTTP
def okhttp3_version = '4.4.0'
implementation "com.squareup.okhttp3:okhttp:$okhttp3_version"
implementation "com.squareup.okhttp3:logging-interceptor:$okhttp3_version"


//Firebase
implementation 'com.google.firebase:firebase-auth:19.3.1'
implementation 'com.google.android.gms:play-services-auth:18.0.0'
implementation 'com.google.firebase:firebase-firestore-ktx:21.4.3'

// arch components
// Arch components
// ViewModel and LiveData
implementation "androidx.lifecycle:lifecycle-extensions:2.2.0"
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.0-alpha03'
def lifecycle_version = '2.2.0'
implementation "androidx.lifecycle:lifecycle-extensions:$lifecycle_version"
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle_version"

// glide for images
implementation 'com.github.bumptech.glide:glide:4.11.0'
kapt 'com.github.bumptech.glide:compiler:4.11.0'

// //Database
// implementation "androidx.room:room-runtime:2.2.4"
// kapt "androidx.room:room-compiler:2.2.4"
def glide_version = '4.11.0'
implementation "com.github.bumptech.glide:glide:$glide_version"
kapt "com.github.bumptech.glide:compiler:$glide_version"

//Dagger 2
def dagger_version = '2.26'
Expand Down
5 changes: 2 additions & 3 deletions app/src/main/java/com/example/movieapp/dagger/App.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ import com.example.movieapp.dagger.component.DaggerAppComponent
import com.example.movieapp.dagger.module.NetworkModule

class App : Application(){
companion object{
lateinit var appComponent: AppComponent
}

companion object{ lateinit var appComponent: AppComponent }

override fun onCreate() {
super.onCreate()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import com.example.movieapp.model.network.news.NewsApi
import com.example.movieapp.model.network.news.NewsSource
import com.example.movieapp.model.network.MovieListSource
import com.jakewharton.retrofit2.adapter.kotlin.coroutines.CoroutineCallAdapterFactory
import com.squareup.moshi.Moshi
import com.squareup.moshi.kotlin.reflect.KotlinJsonAdapterFactory
import dagger.Module
import dagger.Provides
import dagger.Reusable
Expand All @@ -16,8 +14,6 @@ import okhttp3.OkHttpClient
import okhttp3.logging.HttpLoggingInterceptor
import retrofit2.Retrofit
import retrofit2.converter.gson.GsonConverterFactory
import retrofit2.converter.moshi.MoshiConverterFactory
import retrofit2.converter.scalars.ScalarsConverterFactory
import java.io.File
import java.util.*
import java.util.concurrent.TimeUnit
Expand All @@ -41,8 +37,7 @@ class NetworkModule (private val application: Application) {
.readTimeout(60, TimeUnit.SECONDS)
.writeTimeout(60, TimeUnit.SECONDS)
.addInterceptor(interceptor)
.build()
}
.build() }

@Provides
@Reusable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ class ViewModelFactory @Inject constructor(private val viewModels: MutableMap<Cl
if (usedViewModelMap.contains(modelClass)) {
return usedViewModelMap[modelClass] as T
}

val viewModelProvider = viewModels[modelClass]
?: throw IllegalArgumentException(" model class $modelClass not found")
val viewModelProvider = viewModels[modelClass] ?: throw IllegalArgumentException(" model class $modelClass not found")

val viewModel = viewModelProvider.get()
usedViewModelMap[viewModel::class.java] = viewModel
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ abstract class ViewModelModule {
@ViewModelKey(DetailNewsViewModel::class)
internal abstract fun bindDetailNewsViewModel(viewModel: DetailNewsViewModel): ViewModel


@Binds
@IntoMap
@ViewModelKey(ProfileViewModel::class)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.example.movieapp.model.network

import com.example.movieapp.model.network.data.MovieInfo
import com.example.movieapp.model.network.data.SmallMovie
import com.example.movieapp.model.network.data.Results
import com.example.movieapp.model.network.data.SmallMovie
import com.example.movieapp.utils.API_KEY
import retrofit2.http.GET
import retrofit2.http.Path
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,50 +42,42 @@ class DetailFragment : Fragment() {
): View? {
App.appComponent.inject(this)



binding = DetailFragmentBinding.inflate(inflater)
viewModel = ViewModelProvider(this, viewModelFactory).get(DetailViewModel::class.java)

val args = DetailFragmentArgs.fromBundle(requireArguments()).id

sharedPreferences = activity?.getSharedPreferences(SHARED_KEY, Context.MODE_PRIVATE)!!
val id = sharedPreferences.getString(SHARED_KEY, null)
val id = sharedPreferences.getString(SHARED_KEY, null)

if (id != null) {
viewModel.getUserId(id)
viewModel.checkForSavedMovie(id)
}




viewModel.getSelectedMovieById(args)


binding.imageButton.setOnClickListener {
if (id == null || id == "null"){
if (id == null || id == "null") {
Toast.makeText(context, "Please Sing in your account", Toast.LENGTH_SHORT).show()
} else{
} else {
Toast.makeText(context, "Save", Toast.LENGTH_SHORT).show()
viewModel.putMovieInDatabase()
}
}

viewModel.test.observe(viewLifecycleOwner, Observer {
if(it){
if (it) {
binding.imageButton.visibility = View.GONE
} else {
binding.imageButton.visibility = View.VISIBLE
}

})


binding.viewModel = viewModel
binding.lifecycleOwner = this
return binding.root
}


}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,5 +91,4 @@ class DetailViewModel @Inject constructor(private val movieDetailSource: MovieDe
}
}
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,13 @@ class ListFragment : Fragment() {
movieCategory = ListFragmentArgs.fromBundle(requireArguments()).category
sendNewMovieList(movieCategory)

// Create Toolbar and button of back in toolbar


setMovieListToRV()

//Looking for the internet connection
viewModel.eventNetworkError.observe(this, Observer {
viewModel.eventNetworkError.observe(viewLifecycleOwner, Observer {
if (it) onNetworkError()
})


binding.lifecycleOwner = this

return binding.root
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,4 @@ class ListViewModel @Inject constructor(private val networkSource: MovieListSou
fun onNetworkErrorShown() {
_isNetworkErrorShown.value = true
}




}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ class OverviewFragment : Fragment() {

private var errorSnackbar: Snackbar? = null


override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
Expand Down Expand Up @@ -65,7 +64,6 @@ class OverviewFragment : Fragment() {
}
})


//Looking for the internet connection
viewModel.eventNetworkError.observe(viewLifecycleOwner, Observer {
if (it) onNetworkError()
Expand Down
5 changes: 0 additions & 5 deletions app/src/main/res/drawable/ic_email_black_24dp.xml

This file was deleted.

5 changes: 0 additions & 5 deletions app/src/main/res/drawable/ic_local_phone_black_24dp.xml

This file was deleted.

74 changes: 38 additions & 36 deletions app/src/main/res/layout/detail_fragment.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">

<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/frameLayout"
android:layout_width="match_parent"
Expand All @@ -42,7 +43,7 @@
app:layout_constraintTop_toTopOf="@+id/toolbar" />


<TextView
<TextView
android:id="@+id/title_detail"
android:layout_width="0dp"
android:layout_height="wrap_content"
Expand All @@ -59,55 +60,53 @@
tools:text="They Shall Not Grow Old" />

<TextView
android:id="@+id/year_ditale"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="@+id/title_detail"
app:layout_constraintTop_toBottomOf="@+id/title_detail"
tools:text="2019"
android:text="@{viewModel.selectProperty.release_date}"
/>
android:id="@+id/year_ditale"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="@+id/title_detail"
app:layout_constraintTop_toBottomOf="@+id/title_detail"
tools:text="2019"
android:text="@{viewModel.selectProperty.release_date}" />


<TextView
android:id="@+id/year_ditale2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
app:genre="@{viewModel.selectProperty.genres}"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="@+id/title_detail"
app:layout_constraintTop_toBottomOf="@+id/year_ditale"
tools:text="2019" />
<TextView
android:id="@+id/year_ditale2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
app:genre="@{viewModel.selectProperty.genres}"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="@+id/title_detail"
app:layout_constraintTop_toBottomOf="@+id/year_ditale"
tools:text="2019" />

<TextView
android:id="@+id/langue"
android:layout_width="0dp"
android:layout_height="wrap_content"

android:layout_marginEnd="16dp"
android:text="@{viewModel.selectProperty.original_language}"
app:layout_constraintBottom_toBottomOf="@+id/title_detail"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@+id/title_detail"
tools:text="English" />

<TextView
android:id="@+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:text="@string/plot"
android:textColor="?attr/editTextColor"
android:textSize="18sp"
android:textStyle="bold"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/year_ditale2" />
<TextView
android:id="@+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:text="@string/plot"
android:textColor="?attr/editTextColor"
android:textSize="18sp"
android:textStyle="bold"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/year_ditale2" />

<TextView
android:id="@+id/textView11"
Expand All @@ -123,6 +122,7 @@
app:layout_constraintStart_toStartOf="@+id/textView4"
app:layout_constraintTop_toBottomOf="@+id/textView4"
tools:text="A documentary about World War I with never-before-seen footage to commemorate the centennial of the end of the war." />

<ImageButton
android:id="@+id/imageButton"
android:layout_width="wrap_content"
Expand All @@ -136,7 +136,9 @@
app:srcCompat="@drawable/ic_save_black_24dp" />

</androidx.constraintlayout.widget.ConstraintLayout>

</LinearLayout>

</ScrollView>


Expand Down

0 comments on commit 2c51a24

Please sign in to comment.