Created
December 30, 2016 05:18
-
-
Save ajpinedam/3ab51fc64f52cf90fe9450c4cc60c276 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using Android.App; | |
| using Android.Widget; | |
| using Android.OS; | |
| using Android.Content; | |
| using Android.Appwidget; | |
| using Android.Runtime; | |
| using Android.Views; | |
| using System.Net.Sockets; | |
| using System.Text; | |
| using System.Threading; | |
| using System; | |
| using Android.Webkit; | |
| using System.Collections.Generic; | |
| namespace App1 | |
| { | |
| [Activity(Label = "mainmenu")] | |
| public class mainmenu : Activity | |
| { | |
| public TcpClient clientela; | |
| public bool detenedor = true; | |
| public ListView lista; | |
| public ArrayAdapter<string> adaptadol; | |
| protected override void OnCreate(Bundle savedInstanceState) | |
| { | |
| base.OnCreate(savedInstanceState); | |
| SetContentView(Resource.Layout.perfectmain); | |
| string ip; | |
| clientela = new TcpClient(); | |
| try | |
| { | |
| ip = Intent.GetStringExtra("MyData") ?? "Data not available"; | |
| clientela.Client.Connect(ip.Trim(), 100); | |
| } | |
| catch (SocketException) | |
| { | |
| } | |
| Thread actualizarlista = new Thread(new ThreadStart(cojerstream)); | |
| actualizarlista.Start(); | |
| Thread recallear = new Thread(new ThreadStart(recalear)); | |
| recallear.Start(); | |
| ///////////////////////////////#Botones#//////////////////////////////// | |
| ImageView atras = FindViewById<ImageView>(Resource.Id.imageView2); | |
| ImageView adelante = FindViewById<ImageView>(Resource.Id.imageView4); | |
| ImageView play = FindViewById<ImageView>(Resource.Id.imageView3); | |
| ImageView adelantar = FindViewById<ImageView>(Resource.Id.imageView5); | |
| ImageView atrazar = FindViewById<ImageView>(Resource.Id.imageView7); | |
| ImageView fullscreen = FindViewById<ImageView>(Resource.Id.imageView6); | |
| ImageView download = FindViewById<ImageView>(Resource.Id.imageView8); | |
| ImageView voldown = FindViewById<ImageView>(Resource.Id.imageView9); | |
| ImageView volup = FindViewById<ImageView>(Resource.Id.imageView10); | |
| ImageView agregar = FindViewById<ImageView>(Resource.Id.imageView11); | |
| ImageView buscar = FindViewById<ImageView>(Resource.Id.imageView12); | |
| EditText textbox = FindViewById<EditText>(Resource.Id.editText1); | |
| lista = FindViewById<ListView>(Resource.Id.listView1); | |
| //////////////////////////////////////////////////////////////////////// | |
| ///////////////////////////////#clicks#///////////////////////////////// | |
| lista.ItemClick += (sender, easter) => | |
| { | |
| if(lista.Count>0) | |
| { | |
| clientela.Client.Send(Encoding.ASCII.GetBytes("pedirindice();")); | |
| Thread.Sleep(15); | |
| clientela.Client.Send(Encoding.ASCII.GetBytes(easter.Position.ToString())); | |
| } | |
| }; | |
| lista.ItemSelected += (sender, easter) => | |
| { | |
| }; | |
| atras.Click += (sender, easter) => | |
| { | |
| clientela.Client.Send(Encoding.ASCII.GetBytes("back();")); | |
| }; | |
| adelante.Click += (sender, easter) => | |
| { | |
| clientela.Client.Send(Encoding.ASCII.GetBytes("next();")); | |
| }; | |
| play.Click += (sender, easter) => | |
| { | |
| clientela.Client.Send(Encoding.ASCII.GetBytes("playpause();")); | |
| }; | |
| adelantar.Click += (sender, easter) => | |
| { | |
| clientela.Client.Send(Encoding.ASCII.GetBytes("actual+();")); | |
| }; | |
| atrazar.Click += (sender, easter) => | |
| { | |
| clientela.Client.Send(Encoding.ASCII.GetBytes("actual-();")); | |
| }; | |
| fullscreen.Click += (sender, easter) => | |
| { | |
| clientela.Client.Send(Encoding.ASCII.GetBytes("fullscreen();")); | |
| }; | |
| download.Click += (sender, easter) => | |
| { | |
| clientela.Client.Send(Encoding.ASCII.GetBytes("descmp3();")); | |
| }; | |
| voldown.Click += (sender, easter) => | |
| { | |
| clientela.Client.Send(Encoding.ASCII.GetBytes("vol-();")); | |
| }; | |
| volup.Click += (sender, easter) => | |
| { | |
| clientela.Client.Send(Encoding.ASCII.GetBytes("vol+();")); | |
| }; | |
| agregar.Click += (sender, easter) => | |
| { | |
| clientela.Client.Send(Encoding.ASCII.GetBytes("agregar();")); | |
| Thread.Sleep(20); | |
| detenedor = false; | |
| clientela.Client.Send(Encoding.ASCII.GetBytes(textbox.Text.Trim())); | |
| textbox.Text = ""; | |
| detenedor = true; | |
| }; | |
| buscar.Click += (sender, easter) => | |
| { | |
| detenedor = false; | |
| clientela.Client.Send(Encoding.ASCII.GetBytes(textbox.Text.Trim())); | |
| textbox.Text = ""; | |
| detenedor = true; | |
| }; | |
| //////////////////////////////////////////////////////////////////////// | |
| //////////////////////////////////////////////////////////////////////// | |
| } | |
| public void cojerstream() | |
| { | |
| List<string> lista2 = new List<string>(); | |
| while (detenedor == true && clientela.Connected == true) | |
| { | |
| var stream = clientela.GetStream(); | |
| byte[] bites = new byte[256]; | |
| int o; | |
| while((o=stream.Read(bites,0,bites.Length))!=0) | |
| { | |
| string capturado = Encoding.ASCII.GetString(bites, 0, o); | |
| if (capturado == "ya();") | |
| { | |
| adaptadol = new ArrayAdapter<string>(this, Android.Resource.Layout.SimpleListItem1, lista2); | |
| RunOnUiThread(() => lista.Adapter = adaptadol); | |
| adaptadol.NotifyDataSetChanged(); | |
| lista2.Clear(); | |
| } | |
| else | |
| if (capturado != " ") | |
| { | |
| lista2.Add(capturado); | |
| capturado = ""; | |
| } | |
| } | |
| } | |
| } | |
| public void recalear() { | |
| while (detenedor == true && clientela.Connected == true) { | |
| Thread.Sleep(1000); | |
| clientela.Client.Send(Encoding.ASCII.GetBytes("recall();")); | |
| } | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment