mirror of
https://github.com/zoriya/Opus.git
synced 2025-12-06 06:26:15 +00:00
Adding error codes.
This commit is contained in:
@@ -1058,7 +1058,6 @@ namespace Opus.Api
|
||||
}
|
||||
catch (System.Net.Http.HttpRequestException)
|
||||
{
|
||||
MainActivity.instance.Timout();
|
||||
return tracks;
|
||||
}
|
||||
}
|
||||
@@ -1114,13 +1113,8 @@ namespace Opus.Api
|
||||
else
|
||||
song.Title = null;
|
||||
}
|
||||
catch (System.Net.Http.HttpRequestException)
|
||||
{
|
||||
MainActivity.instance.Timout();
|
||||
}
|
||||
catch (System.Net.Http.HttpRequestException) { }
|
||||
}
|
||||
else
|
||||
MainActivity.instance.Timout();
|
||||
|
||||
return song;
|
||||
}
|
||||
|
||||
@@ -251,7 +251,7 @@ namespace Opus.Api.Services
|
||||
}
|
||||
catch
|
||||
{
|
||||
MainActivity.instance.UnknowError();
|
||||
MainActivity.instance.UnknowError(ErrorCode.DL1);
|
||||
Cancel();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -172,7 +172,6 @@ namespace Opus.Code.Api
|
||||
catch (System.Net.Http.HttpRequestException)
|
||||
{
|
||||
Console.WriteLine("&Parse time out");
|
||||
MainActivity.instance.Timout();
|
||||
if (MainActivity.instance != null)
|
||||
MainActivity.instance.FindViewById<ProgressBar>(Resource.Id.ytProgress).Visibility = ViewStates.Gone;
|
||||
song.IsParsed = false;
|
||||
@@ -183,7 +182,7 @@ namespace Opus.Code.Api
|
||||
catch (YoutubeExplode.Exceptions.VideoUnplayableException ex)
|
||||
{
|
||||
Console.WriteLine("&Parse error: " + ex.Message);
|
||||
MainActivity.instance.Unplayable(song.Title, ex.Message);
|
||||
MainActivity.instance.Unplayable(ErrorCode.SP2, song.Title, ex.Message);
|
||||
if (MainActivity.instance != null)
|
||||
MainActivity.instance.FindViewById<ProgressBar>(Resource.Id.ytProgress).Visibility = ViewStates.Gone;
|
||||
|
||||
@@ -209,7 +208,7 @@ namespace Opus.Code.Api
|
||||
}
|
||||
catch //We use this because when the network is reseted, an unknow error is thrown. We also don't want the app to crash at this state so it's ok to use a global catch.
|
||||
{
|
||||
MainActivity.instance.UnknowError(null, Snackbar.LengthLong);
|
||||
MainActivity.instance.UnknowError(ErrorCode.SP1, null, Snackbar.LengthLong);
|
||||
|
||||
song.IsParsed = false;
|
||||
|
||||
|
||||
@@ -266,10 +266,7 @@ namespace Opus.Api
|
||||
if (response.Items.Count > 0)
|
||||
return true;
|
||||
}
|
||||
catch (System.Net.Http.HttpRequestException)
|
||||
{
|
||||
MainActivity.instance.Timout();
|
||||
}
|
||||
catch (System.Net.Http.HttpRequestException) { }
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -365,7 +362,7 @@ namespace Opus.Api
|
||||
if (ex is System.Net.Http.HttpRequestException)
|
||||
MainActivity.instance.Timout();
|
||||
else
|
||||
MainActivity.instance.UnknowError();
|
||||
MainActivity.instance.UnknowError(ErrorCode.SM1);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -349,12 +349,11 @@ namespace Opus
|
||||
|
||||
public void OnFocusChange(View v, bool hasFocus)
|
||||
{
|
||||
if (hasFocus /*&& !SearchableActivity.IgnoreMyself*/)
|
||||
if (hasFocus)
|
||||
{
|
||||
Bundle animation = ActivityOptionsCompat.MakeCustomAnimation(this, Android.Resource.Animation.FadeIn, Android.Resource.Animation.FadeOut).ToBundle();
|
||||
StartActivity(new Intent(this, typeof(SearchableActivity)), animation);
|
||||
}
|
||||
SearchableActivity.IgnoreMyself = false;
|
||||
}
|
||||
|
||||
public void CancelSearch() //SearchableActivity is finishing and no search has been made
|
||||
@@ -544,15 +543,15 @@ namespace Opus
|
||||
#endregion
|
||||
|
||||
#region Snackbars
|
||||
public void YoutubeEndPointChanged()
|
||||
{
|
||||
FindViewById<ProgressBar>(Resource.Id.ytProgress).Visibility = ViewStates.Gone;
|
||||
Snackbar snackBar = Snackbar.Make(FindViewById(Resource.Id.snackBar), Resource.String.youtube_endpoint, Snackbar.LengthLong);
|
||||
snackBar.View.FindViewById<TextView>(Resource.Id.snackbar_text).SetTextColor(Color.White);
|
||||
snackBar.Show();
|
||||
//public void YoutubeEndPointChanged()
|
||||
//{
|
||||
// FindViewById<ProgressBar>(Resource.Id.ytProgress).Visibility = ViewStates.Gone;
|
||||
// Snackbar snackBar = Snackbar.Make(FindViewById(Resource.Id.snackBar), Resource.String.youtube_endpoint, Snackbar.LengthLong);
|
||||
// snackBar.View.FindViewById<TextView>(Resource.Id.snackbar_text).SetTextColor(Color.White);
|
||||
// snackBar.Show();
|
||||
|
||||
Player.instance.Ready();
|
||||
}
|
||||
// Player.instance.Ready();
|
||||
//}
|
||||
|
||||
public void Timout()
|
||||
{
|
||||
@@ -561,18 +560,18 @@ namespace Opus
|
||||
snackBar.Show();
|
||||
}
|
||||
|
||||
public void UnknowError(Action action = null, int Length = Snackbar.LengthIndefinite)
|
||||
public void UnknowError(ErrorCode code, Action action = null, int Length = Snackbar.LengthIndefinite)
|
||||
{
|
||||
Snackbar snackBar = Snackbar.Make(FindViewById(Resource.Id.snackBar), Resource.String.unknow, Length);
|
||||
Snackbar snackBar = Snackbar.Make(FindViewById(Resource.Id.snackBar), GetString(Resource.String.unknow) + " (" + code + ")", Length);
|
||||
if (action != null)
|
||||
snackBar.SetAction("Try Again", (sender) => { action.Invoke(); snackBar.Dismiss(); });
|
||||
else
|
||||
snackBar.SetAction("Dismiss", (sender) => { snackBar.Dismiss(); });
|
||||
snackBar.SetAction("Ok", (sender) => { snackBar.Dismiss(); });
|
||||
snackBar.View.FindViewById<TextView>(Resource.Id.snackbar_text).SetTextColor(Color.White);
|
||||
snackBar.Show();
|
||||
}
|
||||
|
||||
public void Unplayable(string title, string msg)
|
||||
public void Unplayable(ErrorCode code, string title, string msg)
|
||||
{
|
||||
if (msg.Contains("country"))
|
||||
{
|
||||
@@ -587,7 +586,7 @@ namespace Opus
|
||||
snackBar.Show();
|
||||
}
|
||||
else
|
||||
UnknowError();
|
||||
UnknowError(code);
|
||||
}
|
||||
|
||||
public void NotStreamable(string title)
|
||||
@@ -1282,4 +1281,15 @@ namespace Opus
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// From where unknow errors are called. For debugging purpose on a deployed version.
|
||||
/// </summary>
|
||||
public enum ErrorCode
|
||||
{
|
||||
SP1, //Song parser 1
|
||||
SP2, //Song parser 2
|
||||
DL1, //Main downloader loop
|
||||
SM1 //Song Mix 1
|
||||
}
|
||||
}
|
||||
@@ -332,10 +332,7 @@ namespace Opus.Fragments
|
||||
adapter.NotifyDataSetChanged();
|
||||
|
||||
}
|
||||
catch (System.Net.Http.HttpRequestException)
|
||||
{
|
||||
MainActivity.instance.Timout();
|
||||
}
|
||||
catch (System.Net.Http.HttpRequestException) { }
|
||||
}
|
||||
else if (adapter?.tracks.Count != 0)
|
||||
{
|
||||
|
||||
@@ -23,7 +23,6 @@ namespace Opus.Fragments
|
||||
public class SearchableActivity : AppCompatActivity, IMenuItemOnActionExpandListener
|
||||
{
|
||||
public static SearchableActivity instance;
|
||||
public static bool IgnoreMyself = false;
|
||||
public SearchView searchView;
|
||||
public string SearchQuery = null;
|
||||
private ListView ListView;
|
||||
|
||||
@@ -169,14 +169,6 @@ namespace Opus.Fragments
|
||||
|
||||
public async Task Search(string search, string querryType, bool loadingBar)
|
||||
{
|
||||
//SearchableActivity.IgnoreMyself = true;
|
||||
//IMenuItem searchItem = MainActivity.instance.menu.FindItem(Resource.Id.search);
|
||||
//searchItem.ExpandActionView();
|
||||
//SearchView searchView = (SearchView)searchItem.ActionView;
|
||||
//searchView.SetQuery(search, false);
|
||||
//searchView.ClearFocus();
|
||||
//searchView.Focusable = false;
|
||||
|
||||
if (search == null || search == "")
|
||||
return;
|
||||
|
||||
@@ -191,8 +183,6 @@ namespace Opus.Fragments
|
||||
LoadingView.Visibility = ViewStates.Visible;
|
||||
}
|
||||
|
||||
SearchableActivity.IgnoreMyself = false;
|
||||
|
||||
if (!await MainActivity.instance.WaitForYoutube())
|
||||
{
|
||||
ListView.SetAdapter(null);
|
||||
@@ -305,7 +295,6 @@ namespace Opus.Fragments
|
||||
Console.WriteLine("&Exception catched in the youtube search: " + ex.Source + " - " + ex.Message);
|
||||
if(ex is System.Net.Http.HttpRequestException)
|
||||
{
|
||||
MainActivity.instance.Timout();
|
||||
EmptyView.Text = GetString(Resource.String.timout);
|
||||
EmptyView.Visibility = ViewStates.Visible;
|
||||
}
|
||||
@@ -347,7 +336,6 @@ namespace Opus.Fragments
|
||||
YoutubeManager.Play(result[position].song);
|
||||
break;
|
||||
case YtKind.Playlist:
|
||||
SearchableActivity.IgnoreMyself = true;
|
||||
MainActivity.instance.menu.FindItem(Resource.Id.search).CollapseActionView();
|
||||
MainActivity.instance.FindViewById<TabLayout>(Resource.Id.tabs).Visibility = ViewStates.Gone;
|
||||
MainActivity.instance.SupportFragmentManager.BeginTransaction().Replace(Resource.Id.contentView, PlaylistTracks.NewInstance(result[position].playlist)).AddToBackStack("Playlist Track").Commit();
|
||||
|
||||
Reference in New Issue
Block a user