mirror of
https://github.com/Aviortheking/CA_Contest.git
synced 2025-04-22 10:52:11 +00:00
commit
8003095e5b
@ -1,6 +1,8 @@
|
||||
plugins {
|
||||
id 'com.android.application'
|
||||
id 'kotlin-android'
|
||||
id 'kotlin-android-extensions'
|
||||
id 'kotlin-kapt'
|
||||
}
|
||||
|
||||
android {
|
||||
@ -14,6 +16,14 @@ android {
|
||||
versionName "1.0"
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
|
||||
javaCompileOptions {
|
||||
annotationProcessorOptions {
|
||||
arguments =
|
||||
["room.schemaLocation": "$projectDir/schemas".toString()]
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
@ -36,10 +46,13 @@ dependencies {
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
||||
implementation 'androidx.core:core-ktx:1.3.2'
|
||||
implementation 'androidx.appcompat:appcompat:1.2.0'
|
||||
implementation 'com.google.android.material:material:1.2.1'
|
||||
implementation 'com.google.android.material:material:1.3.0'
|
||||
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
|
||||
implementation 'androidx.navigation:navigation-fragment-ktx:2.2.2'
|
||||
implementation 'androidx.navigation:navigation-ui-ktx:2.2.2'
|
||||
// implementation 'androidx.recyclerview:recyclerview:1.1.0'
|
||||
// implementation 'com.google.android.material:material:1.3.0'
|
||||
// implementation 'androidx.preference:preference:1.1.1'
|
||||
// implementation 'androidx.navigation:navigation-fragment-ktx:2.2.2'
|
||||
// implementation 'androidx.navigation:navigation-ui-ktx:2.2.2'
|
||||
testImplementation 'junit:junit:4.+'
|
||||
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
|
||||
@ -57,6 +70,12 @@ dependencies {
|
||||
implementation 'com.squareup.picasso:picasso:2.71828'
|
||||
implementation 'com.squareup.okhttp:okhttp:2.2.0'
|
||||
implementation 'com.squareup.okhttp:okhttp-urlconnection:2.2.0'
|
||||
|
||||
// Database
|
||||
implementation 'androidx.room:room-runtime:2.2.6'
|
||||
implementation 'androidx.room:room-runtime:2.2.6'
|
||||
kapt 'androidx.room:room-compiler:2.2.6'
|
||||
|
||||
}
|
||||
|
||||
apply plugin: 'kotlin-android-extensions'
|
64
app/schemas/com.example.ca_contest.dao.AppDatabase/1.json
Normal file
64
app/schemas/com.example.ca_contest.dao.AppDatabase/1.json
Normal file
@ -0,0 +1,64 @@
|
||||
{
|
||||
"formatVersion": 1,
|
||||
"database": {
|
||||
"version": 1,
|
||||
"identityHash": "8bdf84f071ba217eb3653e01500bac94",
|
||||
"entities": [
|
||||
{
|
||||
"tableName": "country",
|
||||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`countryId` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `country` TEXT, `capitalCity` TEXT, `continent` TEXT, `code` TEXT, `date` INTEGER)",
|
||||
"fields": [
|
||||
{
|
||||
"fieldPath": "countryId",
|
||||
"columnName": "countryId",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "country",
|
||||
"columnName": "country",
|
||||
"affinity": "TEXT",
|
||||
"notNull": false
|
||||
},
|
||||
{
|
||||
"fieldPath": "capitalCity",
|
||||
"columnName": "capitalCity",
|
||||
"affinity": "TEXT",
|
||||
"notNull": false
|
||||
},
|
||||
{
|
||||
"fieldPath": "continent",
|
||||
"columnName": "continent",
|
||||
"affinity": "TEXT",
|
||||
"notNull": false
|
||||
},
|
||||
{
|
||||
"fieldPath": "code",
|
||||
"columnName": "code",
|
||||
"affinity": "TEXT",
|
||||
"notNull": false
|
||||
},
|
||||
{
|
||||
"fieldPath": "date",
|
||||
"columnName": "date",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": false
|
||||
}
|
||||
],
|
||||
"primaryKey": {
|
||||
"columnNames": [
|
||||
"countryId"
|
||||
],
|
||||
"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, '8bdf84f071ba217eb3653e01500bac94')"
|
||||
]
|
||||
}
|
||||
}
|
@ -2,6 +2,7 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.example.ca_contest">
|
||||
<uses-permission android:name="android.permission.INTERNET"/>
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
@ -11,9 +12,7 @@
|
||||
android:usesCleartextTraffic="true"
|
||||
android:theme="@style/Theme.CA_Contest">
|
||||
<activity
|
||||
android:name=".CountrySelectorActivity"
|
||||
android:label="@string/title_activity_country_selector"
|
||||
android:theme="@style/Theme.CA_Contest.NoActionBar"></activity>
|
||||
android:name=".CountrySelectorActivity"></activity>
|
||||
<activity android:name=".MainActivity">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
@ -5,11 +5,13 @@ 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
|
||||
@ -70,5 +72,4 @@ class CountrySelectorActivity : AppCompatActivity() {
|
||||
recycler.adapter?.notifyDataSetChanged()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,19 +1,43 @@
|
||||
package com.example.ca_contest
|
||||
|
||||
import android.content.Intent
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import android.os.Bundle
|
||||
import android.widget.Button
|
||||
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?) {
|
||||
private lateinit var countryAdapter: HomepageCountryAdapter
|
||||
// private lateinit var imageView: ImageView
|
||||
override fun onCreate(savedInstanceState: Bundle?)
|
||||
{
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
setContentView(R.layout.activity_main)
|
||||
var btn = findViewById<Button>(R.id.btnStartAnotherActivity)
|
||||
btn.setOnClickListener {
|
||||
|
||||
val recycler = findViewById<RecyclerView>(R.id.list_country)
|
||||
recycler.setHasFixedSize(true)
|
||||
|
||||
val layoutManager = LinearLayoutManager(this)
|
||||
recycler.layoutManager = layoutManager
|
||||
|
||||
val adapter = HomepageCountryAdapter(
|
||||
AppDatabaseHelper
|
||||
.getDatabase(this)
|
||||
.countryDAO()
|
||||
.getListCountry()
|
||||
)
|
||||
recycler.adapter = adapter
|
||||
}
|
||||
|
||||
fun addCountry(view: View) {
|
||||
val intent = Intent(this, CountrySelectorActivity::class.java)
|
||||
// start your next activity
|
||||
startActivity(intent)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,65 @@
|
||||
package com.example.ca_contest.adapters
|
||||
|
||||
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 android.widget.Toast
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.example.ca_contest.dao.Country
|
||||
import com.squareup.picasso.Picasso
|
||||
|
||||
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 = list[position].date.toString()
|
||||
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!!)
|
||||
}
|
||||
|
||||
// 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
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
13
app/src/main/java/com/example/ca_contest/dao/AppDatabase.kt
Normal file
13
app/src/main/java/com/example/ca_contest/dao/AppDatabase.kt
Normal file
@ -0,0 +1,13 @@
|
||||
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(entities = [Country::class], version = 1)
|
||||
@TypeConverters(Converters::class)
|
||||
abstract class AppDatabase : RoomDatabase()
|
||||
{
|
||||
abstract fun countryDAO(): CountryDAO
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
package com.example.ca_contest.dao
|
||||
|
||||
import android.content.Context
|
||||
import androidx.room.Room
|
||||
|
||||
class AppDatabaseHelper(context: Context)
|
||||
{
|
||||
// Bloc de code "static" :
|
||||
companion object
|
||||
{
|
||||
// Helper :
|
||||
private lateinit var databaseHelper: AppDatabaseHelper
|
||||
// Getter instance :
|
||||
fun getDatabase(context: Context): AppDatabase
|
||||
{
|
||||
if (!::databaseHelper.isInitialized)
|
||||
{
|
||||
databaseHelper = AppDatabaseHelper(context)
|
||||
}
|
||||
return databaseHelper.database
|
||||
}
|
||||
}
|
||||
// Base de données :
|
||||
val database: AppDatabase = Room
|
||||
.databaseBuilder(context.applicationContext, AppDatabase::class.java, "courses.db")
|
||||
.allowMainThreadQueries()
|
||||
.build()
|
||||
}
|
16
app/src/main/java/com/example/ca_contest/dao/Country.kt
Normal file
16
app/src/main/java/com/example/ca_contest/dao/Country.kt
Normal file
@ -0,0 +1,16 @@
|
||||
package com.example.ca_contest.dao
|
||||
|
||||
import androidx.room.Entity
|
||||
import androidx.room.PrimaryKey
|
||||
import java.util.Date
|
||||
|
||||
@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
|
||||
)
|
15
app/src/main/java/com/example/ca_contest/dao/CountryDAO.kt
Normal file
15
app/src/main/java/com/example/ca_contest/dao/CountryDAO.kt
Normal file
@ -0,0 +1,15 @@
|
||||
package com.example.ca_contest.dao
|
||||
|
||||
import androidx.room.*
|
||||
|
||||
@Dao
|
||||
abstract class CountryDAO {
|
||||
@Query("SELECT * FROM country")
|
||||
abstract fun getListCountry(): List<Country>
|
||||
@Insert
|
||||
abstract fun insert(vararg country: Country)
|
||||
@Update
|
||||
abstract fun update(vararg country: Country)
|
||||
@Delete
|
||||
abstract fun delete(vararg country: Country)
|
||||
}
|
16
app/src/main/java/com/example/ca_contest/libs/Converters.kt
Normal file
16
app/src/main/java/com/example/ca_contest/libs/Converters.kt
Normal file
@ -0,0 +1,16 @@
|
||||
package com.example.ca_contest.libs
|
||||
|
||||
import androidx.room.TypeConverter
|
||||
import java.util.*
|
||||
|
||||
class Converters {
|
||||
@TypeConverter
|
||||
fun fromTimestamp(value: Long?): Date? {
|
||||
return value?.let { Date(it) }
|
||||
}
|
||||
|
||||
@TypeConverter
|
||||
fun dateToTimestamp(date: Date?): Long? {
|
||||
return date?.time?.toLong()
|
||||
}
|
||||
}
|
11
app/src/main/res/drawable-anydpi/ic_trash.xml
Normal file
11
app/src/main/res/drawable-anydpi/ic_trash.xml
Normal file
@ -0,0 +1,11 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24"
|
||||
android:tint="#E5446E"
|
||||
android:alpha="0.8">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M6,19c0,1.1 0.9,2 2,2h8c1.1,0 2,-0.9 2,-2V7H6v12zM19,4h-3.5l-1,-1h-5l-1,1H5v2h14V4z"/>
|
||||
</vector>
|
BIN
app/src/main/res/drawable-hdpi/ic_trash.png
Normal file
BIN
app/src/main/res/drawable-hdpi/ic_trash.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 206 B |
BIN
app/src/main/res/drawable-mdpi/ic_trash.png
Normal file
BIN
app/src/main/res/drawable-mdpi/ic_trash.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 146 B |
BIN
app/src/main/res/drawable-xhdpi/ic_trash.png
Normal file
BIN
app/src/main/res/drawable-xhdpi/ic_trash.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 205 B |
BIN
app/src/main/res/drawable-xxhdpi/ic_trash.png
Normal file
BIN
app/src/main/res/drawable-xxhdpi/ic_trash.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 252 B |
16
app/src/main/res/drawable/border_bottom.xml
Normal file
16
app/src/main/res/drawable/border_bottom.xml
Normal file
@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item>
|
||||
<shape android:shape="rectangle">
|
||||
<stroke
|
||||
android:width="1dp"
|
||||
android:color="@color/black" />
|
||||
<solid android:color="@color/white" />
|
||||
</shape>
|
||||
</item>
|
||||
<item android:bottom="1dp">
|
||||
<shape android:shape="rectangle">
|
||||
<stroke android:width="1dp" android:color="@color/white" />
|
||||
</shape>
|
||||
</item>
|
||||
</layer-list>
|
@ -8,33 +8,39 @@
|
||||
|
||||
<EditText
|
||||
android:id="@+id/text"
|
||||
android:layout_width="325dp"
|
||||
android:layout_height="40dp"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="70dp"
|
||||
android:background="#eee"
|
||||
android:hint="Nom du pays"
|
||||
android:paddingLeft="16px"
|
||||
android:inputType="textCapSentences"
|
||||
android:maxLines="1"
|
||||
android:textColor="@android:color/black"
|
||||
app:layout_constraintEnd_toStartOf="@+id/validate"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/validate"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="40dp"
|
||||
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_constraintStart_toEndOf="@+id/text"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<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_constraintTop_toBottomOf="@+id/text"
|
||||
tools:layout_editor_absoluteX="16dp" />
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/text" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
@ -6,24 +6,28 @@
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".MainActivity">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Hello World!"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
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_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnStartAnotherActivity"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="48dp"
|
||||
android:background="#397bb2"
|
||||
android:padding="20sp"
|
||||
android:text="Start Another Activity"
|
||||
android:textColor="#FFF"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:layout_editor_absoluteX="86dp" />
|
||||
android:id="@+id/bouton_retour"
|
||||
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"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
@ -3,22 +3,30 @@
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/border_bottom">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/image"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="72dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:layout_weight="1"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:srcCompat="@tools:sample/avatars" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/name"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:fontFamily="sans-serif-medium"
|
||||
android:textColor="@android:color/black"
|
||||
android:textSize="24sp"
|
||||
app:layout_constraintStart_toEndOf="@+id/image"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:text="Nom Pays" />
|
||||
@ -27,6 +35,7 @@
|
||||
android:id="@+id/capital"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="8dp"
|
||||
android:textColor="@android:color/black"
|
||||
app:layout_constraintStart_toEndOf="@+id/image"
|
||||
app:layout_constraintTop_toBottomOf="@+id/name"
|
||||
@ -36,8 +45,10 @@
|
||||
android:id="@+id/region"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="1dp"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:textColor="@android:color/black"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@+id/image"
|
||||
app:layout_constraintTop_toBottomOf="@+id/capital"
|
||||
tools:text="Continent: Continent" />
|
||||
|
87
app/src/main/res/layout/item_list.xml
Normal file
87
app/src/main/res/layout/item_list.xml
Normal file
@ -0,0 +1,87 @@
|
||||
<?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>
|
@ -1,28 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<navigation 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/nav_graph"
|
||||
app:startDestination="@id/FirstFragment">
|
||||
|
||||
<fragment
|
||||
android:id="@+id/FirstFragment"
|
||||
android:name="com.example.ca_contest.FirstFragment"
|
||||
android:label="@string/first_fragment_label"
|
||||
tools:layout="@layout/fragment_first">
|
||||
|
||||
<action
|
||||
android:id="@+id/action_FirstFragment_to_SecondFragment"
|
||||
app:destination="@id/SecondFragment" />
|
||||
</fragment>
|
||||
<fragment
|
||||
android:id="@+id/SecondFragment"
|
||||
android:name="com.example.ca_contest.SecondFragment"
|
||||
android:label="@string/second_fragment_label"
|
||||
tools:layout="@layout/fragment_second">
|
||||
|
||||
<action
|
||||
android:id="@+id/action_SecondFragment_to_FirstFragment"
|
||||
app:destination="@id/FirstFragment" />
|
||||
</fragment>
|
||||
</navigation>
|
@ -7,4 +7,7 @@
|
||||
<color name="teal_700">#FF018786</color>
|
||||
<color name="black">#FF000000</color>
|
||||
<color name="white">#FFFFFFFF</color>
|
||||
<color name="button">#CD4E61</color>
|
||||
<color name="validation">#2ECB60</color>
|
||||
|
||||
</resources>
|
Loading…
x
Reference in New Issue
Block a user