Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
hds
flexin
android-app
Commits
bef3688c
Commit
bef3688c
authored
Oct 28, 2017
by
Nastuzzi Samy
Browse files
Preparation of grids
Optimization Cleaning
parent
2bd1dbc9
Changes
5
Hide whitespace changes
Inline
Side-by-side
app/src/main/java/fr/utc/simde/payutc/fragments/ArticleFragment.java
View file @
bef3688c
...
...
@@ -11,6 +11,7 @@ import android.view.LayoutInflater;
import
android.view.View
;
import
android.widget.ImageView
;
import
android.widget.LinearLayout
;
import
android.widget.RelativeLayout
;
import
android.widget.TextView
;
import
com.fasterxml.jackson.databind.JsonNode
;
...
...
@@ -43,30 +44,32 @@ public class ArticleFragment extends View {
private
LayoutInflater
layoutInflater
;
private
View
view
;
private
ImageView
imageView
;
private
TextView
textView
;
private
ImageView
iv
;
private
HTTPRequest
request
;
private
LinearLayout
linearLayout
;
public
ArticleFragment
(
final
Activity
activity
,
final
JsonNode
article
)
{
super
(
activity
);
/*
this.layoutInflater = LayoutInflater.from(activity);
this.view = this.layoutInflater.inflate(R.layout.fragment_article, null);
this.textView = view.findViewById(R.id.text_article);
this.textView.setText(article.get("name").textValue());*/
this
.
id
=
article
.
get
(
"id"
).
intValue
();
this
.
price
=
article
.
get
(
"price"
).
intValue
();
this
.
name
=
article
.
get
(
"name"
).
textValue
();
this
.
imageUrl
=
article
.
get
(
"image_url"
).
textValue
();
this
.
layoutInflater
=
LayoutInflater
.
from
(
activity
);
this
.
view
=
this
.
layoutInflater
.
inflate
(
R
.
layout
.
fragment_article
,
null
);
this
.
imageView
=
view
.
findViewById
(
R
.
id
.
image_article
);
this
.
textView
=
view
.
findViewById
(
R
.
id
.
text_article
);
RelativeLayout
.
LayoutParams
parms
=
new
RelativeLayout
.
LayoutParams
(
200
,
200
);
imageView
.
setLayoutParams
(
parms
);
setView
(
activity
);
}
public
void
setView
(
final
Activity
activity
)
{
public
void
setView
(
final
Activity
activity
)
{
/*
this.textView.setText(article.get("name").textValue())
TextView t = new TextView(activity);
iv = new ImageView(activity);
iv.setTag("image_article_" + Integer.toString(this.id));
...
...
@@ -82,9 +85,10 @@ public class ArticleFragment extends View {
linearLayout.addView(iv);
linearLayout.addView(t);
linearLayout.addView(t2);
*/
if
(
this
.
imageUrl
!=
null
&&
!
this
.
imageUrl
.
equals
(
""
))
{
new
Thread
(){
new
Thread
(){
@Override
public
void
run
()
{
request
=
new
HTTPRequest
(
imageUrl
);
...
...
@@ -94,7 +98,8 @@ public class ArticleFragment extends View {
@Override
public
void
run
()
{
try
{
iv
.
setImageBitmap
(
request
.
getImageResponse
());
imageView
.
setImageBitmap
(
request
.
getImageResponse
());
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
...
...
@@ -105,6 +110,8 @@ public class ArticleFragment extends View {
}.
start
();
//new DownloadImageTask(iv).execute(this.imageUrl);
}
this
.
textView
.
setText
(
this
.
name
);
}
public
class
DownloadImageTask
extends
AsyncTask
<
String
,
Void
,
Bitmap
>
{
private
ImageView
imageView
;
...
...
@@ -138,6 +145,6 @@ public class ArticleFragment extends View {
}
public
View
getView
()
{
return
this
.
linearLayout
;
return
this
.
view
;
}
}
app/src/main/java/fr/utc/simde/payutc/fragments/ArticleGroupFragment.java
View file @
bef3688c
package
fr.utc.simde.payutc.fragments
;
import
android.app.Activity
;
import
android.util.Log
;
import
android.view.LayoutInflater
;
import
android.view.View
;
import
android.widget.GridLayout
;
...
...
app/src/main/res/layout/activity_main.xml
View file @
bef3688c
...
...
@@ -19,7 +19,8 @@
android:layout_width=
"100dp"
android:layout_height=
"100dp"
android:layout_marginBottom=
"25dp"
android:src=
"@mipmap/ic_launcher_round"
/>
android:src=
"@mipmap/ic_launcher_round"
android:contentDescription=
"@string/app_name"
/>
<TextView
android:id=
"@+id/text_app_config"
...
...
app/src/main/res/layout/fragment_article.xml
View file @
bef3688c
<?xml version="1.0" encoding="utf-8"?>
<
Linear
Layout
xmlns:android=
"http://schemas.android.com/apk/res/android"
<
Grid
Layout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:orientation=
"vertical"
>
android:orientation=
"vertical"
android:rowCount=
"2"
>
<RelativeLayout
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
android:layout_rowWeight=
"1"
>
<ImageView
android:id=
"@+id/image_article"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:src=
"@mipmap/ic_launcher"
/>
android:src=
"@mipmap/ic_launcher"
android:contentDescription=
"@string/article"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
/>
</RelativeLayout>
<TextView
android:layout_rowWeight=
"1"
android:id=
"@+id/text_article"
android:
layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
/>
</
Linear
Layout>
android:
text=
"@string/article"
/>
</
Grid
Layout>
app/src/main/res/values/strings.xml
View file @
bef3688c
...
...
@@ -69,6 +69,7 @@
<string
name=
"article_error_0"
>
n\'a aucun article à vendre
</string>
<string
name=
"article_error_get_list"
>
Impossible de récupérer la liste des articles
</string>
<string
name=
"article_error_0_categorie_not_0"
>
Toutes les catégories sont vides
</string>
<string
name=
"article"
>
Article
</string>
<string
name=
"user_no_rights"
>
n\'a aucun droit. L\'utilisateur a été automatiquement déconnecté
</string>
<string
name=
"no_right"
>
Il est nécessaire d\'avoir au moins le droit suivant:
</string>
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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