Exemple #1
0
        private void R_Received(object sender, int e)
        {
            ShowProgress();
            ThreadPool.QueueUserWorkItem(o =>
            {
                switch ((ViewMethods)e)
                {
                case ViewMethods.AllTracks:
                    ViewManager = new AllTracksManager(this);
                    break;

                case ViewMethods.ContainingFolders:
                    ViewManager = new FoldersManager(this);
                    break;

                case ViewMethods.Playlist:
                    Intent intent = new Intent(this, typeof(PlaylistManagerActivity));
                    intent.PutExtra("Action", "Select");
                    intent.PutExtra("DataExist", false);
                    RunOnUiThread(() => StartActivityForResult(intent, PlaylistManagerID));
                    break;
                }
                RunOnUiThread(() =>
                {
                    grid.Adapter = ViewManager.GetAdapter();

                    UnRegisterReceiver();
                    HideProgress();
                });
            });
        }
Exemple #2
0
 private void SearchBar_FocusChange(object sender, View.FocusChangeEventArgs e)
 {
     if (e.HasFocus)
     {
         searchBar.Text = string.Empty;
     }
     if (!e.HasFocus)
     {
         ((PapMediaPlayer.ViewManager.Search.ISearchManager)ViewManager).SetSearch(false);
         grid.Adapter = ViewManager.GetAdapter();
     }
 }
Exemple #3
0
 protected override void OnActivityResult(int requestCode, [GeneratedEnum] Result resultCode, Intent data)
 {
     base.OnActivityResult(requestCode, resultCode, data);
     switch (requestCode)
     {
     case PlaylistManagerID:
         if (resultCode == Result.Ok)
         {
             ShowProgress();
             ThreadPool.QueueUserWorkItem(o =>
             {
                 ViewManager = new PlaylistsManager(this, data.GetStringExtra("PlaylistName"));
                 RunOnUiThread(() => { grid.Adapter = ViewManager.GetAdapter(); HideProgress(); });
             });
         }
         break;
     }
 }
Exemple #4
0
 private void Grid_ItemClick(object sender, AdapterView.ItemClickEventArgs e)
 {
     try
     {
         ShowProgress();
         ThreadPool.QueueUserWorkItem(o => {
             PapMediaPlayer.ViewManager.IViewManager temp = ViewManager;
             ViewManager = ViewManager.OnClickHandler(e.Position);
             if (temp != ViewManager)
             {
                 RunOnUiThread(() => grid.Adapter = ViewManager.GetAdapter());
             }
             RunOnUiThread(() => HideProgress());
         });
     }
     catch (sys.OutOfMemoryException ex) { Toast.MakeText(this, ex.Message, ToastLength.Long).Show(); }
     catch (sys.Exception ex) { Toast.MakeText(this, ex.Message, ToastLength.Long).Show(); }
 }
Exemple #5
0
 public override void OnBackPressed()
 {
     if (searchBar.Visibility == ViewStates.Visible)
     {
         searchBar.Visibility = ViewStates.Gone;
         return;
     }
     ShowProgress();
     ThreadPool.QueueUserWorkItem(o =>
     {
         ViewManager.IViewManager temp = ViewManager;
         ViewManager = ViewManager.OnBackPressed();
         if (temp != ViewManager)
         {
             RunOnUiThread(() => grid.Adapter = ViewManager.GetAdapter());
         }
         RunOnUiThread(() => HideProgress());
     });
 }
Exemple #6
0
        private void Grid_ItemLongClick(object sender, AdapterView.ItemLongClickEventArgs e)
        {
            if (ViewManager.GetType() == typeof(FoldersManager))
            {
                Toast.MakeText(this, "Cannot Initialize Selection Mode when browsing on folder view", ToastLength.Long).Show();
                return;
            }
            else if (ViewManager.GetType() == typeof(SelectManager))
            {
                Toast.MakeText(this, "You are already in selection mode!", ToastLength.Long).Show();
                return;
            }

            ShowProgress();
            ThreadPool.QueueUserWorkItem(o =>
            {
                ViewManager = new SelectManager(this, ((ITrackRetriever)ViewManager).GetTracks(), ViewManager);

                RunOnUiThread(() => grid.Adapter = ViewManager.GetAdapter());
                RunOnUiThread(() => HideProgress());
            });
        }
Exemple #7
0
        private void InitializeUI(PapMediaPlayer.ViewManager.DataLoader.DataLoader dll)
        {
            using (ISharedPreferences prefs = this.GetSharedPreferences(Startup.Prefs, FileCreationMode.Private))
            {
                try
                {
                    if (prefs.GetBoolean(Startup.REMEMBER, true))
                    {
                        ServiceSharedPref p        = new ServiceSharedPref(this);
                        string            pullfrom = p.PullDataFrom();
                        if (pullfrom == ServiceSharedPref.PULLDATAFROM_ALLTRACKS)
                        {
                            ViewManager = new AllTracksManager(this, dll.Load(false));
                        }
                        else if (pullfrom == ServiceSharedPref.PULLDATAFROM_FOLDER)
                        {
                            ViewManager = new ContainingFoldersManager(this, p.PullDataPath());
                        }
                        else
                        {
                            ViewManager = new PlaylistsManager(this, p.PullDataPath());
                        }

                        int songIndex = p.PullLastSong();
                        if (songIndex >= ViewManager.TrackCount())
                        {
                            songIndex = 0;
                            p.SaveLastSong(songIndex);
                        }

                        RunOnUiThread(() =>
                        {
                            if (ViewManager.TrackCount() != 0)
                            {
                                CurrentlyPlaying.Text = ViewManager.EnumeratePath() + ((PapMediaPlayer.ViewManager.ITrackRetriever)ViewManager).GetTracks()[songIndex].FullTitle;
                            }
                            else
                            {
                                Toast.MakeText(this, "No Songs found.", ToastLength.Long).Show();
                            }
                        });
                    }
                    else
                    {
                        if (prefs.GetString(Startup.VIEWMETHOD, Startup.ALLTRACKS) == Startup.ALLTRACKS)
                        {
                            ViewManager = new AllTracksManager(this, dll.Load(false));
                        }
                        else if (prefs.GetString(Startup.VIEWMETHOD, Startup.ALLTRACKS) == Startup.CONTFOLDERS)
                        {
                            ViewManager = new FoldersManager(this, dll.Load(false));
                        }
                        else
                        {
                            ViewManager = new PlaylistsManager(this, prefs.GetString(Startup.PLAYLISTNAME, string.Empty));
                        }
                    }
                }catch (TrackFinder.TrackNotFoundException ex)
                {
                    RunOnUiThread(() =>
                    {
                        Toast.MakeText(this, ex.Message + " Attempting to refetch data and restore cache", ToastLength.Long).Show();
                    });
                    ViewManager = new AllTracksManager(this, dll.Load(true, true));
                }
                catch (sys.Exception ex)
                {
                    RunOnUiThread(() =>
                    {
                        Toast.MakeText(this, ex.Message + " Creating Cache.", ToastLength.Long).Show();
                    });
                    ViewManager = new AllTracksManager(this, dll.Load(true, true));
                }
            }
            RunOnUiThread(() =>
            {
                grid.Adapter     = ViewManager.GetAdapter();
                grid.ItemClick  += Grid_ItemClick;
                playPause.Click += PlayPause_Click;
                next.Click      += Next_Click;
                previous.Click  += Previous_Click;
            });
        }
Exemple #8
0
        public override bool OnOptionsItemSelected(IMenuItem item)
        {
            int id = item.ItemId;

            if (id == Resource.Id.ActionBar_Search)
            {
                if (searchBar.Visibility == ViewStates.Gone)
                {
                    searchBar.Visibility = ViewStates.Visible;
                    searchBar.RequestFocus();
                    InputMethodManager imm = (InputMethodManager)GetSystemService(Context.InputMethodService);
                    imm.ShowSoftInput(searchBar, ShowFlags.Implicit);
                }
                else
                {
                    searchBar.Visibility = ViewStates.Gone;
                    InputMethodManager inputMethodManager = (InputMethodManager)GetSystemService(Context.InputMethodService);
                    inputMethodManager.ToggleSoftInput(0, HideSoftInputFlags.ImplicitOnly);
                }

                return(true);
            }
            else if (id == Resource.Id.ActionBar_Sort)
            {
                SetupBoxes();
                RegisterSortReceiver();
                FragmentTransaction trans = FragmentManager.BeginTransaction();

                SortByFragment sortby = new SortByFragment();
                sortby.Show(trans, "Sort_By");
                return(true);
            }
            else if (id == Resource.Id.ActionBar_PlaylistManager)
            {
                SetupBoxes();
                Intent intent = new Intent(this, typeof(PlaylistManagerActivity));
                StartActivity(intent);
                OverridePendingTransition(Resource.Animation.SlidingRightAnim, Resource.Animation.SlidingLeftAnim);
                return(true);
            }
            else if (id == Resource.Id.ActionBar_Advanced)
            {
                SetupBoxes();
                Intent intent = new Intent(this, typeof(AdvancedActivity));
                StartActivity(intent);
                return(true);
            }
            else if (id == Resource.Id.ActionBar_Loopback)
            {
                FragmentTransaction      trans    = FragmentManager.BeginTransaction();
                LoopbackSettingsFragment loopback = new LoopbackSettingsFragment();
                loopback.Show(trans, "LoopBack");
                return(true);
            }
            else if (id == Resource.Id.ActionBar_Refresh)
            {
                ShowProgress();
                ThreadPool.QueueUserWorkItem(o =>
                {
                    PapMediaPlayer.ViewManager.DataLoader.DataLoader loader = new ViewManager.DataLoader.DataLoader(this);
                    ViewManager = new AllTracksManager(this, loader.Load(true));
                    RunOnUiThread(() => grid.Adapter = ViewManager.GetAdapter());
                    RunOnUiThread(() => HideProgress());
                });
            }
            else if (id == Resource.Id.ActionBar_About)
            {
                using (Android.App.AlertDialog.Builder help = new Android.App.AlertDialog.Builder(this, Resource.Style.MyDialogTheme))
                {
                    help.SetTitle("About");
                    help.SetIcon(Resource.Drawable.About);
                    help.SetMessage("\n\nPap Media Player\n\nDeveloper Konstantinos Pap\n\nPowered by Pap Industries \n\nLoading Screens by Nikolaos Pothakis\n\nCopyrights © Konstantinos Pap 2018-2020.");
                    help.Show();
                }
            }
            return(base.OnOptionsItemSelected(item));
        }