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
354a4136
Commit
354a4136
authored
Feb 21, 2024
by
donia
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
detailActivity
parent
ab902137
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
23 additions
and
6 deletions
+23
-6
AndroidManifest.xml
app/src/main/AndroidManifest.xml
+3
-0
DetailScreen.java
...rc/main/java/com/example/tpleboncoin/ui/DetailScreen.java
+2
-1
HomeAdapter.java
...ain/java/com/example/tpleboncoin/ui/home/HomeAdapter.java
+15
-2
HomeFragment.java
...in/java/com/example/tpleboncoin/ui/home/HomeFragment.java
+3
-3
No files found.
app/src/main/AndroidManifest.xml
View file @
354a4136
...
...
@@ -12,6 +12,9 @@
android:supportsRtl=
"true"
android:theme=
"@style/Theme.TPLeBonCoin"
tools:targetApi=
"31"
>
<activity
android:name=
".ui.DetailScreen"
android:exported=
"false"
/>
<activity
android:name=
".MainActivity"
android:exported=
"true"
...
...
app/src/main/java/com/example/tpleboncoin/ui/DetailScreen.java
View file @
354a4136
...
...
@@ -7,6 +7,7 @@ import android.content.Intent;
import
android.os.Bundle
;
import
com.example.tpleboncoin.R
;
import
com.example.tpleboncoin.models.Annonce
;
public
class
DetailScreen
extends
AppCompatActivity
{
ActivityDetailScreenBinding
binding
;
...
...
@@ -18,12 +19,12 @@ public class DetailScreen extends AppCompatActivity {
setContentView
(
binding
.
getRoot
());
Intent
intent
=
this
.
getIntent
();
if
(
intent
!=
null
){
Annonce
annonce
=
intent
.
getParcelableExtra
(
"annonce"
);
String
titre
=
intent
.
getStringExtra
(
"titre"
);
String
adresse
=
intent
.
getStringExtra
(
"adresse"
);
String
description
=
intent
.
getStringExtra
(
"description"
);
Double
prix
=
intent
.
getDoubleExtra
(
"prix"
,
999
);
binding
.
adresseTextView
.
setText
(
adresse
);
binding
.
prixTextView
.
setText
(
prix
.
toString
()+
" €"
);
binding
.
imageView
.
setImageResource
(
R
.
drawable
.
ic_account_circle_black_24dp
);
...
...
app/src/main/java/com/example/tpleboncoin/ui/home/HomeAdapter.java
View file @
354a4136
package
com
.
example
.
tpleboncoin
.
ui
.
home
;
import
android.app.Activity
;
import
android.content.Context
;
import
android.content.Intent
;
import
android.util.Log
;
import
android.view.LayoutInflater
;
import
android.view.View
;
import
android.view.ViewGroup
;
import
android.widget.TextView
;
import
androidx.activity.result.contract.ActivityResultContracts
;
import
androidx.recyclerview.widget.RecyclerView
;
import
com.example.tpleboncoin.R
;
import
com.example.tpleboncoin.models.Annonce
;
import
com.example.tpleboncoin.ui.DetailScreen
;
import
java.util.ArrayList
;
...
...
@@ -19,6 +25,7 @@ public class HomeAdapter extends RecyclerView.Adapter<HomeAdapter.ViewHolder> {
private
ArrayList
<
Annonce
>
mDataSet
;
private
boolean
mIsGrid
;
private
static
Context
mContext
;
/**
* Provide a reference to the type of views that you are using (custom ViewHolder)
...
...
@@ -34,6 +41,11 @@ public class HomeAdapter extends RecyclerView.Adapter<HomeAdapter.ViewHolder> {
@Override
public
void
onClick
(
View
v
)
{
// TODO : mettre la page de Donia
Intent
detailIntent
=
new
Intent
(
mContext
,
DetailScreen
.
class
);
detailIntent
.
putExtra
(
"titre"
,
titreTextView
.
getText
());
detailIntent
.
putExtra
(
"adresse"
,
adresseTextView
.
getText
());
v
.
getContext
().
startActivity
(
detailIntent
);
//detailIntent.putExtra("prix", prix);
Log
.
d
(
TAG
,
"Element "
+
getAdapterPosition
()
+
" clicked."
);
}
});
...
...
@@ -55,9 +67,10 @@ public class HomeAdapter extends RecyclerView.Adapter<HomeAdapter.ViewHolder> {
* @param dataSet String[] containing the data to populate views to be used by RecyclerView.
* @param isGrid boolean = le layout actuel (grille ou linéaire)
*/
public
HomeAdapter
(
ArrayList
<
Annonce
>
dataSet
,
boolean
isGrid
)
{
public
HomeAdapter
(
ArrayList
<
Annonce
>
dataSet
,
boolean
isGrid
,
Context
context
)
{
mDataSet
=
dataSet
;
mIsGrid
=
isGrid
;
mContext
=
context
;
}
// Create new views (invoked by the layout manager)
...
...
app/src/main/java/com/example/tpleboncoin/ui/home/HomeFragment.java
View file @
354a4136
...
...
@@ -86,7 +86,7 @@ public class HomeFragment extends Fragment {
}
// adapter pour gérer le visu de l'annonce
mAdapter
=
new
HomeAdapter
(
mDataset
,
false
);
mAdapter
=
new
HomeAdapter
(
mDataset
,
false
,
this
.
getContext
()
);
mRecyclerView
.
setAdapter
(
mAdapter
);
// bouton pour changer de layout
...
...
@@ -130,7 +130,7 @@ public class HomeFragment extends Fragment {
mCurrentLayoutManagerType
=
LayoutManagerType
.
GRID_LAYOUT_MANAGER
;
// redéfinition de l'adapter
mAdapter
=
new
HomeAdapter
(
mDataset
,
true
);
mAdapter
=
new
HomeAdapter
(
mDataset
,
true
,
this
.
getContext
()
);
mRecyclerView
.
setAdapter
(
mAdapter
);
break
;
case
LINEAR_LAYOUT_MANAGER:
...
...
@@ -138,7 +138,7 @@ public class HomeFragment extends Fragment {
mCurrentLayoutManagerType
=
LayoutManagerType
.
LINEAR_LAYOUT_MANAGER
;
// redéfinition de l'adapter
mAdapter
=
new
HomeAdapter
(
mDataset
,
false
);
mAdapter
=
new
HomeAdapter
(
mDataset
,
false
,
this
.
getContext
()
);
mRecyclerView
.
setAdapter
(
mAdapter
);
break
;
default
:
...
...
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