parent
797ce00665
commit
bf50751c6f
@ -0,0 +1,4 @@
|
||||
package fr.iut.pm.movieapplication.ui.adapter
|
||||
|
||||
class SearchResultAdapter {
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
package fr.iut.pm.movieapplication.ui.fragments
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.fragment.app.viewModels
|
||||
import fr.iut.pm.movieapplication.ui.viewmodel.SearchResultVM
|
||||
import fr.iut.pm.movieapplication.ui.viewmodel.SearchResultVMFactory
|
||||
|
||||
class SearchResultFragment : Fragment() {
|
||||
|
||||
private val searchResultViewModel by viewModels<SearchResultVM> { SearchResultVMFactory(arguments?.getString("query")!!) }
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater,
|
||||
container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View? {
|
||||
return super.onCreateView(inflater, container, savedInstanceState)
|
||||
}
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
package fr.iut.pm.movieapplication.ui.interfaces
|
||||
|
||||
interface MovieSelection {
|
||||
|
||||
fun onMovieSelected(movieId : Int)
|
||||
}
|
@ -1,4 +1,33 @@
|
||||
package fr.iut.pm.movieapplication.ui.viewmodel
|
||||
|
||||
class HomeSectionsVM {
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import fr.iut.pm.movieapplication.model.media.MediaResult
|
||||
import fr.iut.pm.movieapplication.repository.MediaRepository
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
class HomeSectionsVM : ViewModel() {
|
||||
|
||||
private val repository = MediaRepository()
|
||||
|
||||
private var _trendsLiveData : MutableLiveData<List<MediaResult>> = MutableLiveData()
|
||||
fun getTrendsLiveData() : MutableLiveData<List<MediaResult>> = _trendsLiveData
|
||||
|
||||
private var _popularMoviesLiveData : MutableLiveData<List<MediaResult>> = MutableLiveData()
|
||||
fun getPopularMoviesLiveData() : MutableLiveData<List<MediaResult>> = _popularMoviesLiveData
|
||||
|
||||
private var _popularTvShowsLiveData : MutableLiveData<List<MediaResult>> = MutableLiveData()
|
||||
fun getPopularTvShowsLiveData() : MutableLiveData<List<MediaResult>> = _popularTvShowsLiveData
|
||||
|
||||
|
||||
init {
|
||||
viewModelScope.launch {
|
||||
_trendsLiveData.postValue(repository.getTrends())
|
||||
_popularMoviesLiveData.postValue(repository.getPopularMovies())
|
||||
_popularTvShowsLiveData.postValue(repository.getPopularTvShows())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
package fr.iut.pm.movieapplication.ui.viewmodel
|
||||
|
||||
import androidx.lifecycle.LiveData
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
|
||||
class SearchResultVM(private var query : String) : ViewModel() {
|
||||
private var _queryLiveData : MutableLiveData<String> = MutableLiveData()
|
||||
fun getQueryLiveData() : LiveData<String> = _queryLiveData
|
||||
|
||||
init {
|
||||
_queryLiveData.postValue(query)
|
||||
}
|
||||
}
|
||||
|
||||
class SearchResultVMFactory(private var query : String) : ViewModelProvider.Factory
|
||||
{
|
||||
override fun<T:ViewModel>create(modelClass:Class<T>) : T
|
||||
{
|
||||
return SearchResultVM(query) as T
|
||||
}
|
||||
}
|
@ -1,69 +1,86 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layout xmlns:tools="http://schemas.android.com/tools"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<androidx.core.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:contentDescription="@string/section_nested_scroll_view">
|
||||
<data>
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
>
|
||||
<import type="android.view.View" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/home_page_trends_section_title"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/home_page_trends_section_title"
|
||||
android:layout_marginLeft="@dimen/default_margin"
|
||||
android:layout_marginStart="@dimen/default_margin"
|
||||
android:layout_marginTop="@dimen/default_margin"
|
||||
style="@style/SectionTitleStyle"
|
||||
/>
|
||||
<variable
|
||||
name="homeSectionsVM"
|
||||
type="fr.iut.pm.movieapplication.ui.viewmodel.HomeSectionsVM" />
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/home_trends_recycler_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="250dp"
|
||||
android:orientation="horizontal"
|
||||
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" />
|
||||
</data>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/home_page_popularity_section_title"
|
||||
<androidx.core.widget.NestedScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/home_page_popularity_section_title"
|
||||
android:layout_marginLeft="@dimen/default_margin"
|
||||
android:layout_marginStart="@dimen/default_margin"
|
||||
android:layout_marginTop="@dimen/default_margin"
|
||||
style="@style/SectionTitleStyle" />
|
||||
android:contentDescription="@string/section_nested_scroll_view">
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/home_popularity_recycler_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="250dp"
|
||||
android:orientation="horizontal"
|
||||
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/home_page_free_section_title"
|
||||
<LinearLayout
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/home_page_free_section_title"
|
||||
android:layout_marginLeft="@dimen/default_margin"
|
||||
android:layout_marginStart="@dimen/default_margin"
|
||||
android:layout_marginTop="@dimen/default_margin"
|
||||
style="@style/SectionTitleStyle" />
|
||||
>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/home_page_trends_section_title"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/home_page_trends_section_title"
|
||||
android:layout_marginLeft="@dimen/default_margin"
|
||||
android:layout_marginStart="@dimen/default_margin"
|
||||
android:layout_marginTop="@dimen/default_margin"
|
||||
style="@style/SectionTitleStyle"
|
||||
/>
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/home_trends_recycler_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="250dp"
|
||||
android:orientation="horizontal"
|
||||
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
|
||||
tools:listitem="@layout/item_vertical_fragment" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/home_page_popularity_section_title"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/home_page_popular_movies_section_title"
|
||||
android:layout_marginLeft="@dimen/default_margin"
|
||||
android:layout_marginStart="@dimen/default_margin"
|
||||
android:layout_marginTop="@dimen/default_margin"
|
||||
style="@style/SectionTitleStyle" />
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/home_popular_movies_recycler_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="250dp"
|
||||
android:orientation="horizontal"
|
||||
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
|
||||
tools:listitem="@layout/item_vertical_fragment" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/home_page_free_section_title"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/home_page_popular_tv_shows_section_title"
|
||||
android:layout_marginLeft="@dimen/default_margin"
|
||||
android:layout_marginStart="@dimen/default_margin"
|
||||
android:layout_marginTop="@dimen/default_margin"
|
||||
style="@style/SectionTitleStyle" />
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/home_popular_tv_shows_recycler_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="250dp"
|
||||
android:orientation="horizontal"
|
||||
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
|
||||
/>
|
||||
</LinearLayout>
|
||||
|
||||
</androidx.core.widget.NestedScrollView>
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/home_free_recycler_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="250dp"
|
||||
android:orientation="horizontal"
|
||||
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
|
||||
/>
|
||||
</LinearLayout>
|
||||
|
||||
</androidx.core.widget.NestedScrollView>
|
||||
</layout>
|
@ -0,0 +1,35 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<data>
|
||||
<import type="android.view.View" />
|
||||
|
||||
<variable
|
||||
name="searchResultsVM"
|
||||
type="fr.iut.pm.movieapplication.ui.viewmodel.SearchResultVM" />
|
||||
|
||||
</data>
|
||||
<LinearLayout
|
||||
android:layout_height="match_parent"
|
||||
android:layout_width="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/search_results_item_recycler_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginBottom="@dimen/default_margin"
|
||||
app:layoutManager="androidx.recyclerview.widget.GridLayoutManager"
|
||||
app:spanCount="3"
|
||||
tools:listitem="@layout/item_vertical_fragment" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</layout>
|
@ -1,45 +1,51 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<layout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="150dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginTop="10dp">
|
||||
|
||||
<androidx.cardview.widget.CardView
|
||||
android:id="@+id/cardView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="200dp"
|
||||
app:cardCornerRadius="5dp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/item_image"
|
||||
android:layout_width="match_parent"
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<data>
|
||||
<variable
|
||||
name="mediaResult"
|
||||
type="fr.iut.pm.movieapplication.model.media.MediaResult" />
|
||||
</data>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="150dp"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<androidx.cardview.widget.CardView
|
||||
android:id="@+id/cardView"
|
||||
android:layout_width="150dp"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/black"
|
||||
android:scaleType="centerCrop" />
|
||||
app:cardCornerRadius="5dp">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/item_image"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="210dp"
|
||||
android:background="@color/black"
|
||||
android:scaleType="centerCrop"
|
||||
android:contentDescription="description" />
|
||||
|
||||
</androidx.cardview.widget.CardView>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/item_name"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/cardView" />
|
||||
</androidx.cardview.widget.CardView>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/item_date"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/item_name" />
|
||||
<TextView
|
||||
android:id="@+id/item_name"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="20dp"
|
||||
android:layout_gravity="center"
|
||||
android:textAlignment="center"
|
||||
android:text="@{mediaResult.title}"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/item_date"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="20dp"
|
||||
android:layout_gravity="center"
|
||||
android:textAlignment="center"
|
||||
android:text="@{mediaResult.releaseDate}"/>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</LinearLayout>
|
||||
</layout>
|
Loading…
Reference in new issue