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
5e7c677a
Commit
5e7c677a
authored
Feb 16, 2024
by
Lucas NAURY
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Visuel de la page de création d'annonce
parent
7df0974e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
138 additions
and
25 deletions
+138
-25
AjoutAnnonceFragment.java
...le/tpleboncoin/ui/ajout_annonce/AjoutAnnonceFragment.java
+32
-2
AjoutAnnonceViewModel.java
...e/tpleboncoin/ui/ajout_annonce/AjoutAnnonceViewModel.java
+0
-11
fragment_ajout_annonce.xml
app/src/main/res/layout/fragment_ajout_annonce.xml
+106
-12
No files found.
app/src/main/java/com/example/tpleboncoin/ui/ajout_annonce/AjoutAnnonceFragment.java
View file @
5e7c677a
package
com
.
example
.
tpleboncoin
.
ui
.
ajout_annonce
;
import
android.content.Intent
;
import
android.os.Bundle
;
import
android.view.LayoutInflater
;
import
android.view.View
;
import
android.view.ViewGroup
;
import
android.widget.Button
;
import
android.widget.EditText
;
import
android.widget.TextView
;
import
androidx.annotation.NonNull
;
import
androidx.fragment.app.Fragment
;
import
androidx.lifecycle.ViewModelProvider
;
import
androidx.navigation.Navigation
;
import
com.example.tpleboncoin.R
;
import
com.example.tpleboncoin.databinding.FragmentAjoutAnnonceBinding
;
import
com.example.tpleboncoin.ui.home.HomeFragment
;
import
com.google.android.material.snackbar.Snackbar
;
public
class
AjoutAnnonceFragment
extends
Fragment
{
...
...
@@ -24,8 +31,31 @@ public class AjoutAnnonceFragment extends Fragment {
binding
=
FragmentAjoutAnnonceBinding
.
inflate
(
inflater
,
container
,
false
);
View
root
=
binding
.
getRoot
();
final
TextView
textView
=
binding
.
textAjoutAnnonce
;
ajout_annonceViewModel
.
getText
().
observe
(
getViewLifecycleOwner
(),
textView:
:
setText
);
final
EditText
titreAnnonce
=
binding
.
titreAnnonce
;
final
EditText
adresseAnnonce
=
binding
.
adresseAnnonce
;
final
EditText
prixAnnonce
=
binding
.
prixAnnonce
;
final
Button
boutonCreation
=
binding
.
boutonAjoutAnnonce
;
boutonCreation
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
view
)
{
// On vérifie si les informations sont correctement remplies
if
(
titreAnnonce
.
getText
().
toString
().
equals
(
""
)
||
adresseAnnonce
.
getText
().
toString
().
equals
(
""
)
||
prixAnnonce
.
getText
().
toString
().
equals
(
""
)){
Snackbar
.
make
(
view
,
"Veuillez remplir les champs pour créer l'annonce"
,
Snackbar
.
LENGTH_LONG
).
show
();
return
;
}
Navigation
.
findNavController
(
view
).
navigate
(
R
.
id
.
navigation_home
);
//Intent voirNouvelleListe = new Intent(HomeFragment.this, Accelerometre.class);
//startActivity(voirAccel);
}
});
return
root
;
}
...
...
app/src/main/java/com/example/tpleboncoin/ui/ajout_annonce/AjoutAnnonceViewModel.java
View file @
5e7c677a
...
...
@@ -5,15 +5,4 @@ import androidx.lifecycle.MutableLiveData;
import
androidx.lifecycle.ViewModel
;
public
class
AjoutAnnonceViewModel
extends
ViewModel
{
private
final
MutableLiveData
<
String
>
mText
;
public
AjoutAnnonceViewModel
()
{
mText
=
new
MutableLiveData
<>();
mText
.
setValue
(
"Ajouter une annonce"
);
}
public
LiveData
<
String
>
getText
()
{
return
mText
;
}
}
\ No newline at end of file
app/src/main/res/layout/fragment_ajout_annonce.xml
View file @
5e7c677a
...
...
@@ -6,17 +6,111 @@
android:layout_height=
"match_parent"
tools:context=
".ui.ajout_annonce.AjoutAnnonceFragment"
>
<TextView
android:id=
"@+id/text_ajout_annonce"
<LinearLayout
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_marginStart=
"8dp"
android:layout_marginTop=
"8dp"
android:layout_marginEnd=
"8dp"
android:textAlignment=
"center"
android:textSize=
"20sp"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
/>
android:layout_height=
"match_parent"
android:orientation=
"vertical"
android:padding=
"@dimen/activity_horizontal_margin"
>
<TextView
android:id=
"@+id/titre"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:fontFamily=
"sans-serif-black"
android:text=
"Création d'une annonce"
android:textAlignment=
"center"
android:textAppearance=
"@style/TextAppearance.AppCompat.Large"
android:textColor=
"@color/purple_500"
android:textSize=
"24sp"
/>
<Space
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:minHeight=
"@dimen/activity_vertical_margin"
/>
<ImageButton
android:id=
"@+id/imageButton"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:src=
"@drawable/ic_baseline_add_box_24"
/>
<Space
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:minHeight=
"@dimen/activity_vertical_margin"
/>
<TextView
android:id=
"@+id/labelTitre"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:alpha=
"100"
android:fontFamily=
"sans-serif-medium"
android:text=
"Titre de l'annonce :"
android:textAppearance=
"@style/TextAppearance.AppCompat.Medium"
/>
<EditText
android:id=
"@+id/titreAnnonce"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:ems=
"10"
android:hint=
"ex: Annonce test"
android:inputType=
"text"
android:textColorHint=
"#4D000000"
/>
<Space
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:minHeight=
"@dimen/activity_vertical_margin"
/>
<TextView
android:id=
"@+id/labelPrix"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:fontFamily=
"sans-serif-medium"
android:text=
"Prix :"
android:textAppearance=
"@style/TextAppearance.AppCompat.Medium"
/>
<EditText
android:id=
"@+id/prixAnnonce"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:ems=
"10"
android:hint=
"ex: 5.00€"
android:inputType=
"numberDecimal"
android:textColorHint=
"#4D000000"
/>
<Space
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:minHeight=
"@dimen/activity_vertical_margin"
/>
<TextView
android:id=
"@+id/labelAdresse"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:fontFamily=
"sans-serif-medium"
android:text=
"Adresse : "
android:textAppearance=
"@style/TextAppearance.AppCompat.Medium"
/>
<EditText
android:id=
"@+id/adresseAnnonce"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:ems=
"10"
android:hint=
"ex: Douai"
android:inputType=
"text"
android:textColorHint=
"#4D000000"
/>
<Space
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:minHeight=
"@dimen/activity_vertical_margin"
/>
<Button
android:id=
"@+id/boutonAjoutAnnonce"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:text=
"ajouter"
/>
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
\ 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