mirror of
https://github.com/zoriya/Opus.git
synced 2025-12-06 06:26:15 +00:00
Solving bugs with the memory's garbage collector.
This commit is contained in:
@@ -285,10 +285,6 @@ namespace Opus
|
|||||||
if(account != null)
|
if(account != null)
|
||||||
Picasso.With(this).Load(account.PhotoUrl).Transform(new CircleTransformation()).Into(new AccountTarget());
|
Picasso.With(this).Load(account.PhotoUrl).Transform(new CircleTransformation()).Into(new AccountTarget());
|
||||||
|
|
||||||
var item = menu.FindItem(Resource.Id.filter);
|
|
||||||
var filterView = item.ActionView.JavaCast<SearchView>();
|
|
||||||
filterView.QueryTextChange += Search;
|
|
||||||
item.SetVisible(false);
|
|
||||||
menu.FindItem(Resource.Id.search).SetOnActionExpandListener(this);
|
menu.FindItem(Resource.Id.search).SetOnActionExpandListener(this);
|
||||||
((SearchView)menu.FindItem(Resource.Id.search).ActionView).SetOnQueryTextFocusChangeListener(this);
|
((SearchView)menu.FindItem(Resource.Id.search).ActionView).SetOnQueryTextFocusChangeListener(this);
|
||||||
((SearchView)menu.FindItem(Resource.Id.search).ActionView).QueryHint = GetString(Resource.String.youtube_search);
|
((SearchView)menu.FindItem(Resource.Id.search).ActionView).QueryHint = GetString(Resource.String.youtube_search);
|
||||||
@@ -297,6 +293,23 @@ namespace Opus
|
|||||||
return base.OnCreateOptionsMenu(menu);
|
return base.OnCreateOptionsMenu(menu);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void AddFilterListener(EventHandler<SearchView.QueryTextChangeEventArgs> textChanged)
|
||||||
|
{
|
||||||
|
if (menu == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var item = menu.FindItem(Resource.Id.filter);
|
||||||
|
var filterView = item.ActionView.JavaCast<SearchView>();
|
||||||
|
filterView.QueryTextChange += textChanged;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RemoveFilterListener(EventHandler<SearchView.QueryTextChangeEventArgs> textChanged)
|
||||||
|
{
|
||||||
|
var item = menu.FindItem(Resource.Id.filter);
|
||||||
|
var filterView = item.ActionView.JavaCast<SearchView>();
|
||||||
|
filterView.QueryTextChange -= textChanged;
|
||||||
|
}
|
||||||
|
|
||||||
public override bool OnOptionsItemSelected(IMenuItem item)
|
public override bool OnOptionsItemSelected(IMenuItem item)
|
||||||
{
|
{
|
||||||
if(item.ItemId == Android.Resource.Id.Home)
|
if(item.ItemId == Android.Resource.Id.Home)
|
||||||
@@ -348,16 +361,6 @@ namespace Opus
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Search(object sender, SearchView.QueryTextChangeEventArgs e)
|
|
||||||
{
|
|
||||||
if (Browse.instance != null)
|
|
||||||
Browse.instance.Search(e.NewText);
|
|
||||||
if (PlaylistTracks.instance != null)
|
|
||||||
PlaylistTracks.instance.Search(e.NewText);
|
|
||||||
if (FolderTracks.instance != null)
|
|
||||||
FolderTracks.instance.Search(e.NewText);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void OnFocusChange(View v, bool hasFocus)
|
public void OnFocusChange(View v, bool hasFocus)
|
||||||
{
|
{
|
||||||
if (hasFocus)
|
if (hasFocus)
|
||||||
|
|||||||
@@ -34,12 +34,14 @@ namespace Opus.Fragments
|
|||||||
{
|
{
|
||||||
base.OnActivityCreated(savedInstanceState);
|
base.OnActivityCreated(savedInstanceState);
|
||||||
MainActivity.instance.contentRefresh.Refresh += OnRefresh;
|
MainActivity.instance.contentRefresh.Refresh += OnRefresh;
|
||||||
|
MainActivity.instance.AddFilterListener(Search);
|
||||||
ListView.NestedScrollingEnabled = true;
|
ListView.NestedScrollingEnabled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnDestroy()
|
public override void OnDestroy()
|
||||||
{
|
{
|
||||||
MainActivity.instance.contentRefresh.Refresh -= OnRefresh;
|
MainActivity.instance.contentRefresh.Refresh -= OnRefresh;
|
||||||
|
MainActivity.instance.RemoveFilterListener(Search);
|
||||||
base.OnDestroy();
|
base.OnDestroy();
|
||||||
instance = null;
|
instance = null;
|
||||||
}
|
}
|
||||||
@@ -138,12 +140,12 @@ namespace Opus.Fragments
|
|||||||
adapter.NotifyDataSetChanged();
|
adapter.NotifyDataSetChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Search(string search)
|
public void Search(object sender, Android.Support.V7.Widget.SearchView.QueryTextChangeEventArgs e)
|
||||||
{
|
{
|
||||||
if (search == "")
|
if (e.NewText == "")
|
||||||
query = null;
|
query = null;
|
||||||
else
|
else
|
||||||
query = search;
|
query = e.NewText;
|
||||||
|
|
||||||
LoaderManager.GetInstance(this).RestartLoader(0, null, this);
|
LoaderManager.GetInstance(this).RestartLoader(0, null, this);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ namespace Opus.Fragments
|
|||||||
{
|
{
|
||||||
base.OnActivityCreated(savedInstanceState);
|
base.OnActivityCreated(savedInstanceState);
|
||||||
MainActivity.instance.contentRefresh.Refresh += OnRefresh;
|
MainActivity.instance.contentRefresh.Refresh += OnRefresh;
|
||||||
|
MainActivity.instance.AddFilterListener(Search);
|
||||||
|
|
||||||
MainActivity.instance.SupportActionBar.SetDisplayShowTitleEnabled(true);
|
MainActivity.instance.SupportActionBar.SetDisplayShowTitleEnabled(true);
|
||||||
MainActivity.instance.FindViewById(Resource.Id.toolbarLogo).Visibility = ViewStates.Gone;
|
MainActivity.instance.FindViewById(Resource.Id.toolbarLogo).Visibility = ViewStates.Gone;
|
||||||
@@ -42,6 +43,7 @@ namespace Opus.Fragments
|
|||||||
|
|
||||||
public override void OnDestroy()
|
public override void OnDestroy()
|
||||||
{
|
{
|
||||||
|
MainActivity.instance.RemoveFilterListener(Search);
|
||||||
MainActivity.instance.contentRefresh.Refresh -= OnRefresh;
|
MainActivity.instance.contentRefresh.Refresh -= OnRefresh;
|
||||||
instance = null;
|
instance = null;
|
||||||
base.OnDestroy();
|
base.OnDestroy();
|
||||||
@@ -125,12 +127,12 @@ namespace Opus.Fragments
|
|||||||
adapter.NotifyDataSetChanged();
|
adapter.NotifyDataSetChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Search(string search)
|
public void Search(object sender, Android.Support.V7.Widget.SearchView.QueryTextChangeEventArgs e)
|
||||||
{
|
{
|
||||||
if (search == "")
|
if (e.NewText == "")
|
||||||
query = null;
|
query = null;
|
||||||
else
|
else
|
||||||
query = search;
|
query = e.NewText;
|
||||||
|
|
||||||
LoaderManager.GetInstance(this).RestartLoader(0, null, this);
|
LoaderManager.GetInstance(this).RestartLoader(0, null, this);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ using CursorLoader = Android.Support.V4.Content.CursorLoader;
|
|||||||
using PlaylistItem = Opus.DataStructure.PlaylistItem;
|
using PlaylistItem = Opus.DataStructure.PlaylistItem;
|
||||||
using PopupMenu = Android.Support.V7.Widget.PopupMenu;
|
using PopupMenu = Android.Support.V7.Widget.PopupMenu;
|
||||||
using RecyclerView = Android.Support.V7.Widget.RecyclerView;
|
using RecyclerView = Android.Support.V7.Widget.RecyclerView;
|
||||||
|
using SearchView = Android.Support.V7.Widget.SearchView;
|
||||||
using Toolbar = Android.Support.V7.Widget.Toolbar;
|
using Toolbar = Android.Support.V7.Widget.Toolbar;
|
||||||
|
|
||||||
namespace Opus.Fragments
|
namespace Opus.Fragments
|
||||||
@@ -46,7 +47,14 @@ namespace Opus.Fragments
|
|||||||
public override void OnActivityCreated(Bundle savedInstanceState)
|
public override void OnActivityCreated(Bundle savedInstanceState)
|
||||||
{
|
{
|
||||||
base.OnActivityCreated(savedInstanceState);
|
base.OnActivityCreated(savedInstanceState);
|
||||||
|
if(item == null)
|
||||||
|
{
|
||||||
|
MainActivity.instance.SupportFragmentManager.PopBackStack();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
MainActivity.instance.contentRefresh.Refresh += OnRefresh;
|
MainActivity.instance.contentRefresh.Refresh += OnRefresh;
|
||||||
|
MainActivity.instance.AddFilterListener(Search);
|
||||||
MainActivity.instance.DisplaySearch();
|
MainActivity.instance.DisplaySearch();
|
||||||
|
|
||||||
MainActivity.instance.SupportActionBar.SetHomeButtonEnabled(true);
|
MainActivity.instance.SupportActionBar.SetHomeButtonEnabled(true);
|
||||||
@@ -67,7 +75,7 @@ namespace Opus.Fragments
|
|||||||
#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
|
#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
|
||||||
PopulateList();
|
PopulateList();
|
||||||
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
|
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
|
||||||
if(useHeader)
|
if(useHeader && item != null)
|
||||||
CreateHeader();
|
CreateHeader();
|
||||||
//if (item.SyncState == SyncState.Error)
|
//if (item.SyncState == SyncState.Error)
|
||||||
// CreateSyncBanner();
|
// CreateSyncBanner();
|
||||||
@@ -127,6 +135,7 @@ namespace Opus.Fragments
|
|||||||
|
|
||||||
public override void OnDestroyView()
|
public override void OnDestroyView()
|
||||||
{
|
{
|
||||||
|
MainActivity.instance.RemoveFilterListener(Search);
|
||||||
Activity.FindViewById<ImageButton>(Resource.Id.headerPlay).Click -= HeaderPlay;
|
Activity.FindViewById<ImageButton>(Resource.Id.headerPlay).Click -= HeaderPlay;
|
||||||
Activity.FindViewById<ImageButton>(Resource.Id.headerShuffle).Click -= HeaderShuffle;
|
Activity.FindViewById<ImageButton>(Resource.Id.headerShuffle).Click -= HeaderShuffle;
|
||||||
Activity.FindViewById<ImageButton>(Resource.Id.headerMore).Click -= PlaylistMore;
|
Activity.FindViewById<ImageButton>(Resource.Id.headerMore).Click -= PlaylistMore;
|
||||||
@@ -253,6 +262,7 @@ namespace Opus.Fragments
|
|||||||
instance.item = new PlaylistItem() { Name = playlistName, Count = songs.Count, HasWritePermission = false, LocalID = -1, YoutubeID = null };
|
instance.item = new PlaylistItem() { Name = playlistName, Count = songs.Count, HasWritePermission = false, LocalID = -1, YoutubeID = null };
|
||||||
instance.useHeader = false;
|
instance.useHeader = false;
|
||||||
instance.fullyLoadded = true;
|
instance.fullyLoadded = true;
|
||||||
|
instance.isInEditMode = false;
|
||||||
instance.adapter = new PlaylistTrackAdapter(new SearchableList<Song>(songs));
|
instance.adapter = new PlaylistTrackAdapter(new SearchableList<Song>(songs));
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
@@ -262,6 +272,7 @@ namespace Opus.Fragments
|
|||||||
instance = new PlaylistTracks { Arguments = new Bundle() };
|
instance = new PlaylistTracks { Arguments = new Bundle() };
|
||||||
instance.item = item;
|
instance.item = item;
|
||||||
instance.useHeader = true;
|
instance.useHeader = true;
|
||||||
|
instance.isInEditMode = true;
|
||||||
instance.fullyLoadded = item.LocalID != 0 && item.LocalID != -1;
|
instance.fullyLoadded = item.LocalID != 0 && item.LocalID != -1;
|
||||||
|
|
||||||
Task.Run(async () =>
|
Task.Run(async () =>
|
||||||
@@ -437,12 +448,12 @@ namespace Opus.Fragments
|
|||||||
LoadMore();
|
LoadMore();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Search(string search)
|
public void Search(object sender, SearchView.QueryTextChangeEventArgs e)
|
||||||
{
|
{
|
||||||
if (search == "")
|
if (e.NewText == "")
|
||||||
query = null;
|
query = null;
|
||||||
else
|
else
|
||||||
query = search.ToLower();
|
query = e.NewText.ToLower();
|
||||||
|
|
||||||
if(item.LocalID != -1)
|
if(item.LocalID != -1)
|
||||||
LoaderManager.GetInstance(this).RestartLoader(0, null, this);
|
LoaderManager.GetInstance(this).RestartLoader(0, null, this);
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
android:id="@+id/filter"
|
android:id="@+id/filter"
|
||||||
android:icon="@drawable/Filter"
|
android:icon="@drawable/Filter"
|
||||||
android:title="@string/filter"
|
android:title="@string/filter"
|
||||||
|
android:visible="false"
|
||||||
app:showAsAction="always|collapseActionView"
|
app:showAsAction="always|collapseActionView"
|
||||||
app:actionViewClass="android.support.v7.widget.SearchView" />
|
app:actionViewClass="android.support.v7.widget.SearchView" />
|
||||||
<item
|
<item
|
||||||
|
|||||||
Reference in New Issue
Block a user