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

Optimization

Toast the article with the price
Bug fix
parent ef8bdadc
......@@ -5,7 +5,6 @@ import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.AsyncTask;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
......@@ -13,6 +12,7 @@ import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;
import com.fasterxml.jackson.databind.JsonNode;
......@@ -123,9 +123,15 @@ public class ArticleAdapter extends BaseAdapter {
}
}
public void toast(final int position, int lengthLong) {
Toast.makeText(this.activity, articleList.get(position).get("name").textValue() + ": " + String.format("%.2f", new Float(articleList.get(position).get("price").intValue()) / 100.00f) + "€", lengthLong).show();
}
public void onClick(final int position) {
this.nbrClicksList[position]++;
setClickView(position);
toast(position, Toast.LENGTH_SHORT);
}
public void clear() {
......@@ -144,7 +150,7 @@ public class ArticleAdapter extends BaseAdapter {
if (imageList[position] != null)
imageView.setImageBitmap(imageList[position]);
else if (url != null && !url.equals("")) {/*
else if (url != null && !url.equals("")) {
new Thread(){
@Override
public void run() {
......@@ -164,8 +170,8 @@ public class ArticleAdapter extends BaseAdapter {
});
}
}
}.start();*/
new DownloadImageTask(imageView, imageList[position]).execute(url);
}.start();
//new DownloadImageTask(imageView, imageList[position]).execute(url);
}
}
......
......@@ -63,10 +63,9 @@ public class ArticleGroupFragment implements TabHost.TabContentFactory {
gridView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
@Override
public boolean onItemLongClick(AdapterView<?> adapterView, View view, int position, long id) {
JsonNode article = ((JsonNode) articleAdapter.getArticle(position));
Toast.makeText(activity, article.get("name").textValue() + ": " + String.format("%.2f", new Float(article.get("price").intValue()) / 100.00f) + "€", Toast.LENGTH_LONG).show();
articleAdapter.toast(position, Toast.LENGTH_LONG);
return false;
return true;
}
});
}
......
......@@ -6,13 +6,12 @@
android:gravity="center_horizontal"
android:layout_rowWeight="1"
android:orientation="vertical"
android:layout_marginTop="15dp"
android:layout_marginBottom="5dp"
android:rowCount="2">
<RelativeLayout
android:layout_width="match_parent"
android:gravity="center_horizontal"
android:layout_marginTop="10dp"
android:layout_rowWeight="1">
<ImageView
......@@ -42,6 +41,7 @@
<RelativeLayout
android:layout_width="match_parent"
android:gravity="center_horizontal"
android:layout_marginBottom="5dp"
android:layout_rowWeight="1">
<TextView
......
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