Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
U
uv-amse-android
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Lucas NAURY
uv-amse-android
Commits
6d5bca27
Commit
6d5bca27
authored
Feb 21, 2024
by
Lucas NAURY
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ajout de la DB
parent
354a4136
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
17 deletions
+12
-17
MainActivity.java
app/src/main/java/com/example/tpleboncoin/MainActivity.java
+0
-7
Annonce.java
...src/main/java/com/example/tpleboncoin/models/Annonce.java
+5
-5
HomeFragment.java
...in/java/com/example/tpleboncoin/ui/home/HomeFragment.java
+7
-5
No files found.
app/src/main/java/com/example/tpleboncoin/MainActivity.java
View file @
6d5bca27
...
@@ -24,13 +24,6 @@ public class MainActivity extends AppCompatActivity {
...
@@ -24,13 +24,6 @@ public class MainActivity extends AppCompatActivity {
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
super
.
onCreate
(
savedInstanceState
);
ArrayList
<
Annonce
>
annonces
=
new
ArrayList
<
Annonce
>();
annonces
.
add
(
new
Annonce
(
"Annonce 1"
,
"43 rue du test"
,
12
,
12.3
));
annonces
.
add
(
new
Annonce
(
"Annonce 2"
,
"12 rue du android"
,
14
,
9.3
));
annonces
.
add
(
new
Annonce
(
"Annonce 3"
,
"98 avenue du test"
,
11
,
0.3
));
annonces
.
add
(
new
Annonce
(
"Annonce 4"
,
"17 boulevard du test"
,
10
,
120.3
));
binding
=
ActivityMainBinding
.
inflate
(
getLayoutInflater
());
binding
=
ActivityMainBinding
.
inflate
(
getLayoutInflater
());
setContentView
(
binding
.
getRoot
());
setContentView
(
binding
.
getRoot
());
...
...
app/src/main/java/com/example/tpleboncoin/models/Annonce.java
View file @
6d5bca27
...
@@ -11,10 +11,10 @@ public class Annonce implements Parcelable {
...
@@ -11,10 +11,10 @@ public class Annonce implements Parcelable {
private
String
titre
;
private
String
titre
;
private
String
adresse
;
private
String
adresse
;
private
double
prix
;
private
double
prix
;
private
int
image
;
private
String
image
;
// Constructeur
// Constructeur
public
Annonce
(
String
titre
,
String
adresse
,
int
image
,
double
prix
)
{
public
Annonce
(
String
titre
,
String
adresse
,
String
image
,
double
prix
)
{
this
.
titre
=
titre
;
this
.
titre
=
titre
;
this
.
adresse
=
adresse
;
this
.
adresse
=
adresse
;
this
.
image
=
image
;
this
.
image
=
image
;
...
@@ -35,7 +35,7 @@ public class Annonce implements Parcelable {
...
@@ -35,7 +35,7 @@ public class Annonce implements Parcelable {
public
double
getPrix
(){
return
prix
;}
public
double
getPrix
(){
return
prix
;}
public
String
getAdresse
(){
return
adresse
;}
public
String
getAdresse
(){
return
adresse
;}
public
int
getImage
(){
return
image
;}
public
String
getImage
(){
return
image
;}
// Parcelable
// Parcelable
...
@@ -50,7 +50,7 @@ public class Annonce implements Parcelable {
...
@@ -50,7 +50,7 @@ public class Annonce implements Parcelable {
parcel
.
writeString
(
adresse
);
parcel
.
writeString
(
adresse
);
parcel
.
writeDouble
(
prix
);
parcel
.
writeDouble
(
prix
);
parcel
.
write
Int
(
image
);
parcel
.
write
String
(
image
);
parcel
.
writeInt
(
id
);
parcel
.
writeInt
(
id
);
}
}
public
static
final
Parcelable
.
Creator
<
Annonce
>
CREATOR
public
static
final
Parcelable
.
Creator
<
Annonce
>
CREATOR
...
@@ -67,7 +67,7 @@ public class Annonce implements Parcelable {
...
@@ -67,7 +67,7 @@ public class Annonce implements Parcelable {
titre
=
in
.
readString
();
titre
=
in
.
readString
();
adresse
=
in
.
readString
();
adresse
=
in
.
readString
();
prix
=
in
.
readDouble
();
prix
=
in
.
readDouble
();
image
=
in
.
read
Int
();
image
=
in
.
read
String
();
id
=
in
.
readInt
();
id
=
in
.
readInt
();
}
}
}
}
app/src/main/java/com/example/tpleboncoin/ui/home/HomeFragment.java
View file @
6d5bca27
...
@@ -16,6 +16,7 @@ import androidx.recyclerview.widget.LinearLayoutManager;
...
@@ -16,6 +16,7 @@ import androidx.recyclerview.widget.LinearLayoutManager;
import
androidx.recyclerview.widget.RecyclerView
;
import
androidx.recyclerview.widget.RecyclerView
;
import
com.example.tpleboncoin.R
;
import
com.example.tpleboncoin.R
;
import
com.example.tpleboncoin.db.DBManager
;
import
com.example.tpleboncoin.models.Annonce
;
import
com.example.tpleboncoin.models.Annonce
;
import
com.example.tpleboncoin.databinding.FragmentHomeBinding
;
import
com.example.tpleboncoin.databinding.FragmentHomeBinding
;
...
@@ -162,10 +163,11 @@ public class HomeFragment extends Fragment {
...
@@ -162,10 +163,11 @@ public class HomeFragment extends Fragment {
* from a local content provider or remote server.
* from a local content provider or remote server.
*/
*/
private
void
initDataset
()
{
private
void
initDataset
()
{
mDataset
=
new
ArrayList
<
Annonce
>();
DBManager
dbManager
=
DBManager
.
getDBManager
(
this
.
getContext
());
for
(
int
i
=
0
;
i
<
DATASET_COUNT
;
i
++)
{
dbManager
.
open
();
Annonce
annonce
=
new
Annonce
(
"Titre "
+
i
,
"Adresse "
+
i
,
0
,
12.99
);
mDataset
.
add
(
annonce
);
// On récupère toutes les annonces de la DB
}
mDataset
=
dbManager
.
getAll
();
}
}
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment