public override void OnRequestPermissionsResult(int requestCode, string[] permissions, Permission[] grantResults) { if (requestCode == REQUEST_WRITEEXTERNALSTORAGE) { // Check if the only required permission has been granted if (grantResults.Length == 1 && grantResults[0] == Permission.Granted) { Toast.MakeText(this, "Permission Granted", ToastLength.Long).Show(); PapMediaPlayer.ViewManager.DataLoader.DataLoader dll = new ViewManager.DataLoader.DataLoader(this); ThreadPool.QueueUserWorkItem(o => { InitializeUI(dll); RunOnUiThread(() => HideProgress()); }); } else { Toast.MakeText(this, "Permission Not Granted!", ToastLength.Long).Show(); } } else { base.OnRequestPermissionsResult(requestCode, permissions, grantResults); } }
private void RequestPermissions() { if (Android.Support.V4.App.ActivityCompat.CheckSelfPermission(this, Manifest.Permission.WriteExternalStorage) != (int)Permission.Granted) { Android.Support.V4.App.ActivityCompat.RequestPermissions(this, new string[] { Manifest.Permission.WriteExternalStorage }, REQUEST_WRITEEXTERNALSTORAGE); } else { PapMediaPlayer.ViewManager.DataLoader.DataLoader dll = new ViewManager.DataLoader.DataLoader(this); ShowProgress(); ThreadPool.QueueUserWorkItem(o => { InitializeUI(dll); RunOnUiThread(() => HideProgress()); }); } }
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)); }