Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
ElBuenoPeso
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
Merge Requests
0
Merge Requests
0
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
Matis SPINELLI
ElBuenoPeso
Commits
dac8b0cd
Commit
dac8b0cd
authored
Feb 22, 2024
by
Alutulu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix virgule
parent
8395ef26
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
6 additions
and
64 deletions
+6
-64
AdAdapter.kt
...c/main/java/com/example/elbuenopeso/adapters/AdAdapter.kt
+0
-38
DbAdapter.kt
...c/main/java/com/example/elbuenopeso/adapters/DbAdapter.kt
+5
-7
AddFragment.kt
...c/main/java/com/example/elbuenopeso/ui/add/AddFragment.kt
+1
-1
MarketFragment.kt
.../java/com/example/elbuenopeso/ui/market/MarketFragment.kt
+0
-18
No files found.
app/src/main/java/com/example/elbuenopeso/adapters/AdAdapter.kt
deleted
100644 → 0
View file @
8395ef26
import
android.content.Context
import
android.net.Uri
import
android.view.LayoutInflater
import
android.view.View
import
android.view.ViewGroup
import
android.widget.BaseAdapter
import
android.widget.ImageView
import
android.widget.TextView
import
com.example.elbuenopeso.R
import
com.example.elbuenopeso.models.AdModel
class
AdAdapter
(
private
val
context
:
Context
,
private
val
adModelArrayList
:
List
<
AdModel
>)
:
BaseAdapter
()
{
private
val
inflater
:
LayoutInflater
=
LayoutInflater
.
from
(
context
)
override
fun
getCount
():
Int
=
adModelArrayList
.
size
override
fun
getItem
(
i
:
Int
):
Any
=
adModelArrayList
[
i
]
override
fun
getItemId
(
i
:
Int
):
Long
=
i
.
toLong
()
fun
usingJavaStringFormat
(
input
:
Double
,
scale
:
Int
)
=
String
.
format
(
"%.${scale}f"
,
input
)
override
fun
getView
(
i
:
Int
,
view
:
View
?,
viewGroup
:
ViewGroup
):
View
{
val
ad
=
adModelArrayList
[
i
]
val
convertView
:
View
=
inflater
.
inflate
(
R
.
layout
.
item_listview_ad
,
viewGroup
,
false
)
val
imageIV
:
ImageView
=
convertView
.
findViewById
(
R
.
id
.
itemListViewImageView
)
val
titleTV
:
TextView
=
convertView
.
findViewById
(
R
.
id
.
itemListViewTitleView
)
val
addressTV
:
TextView
=
convertView
.
findViewById
(
R
.
id
.
itemListViewTextView
)
val
prixTV
:
TextView
=
convertView
.
findViewById
(
R
.
id
.
itemListViewPrixView
)
imageIV
.
setImageURI
(
Uri
.
parse
(
ad
.
image
))
titleTV
.
text
=
ad
.
title
addressTV
.
text
=
ad
.
address
prixTV
.
text
=
"${usingJavaStringFormat(ad.prix, 2)} €"
return
convertView
}
}
\ No newline at end of file
app/src/main/java/com/example/elbuenopeso/adapters/DbAdapter.kt
View file @
dac8b0cd
...
@@ -18,25 +18,23 @@ class DbAdapter(context: Context, c: Cursor, layout: Int): CursorAdapter(context
...
@@ -18,25 +18,23 @@ class DbAdapter(context: Context, c: Cursor, layout: Int): CursorAdapter(context
return
LayoutInflater
.
from
(
context
).
inflate
(
item_layout
,
viewGroup
,
false
)
return
LayoutInflater
.
from
(
context
).
inflate
(
item_layout
,
viewGroup
,
false
)
}
}
fun
usingJavaStringFormat
(
input
:
Double
,
scale
:
Int
)
=
String
.
format
(
"%.${scale}f"
,
input
)
override
fun
bindView
(
view
:
View
,
context
:
Context
,
cursor
:
Cursor
)
{
override
fun
bindView
(
view
:
View
,
context
:
Context
,
cursor
:
Cursor
)
{
val
titleTextView
:
TextView
=
view
.
findViewById
(
R
.
id
.
itemListViewTitleView
)
val
titleTextView
:
TextView
=
view
.
findViewById
(
R
.
id
.
itemListViewTitleView
)
val
addressTextView
:
TextView
=
view
.
findViewById
(
R
.
id
.
itemListViewTextView
)
val
addressTextView
:
TextView
=
view
.
findViewById
(
R
.
id
.
itemListViewTextView
)
val
imageView
:
ImageView
=
view
.
findViewById
(
R
.
id
.
itemListViewImageView
)
val
imageView
:
ImageView
=
view
.
findViewById
(
R
.
id
.
itemListViewImageView
)
val
prixView
:
TextView
=
view
.
findViewById
(
R
.
id
.
itemListViewPrixView
)
val
prixView
:
TextView
=
view
.
findViewById
(
R
.
id
.
itemListViewPrixView
)
val
_id
:
String
=
cursor
.
getString
(
cursor
.
getColumnIndexOrThrow
(
DBHelper
.
_ID
))
val
title
:
String
=
cursor
.
getString
(
cursor
.
getColumnIndexOrThrow
(
DBHelper
.
TITLE
))
val
title
:
String
=
cursor
.
getString
(
cursor
.
getColumnIndexOrThrow
(
DBHelper
.
TITLE
))
val
address
:
String
=
cursor
.
getString
(
cursor
.
getColumnIndexOrThrow
(
DBHelper
.
ADDRESS
))
val
address
:
String
=
cursor
.
getString
(
cursor
.
getColumnIndexOrThrow
(
DBHelper
.
ADDRESS
))
val
prix
:
Double
=
cursor
.
getDouble
(
cursor
.
getColumnIndexOrThrow
(
DBHelper
.
PRIX
))
val
prix
:
Double
=
cursor
.
getDouble
(
cursor
.
getColumnIndexOrThrow
(
DBHelper
.
PRIX
))
val
image
:
String
=
cursor
.
getString
(
cursor
.
getColumnIndexOrThrow
(
DBHelper
.
IMAGE
))
val
image
:
String
=
cursor
.
getString
(
cursor
.
getColumnIndexOrThrow
(
DBHelper
.
IMAGE
))
titleTextView
.
setText
(
title
)
titleTextView
.
text
=
title
addressTextView
.
setText
(
address
)
addressTextView
.
text
=
address
prixView
.
setText
(
prix
.
toString
())
prixView
.
text
=
"${usingJavaStringFormat(prix, 2)} €"
imageView
.
setImageURI
(
Uri
.
parse
(
image
))
imageView
.
setImageURI
(
Uri
.
parse
(
image
))
//with(Glide)
//TODO: trouver une alternative !!!
}
}
}
}
\ No newline at end of file
app/src/main/java/com/example/elbuenopeso/ui/add/AddFragment.kt
View file @
dac8b0cd
...
@@ -113,7 +113,7 @@ class AddFragment : Fragment() {
...
@@ -113,7 +113,7 @@ class AddFragment : Fragment() {
binding
.
title
.
text
.
toString
(),
binding
.
title
.
text
.
toString
(),
binding
.
address
.
text
.
toString
(),
binding
.
address
.
text
.
toString
(),
this
.
filePath
,
this
.
filePath
,
binding
.
price
.
text
.
toString
().
toDouble
()
binding
.
price
.
text
.
toString
().
replace
(
','
,
'.'
).
toDouble
()
)
)
dbManager
.
insert
(
ad
);
dbManager
.
insert
(
ad
);
...
...
app/src/main/java/com/example/elbuenopeso/ui/market/MarketFragment.kt
View file @
dac8b0cd
package
com.example.elbuenopeso.ui.market
package
com.example.elbuenopeso.ui.market
import
AdAdapter
import
android.database.Cursor
import
android.os.Bundle
import
android.os.Bundle
import
android.util.Log
import
android.view.LayoutInflater
import
android.view.LayoutInflater
import
android.view.View
import
android.view.View
import
android.view.ViewGroup
import
android.view.ViewGroup
import
android.widget.GridView
import
android.widget.GridView
import
android.widget.CursorAdapter
import
android.widget.ListView
import
android.widget.ListView
import
android.widget.ToggleButton
import
android.widget.ToggleButton
import
androidx.fragment.app.Fragment
import
androidx.fragment.app.Fragment
import
androidx.lifecycle.ViewModelProvider
import
androidx.lifecycle.ViewModelProvider
import
com.example.elbuenopeso.databinding.FragmentMarketBinding
import
com.example.elbuenopeso.databinding.FragmentMarketBinding
import
com.example.elbuenopeso.models.AdModel
import
com.example.elbuenopeso.R
import
com.example.elbuenopeso.R
import
com.example.elbuenopeso.adapters.DbAdapter
import
com.example.elbuenopeso.adapters.DbAdapter
import
com.example.elbuenopeso.database.DBManager
import
com.example.elbuenopeso.database.DBManager
...
@@ -49,18 +44,6 @@ class MarketFragment : Fragment() {
...
@@ -49,18 +44,6 @@ class MarketFragment : Fragment() {
toggleButton
=
binding
.
toggleButton
toggleButton
=
binding
.
toggleButton
val
listView
:
ListView
=
binding
.
listView
val
listView
:
ListView
=
binding
.
listView
// seed market items
var
annonces
:
List
<
AdModel
>
=
listOf
<
AdModel
>(
AdModel
(
"Poutre"
,
"1 rue Jean-Pierre"
,
R
.
drawable
.
pichu
.
toString
(),
25.0
),
AdModel
(
"Briques"
,
"2 rue Jean-Michel"
,
R
.
drawable
.
pichu
.
toString
(),
16.0
),
AdModel
(
"Mur en bois"
,
"4 rue Alain-Juju"
,
R
.
drawable
.
pichu
.
toString
(),
7.2
),
AdModel
(
"Maison de pierre"
,
"7 rue Joris Belhomme"
,
R
.
drawable
.
pichu
.
toString
(),
3.99
),
AdModel
(
"Téléphone de Timothé"
,
"8 rue de Timothé"
,
R
.
drawable
.
pichu
.
toString
(),
0.85
),
AdModel
(
"Oridnateur"
,
"10 rue Jean-Charles"
,
R
.
drawable
.
pichu
.
toString
(),
104.98
),
AdModel
(
"Charnières"
,
"22 rue Jeanne-Marie"
,
R
.
drawable
.
pichu
.
toString
(),
2648.97
),
AdModel
(
"Porte en marbre"
,
"1 rue Jean-Pierre"
,
R
.
drawable
.
pichu
.
toString
(),
480.0
),
AdModel
(
"Cheminée"
,
"33 rue du Gouvernement"
,
R
.
drawable
.
pichu
.
toString
(),
800.0
),
)
toggleButton
.
setOnCheckedChangeListener
{
_
,
isChecked
->
toggleButton
.
setOnCheckedChangeListener
{
_
,
isChecked
->
isGridViewEnabled
=
isChecked
isGridViewEnabled
=
isChecked
...
@@ -68,7 +51,6 @@ class MarketFragment : Fragment() {
...
@@ -68,7 +51,6 @@ class MarketFragment : Fragment() {
}
}
val
dbManager
:
DBManager
?
=
DBManager
.
getDBManager
(
requireContext
())
val
dbManager
:
DBManager
?
=
DBManager
.
getDBManager
(
requireContext
())
//dbManager!!.init()
dbManager
!!
.
open
()
dbManager
!!
.
open
()
val
cursor
=
dbManager
.
fetch
()
val
cursor
=
dbManager
.
fetch
()
adapter
=
DbAdapter
(
requireContext
(),
cursor
!!
,
R
.
layout
.
item_listview_ad
)
adapter
=
DbAdapter
(
requireContext
(),
cursor
!!
,
R
.
layout
.
item_listview_ad
)
...
...
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