Commit bef3688c authored by Nastuzzi Samy's avatar Nastuzzi Samy
Browse files

Preparation of grids

Optimization
Cleaning
parent 2bd1dbc9
......@@ -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;
}
}
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;
......
......@@ -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"
......
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
<GridLayout 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" />
</LinearLayout>
android:text="@string/article" />
</GridLayout>
......@@ -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>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment