Ejemplo n.º 1
0
 public TpbQuery(string term, int page, TpbQueryOrder order, int category)
 {
     Category = category;
     Order    = order;
     Page     = page;
     Term     = term;
 }
Ejemplo n.º 2
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            UserDialogs.Init(this);
            Xamarin.Essentials.Platform.Init(this, savedInstanceState);
            SetContentView(Resource.Layout.activity_main);
            Instance            = this;
            listView            = FindViewById <ListView>(Resource.Id.lvresults);
            listView.ItemClick += OnListItemClick;
            toolbar             = FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar);
            SetSupportActionBar(toolbar);
            SupportActionBar.Title = "TorrentTools";
            SupportActionBar.SetHomeAsUpIndicator(Resource.Drawable.ic_backarrow);
            //SupportActionBar.SetDisplayHomeAsUpEnabled(true);
            layoutWelcome = FindViewById <RelativeLayout>(Resource.Id.layout_welcome);

            tvStatusText              = FindViewById <IconTextView>(Resource.Id.status_text);
            rlStatusLayout            = FindViewById <RelativeLayout>(Resource.Id.status_layout);
            rlStatusLayout.Visibility = Android.Views.ViewStates.Gone;
            torSearchView             = FindViewById <Android.Support.V7.Widget.SearchView>(Resource.Id.menu_search);
            statusAnimShow            = AnimationUtils.LoadAnimation(this, Resource.Animation.abc_slide_in_top);
            listViewAnimShow          = AnimationUtils.LoadAnimation(this, Resource.Animation.abc_slide_in_bottom);
            statusAnimHide            = AnimationUtils.LoadAnimation(this, Resource.Animation.abc_fade_out);
            welcomeAnimShow           = AnimationUtils.LoadAnimation(this, Resource.Animation.abc_grow_fade_in_from_bottom);
            welcomeAnimShow.Duration  = 1000;
            layoutWelcome.Animation   = welcomeAnimShow;
            listViewAnimHide          = AnimationUtils.LoadAnimation(this, Resource.Animation.abc_slide_out_bottom);

            Iconify.with(new MaterialModule());
            Iconify.with(new FontAwesomeModule());
            Iconify.with(new MaterialCommunityModule());
            //layoutWelcome.Visibility = ViewStates.Visible;
            //LoadFragment("SearchFragment");
            IsConnected    = true;
            searchCategory = TpbTorrentCategory.All;
            searchOrder    = TpbQueryOrder.ByDefault;

            var searchFragment = new SearchFragment();

            SupportFragmentManager.BeginTransaction()
            .Replace(Resource.Id.content_frame, searchFragment)
            .Commit();

            //Connectivity.ConnectivityChanged += Connectivity_ConnectivityChanged;

            //Check network connection
            //var current = Connectivity.NetworkAccess;
            //if (current != NetworkAccess.Internet)
            //{
            // Toast.MakeText(this, "No internet connection detected", ToastLength.Short).Show();
            // }
        }
Ejemplo n.º 3
0
        public void PerformSearch(string searchQuery, int searchCategory, TpbQueryOrder searchOrder)
        {
            if (MainActivity.Instance.IsConnected == true)
            {
                System.Threading.Thread thread = new System.Threading.Thread(() =>
                {
                    UserDialogs.Instance.ShowLoading("Searching, Please Wait …", MaskType.Black);
                    MainActivity.Instance.torrents = Tpb.Search(new TpbQuery(searchQuery, 0, searchOrder, searchCategory));
                    if (MainActivity.Instance.torrents.Count == 0)
                    {
                        MainActivity.Instance.RunOnUiThread(() => Toast.MakeText(Application.Context, "No results found for " + searchQuery, ToastLength.Short).Show());
                    }
                    else
                    {
                        //listViewAnimShow.Duration = 200;

                        lvResults.StartAnimation(listViewAnimShow);

                        //MainActivity.Instance.RunOnUiThread(() => listView.Visibility = ViewStates.Visible);
                        MainActivity.Instance.RunOnUiThread(() => lvResults.Adapter = new TorListAdapter(MainActivity.Instance, MainActivity.Instance.torrents));
                    };

                    UserDialogs.Instance.HideLoading();
                });;
                thread.Start();
                //torSearchView.ClearFocus();

                //torSearchView.SetQuery("", false);
                //MenuItemCompat.CollapseActionView(item);
                //tvStatusText.Text = "Search results for: " + e.NewText.ToString();
                //tvStatusText.Text = MaterialIcons.md_dis;
                //layoutWelcome.Visibility = ViewStates.Gone;

                //e.Handled = true;
            }
            else
            {
                //torSearchView.ClearFocus();
                Toast.MakeText(Application.Context, "No internet connection detected!", ToastLength.Long).Show();
            };
        }
Ejemplo n.º 4
0
        private void BtnSaveFilters_Click(object sender, System.EventArgs e)
        {
            Toast.MakeText(this, "Search Filters Saved", ToastLength.Short).Show();

            selectedCatId      = rgCategories.CheckedRadioButtonId;
            selectedOrderById  = rgOrderBy.CheckedRadioButtonId;
            rbSelectedCategory = filterDialog.FindViewById <RadioButton>(selectedCatId);
            rbSelectedOrderBy  = filterDialog.FindViewById <RadioButton>(selectedOrderById);
            switch (rbSelectedCategory.Text)
            {
            case "All":
                searchCategory = TpbTorrentCategory.All;
                break;

            case "Audio":
                searchCategory = TpbTorrentCategory.AllAudio;
                break;

            case "Video":
                searchCategory = TpbTorrentCategory.AllVideo;
                break;

            case "Applications":
                searchCategory = TpbTorrentCategory.AllApplication;
                break;

            case "Games":
                searchCategory = TpbTorrentCategory.AllGames;
                break;

            case "P**n":
                searchCategory = TpbTorrentCategory.AllPorn;
                break;

            case "Other":
                searchCategory = TpbTorrentCategory.AllOther;
                break;
            }

            switch (rbSelectedOrderBy.Text)
            {
            case "Default":
                searchOrder = TpbQueryOrder.ByDefault;
                break;

            case "Name":
                searchOrder = TpbQueryOrder.ByName;
                break;

            case "Date":
                searchOrder = TpbQueryOrder.ByUploaded;
                break;

            case "Size":
                searchOrder = TpbQueryOrder.BySize;
                break;

            case "Seeds":
                searchOrder = TpbQueryOrder.BySeeds;
                break;

            case "Leechers":
                searchOrder = TpbQueryOrder.ByLeechers;
                break;

            case "Uploader":
                searchOrder = TpbQueryOrder.ByUledBy;
                break;
            }
            filterDialog.Dismiss();

            //System.Threading.Thread thread = new System.Threading.Thread(() =>
            //{
            //    UserDialogs.Instance.ShowLoading("Please Wait …", MaskType.Black);
            //    torrents = Tpb.Search(new TpbQuery(query));
            //    RunOnUiThread(() => listView.Adapter = new TorListAdapter(this, torrents));
            //    UserDialogs.Instance.HideLoading();
            //}); ;
            // thread.Start();
            //searchDialog.Dismiss();
            //searchDialog.Hide();
        }
Ejemplo n.º 5
0
 public TpbQuery(string term, int page, TpbQueryOrder order)
     : this(term, page, order, TpbTorrentCategory.All)
 {
 }