Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87 public class Accueil extends Activity { private GridView grid_main; private static Drawable mNoImage; private ArrayList<String> mesUrl; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.gridplace); mNoImage = this.getResources().getDrawable(R.drawable.icon); ArrayList<Type> types = ContainerType.getTypes(); for (Type type : types) { Log.e("feedPlayer",type.toString()); } mesUrl = buildListImages(); ListTypeAdapter lfa = new ListTypeAdapter(this, types,mesUrl); grid_main = (GridView)findViewById(R.id.GridView01); grid_main.setAdapter(lfa); grid_main.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> a, View v, int position, long id) { CallFunc(position); } private void CallFunc(int position) { Bundle b = getIntent().getExtras(); int index = b.getInt("id"); Intent intent = new Intent(Accueil.this , ListeResto.class); intent.putExtra("position", index); startActivity(intent); } }); } private ArrayList<String> buildListImages() { int nbTotalImage = 21; ArrayList<String> listFic = new ArrayList<String>(); for(int i = 1; i <= nbTotalImage; i++) { listFic.add(new String(SERVER_IM + "/" + i + ".png")); } return listFic; } public static void setImage(ImageView aView, String url) { try { URL aURL = new URL(url); URLConnection conn = aURL.openConnection(); conn.connect(); InputStream is = conn.getInputStream(); // Bufferisation pour le téléchargement BufferedInputStream bis = new BufferedInputStream(is, 8192); // Création de l'image depuis le flux des données entrant Bitmap bm = BitmapFactory.decodeStream(bis); bis.close(); is.close(); // Fixe l'image sur le composant ImageView aView.setImageBitmap(bm); } catch (IOException e) { aView.setImageDrawable(mNoImage); Log.e("DVP Gallery", "Erreur téléchargement image URL : " ); e.printStackTrace(); } } }
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86 public class ListeResto extends Activity { ListView list; ListRestoAdapter adapter; private static Drawable mNoImage; private ArrayList<String> mesUrl; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.listeresto); mNoImage = this.getResources().getDrawable(R.drawable.icon); Bundle b = getIntent().getExtras(); final int index = b.getInt("position"); ArrayList<Place> places = ContainerPlace.getPlaces(); mesUrl = buildListImages(); ListRestoAdapter lfa = new ListRestoAdapter(this, places,mesUrl); ListView maListViewPerso = (ListView) findViewById(R.id.list); maListViewPerso.setAdapter(lfa); maListViewPerso.setDividerHeight(2); maListViewPerso.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> a, View v, int position, long id) { CallFunc(position); } private void CallFunc(int position) { Intent intent = new Intent(ListeResto.this , PlaceInfo.class); intent.putExtra("position",index); startActivity(intent); } }); } private ArrayList<String> buildListImages() { int nbTotalImage = 21; ArrayList<String> listFic = new ArrayList<String>(); for(int i = 1; i <= nbTotalImage; i++) { listFic.add(new String(SERVER_IM + "/" + i + ".png")); } return listFic; } public static void setImage(ImageView aView, String url) { try { URL aURL = new URL(url); URLConnection conn = aURL.openConnection(); conn.connect(); InputStream is = conn.getInputStream(); // Bufferisation pour le téléchargement BufferedInputStream bis = new BufferedInputStream(is, 8192); // Création de l'image depuis le flux des données entrant Bitmap bm = BitmapFactory.decodeStream(bis); bis.close(); is.close(); // Fixe l'image sur le composant ImageView aView.setImageBitmap(bm); } catch (IOException e) { aView.setImageDrawable(mNoImage); Log.e("DVP Gallery", "Erreur téléchargement image URL : " ); e.printStackTrace(); } } }
Partager