-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSearchResults.cs
More file actions
93 lines (84 loc) · 2.79 KB
/
SearchResults.cs
File metadata and controls
93 lines (84 loc) · 2.79 KB
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
88
89
90
91
92
93
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using Android.App;
using Android.Content;
using Android.OS;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Android.Graphics;
using Imvdb.LibreriaImvdb;
using System.Security.Policy;
using System.Net;
using Android;
//using mtw;
namespace m2w
{
public class SearchResults : BaseAdapter<Video>
{
private readonly Activity _context;
private readonly IList<Video> _videos;
public SearchResults(Activity context, IList<Video> videos)
{
_context = context;
_videos = videos;
}
public override View GetView(int position, View convertView, ViewGroup parent)
{
var view = convertView
?? _context.LayoutInflater.Inflate(Resource.Layout.Video, null);
var video = _videos[position];
//view.FindViewById<ImageView>(Resource.Id.Anteprima).SetImageURI((Uri).Parse(video.Image.t));
var imageBitmap = GetImageBitmapFromUrl(video.image.b);
var imagen = view.FindViewById<ImageView>(Resource.Id.Anteprima_img);
imagen.SetImageBitmap(imageBitmap);
view.FindViewById<TextView>(Resource.Id.SongTitle).Text = video.song_title;
view.FindViewById<TextView>(Resource.Id.Artist).Text = video.artists[position].name;
return view;
}
public override int Count
{
get { return _videos.Count; }
}
public override long GetItemId(int position)
{
return position;
}
public override Video this[int position]
{
get { return _videos[position]; }
}
public Bitmap GetImageBitmapFromUrl(string url)
{
Bitmap imageBitmap = null;
try
{
using (var webClient = new WebClient())
{
var imageBytes = webClient.DownloadData(url);
if (imageBytes != null && imageBytes.Length > 0)
{
imageBitmap = BitmapFactory.DecodeByteArray(imageBytes, 0, imageBytes.Length);
}
}
}
catch (Exception e)
{
Console.WriteLine("Exception is thrown. Message is :" + e.Message);
System.Diagnostics.Debug.WriteLine("Exception is thrown. Message is :" + e.Message);
}
return imageBitmap;
}
}
class Navigation
{
public int BackCheck { get; set; }
public Navigation()
{
this.BackCheck = 0;
}
}
}