public void llenarlista()
        {
            var linkesess = new List <string>();

            listareprod.Clear();
            try
            {
                string[] items = Directory.GetFiles(Android.OS.Environment.ExternalStorageDirectory.AbsolutePath + "/gr3playerplaylist/");


                for (int i = 0; i < items.Length; i++)

                {
                    listareprod2 = items.ToList();
                    listareprod.Add(Path.GetFileNameWithoutExtension(items[i]));
                    if (File.ReadAllText(items[i]).Trim().Length > 4)
                    {
                        linkesess.Add(File.ReadAllText(items[i]).Trim().Split('$')[1].Split(';')[0]);
                    }
                    else
                    {
                        linkesess.Add(items[i]);
                    }
                }
                adapterlistaremotoconeliminar adaptador2 = new adapterlistaremotoconeliminar(this, listareprod, linkesess, "noser", true, false);
                RunOnUiThread(() =>
                {
                    var parcelable  = listbox.OnSaveInstanceState();
                    listbox.Adapter = adaptador2;
                    listbox.OnRestoreInstanceState(parcelable);
                });
                if (listareprod.Count == 0)
                {
                    var adaptadolss = new ArrayAdapter <string>(this, Android.Resource.Layout.SimpleListItem1, new List <string> {
                        "No hay elementos para mostrar.."
                    });
                    RunOnUiThread(() => {
                        var parcelable  = listbox.OnSaveInstanceState();
                        listbox.Adapter = adaptadolss;
                        listbox.OnRestoreInstanceState(parcelable);
                    });
                }
            }
            catch (Exception)
            {
                Directory.CreateDirectory(Android.OS.Environment.ExternalStorageDirectory.AbsolutePath + "/gr3playerplaylist");
                llenarlista();
            }
        }
        public void six(object sender, EventArgs e)
        {
            listanombres = YoutubePlayerServerActivity.gettearinstancia().lapara;
            listalinks   = YoutubePlayerServerActivity.gettearinstancia().laparalinks;



            // botoneliminar.SetBackgroundResource(Resource.Drawable.playlistedit);
            if (listanombres.Count > 0)
            {
                adapterlistaremotoconeliminar adalter22 = new adapterlistaremotoconeliminar(this, listanombres, listalinks, textbox.Text, false, true);
                var parcelable = listbox.OnSaveInstanceState();
                listbox.Adapter = adalter22;
                listbox.OnRestoreInstanceState(parcelable);
            }
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.Menulistaoffline);
            string ipadress = Intent.GetStringExtra("ipadre");

            listareprod   = new List <string>();
            listareprod2  = new List <string>();
            textboxtitulo = FindViewById <TextView>(Resource.Id.textView1);
            ImageView playpause    = FindViewById <ImageView>(Resource.Id.imageView5);
            var       botonelimiar = FindViewById <Android.Support.Design.Widget.FloatingActionButton>(Resource.Id.imageView7);
            var       botonagregar = FindViewById <Android.Support.Design.Widget.FloatingActionButton>(Resource.Id.imageView6);
            ImageView botonhome    = FindViewById <ImageView>(Resource.Id.imageView4);

            listbox = FindViewById <ListView>(Resource.Id.listView1);
            ImageView botonreproducir = FindViewById <ImageView>(Resource.Id.imageView3);

            lineall2     = FindViewById <LinearLayout>(Resource.Id.linearLayout1);
            listaenlinea = Intent.GetStringExtra("listaenlinea");
            lineaa       = FindViewById <LinearLayout>(Resource.Id.linearlayout0);
            instance     = this;

            botonagregar.Enabled = true;
            //  animar2(lineall2);
            var adaptadolo = new ArrayAdapter <string>(this, Android.Resource.Layout.SimpleListItem1, new List <string> {
                "No hay elementos para mostrar.."
            });

            RunOnUiThread(() => {
                var parcelable  = listbox.OnSaveInstanceState();
                listbox.Adapter = adaptadolo;
                listbox.OnRestoreInstanceState(parcelable);
            });
            llenarlista();
            AnimationHelper.AnimateFAB(botonagregar);
            // lineaa.SetBackgroundColor(Android.Graphics.Color.DarkGray);
            tree = new Thread(new ThreadStart(cojerstream));
            tree.Start();
            textboxtitulo.Selected = true;
            // botonelimiar.SetBackgroundResource(Resource.Drawable.playlistedit);
            UiHelper.SetBackgroundAndRefresh(this);
            //  lineall2.SetBackgroundColor(Android.Graphics.Color.ParseColor("#2b2e30"));

            listbox.ItemClick += (aaa, aaaa) =>
            {
                if (listareprod.Count > 0)
                {
                    if (File.ReadAllText(Android.OS.Environment.ExternalStorageDirectory.AbsolutePath + "/gr3playerplaylist/" + listareprod[aaaa.Position]).Split('$')[0].Split(';').ToList().Count >= 1 && File.ReadAllText(Android.OS.Environment.ExternalStorageDirectory.AbsolutePath + "/gr3playerplaylist/" + listareprod[aaaa.Position]).Split('$')[0].Split(';')[0].Trim() != "")
                    {
                        Intent internado = new Intent(this, typeof(Reproducirlistadialog));
                        internado.PutExtra("ip", Intent.GetStringExtra("ipadre"));
                        internado.PutExtra("nombrelista", listareprod[aaaa.Position]);
                        internado.PutExtra("index", aaaa.Position.ToString());
                        StartActivity(internado);
                    }
                    else
                    {
                        Toast.MakeText(this, "La lista esta vacia", ToastLength.Long).Show();
                    }
                }
            };
            botonelimiar.Click += delegate
            {
                animar(botonelimiar);
                if (eneliminacion)
                {
                    eneliminacion = false;
                    //  botonelimiar.SetBackgroundResource(Resource.Drawable.playlistedit);
                    ArrayAdapter adaptador  = new ArrayAdapter(this, Android.Resource.Layout.SimpleListItem1, listareprod);
                    var          parcelable = listbox.OnSaveInstanceState();

                    listbox.Adapter = adaptador;
                    listbox.OnRestoreInstanceState(parcelable);
                }

                else
                {
                    //   botonelimiar.SetBackgroundResource(Resource.Drawable.playlistcheck);
                    adapterlistaremotoconeliminar adaptador = new adapterlistaremotoconeliminar(this, listareprod, listareprod2, "noser", true, false);
                    var parcelable = listbox.OnSaveInstanceState();
                    listbox.Adapter = adaptador;
                    listbox.OnRestoreInstanceState(parcelable);
                    eneliminacion = true;
                }
            };
            botonagregar.Click += delegate
            {
                /*  Intent intento = new Intent(this,typeof(agregarlistaoffline));
                 * intento.PutExtra("ipadre", ipadress);
                 * StartActivity(intento);
                 */
                EditText texto = new EditText(this);
                texto.Hint = "Nombre de la lista";

                new AlertDialog.Builder(this)
                .SetTitle("Introduzca el nombre de la nueva lista de reproduccion")
                .SetView(texto)
                .SetCancelable(false)
                .SetNegativeButton("Cancelar", (ax, ax100) => { })
                .SetPositiveButton("Crear", (xd, xdd) => {
                    if (texto.Text.Length < 3)
                    {
                        Toast.MakeText(this, "El nombre debe tener almenos 3 caracteres", ToastLength.Long).Show();
                    }
                    else
                    {
                        var saas = Directory.GetFiles(Android.OS.Environment.ExternalStorageDirectory.AbsolutePath + "/gr3playerplaylist");
                        if (!saas.Contains(Android.OS.Environment.ExternalStorageDirectory.AbsolutePath + "/gr3playerplaylist/" + RemoveIllegalPathCharacters(texto.Text)))
                        {
                            crearlista(texto.Text);
                        }
                        else
                        {
                            AlertDialog.Builder ad = new AlertDialog.Builder(this);
                            ad.SetTitle("Advertencia");
                            ad.SetMessage("El elemento " + texto.Text + " ya existe desea reemplazarlo??");
                            ad.SetCancelable(false);
                            ad.SetIcon(Resource.Drawable.warningsignonatriangularbackground);
                            ad.SetPositiveButton("Si", (axx, axxx) => {
                                crearlista(texto.Text);
                            });
                            ad.SetNegativeButton("No", (ux, uxdd) => {
                                Toast.MakeText(this, "Operacion cancelada", ToastLength.Long).Show();
                            });
                            ad.Create();
                            ad.Show();
                        }
                    }
                })
                .Create().Show();
            };

            playpause.Click += delegate
            {
                animar(playpause);
                YoutubePlayerServerActivity.gettearinstancia().imgPlay.PerformClick();
            };
            botonhome.Click += delegate
            {
                animar(botonhome);

                tree.Abort();
                this.Finish();
            };



            // Create your application here
        }
Пример #4
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.loadplaylistoffline);
            string ipadre = Intent.GetStringExtra("ip");


            llayout         = FindViewById <LinearLayout>(Resource.Id.linearlayout0);
            llayout2        = FindViewById <LinearLayout>(Resource.Id.linearLayout1);
            botonatras      = FindViewById <ImageView>(Resource.Id.imageView1);
            botonreproducir = FindViewById <Button>(Resource.Id.imageView3);
            listbox         = FindViewById <ListView>(Resource.Id.listView1);
            botonborrar     = FindViewById <ImageView>(Resource.Id.imageView2);
            fondo           = FindViewById <ImageView>(Resource.Id.fondo1);
            animar2(llayout2);
            nombrelista = Intent.GetStringExtra("nombrelista");


            //  llayout.SetBackgroundColor(Android.Graphics.Color.DarkGray);
            //  llayout2.SetBackgroundColor(Android.Graphics.Color.ParseColor(clasesettings.gettearvalor("color")));
            animar2(llayout2);
            // Create your application here
            this.SetFinishOnTouchOutside(true);
            string listaenlinea = File.ReadAllText(Android.OS.Environment.ExternalStorageDirectory.AbsolutePath + "/gr3playerplaylist/" + nombrelista);

            new Thread(() =>
            {
                adart();
            }
                       ).Start();



            partes = listaenlinea.Split('$')[0].Split(';').ToList();
            links  = listaenlinea.Split('$')[1].Split(';').ToList();
            if (partes[partes.Count - 1].Trim() == "")
            {
                partes.RemoveAt(partes.Count - 1);
                links.RemoveAt(links.Count - 1);
            }
            int indez = 0;

            botonborrar.SetBackgroundResource(Resource.Drawable.playlistedit);
            foreach (string it in partes.ToArray())
            {
                if (it.StartsWith(">"))
                {
                    string        papu = it;
                    StringBuilder ee   = new StringBuilder(papu);
                    ee.Replace('>', ' ');
                    ee.Replace('<', ' ');

                    partes[indez] = ee.ToString();
                }

                indez++;
            }

            var lista = partes.ToList();


            adapterlistaremotoconeliminar adalteeel = new adapterlistaremotoconeliminar(this, partes.ToList(), links.ToList(), nombrelista, false, false);

            var parcelable = listbox.OnSaveInstanceState();

            listbox.Adapter = adalteeel;
            listbox.OnRestoreInstanceState(parcelable);

            new Thread(() =>
            {
                try
                {
                    var imagen = ImageHelper.GetImageBitmapFromUrl("http://i.ytimg.com/vi/" + links[0].Split('=')[1] + "/mqdefault.jpg");
                    RunOnUiThread(() =>
                    {
                        fondo.SetImageBitmap(imagen);
                        animar4(fondo);
                    });
                }
                catch (Exception)
                {
                }
            }).Start();


            //   adart(adalteeel);



            listbox.ItemClick += (aa, aaa) =>
            {
                if (links.Count > 0)
                {
                    Intent intento = new Intent(this, typeof(customdialogact));
                    intento.PutExtra("color", "DarkGray");
                    intento.PutExtra("url", links[aaa.Position]);
                    intento.PutExtra("titulo", partes[aaa.Position]);
                    intento.PutExtra("ipadress", "localhost");
                    intento.PutExtra("imagen", @"https://i.ytimg.com/vi/" + links[aaa.Position].Split('=')[1] + "/hqdefault.jpg");
                    StartActivity(intento);
                }
            };

            botonatras.Click += delegate
            {
                animar(botonatras);
                cerraractividad();
            };
            botonreproducir.Click += delegate
            {
                var indice = int.Parse(Intent.GetStringExtra("index"));
                new Thread(() =>
                {
                    YoutubePlayerServerActivity.gettearinstancia().reproducirlalistalocal(nombrelista);
                }).Start();
                cerraractividad();
            };
            botonborrar.Click += delegate
            {
                animar(botonborrar);


                if (enedicion == false)
                {
                    animar(botonborrar);
                    enedicion = true;
                    botonborrar.SetBackgroundResource(Resource.Drawable.playlistcheck);
                    adapterlistaremotoconeliminar adalteeel33 = new adapterlistaremotoconeliminar(this, partes.ToList(), links.ToList(), nombrelista, false, false);
                    var parcelablex = listbox.OnSaveInstanceState();
                    listbox.Adapter = adalteeel33;
                    listbox.OnRestoreInstanceState(parcelablex);
                }
                else
                {
                    animar(botonborrar);
                    enedicion = false;
                    botonborrar.SetBackgroundResource(Resource.Drawable.playlistedit);
                    adapterlistaremotoconeliminar adalteeel2 = new adapterlistaremotoconeliminar(this, partes.ToList(), links.ToList(), nombrelista, false, false);

                    var parcelablexx = listbox.OnSaveInstanceState();
                    listbox.Adapter = adalteeel2;
                    listbox.OnRestoreInstanceState(parcelablexx);
                }
            };
        }