mirror of
https://github.com/Aviortheking/CA-Mad-Rental.git
synced 2025-04-22 10:52:12 +00:00
Updated
Signed-off-by: Avior <florian.bouillon@delta-wings.net>
This commit is contained in:
parent
af88880c5d
commit
b7d5af23d6
@ -9,7 +9,7 @@ android {
|
||||
compileSdkVersion 29
|
||||
|
||||
defaultConfig {
|
||||
applicationId "com.example.ca_contest"
|
||||
applicationId "com.example.ca_kotlin"
|
||||
minSdkVersion 19
|
||||
targetSdkVersion 29
|
||||
versionCode 1
|
||||
|
58
app/schemas/com.example.ca_kotlin.dao.AppDatabase/1.json
Normal file
58
app/schemas/com.example.ca_kotlin.dao.AppDatabase/1.json
Normal file
@ -0,0 +1,58 @@
|
||||
{
|
||||
"formatVersion": 1,
|
||||
"database": {
|
||||
"version": 1,
|
||||
"identityHash": "c0580e88639233d64464b9607839a456",
|
||||
"entities": [
|
||||
{
|
||||
"tableName": "vehicles",
|
||||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`vehicleId` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `name` TEXT, `price` TEXT, `category` TEXT, `image` TEXT)",
|
||||
"fields": [
|
||||
{
|
||||
"fieldPath": "vehicleId",
|
||||
"columnName": "vehicleId",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "name",
|
||||
"columnName": "name",
|
||||
"affinity": "TEXT",
|
||||
"notNull": false
|
||||
},
|
||||
{
|
||||
"fieldPath": "price",
|
||||
"columnName": "price",
|
||||
"affinity": "TEXT",
|
||||
"notNull": false
|
||||
},
|
||||
{
|
||||
"fieldPath": "category",
|
||||
"columnName": "category",
|
||||
"affinity": "TEXT",
|
||||
"notNull": false
|
||||
},
|
||||
{
|
||||
"fieldPath": "image",
|
||||
"columnName": "image",
|
||||
"affinity": "TEXT",
|
||||
"notNull": false
|
||||
}
|
||||
],
|
||||
"primaryKey": {
|
||||
"columnNames": [
|
||||
"vehicleId"
|
||||
],
|
||||
"autoGenerate": true
|
||||
},
|
||||
"indices": [],
|
||||
"foreignKeys": []
|
||||
}
|
||||
],
|
||||
"views": [],
|
||||
"setupQueries": [
|
||||
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
|
||||
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, 'c0580e88639233d64464b9607839a456')"
|
||||
]
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package com.example.ca_contest
|
||||
package com.example.ca_kotlin
|
||||
|
||||
import androidx.test.platform.app.InstrumentationRegistry
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
@ -19,6 +19,6 @@ class ExampleInstrumentedTest {
|
||||
fun useAppContext() {
|
||||
// Context of the app under test.
|
||||
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
|
||||
assertEquals("com.example.ca_contest", appContext.packageName)
|
||||
assertEquals("com.example.ca_kotlin", appContext.packageName)
|
||||
}
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.example.ca_contest">
|
||||
package="com.example.ca_kotlin">
|
||||
<uses-permission android:name="android.permission.INTERNET"/>
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
|
||||
<application
|
||||
@ -9,16 +9,13 @@
|
||||
android:label="@string/app_name"
|
||||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/Theme.CA_Contest"
|
||||
android:theme="@style/Theme.CA_Kotlin"
|
||||
android:usesCleartextTraffic="true">
|
||||
<activity android:name=".CalendarActivity"
|
||||
android:theme="@style/Theme.CA_Contest.NoActionBar"
|
||||
/>
|
||||
<activity
|
||||
android:name=".CountrySelectorActivity"
|
||||
android:name="com.example.ca_kotlin.DetailsActivity"
|
||||
android:label="@string/title_activity_country_selector"
|
||||
android:theme="@style/Theme.CA_Contest.NoActionBar" />
|
||||
<activity android:name=".MainActivity" android:theme="@style/Theme.CA_Contest.NoActionBar">
|
||||
android:theme="@style/Theme.CA_Kotlin.NoActionBar" />
|
||||
<activity android:name="com.example.ca_kotlin.MainActivity" android:theme="@style/Theme.CA_Kotlin.NoActionBar">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
|
@ -1,55 +0,0 @@
|
||||
package com.example.ca_contest
|
||||
|
||||
import android.app.DatePickerDialog
|
||||
import android.content.Intent
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import android.os.Bundle
|
||||
import android.util.Log
|
||||
import android.view.View
|
||||
import android.widget.Button
|
||||
import android.widget.DatePicker
|
||||
import android.widget.Toast
|
||||
import com.example.ca_contest.dao.AppDatabaseHelper
|
||||
import com.example.ca_contest.dao.Country
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.*
|
||||
|
||||
class CalendarActivity : AppCompatActivity() {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_calendar)
|
||||
|
||||
val name=intent.getStringExtra("name")
|
||||
val capital=intent.getStringExtra("capital")
|
||||
val region=intent.getStringExtra("region")
|
||||
val code = intent.getStringExtra("code")
|
||||
var date = Date(0)
|
||||
|
||||
val datePicker = findViewById<DatePicker>(R.id.date)
|
||||
|
||||
val today = Calendar.getInstance()
|
||||
datePicker.init(
|
||||
today.get(Calendar.YEAR),
|
||||
today.get(Calendar.MONTH),
|
||||
today.get(Calendar.DAY_OF_MONTH)
|
||||
) { _, year, month, day ->
|
||||
date = Date(year, month, day)
|
||||
}
|
||||
|
||||
val validateur = findViewById<Button>(R.id.add_date)
|
||||
validateur.setOnClickListener {
|
||||
AppDatabaseHelper
|
||||
.getDatabase(this)
|
||||
.countryDAO()
|
||||
.insert(Country(
|
||||
country = name,
|
||||
capitalCity = capital,
|
||||
continent = region,
|
||||
code = code,
|
||||
date = date
|
||||
))
|
||||
val intent = Intent(this, MainActivity::class.java)
|
||||
startActivity(intent)
|
||||
}
|
||||
}
|
||||
}
|
@ -1,78 +0,0 @@
|
||||
package com.example.ca_contest
|
||||
|
||||
import com.example.ca_contest.adapters.CountryAdapter
|
||||
import android.app.ProgressDialog
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.view.KeyEvent
|
||||
import android.view.MenuItem
|
||||
import android.view.View
|
||||
import android.widget.Button
|
||||
import android.widget.EditText
|
||||
import android.widget.TextView
|
||||
import android.widget.Toast
|
||||
import androidx.appcompat.app.ActionBar
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.example.ca_contest.api.ApiClient
|
||||
import com.example.ca_contest.api.Country
|
||||
import kotlinx.android.synthetic.main.activity_country_selector.*
|
||||
import retrofit2.Call
|
||||
import retrofit2.Callback
|
||||
import retrofit2.Response
|
||||
import kotlin.collections.ArrayList
|
||||
|
||||
class CountrySelectorActivity : AppCompatActivity() {
|
||||
|
||||
companion object {
|
||||
const val PROGRESS_BAR_TITLE = "Récupération des pays..."
|
||||
}
|
||||
|
||||
private var data: ArrayList<Country> = ArrayList()
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
setContentView(R.layout.activity_country_selector)
|
||||
|
||||
// Progress Bar
|
||||
val progressDialog = ProgressDialog(this)
|
||||
progressDialog.setTitle(PROGRESS_BAR_TITLE)
|
||||
progressDialog.setCancelable(false)
|
||||
progressDialog.show()
|
||||
|
||||
// Initialize Recycler
|
||||
val recycler = findViewById<RecyclerView>(R.id.list)
|
||||
recycler.setHasFixedSize(true)
|
||||
|
||||
val layoutManager = LinearLayoutManager(this)
|
||||
recycler.layoutManager = layoutManager
|
||||
|
||||
val adapter = CountryAdapter(data)
|
||||
recycler.adapter = adapter
|
||||
|
||||
// Fetch Countries
|
||||
ApiClient.getClient.getCountries().enqueue(object : Callback<List<Country>> {
|
||||
override fun onResponse(call: Call<List<Country>>?, response: Response<List<Country>>?) {
|
||||
progressDialog.dismiss()
|
||||
data.addAll(response!!.body()!!)
|
||||
adapter.update(data.clone() as ArrayList<Country>)
|
||||
recycler.adapter?.notifyDataSetChanged()
|
||||
}
|
||||
|
||||
override fun onFailure(call: Call<List<Country>>?, t: Throwable?) {
|
||||
progressDialog.dismiss()
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
// Input Text and Button
|
||||
val textView = findViewById<TextView>(R.id.text)
|
||||
var btn = findViewById<Button>(R.id.validate)
|
||||
btn.setOnClickListener {
|
||||
adapter.update((data.filter { country -> country.name.contains(textView.text, true) } as ArrayList<Country>))
|
||||
recycler.adapter?.notifyDataSetChanged()
|
||||
}
|
||||
}
|
||||
}
|
@ -1,47 +0,0 @@
|
||||
package com.example.ca_contest
|
||||
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import androidx.appcompat.app.ActionBar
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.example.ca_contest.adapters.HomepageCountryAdapter
|
||||
import com.example.ca_contest.dao.AppDatabaseHelper
|
||||
import java.util.*
|
||||
|
||||
class MainActivity : AppCompatActivity() {
|
||||
override fun onCreate(savedInstanceState: Bundle?)
|
||||
{
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
setContentView(R.layout.activity_main)
|
||||
|
||||
// Initialize RecyclerView
|
||||
val recycler = findViewById<RecyclerView>(R.id.list_country)
|
||||
recycler.setHasFixedSize(true)
|
||||
|
||||
val layoutManager = LinearLayoutManager(this)
|
||||
recycler.layoutManager = layoutManager
|
||||
|
||||
// Fetch Items in Database
|
||||
val adapter = HomepageCountryAdapter(
|
||||
AppDatabaseHelper
|
||||
.getDatabase(this)
|
||||
.countryDAO()
|
||||
.getListCountry()
|
||||
)
|
||||
recycler.adapter = adapter
|
||||
}
|
||||
|
||||
fun addCountry(view: View) {
|
||||
val intent = Intent(this, CountrySelectorActivity::class.java)
|
||||
startActivity(intent)
|
||||
}
|
||||
|
||||
override fun onBackPressed() {
|
||||
this.finishAffinity()
|
||||
}
|
||||
|
||||
}
|
@ -1,82 +0,0 @@
|
||||
package com.example.ca_contest.adapters
|
||||
|
||||
import android.content.Context
|
||||
import com.example.ca_contest.R
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.ImageView
|
||||
import android.widget.TextView
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.example.ca_contest.dao.AppDatabaseHelper
|
||||
import com.example.ca_contest.dao.Country
|
||||
import com.squareup.picasso.Picasso
|
||||
import java.text.DateFormat
|
||||
|
||||
// Adapter for the homepage
|
||||
class HomepageCountryAdapter(list: List<Country>) : RecyclerView.Adapter<HomepageCountryAdapter.CountryViewHolder>() {
|
||||
|
||||
private var list: List<Country> = ArrayList()
|
||||
|
||||
init {
|
||||
this.list = list
|
||||
}
|
||||
|
||||
// Create the view Holder
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): CountryViewHolder {
|
||||
val viewMemo: View =
|
||||
LayoutInflater.from(parent.context).inflate(R.layout.item_list, parent, false)
|
||||
return CountryViewHolder(viewMemo)
|
||||
}
|
||||
|
||||
// Bind each items
|
||||
override fun onBindViewHolder(holder: CountryViewHolder, position: Int) {
|
||||
holder.name?.text = list[position].country
|
||||
holder.capital?.text = "Capital : " + list[position].capitalCity
|
||||
holder.date?.text = DateFormat.getDateInstance(DateFormat.MEDIUM).format(list[position].date)
|
||||
holder.region?.text = "Continent : " + list[position].continent
|
||||
Picasso.get()
|
||||
.load("http://www.geognos.com/api/en/countries/flag/" + list[position].code + ".png")
|
||||
.into(holder.image!!)
|
||||
holder.button.setOnClickListener {
|
||||
AppDatabaseHelper
|
||||
.getDatabase(holder.context)
|
||||
.countryDAO()
|
||||
.delete(list[position].countryId)
|
||||
val newList = ArrayList(list)
|
||||
newList.removeAt(position)
|
||||
list = newList
|
||||
this.notifyDataSetChanged()
|
||||
}
|
||||
}
|
||||
|
||||
// Update the list
|
||||
fun update(list: ArrayList<Country>) {
|
||||
this.list = list
|
||||
}
|
||||
|
||||
override fun getItemCount(): Int {
|
||||
return list.size
|
||||
}
|
||||
|
||||
inner class CountryViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
|
||||
var name: TextView? = null
|
||||
var capital: TextView? = null
|
||||
var region: TextView? = null
|
||||
var date: TextView? = null
|
||||
var image: ImageView? = null
|
||||
var button: ImageView
|
||||
var context: Context
|
||||
|
||||
init {
|
||||
name = itemView.findViewById(R.id.country)
|
||||
date = itemView.findViewById(R.id.date)
|
||||
capital = itemView.findViewById(R.id.capital)
|
||||
region = itemView.findViewById(R.id.continent)
|
||||
image = itemView.findViewById(R.id.image)
|
||||
button = itemView.findViewById(R.id.delete)
|
||||
context = itemView.context
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,12 +0,0 @@
|
||||
package com.example.ca_contest.api
|
||||
|
||||
import retrofit2.Call
|
||||
import retrofit2.http.GET
|
||||
|
||||
// functions to get the differents elements
|
||||
interface ApiInterface {
|
||||
|
||||
@GET("rest/v2/all")
|
||||
fun getCountries(): Call<List<Country>>
|
||||
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
package com.example.ca_contest.api
|
||||
|
||||
import android.widget.DatePicker
|
||||
import com.google.gson.annotations.Expose
|
||||
import com.google.gson.annotations.SerializedName
|
||||
|
||||
// Model for The API
|
||||
data class Country(
|
||||
@Expose
|
||||
@SerializedName("name")
|
||||
val name: String,
|
||||
|
||||
@Expose
|
||||
@SerializedName("capital")
|
||||
val capital: String,
|
||||
|
||||
@Expose
|
||||
@SerializedName("region")
|
||||
val region: String,
|
||||
@Expose
|
||||
@SerializedName("alpha2Code")
|
||||
val alpha2Code: String,
|
||||
|
||||
val date: DatePicker
|
||||
) {}
|
@ -1,14 +0,0 @@
|
||||
package com.example.ca_contest.dao
|
||||
|
||||
import com.example.ca_contest.libs.Converters
|
||||
import androidx.room.Database
|
||||
import androidx.room.RoomDatabase
|
||||
import androidx.room.TypeConverters
|
||||
|
||||
// Database Manager
|
||||
@Database(entities = [Country::class], version = 1)
|
||||
@TypeConverters(Converters::class)
|
||||
abstract class AppDatabase : RoomDatabase()
|
||||
{
|
||||
abstract fun countryDAO(): CountryDAO
|
||||
}
|
@ -1,17 +0,0 @@
|
||||
package com.example.ca_contest.dao
|
||||
|
||||
import androidx.room.Entity
|
||||
import androidx.room.PrimaryKey
|
||||
import java.util.Date
|
||||
|
||||
// Model for the country
|
||||
@Entity(tableName = "country")
|
||||
class Country(
|
||||
@PrimaryKey(autoGenerate = true)
|
||||
val countryId: Long = 0,
|
||||
val country: String? = null,
|
||||
val capitalCity: String? = null,
|
||||
val continent: String? = null,
|
||||
val code: String? = null,
|
||||
val date: Date? = null
|
||||
)
|
@ -1,16 +0,0 @@
|
||||
package com.example.ca_contest.dao
|
||||
|
||||
import androidx.room.*
|
||||
|
||||
// DAO for the Country
|
||||
@Dao
|
||||
abstract class CountryDAO {
|
||||
@Query("SELECT * FROM country ORDER BY date ASC")
|
||||
abstract fun getListCountry(): List<Country>
|
||||
@Insert
|
||||
abstract fun insert(vararg country: Country)
|
||||
@Update
|
||||
abstract fun update(vararg country: Country)
|
||||
@Query("DELETE FROM country WHERE countryId = :id")
|
||||
abstract fun delete(id: Long)
|
||||
}
|
@ -1,17 +0,0 @@
|
||||
package com.example.ca_contest.libs
|
||||
|
||||
import androidx.room.TypeConverter
|
||||
import java.util.*
|
||||
|
||||
// Convert from and to a Java Date Object to a SQL Date
|
||||
class Converters {
|
||||
@TypeConverter
|
||||
fun fromTimestamp(value: Long?): Date? {
|
||||
return value?.let { Date(it) }
|
||||
}
|
||||
|
||||
@TypeConverter
|
||||
fun dateToTimestamp(date: Date?): Long? {
|
||||
return date?.time?.toLong()
|
||||
}
|
||||
}
|
52
app/src/main/java/com/example/ca_kotlin/DetailsActivity.kt
Normal file
52
app/src/main/java/com/example/ca_kotlin/DetailsActivity.kt
Normal file
@ -0,0 +1,52 @@
|
||||
package com.example.ca_kotlin
|
||||
|
||||
import android.content.Intent
|
||||
import android.database.sqlite.SQLiteConstraintException
|
||||
import android.os.Bundle
|
||||
import android.widget.Button
|
||||
import android.widget.TextView
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import com.example.ca_kotlin.dao.AppDatabaseHelper
|
||||
import com.example.ca_kotlin.dao.Vehicle
|
||||
|
||||
class DetailsActivity: AppCompatActivity() {
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
setContentView(R.layout.details)
|
||||
|
||||
val name = intent.getStringExtra("name")
|
||||
val price = intent.getStringExtra("price")
|
||||
val category = intent.getStringExtra("category")
|
||||
val image = intent.getStringExtra("image")
|
||||
val id = intent.getStringExtra("id")
|
||||
|
||||
val textView = findViewById<TextView>(R.id.text)
|
||||
textView.text = "nom: " + name + "\nPrice: " + price + "\nCategory: " + category
|
||||
|
||||
val button = findViewById<Button>(R.id.favorites)
|
||||
|
||||
button.setOnClickListener {
|
||||
val dao = AppDatabaseHelper.getDatabase(this)
|
||||
.vehicleDAO()
|
||||
val res = dao
|
||||
.find(id.toLong())
|
||||
println(res)
|
||||
|
||||
try {
|
||||
dao.insert(Vehicle(
|
||||
id.toLong(),
|
||||
name, price, category, image
|
||||
))
|
||||
} catch (e: SQLiteConstraintException) {
|
||||
return@setOnClickListener
|
||||
}
|
||||
|
||||
var intent = Intent(this, MainActivity::class.java)
|
||||
startActivity(intent)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
95
app/src/main/java/com/example/ca_kotlin/MainActivity.kt
Normal file
95
app/src/main/java/com/example/ca_kotlin/MainActivity.kt
Normal file
@ -0,0 +1,95 @@
|
||||
package com.example.ca_kotlin
|
||||
|
||||
import android.app.ProgressDialog
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.util.DisplayMetrics
|
||||
import android.view.View
|
||||
import android.widget.CompoundButton
|
||||
import android.widget.Switch
|
||||
import android.widget.Toast
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.example.ca_kotlin.adapters.CountryAdapter
|
||||
import com.example.ca_kotlin.api.ApiClient
|
||||
import com.example.ca_kotlin.api.Vehicles
|
||||
import com.example.ca_kotlin.dao.AppDatabaseHelper
|
||||
import retrofit2.Call
|
||||
import retrofit2.Callback
|
||||
import retrofit2.Response
|
||||
|
||||
class MainActivity : AppCompatActivity() {
|
||||
private var data: ArrayList<Vehicles> = ArrayList()
|
||||
|
||||
companion object {
|
||||
const val PROGRESS_BAR_TITLE = "Récupération des Véhicules..."
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?)
|
||||
{
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
setContentView(R.layout.activity_main)
|
||||
|
||||
// Initialize RecyclerView
|
||||
val recycler = findViewById<RecyclerView>(R.id.list_country)
|
||||
recycler.setHasFixedSize(true)
|
||||
|
||||
val layoutManager = LinearLayoutManager(this)
|
||||
recycler.layoutManager = layoutManager
|
||||
|
||||
// Progress Bar
|
||||
val progressDialog = ProgressDialog(this)
|
||||
progressDialog.setTitle(MainActivity.PROGRESS_BAR_TITLE)
|
||||
progressDialog.setCancelable(false)
|
||||
progressDialog.show()
|
||||
|
||||
val adapter = CountryAdapter(data)
|
||||
recycler.adapter = adapter
|
||||
|
||||
val switch = findViewById<Switch>(R.id.switch1)
|
||||
|
||||
switch.setOnCheckedChangeListener { _, b: Boolean ->
|
||||
if (b) {
|
||||
favorites(adapter, recycler, progressDialog)
|
||||
} else {
|
||||
global(adapter, recycler, progressDialog)
|
||||
}
|
||||
Toast.makeText(this, b.toString(), Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
|
||||
global(adapter, recycler, progressDialog)
|
||||
}
|
||||
|
||||
fun favorites(adapter: CountryAdapter, recycler: RecyclerView, progressDialog: ProgressDialog) {
|
||||
val vehicles = AppDatabaseHelper.getDatabase(this)
|
||||
.vehicleDAO()
|
||||
.getVehicles()
|
||||
data.clear()
|
||||
data.addAll(vehicles as ArrayList<Vehicles>)
|
||||
println(vehicles)
|
||||
adapter.notifyDataSetChanged()
|
||||
}
|
||||
|
||||
fun global(adapter: CountryAdapter, recycler: RecyclerView, progressDialog: ProgressDialog) {
|
||||
ApiClient.getClient.getVehicles().enqueue(object : Callback<List<Vehicles>> {
|
||||
override fun onResponse(call: Call<List<Vehicles>>?, response: Response<List<Vehicles>>?) {
|
||||
|
||||
data.addAll(response!!.body()!!)
|
||||
adapter.update(data.clone() as ArrayList<Vehicles>)
|
||||
adapter.notifyDataSetChanged()
|
||||
progressDialog.dismiss()
|
||||
}
|
||||
|
||||
override fun onFailure(call: Call<List<Vehicles>>?, t: Throwable?) {
|
||||
progressDialog.dismiss()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
override fun onBackPressed() {
|
||||
this.finishAffinity()
|
||||
}
|
||||
|
||||
}
|
@ -1,23 +1,21 @@
|
||||
package com.example.ca_contest.adapters
|
||||
package com.example.ca_kotlin.adapters
|
||||
|
||||
import android.content.Intent
|
||||
import android.util.Log
|
||||
import com.example.ca_contest.R
|
||||
import com.example.ca_kotlin.R
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.ImageView
|
||||
import android.widget.TextView
|
||||
import android.widget.Toast
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.example.ca_contest.CalendarActivity
|
||||
import com.example.ca_contest.api.Country
|
||||
import com.example.ca_kotlin.DetailsActivity
|
||||
import com.example.ca_kotlin.api.Vehicles
|
||||
import com.squareup.picasso.Picasso
|
||||
|
||||
// Adapter for the CountrySelector
|
||||
class CountryAdapter(list: ArrayList<Country>) : RecyclerView.Adapter<CountryAdapter.CountryViewHolder>() {
|
||||
class CountryAdapter(list: ArrayList<Vehicles>) : RecyclerView.Adapter<CountryAdapter.CountryViewHolder>() {
|
||||
|
||||
private var list: ArrayList<Country> = ArrayList()
|
||||
private var list: ArrayList<Vehicles> = ArrayList()
|
||||
|
||||
init {
|
||||
this.list = list
|
||||
@ -33,15 +31,15 @@ class CountryAdapter(list: ArrayList<Country>) : RecyclerView.Adapter<CountryAda
|
||||
// Bind each items
|
||||
override fun onBindViewHolder(holder: CountryViewHolder, position: Int) {
|
||||
holder.name?.text = list[position].name
|
||||
holder.capital?.text = "Capital : " + list[position].capital
|
||||
holder.region?.text = "Continent : " + list[position].region
|
||||
holder.price?.text = "Capital : " + list[position].price
|
||||
holder.category?.text = "Continent : " + list[position].category
|
||||
Picasso.get()
|
||||
.load("http://www.geognos.com/api/en/countries/flag/" + list[position].alpha2Code + ".png")
|
||||
.into(holder.image!!)
|
||||
.load("http://s519716619.onlinehome.fr/exchange/madrental/images/" + list[position].image)
|
||||
.into(holder.image!!)
|
||||
}
|
||||
|
||||
// Update the list
|
||||
fun update(list: ArrayList<Country>) {
|
||||
fun update(list: ArrayList<Vehicles>) {
|
||||
this.list = list
|
||||
}
|
||||
|
||||
@ -51,25 +49,27 @@ class CountryAdapter(list: ArrayList<Country>) : RecyclerView.Adapter<CountryAda
|
||||
|
||||
inner class CountryViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
|
||||
var name: TextView? = null
|
||||
var capital: TextView? = null
|
||||
var region: TextView? = null
|
||||
var price: TextView? = null
|
||||
var category: TextView? = null
|
||||
var image: ImageView? = null
|
||||
|
||||
init {
|
||||
name = itemView.findViewById(R.id.name)
|
||||
capital = itemView.findViewById(R.id.capital)
|
||||
region = itemView.findViewById(R.id.region)
|
||||
price = itemView.findViewById(R.id.price)
|
||||
category = itemView.findViewById(R.id.category)
|
||||
image = itemView.findViewById(R.id.image)
|
||||
|
||||
itemView.setOnClickListener {
|
||||
val context = itemView.context
|
||||
|
||||
// Intent to Calendar
|
||||
context.startActivity(Intent(context, CalendarActivity::class.java)
|
||||
println(list[adapterPosition])
|
||||
context.startActivity(Intent(context, DetailsActivity::class.java)
|
||||
.putExtra("name", list[adapterPosition].name)
|
||||
.putExtra("capital", list[adapterPosition].capital)
|
||||
.putExtra("region", list[adapterPosition].region)
|
||||
.putExtra("code", list[adapterPosition].alpha2Code)
|
||||
.putExtra("price", list[adapterPosition].price)
|
||||
.putExtra("category", list[adapterPosition].category)
|
||||
.putExtra("image", list[adapterPosition].image)
|
||||
.putExtra("id", list[adapterPosition].vehicleId.toString())
|
||||
)
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package com.example.ca_contest.api
|
||||
package com.example.ca_kotlin.api
|
||||
|
||||
import com.google.gson.GsonBuilder
|
||||
import okhttp3.OkHttpClient
|
||||
@ -9,7 +9,7 @@ import retrofit2.converter.gson.GsonConverterFactory
|
||||
// API Client
|
||||
object ApiClient {
|
||||
|
||||
var BASE_URL:String="https://restcountries.eu/"
|
||||
var BASE_URL:String="http://s519716619.onlinehome.fr/"
|
||||
val getClient: ApiInterface
|
||||
get() {
|
||||
|
12
app/src/main/java/com/example/ca_kotlin/api/ApiInterface.kt
Normal file
12
app/src/main/java/com/example/ca_kotlin/api/ApiInterface.kt
Normal file
@ -0,0 +1,12 @@
|
||||
package com.example.ca_kotlin.api
|
||||
|
||||
import retrofit2.Call
|
||||
import retrofit2.http.GET
|
||||
|
||||
// functions to get the differents elements
|
||||
interface ApiInterface {
|
||||
|
||||
@GET("exchange/madrental/get-vehicules.php")
|
||||
fun getVehicles(): Call<List<Vehicles>>
|
||||
|
||||
}
|
27
app/src/main/java/com/example/ca_kotlin/api/Vehicles.kt
Normal file
27
app/src/main/java/com/example/ca_kotlin/api/Vehicles.kt
Normal file
@ -0,0 +1,27 @@
|
||||
package com.example.ca_kotlin.api
|
||||
|
||||
import com.google.gson.annotations.Expose
|
||||
import com.google.gson.annotations.SerializedName
|
||||
|
||||
// Model for The API
|
||||
data class Vehicles(
|
||||
@Expose
|
||||
@SerializedName("id")
|
||||
val vehicleId: Long,
|
||||
|
||||
@Expose
|
||||
@SerializedName("nom")
|
||||
val name: String,
|
||||
|
||||
@Expose
|
||||
@SerializedName("prixjournalierbase")
|
||||
val price: String,
|
||||
|
||||
@Expose
|
||||
@SerializedName("categorieco2")
|
||||
val category: String,
|
||||
|
||||
@Expose
|
||||
@SerializedName("image")
|
||||
val image: String
|
||||
) {}
|
11
app/src/main/java/com/example/ca_kotlin/dao/AppDatabase.kt
Normal file
11
app/src/main/java/com/example/ca_kotlin/dao/AppDatabase.kt
Normal file
@ -0,0 +1,11 @@
|
||||
package com.example.ca_kotlin.dao
|
||||
|
||||
import androidx.room.Database
|
||||
import androidx.room.RoomDatabase
|
||||
|
||||
// Database Manager
|
||||
@Database(entities = [Vehicle::class], version = 1)
|
||||
abstract class AppDatabase : RoomDatabase()
|
||||
{
|
||||
abstract fun vehicleDAO(): VehicleDAO
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package com.example.ca_contest.dao
|
||||
package com.example.ca_kotlin.dao
|
||||
|
||||
import android.content.Context
|
||||
import androidx.room.Room
|
15
app/src/main/java/com/example/ca_kotlin/dao/Vehicle.kt
Normal file
15
app/src/main/java/com/example/ca_kotlin/dao/Vehicle.kt
Normal file
@ -0,0 +1,15 @@
|
||||
package com.example.ca_kotlin.dao
|
||||
|
||||
import androidx.room.Entity
|
||||
import androidx.room.PrimaryKey
|
||||
|
||||
// Model for the country
|
||||
@Entity(tableName = "vehicles")
|
||||
class Vehicle(
|
||||
@PrimaryKey(autoGenerate = true)
|
||||
val vehicleId: Long = 0,
|
||||
val name: String? = null,
|
||||
val price: String? = null,
|
||||
val category: String? = null,
|
||||
val image: String? = null
|
||||
)
|
19
app/src/main/java/com/example/ca_kotlin/dao/VehicleDAO.kt
Normal file
19
app/src/main/java/com/example/ca_kotlin/dao/VehicleDAO.kt
Normal file
@ -0,0 +1,19 @@
|
||||
package com.example.ca_kotlin.dao
|
||||
|
||||
import androidx.room.*
|
||||
|
||||
// DAO for the Country
|
||||
@Dao
|
||||
abstract class VehicleDAO {
|
||||
@Query("SELECT * FROM vehicles")
|
||||
abstract fun getVehicles(): List<Vehicle>
|
||||
@Insert
|
||||
abstract fun insert(vararg country: Vehicle)
|
||||
@Update
|
||||
abstract fun update(vararg country: Vehicle)
|
||||
@Query("DELETE FROM vehicles WHERE vehicleId = :id")
|
||||
abstract fun delete(id: Long)
|
||||
|
||||
@Query("SELECT * FROM vehicles WHERE vehicleId = :id LIMIT 1")
|
||||
abstract fun find(id: Long): Vehicle
|
||||
}
|
@ -1,39 +0,0 @@
|
||||
<?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:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity = "center"
|
||||
tools:context=".CalendarActivity">
|
||||
|
||||
<include
|
||||
android:id="@+id/include2"
|
||||
layout="@layout/toolbar" />
|
||||
|
||||
|
||||
<DatePicker
|
||||
android:id="@+id/date"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:calendarTextColor="@color/purple_200"
|
||||
android:datePickerMode="calendar"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/include2"></DatePicker>
|
||||
|
||||
<Button
|
||||
android:id="@+id/add_date"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="50dp"
|
||||
android:background="@color/validation"
|
||||
android:text="Valider"
|
||||
android:textColor="@android:color/white"
|
||||
app:backgroundTint="@color/validation"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent" />
|
||||
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
@ -1,50 +0,0 @@
|
||||
<?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="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".CountrySelectorActivity">
|
||||
|
||||
<include
|
||||
android:id="@+id/include"
|
||||
layout="@layout/toolbar" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/text"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="70dp"
|
||||
android:background="#eee"
|
||||
android:hint="Nom du pays"
|
||||
android:inputType="textCapSentences"
|
||||
android:maxLines="1"
|
||||
android:paddingLeft="16px"
|
||||
android:textColor="@android:color/black"
|
||||
app:layout_constraintEnd_toStartOf="@+id/validate"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/include" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/validate"
|
||||
android:layout_width="70dp"
|
||||
android:layout_height="0dp"
|
||||
android:background="#eee"
|
||||
android:text="OK"
|
||||
android:textColor="@android:color/white"
|
||||
app:backgroundTint="@color/button"
|
||||
app:layout_constraintBottom_toTopOf="@+id/list"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/include" />
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/text" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
@ -14,24 +14,31 @@
|
||||
android:id="@+id/list_country"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
app:layout_constraintBottom_toTopOf="@+id/bouton_retour"
|
||||
app:layout_constraintBottom_toTopOf="@+id/constraintLayout"
|
||||
app:layout_constraintHorizontal_bias="0.0"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/include" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/bouton_retour"
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/constraintLayout"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="50dp"
|
||||
android:background="#eee"
|
||||
android:onClick="addCountry"
|
||||
android:text="AJOUTER UN PAYS"
|
||||
android:textColor="@android:color/white"
|
||||
app:backgroundTint="@color/button"
|
||||
android:layout_height="60dp"
|
||||
android:background="@color/button"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent" />
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/list_country">
|
||||
|
||||
<Switch
|
||||
android:id="@+id/switch1"
|
||||
android:layout_width="88dp"
|
||||
android:showText="false"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
@ -8,7 +8,7 @@
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/image"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_width="144dp"
|
||||
android:layout_height="72dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
@ -32,7 +32,7 @@
|
||||
tools:text="Nom Pays" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/capital"
|
||||
android:id="@+id/price"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="8dp"
|
||||
@ -42,7 +42,7 @@
|
||||
tools:text="Capital: Capital" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/region"
|
||||
android:id="@+id/category"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="8dp"
|
||||
@ -50,7 +50,7 @@
|
||||
android:textColor="@android:color/black"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@+id/image"
|
||||
app:layout_constraintTop_toBottomOf="@+id/capital"
|
||||
app:layout_constraintTop_toBottomOf="@+id/price"
|
||||
tools:text="Continent: Continent" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
43
app/src/main/res/layout/details.xml
Normal file
43
app/src/main/res/layout/details.xml
Normal file
@ -0,0 +1,43 @@
|
||||
<?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="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<include
|
||||
android:id="@+id/include"
|
||||
layout="@layout/toolbar" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/details"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
android:scaleX="2"
|
||||
android:scaleY="2"
|
||||
android:text="Détails"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/include" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="24dp"
|
||||
android:text="TextView"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/details" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/favorites"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="16dp"
|
||||
android:text="Favoris"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/text" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
@ -1,87 +0,0 @@
|
||||
<?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:id="@+id/list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:background="@drawable/border_bottom">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/linearLayout"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:orientation="vertical"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/image"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="64dp"
|
||||
android:layout_weight="1"
|
||||
tools:srcCompat="@tools:sample/avatars" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/date"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:fontFamily="sans-serif-medium"
|
||||
android:textAlignment="center"
|
||||
android:textColor="@color/black"
|
||||
tools:text="12 sep. 2018" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:orientation="vertical"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@+id/linearLayout"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/country"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:fontFamily="sans-serif-medium"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="24sp"
|
||||
tools:text="France" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/capital"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
tools:text="Capital: Paris" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/continent"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
tools:text="Continent: Europe" />
|
||||
</LinearLayout>
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/delete"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:background="@color/white"
|
||||
android:onClick="deleteCountry"
|
||||
android:src="@drawable/ic_trash"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
@ -9,7 +9,7 @@
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="World Visit"
|
||||
android:text="Mad Cars"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="23sp"></TextView>
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
<resources xmlns:tools="http://schemas.android.com/tools">
|
||||
<!-- Base application theme. -->
|
||||
<style name="Theme.CA_Contest" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
|
||||
<style name="Theme.CA_Kotlin" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
|
||||
<!-- Primary brand color. -->
|
||||
<item name="colorPrimary">@color/purple_200</item>
|
||||
<item name="colorPrimaryVariant">@color/purple_700</item>
|
||||
|
@ -1,5 +1,5 @@
|
||||
<resources>
|
||||
<string name="app_name">CA_Contest</string>
|
||||
<string name="app_name">CA_Kotlin</string>
|
||||
<string name="title_activity_country_selector">CountrySelectorActivity</string>
|
||||
<!-- Strings used for fragments for navigation -->
|
||||
<string name="first_fragment_label">First Fragment</string>
|
||||
|
@ -1,6 +1,6 @@
|
||||
<resources xmlns:tools="http://schemas.android.com/tools">
|
||||
<!-- Base application theme. -->
|
||||
<style name="Theme.CA_Contest" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
|
||||
<style name="Theme.CA_Kotlin" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
|
||||
<!-- Primary brand color. -->
|
||||
<item name="colorPrimary">@color/button</item>
|
||||
<item name="colorPrimaryVariant">@color/button</item>
|
||||
@ -14,12 +14,12 @@
|
||||
<!-- Customize your theme here. -->
|
||||
</style>
|
||||
|
||||
<style name="Theme.CA_Contest.NoActionBar">
|
||||
<style name="Theme.CA_Kotlin.NoActionBar">
|
||||
<item name="windowActionBar">false</item>
|
||||
<item name="windowNoTitle">true</item>
|
||||
</style>
|
||||
|
||||
<style name="Theme.CA_Contest.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
|
||||
<style name="Theme.CA_Kotlin.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
|
||||
|
||||
<style name="Theme.CA_Contest.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
|
||||
<style name="Theme.CA_Kotlin.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
|
||||
</resources>
|
@ -1,4 +1,4 @@
|
||||
package com.example.ca_contest
|
||||
package com.example.ca_kotlin
|
||||
|
||||
import org.junit.Test
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* This Kotlin source file was generated by the Gradle 'init' task.
|
||||
*/
|
||||
package CA_Contest
|
||||
package CA_Kotlin
|
||||
|
||||
import kotlin.test.Test
|
||||
import kotlin.test.assertNotNull
|
||||
|
@ -6,7 +6,7 @@ buildscript {
|
||||
jcenter()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:4.1.2'
|
||||
classpath 'com.android.tools.build:gradle:4.2.0'
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||
classpath "org.jetbrains.kotlin:kotlin-android-extensions:$kotlin_version"
|
||||
// NOTE: Do not place your application dependencies here; they belong
|
||||
|
@ -18,4 +18,5 @@ android.useAndroidX=true
|
||||
# Automatically convert third-party libraries to use AndroidX
|
||||
android.enableJetifier=true
|
||||
# Kotlin code style for this project: "official" or "obsolete":
|
||||
kotlin.code.style=official
|
||||
kotlin.code.style=official
|
||||
kapt.incremental.apt=true
|
||||
|
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-all.zip
|
||||
|
@ -1,2 +1,2 @@
|
||||
include ':app'
|
||||
rootProject.name = "CA_Contest"
|
||||
rootProject.name = "CA_Kotlin"
|
Loading…
x
Reference in New Issue
Block a user