Esempio n. 1
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            // Use this to return your custom view for this Fragment
            // return inflater.Inflate(Resource.Layout.YourFragment, container, false);
            View view = inflater.Inflate(Resource.Layout.ax_Settings, container, false);

            ax_settings = this;

            // --------- SET VARS ---------

            var cbookmarks = view.FindViewById(Resource.Id.clearbookmarks);
            var chistory   = view.FindViewById(Resource.Id.clearhistory);

            msearch    = view.FindViewById <CheckBox>(Resource.Id.msearch);
            hdasearch  = view.FindViewById <CheckBox>(Resource.Id.hdasearch);
            asearch    = view.FindViewById <CheckBox>(Resource.Id.asearch);
            basearch   = view.FindViewById <CheckBox>(Resource.Id.basearch);
            tvasearch  = view.FindViewById <CheckBox>(Resource.Id.tvasearch);
            htvasearch = view.FindViewById <CheckBox>(Resource.Id.htvasearch);
            bmsearch   = view.FindViewById <CheckBox>(Resource.Id.bmsearch);
            hdbasearch = view.FindViewById <CheckBox>(Resource.Id.hdbasearch);

            savelinks  = view.FindViewById <CheckBox>(Resource.Id.savelinks);
            savetitles = view.FindViewById <CheckBox>(Resource.Id.savetitles);
            savem3u    = view.FindViewById <CheckBox>(Resource.Id.savem3u);

            Button updatebtt = view.FindViewById <Button>(Resource.Id.update);

            updatebtt.Visibility = ViewStates.Gone;


            // --------- PING DATA ---------

            seachBoxes = new List <CheckBox> {
                msearch, hdasearch, asearch, basearch, tvasearch, bmsearch, htvasearch, hdbasearch
            };
            for (int i = 0; i < seachBoxes.Count; i++)
            {
                searchTxts[i] = seachBoxes[i].Text;
            }

            Button pingBtt = view.FindViewById <Button>(Resource.Id.pingProviders);

            pingBtt.Click += (o, e) =>
            {
                for (int i = 0; i < providersCount; i++)
                {
                    DelegateWithParameters_int ping =
                        new DelegateWithParameters_int(Ping);

                    IAsyncResult tag =
                        ping.BeginInvoke(i, null, null);
                }
            };

            Button showBtt = view.FindViewById <Button>(Resource.Id.showProviders);

            showBtt.Click += (o, e) =>
            {
                showSites = !showSites;
                for (int i = 0; i < providersCount; i++)
                {
                    seachBoxes[i].Text = searchTxts[i] + (showSites ? (" (" + pingLinks[i] + ")") : "");
                }
            };

            // --------- AUTO UPDATE ---------

            version = Context.PackageManager.GetPackageInfo(Context.PackageName, 0).VersionName;
            TextView versionTxt = view.FindViewById <TextView>(Resource.Id.versionTxt);

            versionTxt.Text = "v" + version;
            sThred          = new Java.Lang.Thread(() =>
            {
                try {
                    WebClient client = new WebClient();
                    string d         = client.DownloadString("https://github.com/LagradOst/CloudStream/releases");
                    string look      = "/LagradOst/CloudStream/releases/tag/";
                    //   float bigf = -1;
                    //     string bigUpdTxt = "";
                    // while (d.Contains(look)) {
                    string tag     = FindHTML(d, look, "\"");
                    string updText = FindHTML(d, look + tag + "\">", "<");

                    /*
                     *  try {
                     *      float tagf = float.Parse(tag.Replace("v", ""));
                     *      print("" + tagf);
                     *      if(tagf > bigf) {
                     *          bigf = tagf;
                     *          bigUpdTxt = updText;
                     *      }
                     *  }
                     *  catch (Exception) {
                     *
                     *  }
                     *  d = d.Substring(d.IndexOf(look) + 1, d.Length - d.IndexOf(look) - 1);
                     */
                    updatebtt.Click += (o, e) =>
                    {
                        if (version != updateTo && updateTo != "-1")
                        {
                            string downloadLink = "https://github.com/LagradOst/CloudStream/releases/download/" + updateTo + "/CloudStream.CloudStream.apk";
                            DownloadFromLink(downloadLink, "CloudStream-" + updateTo, "Downloading APK", this, ".apk", true);
                            updatebtt.Visibility = ViewStates.Gone;
                        }
                    };

                    if (tag != "")
                    {
                        Activity.RunOnUiThread(new Action(() =>
                        {
                            updateTo = tag;
                            if (tag == "v" + version)
                            {
                                versionTxt.Text      = "v" + version + " (Up to date)";
                                updatebtt.Visibility = ViewStates.Gone;
                            }
                            else
                            {
                                versionTxt.Text      = "v" + version + " -> " + tag + " (" + updText + ")";
                                updatebtt.Visibility = ViewStates.Visible;
                                updatebtt.Text       = "Update to " + tag;
                            }
                        }));
                    }
                }
                finally {
                    sThred.Join();
                }
            });
            if (searchForUpdates)
            {
                sThred.Start();
            }
            //  var sdownloads =  view.FindViewById(Resource.Id.showdownloads);

            // sdownloads.Click += (o,e) => MainActivity.mainActivity.ShowDownloads();



            // --------- DEF DATA ---------

            var set = Application.Context.GetSharedPreferences("Settings", FileCreationMode.Private);

            msearch.Checked    = set.GetBoolean("msearch", true);
            hdasearch.Checked  = set.GetBoolean("hdasearch", haveAnimeEnabled);
            asearch.Checked    = set.GetBoolean("asearch", false);
            basearch.Checked   = set.GetBoolean("basearch", false);
            tvasearch.Checked  = set.GetBoolean("tvasearch", false);
            bmsearch.Checked   = set.GetBoolean("bmsearch", false);
            htvasearch.Checked = set.GetBoolean("htvasearch", true);
            hdbasearch.Checked = set.GetBoolean("hdbasearch", false);
            savem3u.Checked    = set.GetBoolean("savem3u", false);

            if (!haveAnimeEnabled)
            {
                hdasearch.Visibility  = ViewStates.Gone;
                asearch.Visibility    = ViewStates.Gone;
                basearch.Visibility   = ViewStates.Gone;
                hdbasearch.Visibility = ViewStates.Gone;
            }


            // --------- SAVE DATA ---------

            savelinks.Checked  = set.GetBoolean("savelinks", true);
            savetitles.Checked = set.GetBoolean("savetitles", true);

            msearch.Click    += (o, e) => SaveBool("msearch", msearch.Checked);
            hdasearch.Click  += (o, e) => SaveBool("hdasearch", hdasearch.Checked);
            asearch.Click    += (o, e) => SaveBool("asearch", asearch.Checked);
            basearch.Click   += (o, e) => SaveBool("basearch", basearch.Checked);
            tvasearch.Click  += (o, e) => SaveBool("tvasearch", tvasearch.Checked);
            bmsearch.Click   += (o, e) => SaveBool("bmsearch", bmsearch.Checked);
            htvasearch.Click += (o, e) => SaveBool("htvasearch", htvasearch.Checked);
            hdbasearch.Click += (o, e) => SaveBool("hdbasearch", hdbasearch.Checked);

            savelinks.Click  += (o, e) => SaveBool("savelinks", savelinks.Checked);
            savetitles.Click += (o, e) => SaveBool("savetitles", savetitles.Checked);
            savem3u.Click    += (o, e) => SaveBool("savem3u", savem3u.Checked); // M3U FILE

            // --------- HISTORY ---------

            chistory.SetBackgroundColor(Color.AliceBlue);
            cbookmarks.SetBackgroundColor(Color.AliceBlue);
            //  sdownloads.SetBackgroundColor(Color.AliceBlue);

            chistory.LongClickable   = true;
            cbookmarks.LongClickable = true;

            chistory.LongClick += (o, e) =>
            {
                ShowSnackBar("Removed All Viewhistory", o);
                var localC = Application.Context.GetSharedPreferences("History", FileCreationMode.Private);
                var edit   = localC.Edit();
                edit.Clear();
                edit.Commit();
            };
            cbookmarks.LongClick += (o, e) =>
            {
                ShowSnackBar("Removed All Bookmarks", o);
                var localC = Application.Context.GetSharedPreferences("Bookmarks", FileCreationMode.Private);
                var edit   = localC.Edit();
                edit.Clear();
                edit.Commit();
                ax_Bookmarks.ax_bookmarks.UpdateList();
            };
            chistory.Click += (o, e) =>
            {
                ShowSnackBar("Hold To Remove History", o);
            };
            cbookmarks.Click += (o, e) =>
            {
                ShowSnackBar("Hold To Remove Bookmarks", o);
            };

            // --------- ACTIONS ---------

            var defAct = view.FindViewById <Spinner>(Resource.Id.DefSpinner);
            var secAct = view.FindViewById <Spinner>(Resource.Id.SecSpinner);


            var adapter = new ArrayAdapter <string>(Context, Android.Resource.Layout.SimpleSpinnerItem, defChecks);

            defAct.Adapter = adapter;
            secAct.Adapter = adapter;

            defActions[0] = SettingsGetDef(0); // set.GetInt("defAct", 0);
            defActions[1] = SettingsGetDef(1); // set.GetInt("secAct", 1);

            defAct.SetSelection(defActions[0]);
            secAct.SetSelection(defActions[1]);

            defAct.ItemSelected += (o, e) => { SaveInt("defAct", e.Position); defActions[0] = e.Position; };
            secAct.ItemSelected += (o, e) => { SaveInt("secAct", e.Position); defActions[1] = e.Position; };

            return(view);
        }
Esempio n. 2
0
        static void GetAllEps()
        {
            MethodInvoker simpleDelegate2 = new MethodInvoker(RefreshLoading);

            simpleDelegate2.BeginInvoke(null, null);

            string tempThred = thredNum.ToString();
            int    cThred    = int.Parse(tempThred);

            addWatched = new List <string>();
            List <int> watch       = new List <int>();
            List <int> watch_multi = new List <int>();

            for (int i = 0; i < movieTitles.Count; i++)
            {
                if (movieTitles[i].Contains("B___"))
                {
                    if (movieProvider[i] != 3)   // 3 cant be multithreded
                    {
                        watch_multi.Add(i);
                        print("Multi add: " + movieTitles[i]);
                    }
                    else
                    {
                        watch.Add(i);
                        print("Watch add: " + movieTitles[i]);
                    }
                }
            }

            currentMovieId = 0;
            totalMovies    = watch.Count + watch_multi.Count;

            for (int q = 0; q < watch.Count; q++)
            {
                int i = watch[q];
                thredNumber++;
                refreshBar.Progress = (int)System.Math.Round((q + 0.5f) * 100f / (totalMovies));
                if (cThred != thredNum)
                {
                    return;
                }
                GetURLFromTitle(i, true, thredNum);
                if (cThred != thredNum)
                {
                    return;
                }
                //AddTitleEps(addToTitleEps, i);
            }
            for (int i = 0; i < watch_multi.Count; i++)
            {
                DelegateWithParameters_int linkServer =
                    new DelegateWithParameters_int(MultiWatchGetEps);

                linkServer.BeginInvoke(watch_multi[i], null, null);
            }
            if (cThred != thredNum)
            {
                return;
            }
        }