parent
3db51c3cb0
commit
32d629f879
@ -0,0 +1,25 @@
|
||||
package fr.iut.cinecool.API.OSM
|
||||
|
||||
import retrofit2.Retrofit
|
||||
import retrofit2.converter.gson.GsonConverterFactory
|
||||
|
||||
object ApiClientOSM {
|
||||
private const val OSM_BASE_URL = "https://nominatim.openstreetmap.org/"
|
||||
private const val ORS_BASE_URL = "https://api.openrouteservice.org/"
|
||||
|
||||
fun getOSMClient(): ApiService {
|
||||
return Retrofit.Builder()
|
||||
.baseUrl(OSM_BASE_URL)
|
||||
.addConverterFactory(GsonConverterFactory.create())
|
||||
.build()
|
||||
.create(ApiService::class.java)
|
||||
}
|
||||
|
||||
fun getORSClient(): ApiService {
|
||||
return Retrofit.Builder()
|
||||
.baseUrl(ORS_BASE_URL)
|
||||
.addConverterFactory(GsonConverterFactory.create())
|
||||
.build()
|
||||
.create(ApiService::class.java)
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package fr.iut.cinecool.API.OSM
|
||||
|
||||
import fr.iut.cinecool.model.CinemaResult
|
||||
import fr.iut.cinecool.model.RouteResult
|
||||
import retrofit2.Call
|
||||
import retrofit2.http.GET
|
||||
import retrofit2.http.Query
|
||||
|
||||
interface ApiService {
|
||||
@GET("search")
|
||||
fun searchCinemas(
|
||||
@Query("q") query: String,
|
||||
@Query("format") format: String = "json"
|
||||
): Call<List<CinemaResult>>
|
||||
|
||||
@GET("v2/directions/driving-car")
|
||||
fun getRoute(
|
||||
@Query("api_key") apiKey: String,
|
||||
@Query("start") start: String,
|
||||
@Query("end") end: String
|
||||
): Call<RouteResult>
|
||||
}
|
@ -1,9 +1,9 @@
|
||||
package fr.iut.cinecool.API
|
||||
package fr.iut.cinecool.API.THMDB
|
||||
|
||||
import retrofit2.Retrofit
|
||||
import retrofit2.converter.gson.GsonConverterFactory
|
||||
|
||||
object ApiClient {
|
||||
object ApiClientTHMDB {
|
||||
private const val BASE_URL = "https://api.themoviedb.org/3/"
|
||||
|
||||
private val retrofit: Retrofit = Retrofit.Builder()
|
@ -1,4 +1,4 @@
|
||||
package fr.iut.cinecool.API
|
||||
package fr.iut.cinecool.API.THMDB
|
||||
|
||||
import retrofit2.http.GET
|
||||
import retrofit2.http.Query
|
@ -1,4 +1,4 @@
|
||||
package fr.iut.cinecool.API
|
||||
package fr.iut.cinecool.API.THMDB
|
||||
|
||||
import android.os.Parcel
|
||||
import android.os.Parcelable
|
@ -1,7 +1,7 @@
|
||||
package fr.iut.cinecool.API
|
||||
package fr.iut.cinecool.API.THMDB
|
||||
|
||||
class Repository {
|
||||
private val apiService = ApiClient.apiService
|
||||
private val apiService = ApiClientTHMDB.apiService
|
||||
|
||||
suspend fun getPopularMovies(apiKey: String, page: Int): MovieResponse {
|
||||
return apiService.getPopularMovies(apiKey, page)
|
@ -1,18 +0,0 @@
|
||||
package fr.iut.cinecool
|
||||
|
||||
import android.app.Activity
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import android.os.Bundle
|
||||
import androidx.navigation.NavController
|
||||
import androidx.navigation.fragment.NavHostFragment
|
||||
|
||||
class CinemaActivity : AppCompatActivity() {
|
||||
private lateinit var navController: NavController
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_cinema)
|
||||
val navHostFragment = supportFragmentManager.findFragmentById(R.id.fragment) as NavHostFragment
|
||||
navController = navHostFragment.navController
|
||||
}
|
||||
|
||||
}
|
@ -1,32 +1,17 @@
|
||||
package fr.iut.cinecool
|
||||
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.widget.EditText
|
||||
import android.widget.ImageView
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import android.os.Bundle
|
||||
import androidx.navigation.NavController
|
||||
import androidx.navigation.fragment.NavHostFragment
|
||||
|
||||
class MainActivity : AppCompatActivity() {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
private lateinit var navController: NavController
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_main)
|
||||
val loginButton = findViewById<ImageView>(R.id.loginButton)
|
||||
loginButton.setOnClickListener(){
|
||||
login()
|
||||
}
|
||||
|
||||
|
||||
/*ActivityCompat.requestPermissions(this,
|
||||
arrayOf(Manifest.permission.ACCESS_FINE_LOCATION,1)
|
||||
)*/
|
||||
}
|
||||
fun login(){
|
||||
val name = findViewById<EditText>(R.id.name).text
|
||||
if (name.isNotEmpty()){
|
||||
val intent = Intent(applicationContext,CinemaActivity::class.java)
|
||||
startActivity(intent)
|
||||
System.out.println(name)
|
||||
}
|
||||
setContentView(R.layout.activity_master)
|
||||
val navHostFragment = supportFragmentManager.findFragmentById(R.id.fragment) as NavHostFragment
|
||||
navController = navHostFragment.navController
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,18 +0,0 @@
|
||||
package fr.iut.cinecool.data
|
||||
|
||||
import fr.iut.cinecool.R
|
||||
import fr.iut.cinecool.model.Cinema
|
||||
import fr.iut.cinecool.model.Movie
|
||||
import fr.iut.cinecool.model.Session
|
||||
import java.util.Date
|
||||
|
||||
class Stub(var sessions:ArrayList<Session> = ArrayList(), var movies:ArrayList<Movie> = ArrayList(), var cinemas:ArrayList<Cinema> = ArrayList()) {
|
||||
fun loading(){
|
||||
val date = Date(2023,3,12)
|
||||
sessions.addAll(listOf(Session(0,date,14,16,"2A"), Session(1,date,4,6,"5B")))
|
||||
movies.add(Movie(1,"trop bg",2,"Pas moi",2.0, R.drawable.no_pictures))
|
||||
movies.add(Movie(0,"Imitation Game",4,"Moi",3.0,R.drawable.imitation_game))
|
||||
cinemas.add(Cinema(0,12367,67894,"clf","CineJaude"))
|
||||
cinemas.add(Cinema(1,87634,43567,"Aubière","CGR Le Paris"))
|
||||
}
|
||||
}
|
@ -1,52 +1,51 @@
|
||||
package fr.iut.cinecool.fragments
|
||||
|
||||
import android.os.Bundle
|
||||
import android.text.method.ScrollingMovementMethod
|
||||
import androidx.fragment.app.Fragment
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.ImageButton
|
||||
import android.widget.ImageView
|
||||
import android.widget.TextView
|
||||
import androidx.fragment.app.activityViewModels
|
||||
import androidx.navigation.fragment.findNavController
|
||||
import fr.iut.cinecool.API.Movie
|
||||
// import fr.iut.cinecool.databinding.FragmentMovieDetailBinding
|
||||
import com.bumptech.glide.Glide
|
||||
import fr.iut.cinecool.R
|
||||
import fr.iut.cinecool.viewModel.cineViewModel
|
||||
|
||||
class MovieDetailFragment : Fragment() {
|
||||
/*private var _binding: FragmentDetailMovieBinding? = null
|
||||
private val binding get() = _binding!!
|
||||
private val sharedViewModel: cineViewModel by activityViewModels()
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater, container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View? {
|
||||
_binding = FragmentDetailMovieBinding.inflate(inflater, container, false)
|
||||
return binding.root
|
||||
// Inflate the layout for this fragment
|
||||
val view = inflater.inflate(R.layout.fragment_detail, container, false)
|
||||
return view
|
||||
}
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
|
||||
// Récupérez le film passé en argument
|
||||
val movie: Movie? = arguments?.getParcelable("movie")
|
||||
|
||||
// Mettez à jour les vues avec les données du film
|
||||
if (movie != null) {
|
||||
binding.titreFilm.text = movie.title
|
||||
binding.description.text = movie.overview
|
||||
|
||||
val imageUrl = "https://image.tmdb.org/t/p/w500${movie.poster_path}"
|
||||
Glide.with(binding.afficheFilm.context)
|
||||
.load(imageUrl)
|
||||
.placeholder(R.drawable.imitation_game)
|
||||
.into(binding.afficheFilm)
|
||||
}
|
||||
|
||||
// Gérer le clic sur le bouton de retour
|
||||
binding.backButton.setOnClickListener {
|
||||
findNavController().popBackStack()
|
||||
init()
|
||||
val button = view.findViewById<ImageButton>(R.id.returnButton)
|
||||
button.setOnClickListener {
|
||||
findNavController().navigate(R.id.action_SessionFragment_to_fragment_movies)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onDestroyView() {
|
||||
super.onDestroyView()
|
||||
_binding = null
|
||||
}*/
|
||||
}
|
||||
|
||||
private fun init() {
|
||||
requireView().findViewById<TextView>(R.id.title).text= sharedViewModel.cine.value?.title
|
||||
val desc = requireView().findViewById<TextView>(R.id.description)
|
||||
desc.text=sharedViewModel.cine.value?.overview
|
||||
desc.isScrollContainer = true
|
||||
desc.movementMethod = ScrollingMovementMethod()
|
||||
val img=requireView().findViewById<ImageView>(R.id.afficheFilm)
|
||||
|
||||
val imageUrl = "https://image.tmdb.org/t/p/w500${sharedViewModel.cine.value?.poster_path}"
|
||||
|
||||
Glide.with(this.requireContext())
|
||||
.load(imageUrl)
|
||||
.placeholder(R.drawable.no_pictures)
|
||||
.into(img)
|
||||
}
|
||||
}
|
@ -1,51 +0,0 @@
|
||||
package fr.iut.cinecool.fragments
|
||||
|
||||
import android.os.Bundle
|
||||
import android.text.method.ScrollingMovementMethod
|
||||
import androidx.fragment.app.Fragment
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.ImageButton
|
||||
import android.widget.ImageView
|
||||
import android.widget.TextView
|
||||
import androidx.fragment.app.activityViewModels
|
||||
import androidx.navigation.fragment.findNavController
|
||||
import com.bumptech.glide.Glide
|
||||
import fr.iut.cinecool.R
|
||||
import fr.iut.cinecool.viewModel.cineViewModel
|
||||
|
||||
class SessionFragment : Fragment() {
|
||||
private val sharedViewModel: cineViewModel by activityViewModels()
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater, container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View? {
|
||||
// Inflate the layout for this fragment
|
||||
val view = inflater.inflate(R.layout.fragment_session, container, false)
|
||||
return view
|
||||
}
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
init()
|
||||
val button = view.findViewById<ImageButton>(R.id.returnButton)
|
||||
button.setOnClickListener {
|
||||
findNavController().navigate(R.id.action_SessionFragment_to_fragment_movies)
|
||||
}
|
||||
}
|
||||
private fun init() {
|
||||
requireView().findViewById<TextView>(R.id.title).text= sharedViewModel.cine.value?.title
|
||||
val desc = requireView().findViewById<TextView>(R.id.description)
|
||||
desc.text=sharedViewModel.cine.value?.overview
|
||||
desc.isScrollContainer = true
|
||||
desc.movementMethod = ScrollingMovementMethod()
|
||||
val img=requireView().findViewById<ImageView>(R.id.afficheFilm)
|
||||
|
||||
val imageUrl = "https://image.tmdb.org/t/p/w500${sharedViewModel.cine.value?.poster_path}"
|
||||
|
||||
Glide.with(this.requireContext())
|
||||
.load(imageUrl)
|
||||
.placeholder(R.drawable.no_pictures)
|
||||
.into(img)
|
||||
}
|
||||
}
|
@ -1,3 +1,23 @@
|
||||
package fr.iut.cinecool.model
|
||||
|
||||
data class Cinema (val id:Int, val latitude:Int, val longitude:Int, val city:String, val name:String, /*var movies:ArrayList<Movie>*/)
|
||||
data class CinemaResult(
|
||||
val lat: Double,
|
||||
val lon: Double,
|
||||
val display_name: String
|
||||
)
|
||||
|
||||
data class RouteResult(
|
||||
val routes: List<Route>
|
||||
)
|
||||
|
||||
data class Route(
|
||||
val segments: List<Segment>
|
||||
)
|
||||
|
||||
data class Segment(
|
||||
val steps: List<Step>
|
||||
)
|
||||
|
||||
data class Step(
|
||||
val instruction: String
|
||||
)
|
||||
|
@ -1,65 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".MainActivity">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/Background"
|
||||
android:layout_width="3000px"
|
||||
android:layout_height="3000px"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:srcCompat="@drawable/background" />
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/constraintLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="300sp"
|
||||
android:background="@drawable/login_background"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.0"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintVertical_bias="0.821">
|
||||
|
||||
<EditText
|
||||
android:id="@+id/name"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:ems="17"
|
||||
android:inputType="textPersonName"
|
||||
android:text="Name"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.49"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintVertical_bias="0.235" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/loginButton"
|
||||
android:layout_width="100dp"
|
||||
android:layout_height="100dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/editTextTextPersonName"
|
||||
app:srcCompat="@drawable/connection_button" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/Logo"
|
||||
android:background="@color/white"
|
||||
android:layout_width="189dp"
|
||||
android:layout_height="199dp"
|
||||
app:layout_constraintBottom_toTopOf="@+id/constraintLayout"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:srcCompat="@drawable/cinema" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
Loading…
Reference in new issue