🚧 build the interface of the main activity

The interface of the home page is created
Next step --> do the fragments and use the navigation menu
features/retrofit/1
Jordan ARTZET 2 years ago
parent c55abc271a
commit 48273833cc

@ -10,41 +10,45 @@ import java.util.Date
@Entity(tableName = "movies_table") @Entity(tableName = "movies_table")
data class Movie( data class Movie(
@ColumnInfo(name = "adult") @ColumnInfo(name = "adult")
var adult: Boolean, val adult: Boolean,
@ColumnInfo(name = "budget") @ColumnInfo(name = "budget")
var budget: Int, val budget: Int,
@ColumnInfo(name = "genres") @ColumnInfo(name = "genres")
var genres: Array<Genre>, val genres: Array<Genre>,
@ColumnInfo(name = "homepage") @ColumnInfo(name = "homepage")
var homePage: String?, val homePage: String?,
@PrimaryKey @PrimaryKey
@ColumnInfo(name = "id") @ColumnInfo(name = "id")
var movieId: Int, val movieId: Int,
@ColumnInfo(name = "original_language") @ColumnInfo(name = "original_language")
var originalLanguage: String, val originalLanguage: String,
@ColumnInfo(name = "original_title") @ColumnInfo(name = "original_title")
var originalTitle: String, val originalTitle: String,
var overview: String?, val overview: String?,
var popularity: Int, val popularity: Int,
//var posterPath : String?, @ColumnInfo(name = "poster_path")
val posterPath : String?,
@Embedded @Embedded
var productionCompanies: Array<ProductionCompany>, val productionCompanies: Array<ProductionCompany>,
@Relation( @Relation(
parentColumn = "movieId", parentColumn = "movieId",
entityColumn = "" entityColumn = ""
) )
var productionCountries: Array<ProductionCountry>, @ColumnInfo(name = "production_countries")
var releaseDate: Date, val productionCountries: Array<ProductionCountry>,
var revenue: Int, @ColumnInfo(name = "release_date")
var runtime: Int?, val releaseDate: Date,
val revenue: Int,
val runtime: Int?,
//var spokenLanguages : Array<SpokenLanguage>, //var spokenLanguages : Array<SpokenLanguage>,
var status: String, val status: String,
var tagLine: String?, @ColumnInfo(name = "tag_line")
var title: String, val tagLine: String?,
val title: String,
@ColumnInfo(name = "vote_average") @ColumnInfo(name = "vote_average")
var voteAverage: Number, val voteAverage: Number,
@ColumnInfo(name = "vote_count") @ColumnInfo(name = "vote_count")
var voteCount : Int val voteCount : Int
) { ) {

@ -2,11 +2,22 @@ package fr.iut.pm.movieapplication.ui.activity
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle import android.os.Bundle
import com.google.android.material.bottomnavigation.BottomNavigationView
import fr.iut.pm.movieapplication.R import fr.iut.pm.movieapplication.R
import fr.iut.pm.movieapplication.ui.fragments.HomeSectionsFragment
class MainActivity : AppCompatActivity() { class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main) setContentView(R.layout.activity_main)
//Trends fragment injected in main activity
val transaction = supportFragmentManager.beginTransaction()
transaction.replace(R.id.trends_section_container, HomeSectionsFragment())
transaction.addToBackStack(null)
transaction.commit()
//val bottomNavigationView = findViewById<BottomNavigationView>(R.id.navigation_view)
} }
} }

@ -0,0 +1,25 @@
package fr.iut.pm.movieapplication.ui.adapter
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import androidx.recyclerview.widget.RecyclerView
import fr.iut.pm.movieapplication.R
class HomeItemAdapter(private val layoutId : Int) : RecyclerView.Adapter<HomeItemAdapter.ViewHolder>() {
class ViewHolder(view : View) : RecyclerView.ViewHolder(view) {
}
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
val view = LayoutInflater
.from(parent.context)
.inflate(R.layout.item_horizontal_home_page, parent, false)
return ViewHolder(view)
}
override fun onBindViewHolder(holder: ViewHolder, position: Int) {}
override fun getItemCount(): Int = 5
}

@ -0,0 +1,12 @@
package fr.iut.pm.movieapplication.ui.adapter
import android.graphics.Rect
import android.view.View
import androidx.recyclerview.widget.RecyclerView
class HomeItemDecoration : RecyclerView.ItemDecoration() {
override fun getItemOffsets(outRect: Rect, view: View, parent: RecyclerView, state: RecyclerView.State) {
outRect.left = 20
}
}

@ -0,0 +1,34 @@
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.recyclerview.widget.RecyclerView
import fr.iut.pm.movieapplication.R
import fr.iut.pm.movieapplication.ui.adapter.HomeItemAdapter
import fr.iut.pm.movieapplication.ui.adapter.HomeItemDecoration
class HomeSectionsFragment : Fragment() {
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
val view = inflater.inflate(R.layout.fragment_home_sections, container, false)
//get the trends RecyclerView
val homeTrendsRecyclerView = view?.findViewById<RecyclerView>(R.id.home_trends_recycler_view)
homeTrendsRecyclerView?.adapter = HomeItemAdapter(R.layout.item_horizontal_home_page)
homeTrendsRecyclerView?.addItemDecoration(HomeItemDecoration())
//get the popularity RecyclerView
val homePopularityRecyclerView = view?.findViewById<RecyclerView>(R.id.home_popularity_recycler_view)
homePopularityRecyclerView?.adapter = HomeItemAdapter(R.layout.item_horizontal_home_page)
homePopularityRecyclerView?.addItemDecoration(HomeItemDecoration())
//get the free RecyclerView
val homeFreeRecyclerView = view?.findViewById<RecyclerView>(R.id.home_free_recycler_view)
homeFreeRecyclerView?.adapter = HomeItemAdapter(R.layout.item_horizontal_home_page)
homeFreeRecyclerView?.addItemDecoration(HomeItemDecoration())
return view
}
}

@ -0,0 +1,26 @@
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.recyclerview.widget.RecyclerView
import fr.iut.pm.movieapplication.R
import fr.iut.pm.movieapplication.ui.adapter.HomeItemAdapter
import fr.iut.pm.movieapplication.ui.adapter.HomeItemDecoration
class MoviesFragment : Fragment() {
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
val view = inflater.inflate(R.layout.fragment_movies, container, false)
//get the recycler view
val moviesRecyclerView = view?.findViewById<RecyclerView>(R.id.movies_item_recycler_view)
moviesRecyclerView?.adapter = HomeItemAdapter(R.layout.item_vertical_fragment)
moviesRecyclerView?.addItemDecoration(HomeItemDecoration())
return view
}
}

@ -0,0 +1,5 @@
<vector android:height="24dp" android:tint="#000000"
android:viewportHeight="24" android:viewportWidth="24"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="@android:color/white" android:pathData="M22,9.24l-7.19,-0.62L12,2 9.19,8.63 2,9.24l5.46,4.73L5.82,21 12,17.27 18.18,21l-1.63,-7.03L22,9.24zM12,15.4l-3.76,2.27 1,-4.28 -3.32,-2.88 4.38,-0.38L12,6.1l1.71,4.04 4.38,0.38 -3.32,2.88 1,4.28L12,15.4z"/>
</vector>

@ -0,0 +1,5 @@
<vector android:height="24dp" android:tint="#000000"
android:viewportHeight="24" android:viewportWidth="24"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="@android:color/white" android:pathData="M10,20v-6h4v6h5v-8h3L12,3 2,12h3v8z"/>
</vector>

@ -0,0 +1,5 @@
<vector android:height="24dp" android:tint="#000000"
android:viewportHeight="24" android:viewportWidth="24"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="@android:color/white" android:pathData="M18,4l2,4h-3l-2,-4h-2l2,4h-3l-2,-4H8l2,4H7L5,4H4c-1.1,0 -1.99,0.9 -1.99,2L2,18c0,1.1 0.9,2 2,2h16c1.1,0 2,-0.9 2,-2V4h-4z"/>
</vector>

@ -0,0 +1,5 @@
<vector android:height="24dp" android:tint="#000000"
android:viewportHeight="24" android:viewportWidth="24"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="@android:color/white" android:pathData="M21,6h-7.59l3.29,-3.29L16,2l-4,4 -4,-4 -0.71,0.71L10.59,6L3,6c-1.1,0 -2,0.89 -2,2v12c0,1.1 0.9,2 2,2h18c1.1,0 2,-0.9 2,-2L23,8c0,-1.11 -0.9,-2 -2,-2zM21,20L3,20L3,8h18v12zM9,10v8l7,-4z"/>
</vector>

@ -2,21 +2,57 @@
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/main_container"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
tools:context=".ui.activity.MainActivity"> tools:context=".ui.activity.MainActivity">
<TextView <TextView
android:layout_width="wrap_content" android:id="@+id/home_page_title"
android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginEnd="299dp" android:textSize="30sp"
android:layout_marginRight="299dp" android:text="@string/home_page_title"
android:layout_marginBottom="712dp"
android:text="@string/app_name"
android:textColor="@color/design_default_color_primary_variant" android:textColor="@color/design_default_color_primary_variant"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
/>
<TextView
android:id="@+id/home_page_subtitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="24sp"
android:text="@string/home_page_subtitle"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/home_page_title" />
<androidx.appcompat.widget.SearchView
android:id="@+id/searchView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/home_page_subtitle" />
<FrameLayout
android:id="@+id/trends_section_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="150dp"
android:layout_marginBottom="55dp"
app:layout_constraintBottom_toTopOf="@+id/navigation_view"
app:layout_constraintTop_toBottomOf="@+id/searchView" />
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@+id/navigation_view"
android:layout_width="match_parent"
android:layout_height="55dp"
android:background="@color/material_dynamic_neutral80"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" /> app:menu="@menu/bottom_navigation_menu"
/>
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>

@ -0,0 +1,59 @@
<?xml version="1.0" encoding="utf-8"?>
<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">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<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:textSize="20sp" />
<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" />
<TextView
android:id="@+id/home_page_popularity_section_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/home_page_popularity_section_title"
android:textSize="20sp" />
<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"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/home_page_free_section_title"
android:textSize="20sp" />
<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>

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/movies_item_recycler_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layoutManager="androidx.recyclerview.widget.GridLayoutManager"
/>
</LinearLayout>

@ -0,0 +1,46 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
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" >
<androidx.cardview.widget.CardView
android:id="@+id/cardView"
android:layout_width="match_parent"
android:layout_height="200dp"
app:cardCornerRadius="15dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<ImageView
android:id="@+id/home_section_item_image"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/black"
android:scaleType="centerCrop" />
</androidx.cardview.widget.CardView>
<TextView
android:id="@+id/home_section_item_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Nom du film"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/cardView" />
<TextView
android:id="@+id/home_section_item_date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="23 nov 2012"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/home_section_item_name" />
</androidx.constraintlayout.widget.ConstraintLayout>

@ -0,0 +1,44 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="150dp"
android:layout_height="match_parent">
<androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="parent"
app:cardCornerRadius="10dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<ImageView
android:layout_width="match_parent"
android:layout_height="200dp"
android:background="@color/black" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Nom du film"
android:layout_gravity="center"
android:textAlignment="center"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="23 nov 2015"
android:layout_gravity="center"
android:textAlignment="center"
/>
</LinearLayout>
</androidx.cardview.widget.CardView>
</androidx.constraintlayout.widget.ConstraintLayout>

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/home_page"
android:title="@string/bottom_home_item"
android:icon="@drawable/ic_home"
/>
<item
android:id="@+id/movies_page"
android:title="@string/bottom_movies_item"
android:icon="@drawable/ic_movie"
/>
<item
android:id="@+id/series_page"
android:title="@string/bottom_series_item"
android:icon="@drawable/ic_tv_shows"
/>
<item
android:id="@+id/artist_page"
android:title="@string/bottom_artist_item"
android:icon="@drawable/ic_baseline_star_border_24"/>
</menu>

@ -1,3 +1,17 @@
<resources> <resources>
<string name="app_name">Movie Application</string> <string name="app_name">Movie Application</string>
<string name="bottom_home_item">Accueil</string>
<string name="bottom_movies_item">Films</string>
<string name="bottom_series_item">Séries</string>
<string name="bottom_artist_item">Artistes</string>
<!-- Home page -->
<string name="home_page_title">Bienvenue</string>
<string name="home_page_subtitle">Des millions de films, émissions télévisées et artistes…</string>
<string name="home_page_trends_section_title">Tendances</string>
<string name="home_page_popularity_section_title">Populaires</string>
<string name="home_page_free_section_title">Gratuits</string>
<string name="section_nested_scroll_view">section_nested_scroll_view</string>
</resources> </resources>
Loading…
Cancel
Save